2016-09-07 15:05:01

by Montague, Jay

[permalink] [raw]
Subject: bluez bluetooth problem

Dear Bluez,

I am having a problem that I wondered whether you could help me with?

I'm currently working on a project in which I'm trying to communicate to an=
Intel Edison board from my Windows PC via Bluetooth. I have managed to suc=
cessfully connect and communicate via Bluetooth using the serial port and b=
luez version 5.22. But my problem is that I can only auto connect to the PC=
once I have already manually paired to the device. So my aim is to have so=
ftware running on the Edison which will be able to auto pair to a PC and co=
nnect without knowing the PC device id in advance, for the PC to then send =
commands and eventually files to the Edison.

I have been able to manually send serial commands to the Edison by using a =
Putty terminal and using rfcomm and the "cat /dev/rfcomm0" command. Using p=
rocess below on the Edison:

rfkill unblock bluetooth
sdptool add -channel=3D22 SP
rfcomm watch /dev/rfcomm0 22 > /dev/null &
bluetoothctl
agent NoInputNoOutput
default-agent
discoverable on

"pair with Edison from PC and accept pairing on the Edison"

cat /dev/rfcomm0

"send text to Edison via Putty terminal com port"


So I have been trying to automate this process by writing C code on the Ecl=
ipse IDE and also by writing scripts running on the Edison but I have not b=
een able to successfully send commands to the bluetoothctl function.

I have tried to send commands using the Eclipse IDE but when I send the fol=
lowing:

system("echo -e 'agent NoInputNoOutput\n | bluetoothctl");

On the Edison it reports "No agent is registered" and the following message=
:

(bluetoothctl:690): GLib-CRITICAL **: Source ID 22 was not found when attem=
pting to remove it


Also if I try to create a script file like the following:

#!/bin/sh
rfkill unblock bluetooth
sdptool add -channel=3D22 SP
sleep 1
bluetoothctl << EOF
agent NoInputNoOutput
EOF
sleep 1

Again it just report "No agent is registered".


I have been in communication with Intel support but I've got to a point whe=
re I don't think I can get any further and they have recommended that I con=
tact you.

https://communities.intel.com/thread/104504


Any help would be very much appreciated.

Kind regards

Jay Montague
Software Engineer


Scott Safety
Unit 14, Repton Close,
Basildon, Essex. SS13 1LN UK
Office: +44 (0)1268 527 700 Ext. 210
Direct: +44 (0)1268 885 360
Fax: +44 (0)1268 527 799

[email protected]
http://www.ScottSafety.com

Follow Scott Safety





CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is =
for the sole use of the intended recipient(s) and may contain confidential =
and privileged information or information otherwise protected by law. Any u=
nauthorized review, use, disclosure or distribution is prohibited. If you a=
re not the intended recipient, please contact the sender by reply e-mail an=
d destroy all copies of the original message. Any applicable rights to priv=
ilege have not been waived.




________________________________

This e-mail contains privileged and confidential information intended for t=
he use of the addressees named above. If you are not the intended recipient=
of this e-mail, you are hereby notified that you must not disseminate, cop=
y or take any action in respect of any information contained in it. If you =
have received this e-mail in error, please notify the sender immediately by=
e-mail and immediately destroy this e-mail and its attachments.


2016-09-09 15:33:09

by Montague, Jay

[permalink] [raw]
Subject: RE: bluez bluetooth problem

VGhhbmtzIEJhcnJ5DQoNCi0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQpGcm9tOiBCYXJyeSBC
eWZvcmQgW21haWx0bzozMWJhejY2QGdtYWlsLmNvbV0NClNlbnQ6IDA5IFNlcHRlbWJlciAyMDE2
IDE2OjI3DQpUbzogTW9udGFndWUsIEpheSA8am1vbnRhZ3VlQHR5Y29pbnQuY29tPg0KQ2M6IEpv
aGFuIEhlZGJlcmcgPGpvaGFuLmhlZGJlcmdAZ21haWwuY29tPjsgbGludXgtYmx1ZXRvb3RoQHZn
ZXIua2VybmVsLm9yZw0KU3ViamVjdDogUmU6IGJsdWV6IGJsdWV0b290aCBwcm9ibGVtDQoNCkhp
IEpheSwNCg0KT24gOSBTZXB0ZW1iZXIgMjAxNiBhdCAxNjoxNCwgTW9udGFndWUsIEpheSA8am1v
bnRhZ3VlQHR5Y29pbnQuY29tPiB3cm90ZToNCj4gPiB5b3UgbWlnaHQgd2FudCB0byBsb29rIGlu
dG8gdXNpbmcgdGhlIHByb2ZpbGUgQVBJIGluc3RlYWQgKHNlZSBkb2MvcHJvZmlsZS1hcGkudHh0
IGFuZCB0ZXN0L3Rlc3QtcHJvZmlsZSkuDQo+IEJ1dCBJIGd1ZXNzIGlsbCBsb29rIGludG8gdXNp
bmcgdGhlIEF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Jrd0EzbzNt
VUNtZmxuaTVybEJMUjgmZT0NCg0KX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18NCg0K
VGhpcyBlLW1haWwgY29udGFpbnMgcHJpdmlsZWdlZCBhbmQgY29uZmlkZW50aWFsIGluZm9ybWF0
aW9uIGludGVuZGVkIGZvciB0aGUgdXNlIG9mIHRoZSBhZGRyZXNzZWVzIG5hbWVkIGFib3ZlLiBJ
ZiB5b3UgYXJlIG5vdCB0aGUgaW50ZW5kZWQgcmVjaXBpZW50IG9mIHRoaXMgZS1tYWlsLCB5b3Ug
YXJlIGhlcmVieSBub3RpZmllZCB0aGF0IHlvdSBtdXN0IG5vdCBkaXNzZW1pbmF0ZSwgY29weSBv
ciB0YWtlIGFueSBhY3Rpb24gaW4gcmVzcGVjdCBvZiBhbnkgaW5mb3JtYXRpb24gY29udGFpbmVk
IGluIGl0LiBJZiB5b3UgaGF2ZSByZWNlaXZlZCB0aGlzIGUtbWFpbCBpbiBlcnJvciwgcGxlYXNl
IG5vdGlmeSB0aGUgc2VuZGVyIGltbWVkaWF0ZWx5IGJ5IGUtbWFpbCBhbmQgaW1tZWRpYXRlbHkg
ZGVzdHJveSB0aGlzIGUtbWFpbCBhbmQgaXRzIGF0dGFjaG1lbnRzLg0K

