question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Write long data over BLE (+ than 20 bytes)

See original GitHub issue

Steps to reproduce

  1. use the BLE explorer application

  2. modify to send more than 20 bytes

Expected behavior

I develop a long data function sender like follow :

public async void sendDataBle(List<List<Byte>> trame)
        {
           Task isSendCompleted = new Task();
            for (Byte numPaquet = 0; numPaquet < trame.Count; numPaquet++)
            {
                await(isSendCompleted  = WriteToTXCharacteristic(trame.ElementAt(numPaquet).ToArray())));
                while (!isSendCompleted.IsCompleted) ;
            }
        }

the List<Byte> in list trame have a maximum of 20 Bytes.

I tried this implementation too :

 public async void sendDataBle(List<List<Byte>> trame)
        {
            for (Byte numPaquet = 0; numPaquet < trame.Count; numPaquet++)
            {
                await WriteToTXCharacteristic(trame.ElementAt(numPaquet).ToArray());
            }
        }

this is the writeToTXCharacteristic function :

        public async Task WriteToTXCharacteristic(byte [] dataTX)
        {
            if (_UartTXcharac.CanWrite)
                await _UartTXcharac.WriteAsync(dataTX);

            await Task.Delay(200); //try to get tempo between two characteristic write
        }

Actual behavior

When i send less than or 20Bytes, it’s ok, i receive my packet.

When i send data (more than 20Bytes), this function try to send 2 packets. I receive one of them but after that nothing, i never receive the second.

Crashlog

There are no crash log

Configuration

Version of the Plugin: 1.2.1

Platform: e.g. iOS 10 / Android 4.4

Device: e.g. Wiko raimbow 4G

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Tijgerdcommented, Oct 3, 2019

I havent seen “INITIAL_MESSAGE_PACKET” at the time I was using Xamarin so I can’t help you with that.

If you consider using my method, there are serveral ways to “mark” the chunks:

1 (I used this one and never had any “false-positive” outcomes):

  • In the first part of the message, send the total number of bytes you are going to send
  • Send all the chunks
  • The last chunk should contain a CRC to check if all previous bytes where send correctly

2:

  • Mark the start of each chunk with the chunk-number (this will reduce the maximum data-bytes you can send with each chunk but is more secure)
  • You will still need to send the number of chunks you are going to send
  • A CRC is still advised

Just be creative, Hope this helps!

0reactions
trix0commented, Oct 3, 2019

@Tijgerd I have my data divided into the chunks of data. My question is: How do I mark the start and how do I mark the last chunk.

I am very confused in here, IF I look to this stackoverflow question, In the answer there is something like initial_packet[0] = BLE.INITIAL_MESSAGE_PACKET; Do I need to specify this somehow or just send data randomly and my characteristic should take care of it ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Write long data over BLE (+ than 20 bytes) · Issue #205
Steps to reproduce use the BLE explorer application modify to send more than 20 bytes Expected behavior I develop a long data function ......
Read more >
Sending more than 20 bytes with BLE
I want to send commands through BLE, which are often more than 20 bytes. How can i do to split my data, and...
Read more >
BLE Sending more than 20 Bytes of Data | Thejesh GN
This works really well. But the maximum amount of data you can send is 4606 bytes (256*20 - 256*2 -2). Most of my...
Read more >
How to send data more than 20 bytes over BLE
I am trying to send more than a 20 byte data through ble to an android app. But all I am able to...
Read more >
BLE write long data [37031096] - Issue Tracker - Google
We try to send "long" (more than 20 bytes) data to Bluetooth smart device using the BluetoothGatt API. 1) Using write characteristic only...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found