Adding many Customs Services in RSL10 BLE


I’m developing a BLE application on the RSL10. I’m using with 3.4.2 SDK version.

In my application I want to have two custom services + generic ones.

To do that, I created two functions like below, based from peripheral_server_sleep example :

void CustomService_ServiceAdd(void)
    struct gattm_add_svc_req *req = KE_MSG_ALLOC_DYN(GATTM_ADD_SVC_REQ,
                                                     TASK_GATTM, TASK_APP,
                                                     CS_IDX_NB * sizeof(struct

    uint8_t i;
    const uint8_t svc_uuid[ATT_UUID_128_LEN] = CS_SVC_UUID;

    const struct gattm_att_desc att[CS_IDX_NB] =
        /* Attribute Index  = Attribute properties: UUID,
         *                                          Permissions,
         *                                          Max size,
         *                                          Extra permissions */

        /* TX Characteristic */
                                                            PERM(RD, ENABLE) | PERM(NTF, ENABLE),

        /* RX Characteristic */
                                                            PERM(RD, ENABLE)
                                                            | PERM(WRITE_REQ, ENABLE) | PERM(WRITE_COMMAND, ENABLE),

    /* Fill the add custom service message */
    req->svc_desc.start_hdl = 0;
    req->svc_desc.task_id = TASK_APP;
    req->svc_desc.perm = PERM(SVC_UUID_LEN, UUID_128);
    req->svc_desc.nb_att = CS_IDX_NB;

    memcpy(&req->svc_desc.uuid[0], &svc_uuid[0], ATT_UUID_128_LEN);

    for (i = 0; i < CS_IDX_NB; i++)
        memcpy(&req->svc_desc.atts[i], &att[i], sizeof(struct gattm_att_desc));

    /* Send the message */

Then, to Read and Write data of each Custom service, I defined functions based on the event needed. For example, to read data, I do that:

  • DEFINE_MESSAGE_HANDLER(GATTC_READ_REQ_IND, Service0_ReadReqInd) : to read data from service 0

  • DEFINE_MESSAGE_HANDLER(GATTC_READ_REQ_IND, Service1_ReadReqInd): to read data from service 1

My custom services are added as expected because I can see them with a BLE client. But when reading the attribute of the custom service 0, I get the one from the custom service 1. There is a conflict and I know why, given that the event is the same (GATTC_READ_REQ_IND) for both services.

I wonder in this case; how can we do to distinguish between event operations?

Best regards,


It would be best for you to implement Custom Service functionality similar to what is done in our new BLE Abstraction samples.

The new Abstraction will keep track of Start_Handle and End_Handle variables for each Characteristics in the Custom Services.

Then, when a Write or Read Request is received, both Custom Service Handlers will be triggered, but you can then compare the Handle being Written/Read and only reply from the Custom Service that contains the Handle you are trying to interact with.

For a detailed implementation, you can look into the ‘ ble_gatt.c ’ & ‘ ble_gatt.c ’ abstraction files to observe how they manage the multiple Custom Services.

Thank you for using our Community Forum.

Thank you Rastislav for your answer.

That mean that using the same way as peripheral_server_sleep_ext example is not a good idea ?
In this example BLE abstraction is not used in this case.

Best regards,


You can refer to samples starting with BLE_... prefix. Those use BLE Abstraction.

You can still use the peripheral_server_sleep_ext especially considering it is the only sample that implements specific this functionality, but you will need to add the multiple Custom Service support as outlined in required steps above.

Thank you for using our Community Forum.