Renaming service and characteristic ID Adafruit Bluefruit LE SPI Friend

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
gndAdafruit
 
Posts: 28
Joined: Wed Dec 29, 2021 4:00 pm

Renaming service and characteristic ID Adafruit Bluefruit LE SPI Friend

Post by gndAdafruit »

Hello!

How do I rename the service and characteristic ID's of the Adafruit Bluefruit LE SPI Friend?

I have created them and I can add only one property to each, but I don't know how to rename them.

I am programming in Arduino btw.

https://www.adafruit.com/product/2633

User avatar
mikeysklar
 
Posts: 17737
Joined: Mon Aug 01, 2016 8:10 pm

Re: Renaming service and characteristic ID Adafruit Bluefruit LE SPI Friend

Post by mikeysklar »

You get to name the service and characterisic ID upon creation. Are you trying to rename them after that?

(generated example):

Code: Select all

// Custom UUIDs
#define CUSTOM_SERVICE_UUID        "12345678-1234-5678-1234-56789abcdef0"
#define CUSTOM_CHARACTERISTIC_UUID "abcdef01-1234-5678-1234-56789abcdef0"
#define ANOTHER_CHARACTERISTIC_UUID "fedcba09-8765-4321-fedc-ba0987654321"

// Define services and characteristics
BLEService customService = BLEService(CUSTOM_SERVICE_UUID);
BLECharacteristic customCharacteristic = BLECharacteristic(CUSTOM_CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_NOTIFY);
BLECharacteristic anotherCharacteristic = BLECharacteristic(ANOTHER_CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE);

User avatar
gndAdafruit
 
Posts: 28
Joined: Wed Dec 29, 2021 4:00 pm

Re: Renaming service and characteristic ID Adafruit Bluefruit LE SPI Friend

Post by gndAdafruit »

This is how I am doing it thus far.

Code: Select all

    
/* SERVICE 1 */
/* Main Attributes to show or listen to. */
#define BLE_MAIN_SERVICE_UUID "00-b5-74-fe-7a-a4-43-d6-94-a0-c6-6d-a0-ec-92-56"
#define BLE_PLATFORM_CHAR_UUID "be-12-fc-49-7b-50-4f-5b-81-63-19-2a-71-f6-e6-51"
#define BLE_BLADELOCATION_CHAR_UUID "c5-be-51-da-f1-0a-4a-ef-a9-d4-a0-a1-f7-80-4f-50"
#define BLE_MEASUREMENT_CHAR_UUID "ab-9e-8b-0f-68-1c-48-b9-8d-bf-f3-ce-08-96-da-69"

/*SERVICE 2 */
/* Settings type of Attributes to show or listen to. */
#define BLE_SETTINGS_SERVICE_UUID "e3-d2-fc-cb-1a-65-4c-ad-a4-8f-1d-db-a3-74-29-82"
#define BLE_SWREV_CHAR_UUID "ce-17-ff-cf-da-5c-4c-03-a0-a8-e9-b9-01-f8-bc-b9"
    
    // Start advertising
    ble.sendCommandCheckOK("AT+GAPSTARTADV");
    Serial.println("Advertising started, waiting for connection...");

    // Set up 1st service and characteristic
    Serial << "Adding 1 service ID and characteristic ID's." << endl;
    success = ble.sendCommandWithIntReply(F("AT+GATTADDSERVICE=UUID128=" BLE_MAIN_SERVICE_UUID ""), &serivceID);  // Add service
    if (!success) {
        error(F("Could not add service."));
    }
    success = ble.sendCommandWithIntReply(F("AT+GATTADDCHAR=UUID128=" BLE_PLATFORM_CHAR_UUID ", PROPERTIES=0X10, MIN_LEN=2, MAX_LEN=5, VALUE=00-44"), &charID_0);  // create characteristic
    if (!success) {
        error(F("Could not add characteristic."));
    }
    success = ble.sendCommandWithIntReply(F("AT+GATTADDCHAR=UUID128=" BLE_BLADELOCATION_CHAR_UUID ", PROPERTIES=0X10, MIN_LEN=2, MAX_LEN=5, VALUE=00-44"), &charID_1);  // create characteristic
    if (!success) {
        error(F("Could not add characteristic."));
    }
    success = ble.sendCommandWithIntReply(F("AT+GATTADDCHAR=UUID128=" BLE_MEASUREMENT_CHAR_UUID ", PROPERTIES=0X10, MIN_LEN=2, MAX_LEN=5, VALUE=00-44"), &charID_2);  // create characteristic
    if (!success) {
        error(F("Could not add characteristic."));
    }
    success = ble.sendCommandWithIntReply(F("AT+GATTADDCHAR=UUID128=" BLE_SETTINGS_SERVICE_UUID ", PROPERTIES=0X10, MIN_LEN=2, MAX_LEN=5, VALUE=00-44"), &charID_3);  // create characteristic
    if (!success) {
        error(F("Could not add characteristic."));
    }
    success = ble.sendCommandWithIntReply(F("AT+GATTADDCHAR=UUID128=" BLE_SWREV_CHAR_UUID ", PROPERTIES=0X10, MIN_LEN=2, MAX_LEN=5, VALUE=00-44"), &charID_4);  // create characteristic
    if (!success) {
        error(F("Could not add characteristic."));
    }

    Serial << "Add service to the advertising data (needed for Nordic apps to detect the service)." << endl;
    ble.sendCommandCheckOK(F("AT+GAPSETADVDATA=02-01-06-05-02-0d-18-0a-18"));

User avatar
gndAdafruit
 
Posts: 28
Joined: Wed Dec 29, 2021 4:00 pm

Re: Renaming service and characteristic ID Adafruit Bluefruit LE SPI Friend

Post by gndAdafruit »

Also I am following this guide but I am not sure why it doesn't explain how to rename services and characteristics.

https://learn.adafruit.com/introducing- ... d/ble-gatt

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Arduino”