When I use sd_ble_gatts_hvx() to send data to iOS and Android device I meet a problem:
Data send to iOS ok,but will return error 8 (invalid states) when send to Android 4.4 device.
I am sure notification is enable.
Is there any other different from iOS to Android?
// Send value if connected and notifying
if ((p_bas->conn_handle != BLE_CONN_HANDLE_INVALID) && p_bas->is_notification_supported)
{
printf(WK_DEBUG_LEVEL_FATAL, "ready to send data, notification_supported = %d", p_bas->is_notification_supported);
ble_gatts_hvx_params_t hvx_params;
memset(&hvx_params, 0, sizeof(hvx_params));
len = sizeof(uint8_t);
hvx_params.handle = p_bas->wk_handles.value_handle;
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
hvx_params.offset = 1;
hvx_params.p_len = &len;
hvx_params.p_data = &battery_level;
err_code = sd_ble_gatts_hvx(p_bas->conn_handle, &hvx_params);
printf(WK_DEBUG_LEVEL_FATAL, "**** err_code %d", err_code); // this will return error 8
}
else
{
printf(WK_DEBUG_LEVEL_FATAL, "*** notification is not supported");
err_code = NRF_ERROR_INVALID_STATE;
}
Is there any other things to do to make sure notification send ok with Android? Please help!