AT+GATTADDCHAR characteristic index?

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
ssworks
 
Posts: 18
Joined: Fri Apr 13, 2018 2:58 pm

AT+GATTADDCHAR characteristic index?

Post by ssworks »

Hi,

I'd like to create a custom characteristic on a Adafruit Feather M0 Bluefruit LE. I'm using the Arduino IDE. I don't know how to get the index of the custom characteristic that I create.

I'm looking at the AT+GATTCHAR documentation which has the following code.

Code: Select all

# Clear any previous custom services/characteristics
AT+GATTCLEAR
OK

# Add a battery service (UUID = 0x180F) to the peripheral
AT+GATTADDSERVICE=UUID=0x180F
1
OK
  
# Add a battery measurement characteristic (UUID = 0x2A19), notify enabled
AT+GATTADDCHAR=UUID=0x2A19,PROPERTIES=0x10,MIN_LEN=1,VALUE=100
1
OK

# Read the battery measurement characteristic (index ID = 1)
AT+GATTCHAR=1
0x64
OK

# Update the battery measurement characteristic to 32 (hex 0x20)
AT+GATTCHAR=1,32
OK
The `AT+GATTADDCHAR` command returns `1` which is the index of the characteristic. This index needs to be used in the subsequent `AT+GATTCHAR` read and write calls.

When I'm writing my sketch in the Arduino IDE, I don't know how to get the result of a call to `ble.atcommand("AT+GATTADDCHAR", "UUID=0x2A19,PROPERTIES=0x10,MIN_LEN=1,VALUE=100")`. How do I read the AT command's result so that I can store the index and then use it later when I want to set the characteristic value?

Where is the documentation for `ble.atcommand`?

I already do the following in my code successfully.

Code: Select all

ble.atcommand("AT+GAPDEVNAME", MY_DEVICE_NAME);
ble.atcommand("AT+GAPSTOPADV");
ble.atcommand("AT+GAPSETADVDATA", MY_ADVERTISING_DATA);
ble.atcommand("AT+GAPSTARTADV");
THANKS!!!

Steve

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

Return to “Wireless: WiFi and Bluetooth”