So I have a remote, a central, and it's connected to my peripheral. The remote is based on the multilink example. SDK V11.
I want to press a button on my central and send send a value to a characteristic on the peripheral.
I have interrupt handlers interrupting and getting an event to client_handeling.c where I have a nice little function to send a message.
I patterned my function of the existing notif_enable()
Problem is how to get a valid handle?
Everything else gets p_client passed in. like;
write_params.handle = p_client->srv_db.services[0].charateristics[p_client->char_index].cccd_handle;
but where do baby p_clients come from if you aren't being called in a callback from the dm?
Using m_client directly doesn't seem to work either... Not working meaning the peripheral returns an invalid handle according to wire shark.
The function call to sd_ble_gattc_write() returns no error
Here's my function. It's called when a button is pressed. Not from inside the ISR either :)
void command_send(ButtonEvents_t btn)
{
uint32_t err_code;
ble_gattc_write_params_t write_params;
uint8_t buf[BLE_CCCD_VALUE_LEN]; // 2
buf[0] = 1; //volume up command, hard coded for testing
buf[1] = 0;
write_params.write_op = BLE_GATT_OP_WRITE_REQ;
write_params.handle = ?????
write_params.offset = 0;
write_params.len = 1; //hardcoded for testing
write_params.p_value = buf;
err_code = sd_ble_gattc_write(p_client->srv_db.conn_handle, &write_params);
NRF_LOG_PRINTF("Btn cmd err; %d\n", err_code);
}
Thanks!