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

    Passive beacons.

    Scheduled Pinned Locked Moved SiPy
    blesypybeacon
    19 Posts 2 Posters 4.1k 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.
    • papasmurphP Offline
      papasmurph @alidaf
      last edited by

      @alidaf Actually, I was mistaken (bad memory). The intention of the filtering is only to check that it's an iBeacon, discriminating other types of advertisements. It's not more specific than that. Do you in practice see other values for iBeacons?

      A 2 Replies Last reply Reply Quote 0
      • A Offline
        alidaf @papasmurph
        last edited by

        @papasmurph Yes, I made a list of everything I can pick up to determine whether it's a beacon, feather, mobile or anything else. For some reason in my own code it just wouldn't pick up beacons. I've modified yours to include specific filters and ignore anything that is not a beacon or feather and it works fine. I just need to incorporate what works back into mine!

        1 Reply Last reply Reply Quote 0
        • A Offline
          alidaf @papasmurph
          last edited by

          @papasmurph For some reason, I can only detect the beacons if using the callback function.

          papasmurphP 1 Reply Last reply Reply Quote 0
          • papasmurphP Offline
            papasmurph @alidaf
            last edited by papasmurph

            @alidaf No doubt my code works fine for me. I'll test with the latest Pycom LoPy firmware. BLE should work the same on WiPy, LoPy etc.

            I upgraded to latest LoPy firmware. Still works.

            A 1 Reply Last reply Reply Quote 0
            • A Offline
              alidaf @papasmurph
              last edited by

              @papasmurph I had a 1 second sleep to make the output readable. That was enough to kill capturing the beacons.

              Is there an equivalent of a mutex to know when the callback is in operation?

              papasmurphP 1 Reply Last reply Reply Quote 0
              • papasmurphP Offline
                papasmurph @alidaf
                last edited by

                @alidaf My advice is to not use any sleeps at all, except very short, as the advertisement buffer is very small. 1 second is way too much. Not sure about any mutex and why you'd need it.

                If I want to analyze data I copy-paste text from Termite.

                A 1 Reply Last reply Reply Quote 0
                • A Offline
                  alidaf @papasmurph
                  last edited by

                  @papasmurph Yes, that makes sense.

                  The reason for a mutex is that I am creating a managed list of devices that are given a time to live. Once the time to live is up, the device is removed from the list. I don't want to remove from the list if the callback is currently adding to the list, or visa-versa.

                  I can live without the callback, but since it is something I have now learned, I would like to use it properly and avoid race conditions, if they are even possible in Python. I'm coming to Python from C!

                  papasmurphP 1 Reply Last reply Reply Quote 0
                  • papasmurphP Offline
                    papasmurph @alidaf
                    last edited by

                    @alidaf That's some of the things my CliqTags Spotter application does (and much more: geofencing, server communication, content presentation etc), developed in Javascript for Cordova (iOS and Android), so I understand this issue. Javascript is asynchronous and (luckily) single-threaded, so I can treat each function and whatever it does as atomic, and don't get race conditions.

                    Maybe this is included: https://docs.python.org/3/library/asyncio-sync.html

                    I also dabble with Python :).

                    A 1 Reply Last reply Reply Quote 0
                    • A Offline
                      alidaf @papasmurph
                      last edited by

                      @papasmurph That sounds awesome but way beyond my current level. Python is proving a lot more difficult than I thought it would, but anyway, many, many thanks for your help.

                      papasmurphP 1 Reply Last reply Reply Quote 0
                      • papasmurphP Offline
                        papasmurph @alidaf
                        last edited by

                        @alidaf You could maybe set a global to true when entering the callback and false when leaving, and then test on that before you affect the table outside of the callback.

                        A 1 Reply Last reply Reply Quote 0
                        • A Offline
                          alidaf @papasmurph
                          last edited by

                          @papasmurph That was my initial thought unless I could find some mutex equivalent. I'm happy with what I have working now. The key was the delay but you also allowed me to find some more useful information from the broadcast, like the tx power. I'm seeing if I can determine the distances of the beacons from the receiver. Happy days!

                          papasmurphP 1 Reply Last reply Reply Quote 0
                          • papasmurphP Offline
                            papasmurph @alidaf
                            last edited by

                            @alidaf You can subtract TX from RSSI to get a rough distance estimation a la iBeacon's "far", "near", "immediate", but I've learned to not trust TX for real distance measurement, as most beacon manufacturers don't understand they need to relate it to the actual power. My Beacon Writer app for Wellcore's beacons makes that adjustment though.

                            A 1 Reply Last reply Reply Quote 0
                            • A Offline
                              alidaf @papasmurph
                              last edited by

                              @papasmurph Exactly. I've been trying to use a complex exponential relationship with some empirically based factors but because I have different types of device, the relative numbers between device types are awful. The simplest approach is the best so far!

                              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