Number of received data via BLE is mismatched with my code.

Hello.

I'm developing some kind of wearable device with using nRF52832.

I'm using Segger Embedded Studio for developing.

I write my code by modifying ble_app_template.

My device is sending datas 5 times in second. 

Here is my code as follows.

#define OUR_CHAR_TIMER_INTERVAL APP_TIMER_TICKS(200) // 200 ms intervals, 

static void timer_timeout_handler(void * p_context)
{
// Step 3.F, Update temperature and characteristic value.


read_sensor_data(); // *modify where sensor measurement function goes
sd_temp_get(&temp_data);

data_set[0] = store2[0];
data_set[1] = store1[0];
data_set[2] = store4[0];
data_set[3] = store3[0];
data_set[4] = store6[0];
data_set[5] = store5[0];

our_sensor_characteristic_update(&m_our_service, data_set); // make a call to characteristic update function
//check_cap_value();
nrf_gpio_pin_toggle(17);

}

As you can see, there is timer for 200ms, and when timer is reached, device update datas.

However, when I try to analyze sampling data by using nRF Sniffer, I see there is some strange data what is not received for 200 ms delay.

Can you tell me why it happen?

if you need to get full code for understanding situation, just let me know.

Best regards,

Seunghun.

  • Hello Vidar,

    I don't try to use that code yet.

    But I have some point about that.

    Data is from another IC via SPI to nRF52. 

    To prevent nRF is stucked in SPI protocol, I set SPI interrupt priority is higher than BLE interrupt priority.

    In my opinion,  If SPI protocol and BLE characteristic update is conducted in same time, BLE notification can be cancled, and it leads device to fail to send notification.

    If my assumption is true, what can I do for solving this issue?

    Is there any way that I can try to send notification again if it is failed?

    Best regards,

    Seunghun.

  • Hello Seunghun,

    As long as you avoid selecting interrupt priorities reserved for the Softdevice, application interrupts should not interfere with the transmission of your notifications. In general, it is safest to use the same priority for all application interrupts to avoid potential race conditions. 

    Is there any way that I can try to send notification again if it is failed?

    This is up to the application to handle. 

    Best regards,

    Vidar

Related