Extending Adafruit_BLE Arduino Library

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tomegan
 
Posts: 2
Joined: Mon Dec 04, 2017 5:32 pm

Extending Adafruit_BLE Arduino Library

Post by tomegan »

Sometimes it is helpful to grab the string(char *) output of an AT command from the BlufruitLE (or other board supported by the Adafruit_BLE library). The library at least version 1.9.5 has support for commands that result in success/failure or an integer but not a string. I personally had a need for the Bluefruit's hardware address which is returned by "AT+BLEGETADDR". My solution was to subclass Adafruit_BluefruitLE_UART which otherwise worked for me and is derived from Adafruit_BLE. My subclass is attached. Usage:

Change:

Code: Select all

Adafruit_BluefruitLE_UART ble(BLUEFRUIT_HWSERIAL_NAME, -1);
to:

Code: Select all

BB_Bluetooth ble(BLUEFRUIT_HWSERIAL_NAME, -1);
Add:

Code: Select all

#define DEVICE_ID_LEN	18
at the top of your code.

Then in your setup or loop code you can use:

Code: Select all

char ble_device_id[DEVICE_ID_LEN];
ble.sendCommandWithStringReply(F("AT+BLEGETADDR"), ble_device_id, 18);
and after the code runs, ble_device_id will contain the Bluefruit's hardware address
Attachments
Bluetooth.cpp
(713 Bytes) Downloaded 57 times
Bluetooth.h
(484 Bytes) Downloaded 51 times

Locked
Please be positive and constructive with your questions and comments.

Return to “Wireless: WiFi and Bluetooth”