This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to periodically read peripheral data?

Can I periodically or continuously read the characteristic of peripheral after the connection?

If there is a change in the value in peripheral, then the value is received in central. (Should 'BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP' be used?)

(Central is nordic, Peripheral is my own device.)

I would like to use the example of 'ble_app_uart_c'. 

Best regards,

Lyrics

  • Hello,

    That really depends on the peripheral, but if it is your own peripheral, I suggest you look into notifications. Our central example ble_app_uart_c is intended to work with the peripheral example ble_app_uart, which uses notifications. 

    There are several ways to send/receive data in BLE. One possibility is that the central reads the characteristic. There are a few different approaches to this (with and without authentication), but if you want the central to be notified whenever the peripheral changes the value of the characteristic, then notifications are definitely the way to go. 

    Look at how the notifications are implemented in the ble_app_uart example. I don't know what your peripheral project device is. Is it an nRF? Did you write the code yourself?

    Notifications also needs to be enabled by the central. The ble_app_uart_c example does this in the discovery complete event. See how it uses ble_nus_c_tx_notif_enable() and how this is implemented.

    Best regards,

    Edvin

Related