BLE Toolkit
BLE (Bluetooth LE, Bluetooth low energy, marketed as Bluetooth Smart) is a wireless personal area network technology designed and marketed by the Bluetooth Special Interest Group aimed at novel applications in the healthcare, fitness, beacons, security, and home entertainment industries. Compared to Classic Bluetooth, Bluetooth Smart is intended to provide considerably reduced power consumption and cost while maintaining a similar communication range. Wikipedia entry.
While LabVIEW supports Classic Bluetooth (on Windows), it does not provide support for BLE. To solve this issue, a workaround is to use a BLE dongle to handle the communication. http://digital.ni.com/public.nsf/allkb/4BA51235CFC8519086257F5E005E81D5
The BLE toolkit for LabVIEW is an implementation of the API Bluegica BGAPI v1.10 , that allows to communicate with Bluegiga BLE(D)11x and WF121 devices using USB/UART.
During the development of the Toolkit, the BLED112 USB dongle was used
Beside the Toolkit, three examples are provided:
* Discover and connect to BLE devices (ble_scan_devices.vi)
* Reading and Writing Characteristics values (ble_read_write_characteristics.vi)
* Acquiring Heart Rate data stream (ble_read_hr_monitor.vi)
Instructions.
1. Get a BLED112 USB dongle (e.g. in Digi-Key)
2. Install the drivers provided by Bluegiga
3. Verify the COM number for the dongle in Device Manager > Ports
4. Download and install the LabVIEW BLE Toolkit (package below)
5. Open the ble_scan_devices.vi example provided in
<Labview>\examples\BLE\Examples\ble_scan_devices.vi
6. Select the COM port for your BLED112 dongle
7. Run the VI
The source files for this Toolkit are available on GitHub: https://github.com/MuSAELab/BLE-Toolkit-LabVIEW
INSTALLATION
To install the BLE Toolkit for LabVIEW, the VI Package Manager by JKI is needed.
Hello rCassani,
Thank you for such a wonderfull toolkit. It worked like magic in deteting heart rate.
Although we had initial issues like, the device must have public MAC address and the Random MAC address was assigned to android mobiles. Hence we were not able to communicate to Mobile Phones. But embedded device with public MAC address works.
Thank you very much for the great tool kit.
Ideally I would like to read a message which is longer than the 23 bytes which the BLED112 dongle supports. Is there a way to read longer messages or do multiple reads in order to transfer messages which are longer than 20 bytes?
Thank you very much for your kind help.
All the best
Peter
Hi all,
Me also have same problem. That is, one packet have the size of 100 bytes. but this VI is reading only first 20 bytes. other 80 bytes in one packet is missing. how can i read the hex values of more than 20 bytes from one packet?
Any help is greatly appreciated.
thanks
Hello,
firstly, thank you for this toolkit. I would like to ask you about the sample rate. I acquire a signal from the BLE113 where the soft timer was set on 100 Hz (100 S/s). However, the signal which I obtain in LabView has an unconstant sample rate which is around 94 S/s. Do you have please any experience regarding this or any suggestion on how to deal with that?
I am also not sure where that number (94 S/s) came from. If you have an idea how to calculate it in this I would be grateful. I need to obtain the RR interval from the ECG signal so I need the sample rate to get the time from the samples.
Thank you,
Dan
@satode, how did you resolve your problem?
I have got the same problem as you..
("Error 0 occurred at Service: 1800 and Characteristic 2A00 were not found")
Did you ever found out how to subscribe for notifications for a certain characteristic?
I have the same issue: https://forums.ni.com/t5/LabVIEW/LabVIEW-BLE-Bluetooth-Low-Energy-toolkit-and-Inkbird-IBT6X/td-p/405...
Hi,
Thank you for developing this toolkit!
I'm facing some issues when I try to read characteristics with a long 128-bit Uuid. Is there any way to implement this long custom Uuid in the .vi?
Many thanks
Fulvio
Hi,
Thanks for developing this toolkit! Currently I have an issue in regards to disconnecting the dongle. I'm using the ble_evt_attclient_attribute_value API in a loop to read incoming large amount of data that the peripheral device sends every few minutes. The peripheral sends 276 packets of data (20 bytes each) after a few minutes. I noticed that when the peripheral hasn't sent data yet, the loop runs slowly even though I did not put any wait function, I suspect that the API is trying to find data and will keep finding it until the given timeout and then move to the next loop iteration. When the peripheral data is sending data I can see the data received and the loop runs really fast.
I tried to disconnect while the loop is running slowly and I get the error shown in the image below and I'm not sure how to solve that. I used the BLE GUI which also uses the same API and I was able to disconnect.
How do I get the GATT table from a device using LabVIEW BLE Toolkit?
I've managed to communicate with the device using a Handle, but it turns out that the Handle isn't persistent and the UUID should be used. By reading the GATT table, I could find which Handle is connected to a specific UUID.
Hi,
I have found this toolkit very useful for my application. However; it has one drawback for me -- when I read a characteristic I only get the first 22 bytes of the data. I would like to get as much as 32 bytes when reading a characteristic. I see a similar 22 byte data limit was encountered by acovian on 10/6/17. Has anyone found a way to get more than 22 bytes of data from a characteristic?
Thanks in advance for any information.
Steve
Hi FrasseKatt.
Did you ever figure out how to access the GATT w/ the toolkit? I am also interested in whether or not this is possible.
Thanks,
George
More than 22 bytes can be read using "Read long" command. This is supported by the driver, message ID is 0x08 (instead of 0x04):
Then cycle serial read until received data size is below 22:
Here are modified vi's if interested: https://drive.google.com/file/d/1TI2hrPDVpciMO7tJ9CVEhvzHnfogAvo7/view?usp=sharing
Cristian G.
R&D Software Developoer
Hi,
This post is to answer some questions about the BLE Toolkit.
Besides this NI Community Document, please submit your comments and questions in the GitHub repository for the toolkit:
https://github.com/MuSAELab/BLE-Toolkit-LabVIEW
- @LvTech and @FrasseKatt. Yes, you can get the handle table with the Toolkit, this is done in the three examples. For sake of UI space the table is a Hidden Indicator, this can be easily changed.
The VI ble_discover_handle_table.vi gets the relation between Handle and Service:Characteristic. Then the Service:Characteristic information can be used to R/W information in the BLE device regardless the Handle number. (Snippet from ble_scan_devices.vi that gets the table, and reads data from characteristic 0x2A00 in service 0x1800)
- @steve_morris The toolkit was updated (29-Nov-2021) to perform Long Read.
Hello all Labview Experts,
If I install a Labview 2021 Community version on my Windows 10 and my BLE dongle is a non-Silicon Labs device, will this VI work?
Hi HKPhysicist,
Sorry, this BLE toolkit for LabVIEW is only for the Bluegiga BLE(D)11x and WF121 devices using USB/UART.
Hello !
Solution for notification !
To activate the notification, you must write 0x01 to the following address of the address on which you want to receive the information.
For me (native UART with Nordic BLE) :
I need to read in the Handle 0x000F
I have to write 0x0001 in this handle first.
Note : For me Read by service/UUID works fine but writing by UUID at this address "2902" don't. That's why I write by handle.
I hope it helps!
Nordic doc :
hi all, can anyone tell me what is the purpose of "ble_rsp_attclient_attribute_write.vi" in ""ble_write_by_handle_uint8array.vi>>ble_write_by_service_characteristic_uint8array.vi"". is it for any acknowledgement from the other end for the data wrote or something else. I am facing an error here while writing data to a ble peripheral. my client device doesn't give any acknowledgment after writing to it. can i simply just remove it.?? does that works fine?? please help.
Hi shiva437, from the BGAPI documentation:
https://www.silabs.com/documents/public/reference-manuals/Bluetooth-LE-Software-API%20Reference-Manu...
"The command messages are transmitted from the Application to the Stack [Bluegiga BT device] and the Stack provides a response to every successfully received command."
"The Application should always wait for the response to a command before issuing another command."
The Bluegiga BT device will provide this response if the write command was well received. It is not from the remote device you want to write to.
Once the remote device acknowledges the write operation to the Bluegiga BT device, a procedure_completed event will be generated. This is read with "ble_evt_attclient_procedue_completed.vi" in "ble_write_by_handle_uint8array"
hI rCassani, Thank you very much for the detailed explanation. it helped.😊👍
Hi again Cassani,
Is there any function for performing MTU size exchange operation from BLED112. I see that the new ble_cmd_attclient_read_by_handle.vi has an option to read longer messages but that doesn't fit my application. my device sends notification packets of more than 23 bytes. When I tested with an android application I am able to receives data packets after updating the MTU size. I want to replicate the same with Labview, Can you suggest me any ways how to solve this?
Thanks,
shiva
Hi All,
Has there been any examples for connecting to a device with security?
Such as using a MAC (MM:MM:MM:MM:MM:MM) and six-digit pin (DDDDDD).
I know there is an option for changing the Command Class in some VIs to be "Security Manager", Would i just send the MAC address followed by the 6 Digit Code (all data in HEX) or would it need to be a seperate VI?
Thanks
J.Harding
Hi rCassani,
Do you have any ideal Ble payload reading data doesn't match with the bluegiga tool output data and the length of data? Any help would be appreciated.
Thanks
Johnny
Hi all,
I have seen question about notifications but I have not been able to get a solution to work with my device.
I am using the BLED112 Dongle and it is connecting to my device correctly and is reading the name successfully.
Using the bluegiga BLE GUIT I can connect write 0100 to handle 22d (0x16) and I can then see notifications coming in on handle 21d (0x15) in column raw.
In my VI I have tried multiple different reads but none of them are updating the payload. Current attempt snipped below.
Any advice?
Thanks
Joe
Hi All,
I've been using this toolkit very successfully to test some devices. The API allows for reading characteristics greater than 22 bytes by using a read long command. However, I'm trying to read larger notifications, but the user data payload is always truncated to 20 bytes. I can read notification less than 20 bytes successfully but since this is an event, not a response to a command, I don't see in the API manual how to achieve this? Has anyone else been able to receive notification >20 bytes? I hope it is not a limit of the Bluegiga API, but it appears to be.
Thanks,
James
I have found the solution to a 6 Digit security code.
Not all these steps are needed but its my current flow.
This might not work with all set ups but i found it at least lets me connect every 2nd time to my device.
This also relies on using the ble_write_message.vi as opposed to a premade VI and requires some ble_read_message.vi after each command.
Looking for some help with this library. I have had good luck reading characteristic values but I'm really struggling to write values. I'm able to write the values from nRF Connect Android and the device accepts and responds to them. But when I try the same with the BLE Toolkit it's now working.
Here is the portion that does the writing. The array values are 0x00 to request control and then 0x04FF to set a target resistance. It would also be helpful if I could see the Indication response from this write to know if the command was accepted, but I have not figured out how to read an indicated value (as opposed to a notify). Any help is appreciated.
Hi rCassani,
I am going through "ble_read_write_characteristics.vi". However I do not see any numeric control for reading/writing a characteristic value. Can you please guide on this.
I can see below screen when I open the VI:
Secondly, I can see that you have implemented another VI which reads the heart rate characteristic value and displays it. Have you developed any VI which writes a characteristic value using this toolkit? Appreciate your help on this.
Regards.
Hello,
I have the same problem described by James1234: I use notification to read data and I need to read a payload of 128 bytes. It seems that the current BLUEGIGA driver does not allow to have such a payload. It seems to be limited to 20 bytes. Does anyone know if there is a way to fix it?
Thanks