This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

changing the BLE device name, BLE service and GATT Characteristics dynamically

Hi, I am using nRF52832 module (GAP peripheral, GATT server) with nRF5SDK, ble_app_uart_pca10040_s112 application.

I need some help on dynamically changing the BLE device name, BLE service and GATT Characteristics.

What I tried:
In main(), I initialized only the UART module. Once UART is up, the nRF module receives data from an application chip (MCU).
In uart_event_handle function, I use a function call to process the received data and set the BLE device name accordingly, inside this function call I am initializing BLE stack, GAP parameters, GATT Init, Services Init followed by BLE advertisement.

This way, I was successfully able to set BLE device name and Services dynamically. However, after few minutes of communication with a GATT client, incorrect/incomplete data is being transmitted to that peer device.

Is it good to initialize BLE this way? If not, what should be done?

Also, I have found few of the forum discussions on how to change the BLE Device name in run time, but not seen anything related to changing GATT characteristics dynamically.
Please help, Thank you in advance.

Parents
  • Hi,

    It is possible to add BLE service and characteristics dynamically, but it is not possible to remove them. It is required to send a service change notification to let the gatt client know that the attribute table has been updated.
    Regarding the device name, it is possible to change device name using sd_ble_gap_device_name_set().

    Best regards,
    Dejan

  • I would like to mention that I wanted to change the BLE service and characteristics dynamically so that nRF module connects with different GATT client in run time. In this case, may I know how service change notification would help? Please share any references if possible.

    What I tried:
    In main(), I initialized only the UART module. Once UART is up, the nRF module receives data from an application chip (MCU).
    In uart_event_handle function, I use a function call to process the received data and set the BLE device name accordingly, inside this function call I am initializing BLE stack, GAP parameters, GATT Init, Services Init followed by BLE advertisement.

    This way, I was successfully able to set BLE device name and Services dynamically. However, after few minutes of communication with a GATT client, incorrect/incomplete data is being transmitted to that peer device.

    Is it good to initialize BLE this way? If not, what should be done?

    Also, I would like to know if this method which I followed is correct or not. 

    Please help, Thanks.

  • Hi,

    Could you show relevant part where the function call is located and how you use it?
    Is this the same function call through which you receive data, make initializations and advertisements?

    Best regards,
    Dejan

Reply Children
  • Hi, herewith I have attached the pseudo code for my custom application. Please check it.

    nrf52832_pseudocode

  • Hi,

    In general, what you have described might work. However, it might not be possible to change dynamically services and characteristics without updating attribute table and that would require terminating the connection. On the other hand, there is no such limitation on dynamically updating the device name.

    Best regards,
    Dejan

  • Hi, thank you for your response.

    In general, what you have described might work. However, it might not be possible to change dynamically services and characteristics without updating attribute table and that would require terminating the connection.

    I understand that, attribute table needs to be updated for changing the services and characteristics. 

    In my application, the BLE initialization is performed based on data received at run time. If that can work without an issue, then may I know what could be the reason for transmitting incorrect/incomplete data to a GATT client after some point of time? I am not able to debug it since I am not having a Jlink debugger.

    Kindly help, Thank you.

  • Hi,

    Indication suggests to the central to do service discovery without the guarantee that this is immediate action. Service discovery is usually done on next re-connection.

    In general, it is not  recommended to do attribute table change dynamically.
    Could you be more specific about your use case? Is there a specific reason why you need to do it dynamically?

    Best regards,
    Dejan

  • Hi,

    Could you be more specific about your use case? Is there a specific reason why you need to do it dynamically?

    I have added the use case in this nRF_usecase document, please check. Thank you.

Related