Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Send message from LoPy through BLE

    Scheduled Pinned Locked Moved Getting Started
    lopyble
    7 Posts 2 Posters 746 Views 2 Watching
    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.
    • G Offline
      GMB124
      last edited by

      Hi everyone!

      I'm trying to connect two LoPy 4 via BLE and then send a simple message. I've already done it using Wi-Fi, but on the tutorial nothing is said about sockets, so there's someone who managed to send messages using BLE and what code can I use?

      Thanks in advance

      1 Reply Last reply Reply Quote 0
      • E Offline
        Eric73
        last edited by

        Hi, BLE dosen't allow this processing. You can have one device listening (master scanning for advertising frame) and the other device with advertiser connectable role.
        Once BLE master is connected to advertiser it can read/write/notify characteristic in advertiser. This allow data exchange (without socket).
        BUT last time i have take a look at pycom BLE documentation it's only allow basic BLE, scanning and advertising.

        G 1 Reply Last reply Reply Quote 0
        • G Offline
          GMB124 @Eric73
          last edited by GMB124

          @Eric73 Thank you very much for your answer.

          I managed to scan, advertise and pair through BLE, but if I understood correctly there's no way to send a basic message (such 'Hi') every, let's say, 5 seconds? As far as I know, programming a GANTT service (in my case, sending 'Hi') on the Pycom acting as GANTT server should be possible. Otherwise the only thing I can do with the boards is connecting to an existing service as in the example of 'Heart rate' (https://docs.pycom.io/tutorials/all/ble/).

          E 1 Reply Last reply Reply Quote 0
          • E Offline
            Eric73 @GMB124
            last edited by

            @GMB124 I am not a pycom bluetooth expert, but i have worked on BLE with NRF chip.
            It's look like BLE-Notification is what you can use.
            Once connected to a device, BLE-master scan slave for services&characteristic and read if several property is set for every characteristic,(can be read write notify and indication).
            Every time the slave BLE change a characterstic with notify field set, it send an event to the master on the next keep-connected frame sent by low level connection driver. So if you change a characteristique master can be informed without perform a specific read.

            If you want to "send" every 5 second different data without be connected to a master, you have to change your advertising data.

            G 1 Reply Last reply Reply Quote 0
            • G Offline
              GMB124 @Eric73
              last edited by

              @Eric73 Thank you very much for your help, now it's clearer to me how the BLE works.

              Connecting and seeing the changes is fine for me. I followed this topic as it does something like what I want (https://forum.pycom.io/topic/1500/support-for-bluetooth-le-notifications). The problem now is that I don't manage to repeat the experience following the given code (https://github.com/pycom/pycom-micropython-sigfox/issues/40), as the LoPy doesn't seem to accept the connection. As soon as my smartphone running ''BLE scanner for Android'' connects to the LoPy, it is disconnected again. Maybe I have to connect the devices again in a while(True) cycle...

              E 1 Reply Last reply Reply Quote 0
              • E Offline
                Eric73 @GMB124
                last edited by

                @GMB124 I have just test the code you have linked and on my lopy4 firmware 1.18.x it work well as expected.
                I connect my phone by nrfconnect android application and notification work fine (and i have connection and no unwanted disconnection).
                I don't do anithing more than the code show, nothing connected on lopy4 wifi.
                Have you check your Lopy firmware release ? and do update if needed ?
                in REPL

                import os
                os.uname()

                G 1 Reply Last reply Reply Quote 0
                • G Offline
                  GMB124 @Eric73
                  last edited by

                  @Eric73

                  I updated the firmware to 1.18 too and it works now.

                  Thank you very much for your precious help and time!

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

                  Pycom on Twitter

                  Pycom