8.0, multilink example, peripheral, s110 softdevice.
I modified the button_event_handler() function in main.c into this:
static void button_event_handler(bsp_event_t button_action)
{
uint32_t err_code, i,j;
if(button_action == BSP_EVENT_KEY_0)
{
if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
{
static uint8_t value = 0;
ble_gatts_hvx_params_t hvx_params;
uint16_t len = 1;
value = (value == 0) ? 1 : 0;
memset(&hvx_params, 0, sizeof(hvx_params));
hvx_params.handle = m_char_handles.value_handle;
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
hvx_params.offset = 0;
//hvx_params.p_len = (uint16_t*)(4*sizeof(uint8_t));
hvx_params.p_len = &len;
hvx_params.p_data = &value;
RPT: err_code = sd_ble_gatts_hvx(m_conn_handle, &hvx_params);
APP_ERROR_CHECK(err_code);
value = (value == 0) ? 1 : 0;
for (i=0;i<=0xfffff;i++)
{
j++;
}
goto RPT;
if (value == 0)
{
err_code = bsp_indication_set(BSP_INDICATE_ALERT_OFF);
APP_ERROR_CHECK(err_code);
}
else
{
err_code = bsp_indication_set(BSP_INDICATE_ALERT_3);
APP_ERROR_CHECK(err_code);
}
}
}
}
so the idea is, whenever I press the appropriate button, the corresponding LED on central board will flash on and off forever since I made the code stuck in a infinite loop.
But that's not what really happened: the LED flashed 4 times, which means 8 bytes of data were transmitted. Then the board (peripheral, s110 softdevice) restted. (Most likely resetted by the APP_ERROR_CHECK(err_code);).
Why is this happenning? It's always 8 bytes, nothing more, nothing less. Truly puzzling.
Can somebody help me? Thanks.