J'essaie d'ajouter des descriptions d'utilisateur caractéristiques à mon service BLE GATT personnalisé, en utilisant le mbed API. Mon travail a jusqu'à présent été basé sur la structure du code this. Cependant, j'aimerais ajouter des noms à ces caractéristiques. Il n'y a pas beaucoup d'informations que je pourrais trouver sur la façon de le faire. Cependant, ci-dessous est un commentaire d'un forum, indiquant comment le faire.Ajout de la description d'utilisateur caractéristique au service GATT C++ BLE GATT
The constructor for GattCharacteristic() takes an array of GattAttribtues as an optional argument. You can populate your User-Description into a GattAttribute and pass it along to the Characteristic.
Jusqu'ici, j'ai cette structure qui configure mes caractéristiques.
uint16_t newServiceUUID = 0xA000;
uint16_t PercentageUUID = 0xA001;
uint16_t TimeUUID = 0xA002;
uint16_t UseProfileUUID = 0xA003;
const static char DEVICE_NAME[] = "Device"; // Device name
static const uint16_t uuid16_list[] = {0xFFF};
static uint8_t percentageValue[10] = {0};
WriteOnlyArrayGattCharacteristic<uint8_t,
sizeof(percentageValue)> percentageChar(PercentageUUID, percentageValue);
static uint8_t timeValue[10] = {0};
ReadWriteArrayGattCharacteristic<uint8_t,
sizeof(timeValue)> timeChar(TimeUUID, timeValue);
static uint8_t UseProfileValue[10] = {0};
WriteOnlyArrayGattCharacteristic<uint8_t,
sizeof(UseProfileValue)> UseProfileChar(UseProfileUUID, UseProfileValue);
// Set up custom service
GattCharacteristic *characteristics[] = {&percentageChar, &timeChar, &UseProfileChar};
GattService newService(newServiceUUID, characteristics, sizeof(characteristics)/sizeof(GattCharacteristic *));
Comment ajouter les descriptions à ces 3 caractéristiques?
EDIT
J'ai maintenant:
static uint8_t percentageValue[10] = {0};
GattAttribute descr(BLE_UUID_DESCRIPTOR_CHAR_USER_DESC, (uint8_t *)"Percentage", strlen("Percentage"));
WriteOnlyArrayGattCharacteristic<uint8_t,
sizeof(percentageValue)> percentageChar(PercentageUUID,
percentageValue,
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_EXTENDED_PROPERTIES,
&descr,
1);
Il jette un Error: No instance of constructor "WriteOnlyArrayGattCharacteristic<T, NUM_ELEMENTS>::WriteOnlyArrayGattCharacteristic [with T=std::uint8_t, NUM_ELEMENTS=10U]" matches the argument list in "main.cpp"
sur la ligne "de taille".
Merci, la première ligne renvoie cette erreur: Erreur: 'Aucune instance de constructeur" WriteOnlyArrayGattCharacteristic :: WriteOnlyArrayGattCharacteristic [avec T = std :: uint8_t, NUM_ELEMENTS = 10U] "correspond à la liste des arguments dans" main .cpp "' –
Essayez '&& descr' car cela nécessite un pointeur vers le tableau. Il serait plus sûr/plus agréable de déclarer un tableau réel de 'GattAttribute', comme vous l'avez fait pour les caractéristiques. – jpo38
qui déclenche l'erreur du compilateur: 230 - Erreur (s) de syntaxe dans Assembly. –