void m_mouse_movement_send(int16_t x_delta, int16_t y_delta)
{
ret_code_t err_code;
if (m_in_boot_mode)
{
x_delta = MIN(x_delta, 0x00ff);
y_delta = MIN(y_delta, 0x00ff);
err_code = ble_hids_boot_mouse_inp_rep_send(&m_hids,
0x00,
(int8_t)x_delta,
(int8_t)y_delta,
0,
NULL);
}
else
{
uint8_t buffer[INPUT_REP_MOVEMENT_LEN];
APP_ERROR_CHECK_BOOL(INPUT_REP_MOVEMENT_LEN == 3);
x_delta = MIN(x_delta, 0x0fff);
y_delta = MIN(y_delta, 0x0fff);
buffer[0] = x_delta & 0x00ff;
buffer[1] = ((y_delta & 0x000f) << 4) | ((x_delta & 0x0f00) >> 8);
buffer[2] = (y_delta & 0x0ff0) >> 4;
err_code = ble_hids_inp_rep_send(&m_hids,
INPUT_REP_MOVEMENT_INDEX,
INPUT_REP_MOVEMENT_LEN,
buffer);
}
if ((err_code != NRF_SUCCESS) &&
(err_code != NRF_ERROR_INVALID_STATE) &&
(err_code != NRF_ERROR_RESOURCES) &&
(err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
)
{
APP_ERROR_HANDLER(err_code);
}
}
I created a 500ms timer to send mouse movement as follows.
m_mouse_movement_send(5,0);
When the device runs there, the device will restart. The error code is NRF_ERROR_FORBIDDEN.
if ((err_code != NRF_SUCCESS) &&
(err_code != NRF_ERROR_INVALID_STATE) &&
(err_code != NRF_ERROR_RESOURCES) &&
(err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
)
{
APP_ERROR_HANDLER(err_code);
}
When i add the NRF_ERROR_FORBIDDEN handle, the device runs normally.
if ((err_code != NRF_SUCCESS) &&
(err_code != NRF_ERROR_BUSY) &&
(err_code != NRF_ERROR_RESOURCES) &&
(err_code != NRF_ERROR_FORBIDDEN) &&
(err_code != NRF_ERROR_INVALID_STATE) &&
(err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
)
{
APP_ERROR_HANDLER(err_code);
}
By the way, the hid_init is behind th services_init.