Setting GATT characteristic UUID

DerrickLau
Posts: 7
Joined: Mon Apr 13, 2020 9:09 pm

Setting GATT characteristic UUID

Postby DerrickLau » Wed Sep 09, 2020 12:22 am

I'm trying to set the UID for a GATT characteristic of my ESP32 BLE GATTs server application.

First I do this:

Code: Select all

esp_bt_uuid_t AlgCharGuid = 0xbe;
I then pass that value into a method here:

Code: Select all

esp_err_t add_char_ret = _alg.RegisterCharacteristicWithGatt(serviceHandle, AlgCharGuid);
The RegisterCharacteristicWithGatt() method looks like this:

Code: Select all

sp_err_t BleGattCharacteristic::RegisterCharacteristicWithGatt(uint16_t serviceHandle, esp_bt_uuid_t charGuid)
{
    ESP_LOGV(REGISTER_CHARACTERISTIC_WITH_GATT, "Calling esp_ble_gatts_add_char()...");
    if (nullptr == charGuid)
    {
        ESP_LOGV(REGISTER_CHARACTERISTIC_WITH_GATT, "Passed in NULL pointer for characteristic GUID");
        return 0;
    }
     _add_char_ret = esp_ble_gatts_add_char(serviceHandle, charGuid, ESP_GATT_PERM_WRITE,
                                                     _gattProperty, &_attrValue, NULL);
    ESP_LOGV(REGISTER_CHARACTERISTIC_WITH_GATT, "Called esp_ble_gatts_add_char().");
    //_attrValue.attr_len = charGuid->len;
    //_attrValue.attr_len = GATT_CHAR_SIZE;
    //_char_uuid.uuid128 = charGuid;
    memcpy(charGuid, _char_uuid, sizeof(charGuid));
    ESP_LOGV(REGISTER_CHARACTERISTIC_WITH_GATT, "Characteristic attribute size set.");


     if (_add_char_ret)
     {
         ESP_LOGE(REGISTER_CHARACTERISTIC_WITH_GATT, "add characteristic failed, error code =%x",_add_char_ret);
     }

     
     return _add_char_ret;
}
However I don't get very far. I get this error thrown during build:

Code: Select all

../main/BleIdToken.h:85:30: error: could not convert '190' from 'int' to 'esp_bt_uuid_t'
  esp_bt_uuid_t AlgCharGuid = 0xbe;
 
How do I assign a value to a variable of type esp_bt_uuid_t? Also, is my above RegisterCharacteristicWithGatt() method correctly assigning a UID to my characteristic?

Thanks!

Who is online

Users browsing this forum: No registered users and 360 guests