I'm trying toa custom nRF52840 board using SDK 17.02 and SD 7.01
I create a read/Write only service, it shows up in nRF Connect just fine
I can write to the service using the NRFConnect app and catching the event BLE_GATTS_EVT_WRITE, then checking the handle to determine which characteristic got called.
That works, but how the heck do I save that value so when I do a read from the nRFConnet app I get that same value??
else if (p_evt_write->handle == p_mtgw->LoRSync_handles.value_handle)
{
uint16_t ScanRate;
if(p_evt_write->len == 2)
{
ScanRate = uint16_big_decode(p_evt_write->data);
BLEScanRateCallback(ScanRate);
ble_gatts_value_t val;
uint8_t data[2];
uint16_big_encode(ScanRate, data);
val.len = 2;
val.offset = 0;
val.p_value = data;
ret_code_t err_code = sd_ble_gatts_value_set(BLE_CONN_HANDLE_INVALID/*p_ble_evt->evt.gatts_evt.conn_handle*/, p_mtgw->LoRSync_handles.value_handle, &val);
if (err_code == NRF_SUCCESS)
{
NRF_LOG_INFO("Sync rate has been updated: %x %x", data[0], data[1])
// Save new battery value.
// p_bas->battery_level_last = battery_level;
}
else
{
NRF_LOG_DEBUG("Error during Sync rate update: 0x%08X", err_code)
return;// err_code;
}
NRF_LOG_INFO("Lora Sync Rate: %x", ScanRate);
}
}