gatt.addCharacteristic failing

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
gregnsantos
 
Posts: 3
Joined: Fri Sep 07, 2018 12:14 am

gatt.addCharacteristic failing

Post by gregnsantos »

Folks,

I'm having some fundamental problems with some code that I'm trying to port from the Arduino 101 to the Adafruit Feather M0 Bluefruit LE that supports Homebridge sensor information Using this code as a baseline:

https://github.com/vojtamolda/homebridg ... efruit.ino

I'm trying to establish a characteristic but it is always returning a fail return code using the following:

#include <SPI.h>
#include <Arduino.h>
#include <Adafruit_BLE.h>
#include <Adafruit_BLEGatt.h>
#include <Adafruit_BluefruitLE_SPI.h>
Adafruit_BluefruitLE_SPI ble(8, 7, 4); // Firmware > 0.7.0
Adafruit_BLEGatt gatt(ble);
int32_t informationService;
int32_t modelCharacteristic;

informationService = gatt.addService(0x180A); <-- No problem this works

char model[] = "Feather";
modelCharacteristic = gatt.addCharacteristic(0x2A24, GATT_CHARS_PROPERTIES_READ,
sizeof(model)+1, sizeof(model)+1, BLE_DATATYPE_STRING);
if(modelCharacteristic == 0) {
Serial.println("Could not add model characteristic"); <-- This always executes
}

This code works:
if (ble.sendCommandCheckOK("AT+GATTADDCHAR=UUID=0x2A24,PROPERTIES=0x02, MIN_LEN=1, MAX_LEN=9,VALUE=Feather")) {
Serial.println("BLE GATT add model characteristic successful");
}

I've just found that the gatt.addCharacteristic is NOT functioning. Are the AT+GATT commands the only way to work with the Adafruit M0 Feather Bluefruit LE? Am I missing some requirement for the gatt.addCharacteristic to work properly on the Adafruit M0 Feather Bluefruit LE?

I would appreciate your help....I'm sure it's something obvious, but if you can guide me in the correct direction, then I would appreciate it. Thanks Greg

User avatar
gregnsantos
 
Posts: 3
Joined: Fri Sep 07, 2018 12:14 am

Re: gatt.addCharacteristic failing

Post by gregnsantos »

I've debugged this further, and found that the

Example: Adafruit Bluefruit nRF51 --> healththermometer

Has the same issue on my Adafruit Feather M0 Bluefruit LE. I get an error when the following is executed:

htsMeasureCharId = gatt.addCharacteristic(0x2A1C, GATT_CHARS_PROPERTIES_INDICATE, 5, 5, BLE_DATATYPE_BYTEARRAY);
if (htsMeasureCharId == 0) {
error(F("Could not add Temperature characteristic"));
}

In the monitor I see:
AT+GATTADDCHAR=UUID=10780,PROPERTIES=32,MIN_LEN=5,MAX_LEN=5,DATATYPE=2
Option Error: DATATYPE=2

What could be wrong with the DATATYPE? Based on the Adafruit_BLE.h, it looks valid

enum BLEDataType_t
{
BLE_DATATYPE_AUTO = 0,
BLE_DATATYPE_STRING,
BLE_DATATYPE_BYTEARRAY,
BLE_DATATYPE_INTEGER,
};

Any ideas?

User avatar
gregnsantos
 
Posts: 3
Joined: Fri Sep 07, 2018 12:14 am

Re: gatt.addCharacteristic failing

Post by gregnsantos »

Okay, maybe I should have read the fine print a little more. If you have an Adafruit Feather M0 Bluefruit LE, then make sure you update the BLE firmware via formation at this link:

https://learn.adafruit.com/adafruit-fea ... it-updates

In my case, I used the IOS app (Bluefruit LE Connect app available in the App Store) to update to 0.8.0

As it turned out, my onboard Bluefruit BLE firmware was downlevel, and this was the source of multiple errors I was getting when trying to use gatt.addCharacteristic and gatt.getChar functions in the Adafruit_BluefruitLE_nRF51 library.

Hope this helps someone else.....Greg

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

Return to “Wireless: WiFi and Bluetooth”