This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

disconnect if wrong characteristic should be written

Hi guys,

i have a service with more characteristics and more states. Not every characteristic should be available in each state. Thus there are services which are just allowed in one specific state.

If a device wants to write the wrong characteristic in a state, i just want to disconnect the connection (during the write operation). Is that allowed or is there a good way to disconnect during the write operation?

Like:

if ((p_evt_write->handle == p_ps->char_handle.value_handle) &&
    (p_evt_write->len < MAX_DATA_LENGTH) &&
    (p_ps->handler_char != NULL))
{
     if(incorrectState) { sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); }

}

Thanks in advance! greetings

Related