2016-09-09 15:27:19

by Barry Byford

[permalink] [raw]
Subject: Re: bluez bluetooth problem

Hi Jay,

On 9 September 2016 at 16:14, Montague, Jay <[email protected]> wrote:
> > you might want to look into using the profile API instead (see doc/profile-api.txt and test/test-profile).
> But I guess ill look into using the API profile instead. You didn't attach any documents so I guess these are available on github or something.
To give the full paths...

The documentation can be found at:
http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/profile-api.txt

The Python example for using that API is at:
http://git.kernel.org/cgit/bluetooth/bluez.git/tree/test/test-profile

2016-09-09 15:14:49

by Montague, Jay

[permalink] [raw]
Subject: RE: bluez bluetooth problem

Hi Johan,

When I manually enter the command "agent NoInputNoOutput" in bluetoothctl i=
t works and registers the agent to be used for when pairing to a Bluetooth =
device. But when I try the same command in code it doesn't register it like=
I described originally, and it doesn't exit bluetoothctl either. It also d=
oesn't work with other commands like "discoverable on" etc.

But I guess ill look into using the API profile instead. You didn't attach =
any documents so I guess these are available on github or something.

Jay

-----Original Message-----
From: Johan Hedberg [mailto:[email protected]]
Sent: 09 September 2016 11:43
To: Montague, Jay <[email protected]>
Cc: [email protected]
Subject: Re: bluez bluetooth problem

Hi Jay,

On Wed, Sep 07, 2016, Montague, Jay wrote:
> I have tried to send commands using the Eclipse IDE but when I send the f=
ollowing:
>
> system("echo -e 'agent NoInputNoOutput\n | bluetoothctl");
>
> On the Edison it reports "No agent is registered" and the following messa=
ge:

bluetoothctl *is* the agent, and since I assume it exits after piping the c=
ommand to it, it's not really a surprise that bluetoothd says there is no a=
gent.

> #!/bin/sh
> rfkill unblock bluetooth
> sdptool add -channel=3D22 SP
> sleep 1
> bluetoothctl << EOF
> agent NoInputNoOutput
> EOF
> sleep 1
>
> Again it just report "No agent is registered".

As I said earlier, that's because bluetoothd presumably exited. It needs to=
run in order for an agent to exist.

Regarding sdptool & rfcomm usage, you might want to look into using the pro=
file API instead (see doc/profile-api.txt and test/test-profile).
It'll take care of the SDP and RFCOMM details for you, and e.g.
completely skip TTYs in favor of RFCOMM sockets (I see you reported that yo=
u had some kernel issues with the TTYs).

Johan

________________________________

This e-mail contains privileged and confidential information intended for t=
he use of the addressees named above. If you are not the intended recipient=
of this e-mail, you are hereby notified that you must not disseminate, cop=
y or take any action in respect of any information contained in it. If you =
have received this e-mail in error, please notify the sender immediately by=
e-mail and immediately destroy this e-mail and its attachments.

2016-09-09 10:42:47

by Johan Hedberg

[permalink] [raw]
Subject: Re: bluez bluetooth problem

Hi Jay,

On Wed, Sep 07, 2016, Montague, Jay wrote:
> I have tried to send commands using the Eclipse IDE but when I send the following:
>
> system("echo -e 'agent NoInputNoOutput\n | bluetoothctl");
>
> On the Edison it reports "No agent is registered" and the following message:

bluetoothctl *is* the agent, and since I assume it exits after piping
the command to it, it's not really a surprise that bluetoothd says there
is no agent.

> #!/bin/sh
> rfkill unblock bluetooth
> sdptool add -channel=22 SP
> sleep 1
> bluetoothctl << EOF
> agent NoInputNoOutput
> EOF
> sleep 1
>
> Again it just report "No agent is registered".

As I said earlier, that's because bluetoothd presumably exited. It needs
to run in order for an agent to exist.

Regarding sdptool & rfcomm usage, you might want to look into using the
profile API instead (see doc/profile-api.txt and test/test-profile).
It'll take care of the SDP and RFCOMM details for you, and e.g.
completely skip TTYs in favor of RFCOMM sockets (I see you reported that
you had some kernel issues with the TTYs).

Johan