Problem with writing value to gatt attribute in connection.

Hi. I have a problem with writing value to gatts attribute when device is in connection mode. In my application I want to check if the parameter writing by the client to server's attribute has a proper value and if not, I want to set there my own value. I am using "on_ble_evt(ble_evt_t * p_ble_evt)" function and BLE_GATTS_EVT_WRITE to detect writing event and I am checking the value - this part works fine. But when incorrect value is detected I cant write my own value with "sd_ble_gatts_value_set" - it works only after disconnection. I would like to ask is it possible to set attribute's value in connection mode?

Best regards, Martin

  • In this case, I'd suggest that you instead use the Write Command property, and authorization. In that way, you can simply deny the write in the first place. Take a look at this MSC to show the sequence of events this would cause. You get this behavior by enabling the wr_auth field when adding the characteristic.

    If you absolutely don't want to do this, could you please include what error code you get back from sd_ble_gatts_value_set()?