How to set MTU for BLEUARTClient
-
Hello, I am trying to receive data on a Core2 that I am sending from an Atom S3 Lite.
On the S3, I send the data via BLE server with a simple ‘write’ and I can read the data on a smartphone.
When I establish a connection on the Core2 as a BLE client, the connection works, but with ‘read’ I only get the first 20 characters of the sent data.
This is probably normal for BLE connections, but I get the full length on the smartphone, so sending is not the problem. Normally, you can set an MTU on the receiving side. However, the ‘set_mtu’ command does not seem to exist on the Core2.
The ‘new’ library contains this ‘set_mtu’ command.
HOW can you set the MTU on the Core2 BLE client?
-
I have now tested the ‘new’ BLE Brick, and although it has an MTU command, the following error occurs:
Traceback (most recent call last):
File ‘<stdin>’, line 27, in ble_client_on_connected_event
File ‘m5ble/m5ble.py’, line 556, in set_mtu
ValueError: Not connected to a serverI set the MTU within the ‘ble_client_on_connected_event’ function, which is only called after connecting to the server, and I can both read and write with the server.
-
Btw:
The BLE server can send and receive long messages.
The BLE client can send long messages, but has this limitation for received messages.
-
After many try and more than many errors .. I´m able to reveive 256 bytes instead of 20 .. but in these 256 bytes are only 20 byte long pieces of the original message.
Send thee lines like "ab<30 characters long>/r/n"
Receive 60 bytes like "ab..<only first 20 bytes>ab..<only first 20 bytes>ab..<only first 20 bytes>"
And my Smartphone receives the full sent characters seperated like "ab<30 characters long>/r/n", "ab<30 characters long>/r/n", "ab<30 characters long>/r/n"
I ended now up with chunking my message into 20 byte pieces before sending and putting the message together after receiving.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login