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

    not receiving BLE notifications on pycom fipy

    Scheduled Pinned Locked Moved Pybytes IoT platform
    6 Posts 3 Posters 110 Views 3 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.
    • R Offline
      Robert.N
      last edited by

      Hello,

      I am trying to receive bluetooth NOTIFY messages using the FiPy.

      The script I am running is as follows:

      from network import Bluetooth
      
      def mycb(chr):
          print("Callback succesful!")
      
      bt = Bluetooth()
      if not bt.isscanning(): #scan for devices
          bt.start_scan(-1)
      
      
      while True:
          adv = bt.get_adv()
          if adv and adv.mac == b"my_dev_mac":
              try:
                  conn = bt.connect(adv.mac)
                  services = conn.services()
                  for service in services:
                          if service.uuid() ==  b'my_serv_uuid':
                              chars = service.characteristics()
                              for char in chars:
                                  if char.uuid() == b'my_char_uuid':
                                      char.callback(trigger = Bluetooth.CHAR_NOTIFY_EVENT, handler=mycb)
      

      Using a different app (nRF on android) I can see the NOTIFYs being transmitted, so it's certain they are being transmitted. Reading and writing values also works fine, however the callback does not seem to work.

      What am I missing?

      Sincerely,
      Robert

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jcaron @Robert.N
        last edited by

        @Robert-N have you checked that you actually get the service and characteristic and that the callback is correctly installed?

        1 Reply Last reply Reply Quote 0
        • R Offline
          Robert.N
          last edited by

          @jcaron I am certain the services and characteristics are being transmitted, as I can read them. I am not quite sure what you mean by "callback being correctly installed", do I need to install the callback seperately? Is this not something that works out of the box?

          J 1 Reply Last reply Reply Quote 0
          • J Offline
            jcaron @Robert.N
            last edited by

            @Robert-N I mean, are you sure ˋchar.callback` is actually called? Add a trace there to make sure that happens. Just to make sure it’s not some stupid typo or something that prevents it from being executed.

            R 1 Reply Last reply Reply Quote 0
            • R Offline
              Robert.N @jcaron
              last edited by

              @jcaron I am sure that the callback works, I have gotten into the callback when using the nRF connect app as a server and sending notifications with that server. However after further tracing, it seems that I cannot properly subscribe to the NOTIFY characteristic. To subscribe for notifications it seems that you have to send a value to the descriptor, not the characteristic as I have been trying. The same problem got mentioned here: https://github.com/pycom/pycom-micropython-sigfox/issues/37, although it is still not clear how to write to the descriptor. Is there any way to write to the descriptor?

              F 1 Reply Last reply Reply Quote 0
              • F Offline
                Fredrik Andersson @Robert.N
                last edited by

                @Robert-N have you had any success with notify egen connecting a pycom board as a client to a server (sensor) or is this not possible?

                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