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

How to get UUID of Characteristic from a ble_evt_t?

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

Parents
  • Oh, i am sorry. I accidentally converted your comment to the answer. Sorry for that.I think now i understand what you want to do, however i got no clue why do you want to do it that way. Anyway, i don't know the answer to that right now. I'll try to test it and give you the feedback as soon as possible. Maybe in the meantime you will get an answer from someone else here who knows that.

Reply
  • Oh, i am sorry. I accidentally converted your comment to the answer. Sorry for that.I think now i understand what you want to do, however i got no clue why do you want to do it that way. Anyway, i don't know the answer to that right now. I'll try to test it and give you the feedback as soon as possible. Maybe in the meantime you will get an answer from someone else here who knows that.

Children
No Data
Related