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

Multilink Peripheral BLE Services

Hello,

for multilink client services Nordic introduced the *_EVT_DISCOVERY_COMPLETE events and the *_c_handles_assign functions. Like the BLE_BAS_C_EVT_DISCOVERY_COMPLETE event and the ble_bas_c_handles_assign function for the Batterie Client Service

What is the procedure for multilink server services like the Batterie Server Service? How can I instantiate this service multiple times i.e. one for each possible connection? At the moment the service captures the connection handle

static void on_connect(ble_bas_t * p_bas, ble_evt_t const * p_ble_evt)
{
    p_bas->conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
}

So that even when I instantiate the service several times, they all capture the last connection handle. This has the consequence, that when I call ble_bas_battery_level_update only the last connected device received the notification. I have no choice to select a specific device.

For the LED Button Service Server Nordic the "button change" function has an explicit conn_handle argument to select the client.

uint32_t ble_lbs_on_button_change(uint16_t conn_handle, ble_lbs_t * p_lbs, uint8_t button_state);

How can I use the Nordic server services like the Batterie Service with multiple clients?

Related