Hello ! I am trying to implement a write request but for unknown reason it doesn't transmit back the gatt_status. I have setup the wr_auth = 1. GPIO number 19 si actually a LED and it blinks every time I make a write request for DIODEONE_CHARACTERISTIC1. Here is my code :
void DIODEONE_on_ble_evt(ble_evt_t * p_ble_evt){
switch(p_ble_evt->header.evt_id){
case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
{
//check if write request on the diodeone characteristic
if (p_ble_evt->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE &&
p_ble_evt->evt.gatts_evt.params.authorize_request.request.write.uuid.uuid == DIODEONE_CHARACTERISTIC1){
ble_gatts_rw_authorize_reply_params_t reply;
memset(&reply, 0, sizeof(ble_gatts_rw_authorize_reply_params_t));
reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
//check if it is possible to switch diodes. replace 1==1
if (1==1){
//memorize the received data
diodeone_data[0] = p_ble_evt->evt.gatts_evt.params.authorize_request.request.write.data[0];
//set the new value in GATT server
/*ble_gatts_value_t gatts_value;
memset(&gatts_value, 0, sizeof(gatts_value));
gatts_value.len = 1;
gatts_value.offset = 0;
gatts_value.p_value = &diodeone_data[0];
sd_ble_gatts_value_set(*(connection_handle), accx_handles5.value_handle, &gatts_value);*/
nrf_gpio_cfg_output(19);
nrf_gpio_pin_set(19);
nrf_delay_ms(500);
nrf_gpio_pin_clear(19);
nrf_delay_ms(500);
reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS;
}
else if (1 > 2){
reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED;
}
sd_ble_gatts_rw_authorize_reply(p_ble_evt->evt.gap_evt.conn_handle, &reply);
}
}
break;
}
}
Can you please help me with some ideas ? I have nrf51822QFAC with softdevice s130 and I am using the sdk 11.0