I'm modifying the LED button example to fit my custom characteristic.
How could I modify the functionns to reject a value if the value is not in range?
I have the following functione that get called in secuence when the LED characteristic is written. Where can I reject the value if it is not 0 or 1?
static void on_write(ble_lbs_t * p_lbs, ble_evt_t * p_ble_evt)
{
ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;
if ((p_evt_write->handle == p_lbs->led_char_handles.value_handle) &&
(p_evt_write->len == 1) &&
(p_lbs->led_write_handler != NULL))
{
p_lbs->led_write_handler(p_lbs, p_evt_write->data[0]);
}
}
static void led_write_handler(ble_lbs_t * p_lbs, uint8_t led_state)
{
if (led_state == 1)
{
LEDS_ON(LEDBUTTON_LED_PIN);
}
else if(led_state == 0)
{
LEDS_OFF(LEDBUTTON_LED_PIN);
}
else reject????() <-- Could I insert some sort of reject function here? How do I do it?
}