This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Notification frequency

Hi

I'm using nrf51 to notify some data to an andriod device. I set the connection interval of my nrf51 program to 7.5ms. And I need to send 100 packets per second (20 bytes per packet). However, sometimes there are packets loss and I cannot receive 100 packets per second. So what could I do wrong to cause the packets loss? Thank you!

  • show code - it all depends how you send notifications. If you are pushing them even if there are no more tx buffers available, you will loose some of them. you have to wait till all buffers are emptied. there are plenty of topics here on devzone describing how to get high throughput - you should familiarize yourself with them

  • hi wojtek

    Thank you for your reply.

    This is the part of sending notification. I use a timer to control the time. In one second, the nrf51 reads the sensor 100 times and everytime it finished the reading, ble_mpu_update is used to notify the data. accel_values_t is a 20 bytes struct.

    void ble_mpu_update(ble_mpu_t *p_mpu, accel_values_t * accel_values)
    {
        // Send value if connected and notifying
        if (p_mpu->conn_handle != BLE_CONN_HANDLE_INVALID)
        {
            uint16_t               len = sizeof(accel_values_t);
            ble_gatts_hvx_params_t hvx_params;
            memset(&hvx_params, 0, sizeof(hvx_params));
    
            hvx_params.handle = p_mpu->accel_char_handles.value_handle;
            hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
            hvx_params.offset = 0;
            hvx_params.p_len  = &len;
            hvx_params.p_data = (uint8_t*)accel_values;  
    
            sd_ble_gatts_hvx(p_mpu->conn_handle, &hvx_params);
        } 
        
    }
    
  • Ok, so i see you are not checking sd_ble_gatts_gvx returned value. Check it and if it is not success, you should wait more time to send the notification. Also, how many packets you loose? I did succesfully manage to send about 133x20byte packets/second when using 7.5ms interval.

  • 1-5 packets loss sometimes. not always receive 100 packets. I will try to check the return value. Thank you a lot!

  • If transmission is not succesfull (not acked by the peer), transmission buffer may not be emptied, so adding another packets is probably not successful. buffering the data and trying to send it just a bit later should do the work :)

Related