Cannot create a custom service

Hello,

I’m trying to add a custom service to the ble_peripheral_server_hrp_fota_sleep example. From my understanding, GATTM_AddAttributeDatabase can only be called once. Therefore, I temporary commented “DFUS_Initialize()” call in main to avoid the DFU service to be initialized (in the future I will correctly implement it to create my custom service and the DFU service).

I don’t want the heart rate profile server to be created either so I commented HRPS_Setup(). Then I added my custom service initialization and I did the same as bel_dfus.c which is:

  1. Create (and registered) a MsgHandler to receive GAPM_CMP_EVT, GAPC_CONNECTION_REQ_IND, GAPC_DISCONNECT_IND and GATTM_ADD_SVC_RSP events
  2. In this handler, when I receive GAPM_CMP_EVT event, I check the operation, if it’s GAPM_SET_DEV_CONFIG, then I’m calling GATTM_AddAttributeDatabase like below
  3. Start advertising to allow connection
static const struct att_db_desc sensor_att_db[SENSOR_ATT_NB] =
{
    /* Service SENSOR */
    CS_SERVICE_UUID_128(SENSOR_SVC, SENSORS_SVC_UUID),
    /* Temperature measurement Characteristic */
    CS_CHAR_UUID_128(SENSOR_TEMP_CHAR, SENSOR_TEMP_VAL, SENSORS_TEMP_UUID,
                     PERM(RD, ENABLE),
                     2, NULL, SensorsCallback),
    CS_CHAR_TEXT_DESC(SENSOR_TEMP_NAME, "Temperature measurement")

GATTM_AddAttributeDatabase(sensor_att_db, SENSOR_ATT_NB);
};

But when I connect with a smartphone, I still see the heart rate and dfu services. All characteritics cannot be read or written though.

What step am I missing to see my custom service?

Thanks for your help

@arthur

If you do not want to use DFU for BLE, you need remove the configuration in preprocessor.

It is not good to commented “DFUS_Initialize()” call in main only.

Hello Martin,

Ok understood but I commented DFUS_Initialize() just for testing. In the end, I would like to have DFU enabled. Isn’t it possible to have a custom service in addition of the DFU service?

@arthur

Isn’t it possible to have a custom service in addition of the DFU service?

Answer: It is possible to add custom service in addition of DFU service.

Please refer to the following topics in community forum.

FOTA with custom services
We want to use the FOTA Image system with our custom application. There are custom BLE services in this app. But the FOTA user’s guide indicates:
Is there an example to illustrate how to add custom services and characteristics with FOTA system?

and

Adding Custom Service Support to an RSL10 Firmware that uses the DFU Service (FOTA)
When designing a Bluetooth Low Energy solution on the RSL10, it may be necessary to create your own Custom Service if the standard Profiles are not meeting all of your needs.
On the RSL10, it is required to have only a single Attribute Database that describes all of the various Custom Services that will be passed to the Stack. Therefore, because the DFU Service is also a unique Custom Service, if you are using FOTA as well, you will be required to merge the DFU Service Attribute Database with any other Custom Service Attribute Databases you wish to use.

Is there a sample available that provides an outline/guide on how multiple Custom Services can be supported alongside FOTA?

Thank you for using our community forum!