简体   繁体   中英

BLE GATT upload data - Android

Trying to connect to BLE device(GATT Server) Using Samsung Galaxy S4, I succeeded to connect to device and got heartbeat.

now I need to send 1280 bytes as 16 chunks of 80 bytes. the Device after receiving those 16 chunks should reply with 16 upload status,

what I get is only one upload status for one of the chunks (not specific one , randomly)

I tried to change the sending interval by (this.wait, Thread.sleep..) with many values , without any good result.

Similar application with Objective-c (iPhone ) works fine with device :(

** I thought it might be related to the Any hints about the issue ? or a way to manage transmission rate (interval)**

runOnUiThread(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < chunkToUpload; ++i) {
                sendNthModeData(i);
                try {   
                    //this.wait(100);
                    Thread.sleep(30,1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }
    });

You need to wait for onCharacteristicWrite to be called in the BluetoothGattCallback before you can send the next bit of data, otherwise the other data will get dropped on the ground. So in your override of onCharacteristicWrite , if you have more to write then spin up a Runnable for that write.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM