Community
cancel
Showing results for 
Search instead for 
Did you mean: 
CLin82
New Contributor I
1,215 Views

How to implement Yocto command in arduino? Bluez, Gatt

Jump to solution

Hi all,

I am using a NRF8001 Bluetooth 4.0 module + PIR sensor to communicate with my Intel Edison. Following some instructions I found in this forum, one of the possible solution is to use GATT (https://software.intel.com/en-us/articles/using-the-generic-attribute-profile-gatt-in-bluetooth-low-... https://software.intel.com/en-us/articles/using-the-generic-attribute-profile-gatt-in-bluetooth-low-...). First I installed Gatttool as well as Bluez-5.24 software package in my Edison.

The command I used in Yocto is:

root------my password------rfkill unblock bluetooth ------export PATH=$PATH:~/bluez-5.24/attrib/ ------gatttool -b D2:AD:9F:B7:BB:60 -I -t random ------connect------char-write-req 0xe 0100

When the PIR sensor is triggered, it sends 0x31 (AscII which is char '1' ). And I can now receive it on the command window.

Now the problem is how to script it into Arduino code ?

I tried to use system() call in my arduino sketch like:

void setup() {

Serial.begin(115200);

system("root");

system("my password");

system("rfkill unblock bluetooth");

system("export PATH=$PATH:~/bluez-5.24/attrib");

system("gatttool -b D2:AD:9F:B7:BB:60 -I -t random");

system("char-write-req e 0100");

}

void loop() {

// other code

}

But it did not work, the bluetooh link is not established as expectation. And I also would like to ask how to display the message I received "0x31" in the arduino serial port?

1 Solution
Pedro_M_Intel
Employee
68 Views

Hello channinglin,

If using the system command is not working for you, then I'd suggest to use a system service instead. By the way, you don't need to call "root" and your password when using the command system.

I wrote a document about a similar subject that you might find of help. It will require some modifications but probably not many:

/docs/DOC-102152 Automatically connect to a device through Bluetooth

Regarding your second question, the user CMata_Intel wrote a very good example on how to "see" Linux info in the Arduino serial port, check /message/370799# 370799 Re: Battery supply monitor, it might be of your interest.

Peter.

View solution in original post

1 Reply
Pedro_M_Intel
Employee
69 Views

Hello channinglin,

If using the system command is not working for you, then I'd suggest to use a system service instead. By the way, you don't need to call "root" and your password when using the command system.

I wrote a document about a similar subject that you might find of help. It will require some modifications but probably not many:

/docs/DOC-102152 Automatically connect to a device through Bluetooth

Regarding your second question, the user CMata_Intel wrote a very good example on how to "see" Linux info in the Arduino serial port, check /message/370799# 370799 Re: Battery supply monitor, it might be of your interest.

Peter.

View solution in original post

Reply