BLE python script
Answer
6/28/17 5:02 PM

Dear XDK community,

 

I've spent a lot of time to set up a BLE connection between the Bosch XDK and the Raspberry pi. The aim is that I can send sensor Data from the XDK to the Pi. On the Pi side I use Bluez and run a python script. I'm able to pair and connect both devices. But I'm not able to exchange datas (like it works with the Alpwise BLE App). With the Pi I can detect 3 BLE services of the XDK (Generic Access Profile, Generic Attribute Profile and Alpwise Data Exchange service. I miss the RX and TX data exchange service of Alpwise, could I activate them at the XDK, but as  I mentioned the exchange with Alpwise App work?). Has anybody an idea what BLE services I have to use for data exchange? Or has an already running python script for data exchange, so that I could compare?

For python I use the Adafruit_BluefruitLE library (is for BLE). On the XDK runs the "SendAccelerometerDataoverBLE" example.

Thank you very much :)

Bjoern

+2 (2 Votes)
RE: BLE python script
Answer
6/29/17 2:36 PM as a reply to Bjoern Michele.

Hi Bjorn, I have been developing a application with share some points of  your project, XDK communicating with a Linux based computer (such RPi or another that uses BlueZ), In this project we developed our own application in C on linux side with a Gatt layer that can capture data from XDK using alpiwise exchange data service.

You can use my project sources as hint how to perform this communication in XDK and in linux side, then just use some IPC (such DBUS) to comunicate with you python script please refer the repos:

XDK fw: https://github.com/uLipe/beeinformed_edge_fw

Linux SBC C apllication: https://github.com/uLipe/beeinformed_gateway_fw

Gattlib layert to access BLE as service and characteristic fashion: https://github.com/uLipe/gattlib

Of course you can find the full project in instructables: https://www.instructables.com/id/BeeInformed-Environmental-Analyzer-for-Beekeeping/

Please let me know if this helped you.

Best

Felipe

 

+1 (1 Vote)
RE: BLE python script
Answer
6/30/17 12:49 PM as a reply to Felipe Neves.

Hi Felipe,

 

thank you very much for your  answer, the code examples help me very much, I haven't thought about using C but that's a good idea. 

 

Have a great weekend.

 

Best regards

Bjoern

0 (0 Votes)
RE: BLE python script
Answer
6/30/17 2:25 PM as a reply to Bjoern Michele.

Hello Bjoern,

Welcome to the XDK community.

@Felipe, thank you very much for your reply.

The “SendAccelerometerDataoverBle” example makes use of the alpwise data exchange service and should “activate” the service per default.

Nevertheless I would recommend to go through the BLE Guide to get a basic understanding of the differences between profiles, services and characteristics. 

In addition the guide explains in detail how to setup up and use the interface on the XDK.

If you are sure the XDK is running correctly I would recommend to implement the python script. I would recommend this order in particular because I assume that the connection issue could be caused by Bluez and not by your python script. 

As far as I know, there were data exchanging issues between HCI tools, GATT tools and the XDK.

There is an old thread about the topic in the XDK community, where a user tried to build a similar application.

Please let me know if this was helpful and do not hesitate to ask if you have further questions.

Kind regards,
Manuel

+1 (1 Vote)
RE: BLE python script
Answer
7/5/17 8:42 PM as a reply to Manuel Cerny.

Hello Manuel,

thank you very much, the old thread looks very helpful. I will check it in the next few days.(Unfortunately I was out of office the last day, so sorry for my late answer.)

Just to make my question clear, in my oppinion the part at Bosch XDK runs, because I'm able to get the information  with the ALPWISE BLE App, so  I would say the XDK sends the information via Bluetooth correctly. (But perhaps I missunderstand something, so please correct me if you meant something different)

 

Have a greet week.

 

Best regards Bjoern

0 (0 Votes)
RE: BLE python script
Answer
7/6/17 2:01 PM as a reply to Bjoern Michele.

Hello Bjoern,

You are correct, the BLE implementation regarding the Alpwise exchange service should work fine on the XDK, if you are able to receive data by using the Alpwise app.

Thus as I mentioned I guess that there is an issue regarding GATT (Generic Attribute Profile) within BlueZ and that’s the reason why you are unable to see the RX and TX services on your Linux server side.

To solve this, I recommend to use the GATT layer Felipe mentioned in his post to be able to exchange data with the XDK.

Please do not hesitate to ask, if you have further questions.

Kind regards,
Manuel

0 (0 Votes)
RE: BLE python script
Answer
1/24/19 10:16 AM as a reply to Manuel Cerny.

Hi Felipe,

I try to import your project beeinformed_edge_fw to WB, but I can not. Do you have any tricks?

Béla

0 (0 Votes)