android - Sending continues data stream in bluetooth Ble with less delay -


background

i'm developing android application can communicates nordic bluetooth 4 device, can able send , receive data nordic.

the problem whenever want send bulk data have break data in several 20 byte data , send delay of 50ms

as show below code

private boolean sendbytes(byte[] ibytes){     sendresetbytes();     byte[] arr=new byte[20];     for(int i=0;i<ibytes.length;i++){         if(i!=0&&i%20==0){             if(!mbluetoothgeneric.send(arr))return false;             arr=new byte[20];             try {                 thread.sleep(50);             } catch (interruptedexception e) {                 e.printstacktrace();             }         }         arr[i%20]=ibytes[i];     }     if(arr.length!=0)         if(!mbluetoothgeneric.send(arr))return false;     return true; } 

for sending bytes used uartservice library given nordic

send() implemented call writerxcharacteristics() fn

 public boolean writerxcharacteristic(byte[] value) {       bluetoothgattservice rxservice = mbluetoothgatt.getservice(rx_service_uuid);     showmessage("mbluetoothgatt null"+ mbluetoothgatt);     if (rxservice == null) {         showmessage("rx service not found!");         broadcastupdate(device_does_not_support_uart);         return false;     }     bluetoothgattcharacteristic rxchar = rxservice.getcharacteristic(rx_char_uuid);     if (rxchar == null) {         showmessage("rx charateristic not found!");         broadcastupdate(device_does_not_support_uart);         return false;     }     rxchar.setvalue(value);     boolean status = mbluetoothgatt.writecharacteristic(rxchar);     return status; } 

my question, there method can send bulk data nordic minimum possible delay

first call setwritetype(write_type_no_response) on characteristic able send multiple packets in 1 connection event.

then need write each chunk @ time , wait oncharacteristicwrite before send next one, since there can 1 outstanding gatt operation @ time in android's ble stack.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -