Page 1 of 1

BLE QUESTION: How can I add more advertised GATT services to a BLE mesh node?

Posted: Sat Jan 14, 2023 6:06 pm
by lukecam95
Hi,

I am currently writing a mobile application with Capacitor framework and I need the app and a node in a ESP-BLE mesh to share data. To do this, I have the idea of creating 2 GATT services on the BLE mesh node; 1 for receiving another 1 for transmitting.

When I scan the BLE node using the app, I see that it has 1 service used for the mesh advertising. How can I add another custom GATT service?

Thank you for your time.

Re: BLE QUESTION: How can I add more advertised GATT services to a BLE mesh node?

Posted: Sun Jan 15, 2023 4:50 pm
by ujurmsde
I do not know about which BLE framework, lets say esp's own(bluedroid) or NimBLE port for ESP32 you are using.?

But Nimble also supports mesh network. For that you need to define a struct containing services and characteristics. Then you should have callbacks for those BLE GATT/GAP events. This is the normal flow...

Example....

Code: Select all

static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
    {
        .type = BLE_GATT_SVC_TYPE_PRIMARY,
        .uuid = &gatt_server_service_uuid.u,
        .characteristics = (struct ble_gatt_chr_def[]){ {
        
        .uuid = &gatt_server_f_characteristic_uuid.u,
        .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ,
        .access_cb = gatt_callback
        //.val_handle = &gatt_svr_chr_val_handle,       
    
    },  {
        .uuid = &gatt_server_s_characteristic_uuid.u,
        .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ,
        .access_cb = gatt_callback
        //.val_handle = &gatt_svr_chr_val_handle,    
    }, {
        .uuid = &gatt_server_t_characteristic_uuid.u,
        .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ,
        .access_cb = gatt_callback
        //.val_handle = &gatt_svr_chr_val_handle,
        
    },  {
    0,
    },
    }
    },
    {
    0,
    },
};

Re: BLE QUESTION: How can I add more advertised GATT services to a BLE mesh node?

Posted: Sun Jan 15, 2023 5:07 pm
by lukecam95
Thanks for the reply.

I am using the ESP-BLE-MESH library with NimBLE stack.

The confusing part for me is how to register those GATT services when setting the ESP32 as a BLE Mesh node since the initialization of the GATT server and registering of services is handled internally by the BLE-MESH library code. Hence, I do not have a pointer to the GATT server to register custom services.