Hello:
I am writing a BLE profile involving several characteristics. One of the characteristics is an operation code (read/write) tunnel.
Each time a BLE central device writes to the BLE peripheral (nRF51 10028 board), I would like to check the characteristic being written to, so that the application can properly respond to whatever operation is requested by the central.
I figure that I would do this by getting the UUID of the characteristic that was written. Any write to a characteristic will trigger a BLE event (in the on_ble_evt() event handler in main.c) with a header.evt_uid of BLE_GATTS_EVT_WRITE.
How would I go about getting the UUID of the characteristic being written (i.e., the one triggering the BLE event handler, which throws the BLE_GATTS_EVT_WRITE)?
Is this the right way to model a central-peripheral, command-response relationship? Is checking the UUID of the written characteristic the best way to respond to written commands?
static void command_characterstic_write_evt_dispatch(ble_evt_t * p_ble_evt)
{
//Get characteristic UUID and handle actions from there (or check respective value of each characteristic (compared to previous value) and do proper action).
ble_uuid_t evt_uuid = p_ble_evt->evt.gattc_evt.params.char_val_by_uuid_read_rsp;
SEGGER_RTT_printf(0,"\n Updated characteristic with handle (UUID) %o", evt_uuid);
switch(evt_uuid)
{
case BLE_UUID_COMMAND_BUFFER_TUNNEL_CHARACTERISTIC_UUID:
default:
break;
} }
Where the characteristic UUID is 0x2000 or BLE_UUID_COMMAND_BUFFER_TUNNEL_CHARACTERISTIC_UUID