bt_nus_send -12(ENOMEM) Error

Hi. I got a problems on send data using  bt_nus_send function.

This is my code for send data

void BLE_PERIPHERAL::Write(uint8_t *data, uint16_t data_length){
	int32_t result = bt_nus_send(NULL, data, data_length);
	printk("Result : %d\n", result);
}

When I call this function for one time per second, there is no problem.

But I call it 40 times per second, bt_nus_send return -12 error.(ENOMEM, maybe)

I need to send data at least 50 time per second. How can I fix it?

Parents
  • When you are trying to transmit faster than what could be buffered and sent out, then eventually you will get this error. There are two ways to handle this

    1. wait for some time in a lower priority thread and try again and do this until you get a ENOMEM error
    2. Calibrate the BLE buffers and other configurations to send bigger chunk of data per event.

    This error and this topic has been discussed a lot in this forum and you can try to see if any of those threads help you with calibrating your BLE stack and application and optimize it for speed of data transfer.

Reply
  • When you are trying to transmit faster than what could be buffered and sent out, then eventually you will get this error. There are two ways to handle this

    1. wait for some time in a lower priority thread and try again and do this until you get a ENOMEM error
    2. Calibrate the BLE buffers and other configurations to send bigger chunk of data per event.

    This error and this topic has been discussed a lot in this forum and you can try to see if any of those threads help you with calibrating your BLE stack and application and optimize it for speed of data transfer.

Children
Related