How to add add, insert and remove BLE services dynamically at run time and if I have to send multiple data under one service

if I have to send multiple data under one service 

like: Service 1(Information)

Hardware Revision String

Model Number String, the

Regulatory Certification Data List 

Then what should be the proper format (like string, array, individually or something else) of sending data? 

  • Hi Ayu, 
    Sorry for late response. We are under reduced staff in the summer. 

    1. Please study the code and check where the log is printed. 

    2. Please verify if you can add new service by using a phone to see after you add a service would you have more service when you disconnect and then connect. 

    3. I don't really understand you. If you don't want to click a button, you can change the code to do it based on something else, timer or other event. I don't see any limitation on why you can't change that. 

  • Thanks  , I understood the output. Also I am able to add custom services and characteristics dynamically. But still every time I need to refresh the nrfconnect application to see the newly added characteristics. Can I automate it, can I send any notification that new characteristics has been added, so that app can refresh it.  I want to know about peripheral side rather than client(mobile) side. Can you please help me in this.

  • Hi Ayu, 

    There is a button in NRF Connect called "Refresh service" (click on 3 dots) you can click that to have the service discovery again. 

    If you develop your own app you can automate it.

    Have you sent service changed indication ? If you did, I believe you can get the indication from the app and can automatically do service discovery again. 

  • Hi, I called this function :  

    void our_service_change(ble_os_t * p_our_service)
    {
    uint32_t err_code_2;

    static uint16_t start_handle= 0x000B;
    const uint16_t end_handle = 0xFFFF;

    err_code_2 = sd_ble_gatts_service_changed(p_our_service->conn_handle,
    start_handle,
    end_handle);

    APP_ERROR_CHECK(err_code_2);
    }

    but its showing 12291 error.

  • Hi again, 
    When you see an assert , please try to do debugging. 

    12291 = 0x3003 and it's equal to BLE_ERROR_INVALID_ATTR_HANDLE

    In the description of sd_ble_gatts_service_changed you can find this: 

Related