Hello, I'm working on a project where I want to send data through notifications between nrf52832 custom ble service server to the hrs_c example client. I'm using s132. When I connect my server to my phone the sd_ble_gatts_hvx returns error 8, and as soon as I enable notifications from my phone sd_ble_gatts_hvx returns 0, meaning I can see the information correctly displayed on my phone.
When I connect to the client, however, it does not enable notifications and sd_ble_gatts_hvx returns 8 continuously, not sending any data. After reading about it I tried to overcome the problem by manually enabling notifications on the server immediately upon connection as such:
static void on_connect(ble_cus_t * p_cus, ble_evt_t const * p_ble_evt) { p_cus->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; ble_cus_evt_t evt; evt.evt_type = BLE_CUS_EVT_CONNECTED; p_cus->evt_handler(p_cus, &evt); printf("Force notifications.\n\r"); uint16_t buffer[4]; // conn_handle = p_event->evt.gap_evt.conn_handle; // save connection handle to global variable buffer[0] = 16; // cccd handle buffer[1] = 2; // cccd attribute size = 2 buffer[2] = 1; // 0 = disable notifications 1 = enable buffer[3] = 0xCACD; // CRC-CCITT (0xFFFF) sd_ble_gatts_sys_attr_set(p_cus->conn_handle, (uint8_t*)(buffer), 8, 0); // initialize cccd attribute }
It worked for some time, but after erasing all software from the board and reprogramming it began to show many errors. I'm now getting error 8 every time, even with the manual notifications enabled. Note that the phone's behavior remained the same, being able to allow notifications well.
Before getting to this point sd_ble_gatts_hvx was returning error 3401, and to fix that I implemented:
case BLE_GAP_EVT_CONNECTED: sd_ble_gatts_sys_attr_set(p_cus->conn_handle, NULL, NULL, NULL); on_connect(p_cus, p_ble_evt); break;
Even when I ran de code for enabling notifications from the central error 8 was still the outcome from sd_ble_gatts_hvx, as if ble_hrs_c_hrm_notif_enable(p_hrs_c) was not doing anything.
Any help would be very welcome, and thank you in advance for your time.