Nimble char descriptor

jeanbi
Posts: 4
Joined: Mon Jan 06, 2020 12:56 pm

Nimble char descriptor

Postby jeanbi » Mon Jan 06, 2020 1:04 pm

Hello,

I'm using Nimble on esp-idf v4.0-beta1. I followed the example https://github.com/espressif/esp-idf/tr ... le/bleprph to make a peripheral and it's ok but there is not any descriptors in the example.
I tried to implement that with documentation of Mynext Nimble without success.

Do you have an example that is working?

Thank you.

Here is my code :

Code: Select all

static const struct ble_gatt_svc_def gatt_svr_svcs[] = 
{
    {
        /*** Service: Sensor Gateway. */
        .type = BLE_GATT_SVC_TYPE_PRIMARY,
        .uuid = &gatt_svr_svc_sensor_gateway_uuid.u,
        .characteristics = (struct ble_gatt_chr_def[])
        { {
                /*** Characteristic: Gateway ID. */
                .uuid = &gatt_svr_chr_gateway_id_uuid.u,
                .access_cb = gatt_svr_chr_access_gateway_sensor,
                .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_WRITE,
                .descriptors = (struct ble_gatt_dsc_def[])
                { {
                        .uuid = &GATT_DESCRIPTOR_UUID.u,
                        .att_flags = BLE_GATT_CHR_F_READ,
                        .access_cb = gatt_srv_descriptor_gateway_sensor,
                        .arg = (void*) "description1",
                    },
                    {
                        0 // No more descriptors
                    },
                }
            }, {
                /*** Characteristic: Script ID. */
                .uuid = &gatt_svr_chr_script_id_uuid.u,
                .access_cb = gatt_svr_chr_access_gateway_sensor,
                .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_WRITE,
            }, {
                /*** Characteristic: Server IP. */
                .uuid = &gatt_svr_chr_server_ip_uuid.u,
                .access_cb = gatt_svr_chr_access_gateway_sensor,
                .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_WRITE,
            }, {
                /*** Characteristic: ....
....

br10101
Posts: 15
Joined: Thu Nov 24, 2022 11:08 am

Re: Nimble char descriptor

Postby br10101 » Fri Feb 10, 2023 11:11 am

You need
  1. {
  2.   .uuid =BLE_UUID16_DECLARE(0x2901),
  3.   .access_cb = gatts_conf_chr_access,
  4.   .att_flags = BLE_ATT_F_READ,
  5. }
And in the access_cb you write the description into the mbuf:
  1. os_mbuf_append(ctx->om, "Test", 4);

Who is online

Users browsing this forum: No registered users and 83 guests