🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    How to set MTU for BLEUARTClient

    Scheduled Pinned Locked Moved UiFlow 2.0
    4 Posts 1 Posters 865 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      mchott
      last edited by mchott

      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?

      M 1 Reply Last reply Reply Quote 0
      • M Offline
        mchott @mchott
        last edited by

        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 server

        I 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.

        1 Reply Last reply Reply Quote 0
        • M Offline
          mchott
          last edited by

          Btw:

          The BLE server can send and receive long messages.

          The BLE client can send long messages, but has this limitation for received messages.

          1 Reply Last reply Reply Quote 0
          • M Offline
            mchott
            last edited by mchott

            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.

            1 Reply Last reply Reply Quote 0

            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
            • First post
              Last post