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

    Setting bluetooth characteristic in new firmware

    Scheduled Pinned Locked Moved Discussion
    7 Posts 5 Posters 237 Views 5 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.
    • L Offline
      lmo
      last edited by

      Hello!

      I'm trying to use Wipy as a BLE sensor. The following code is working on firmware 1.18.2.r7. I'm using the nRF Connect and with notifications enabled, characteristic changes are updated.
      But with newer firmware it crashes on chr1.value(i) with "OSError: Erorr while sending BLE indication/notification".

      from network import Bluetooth
      import time
      
      bt = Bluetooth()
      bt.set_advertisement(name='test-sensor', service_uuid=b'1234567890123456')
      
      bt.advertise(True)
      
      srv1 = bt.service(uuid=0x3000, isprimary=True, nbr_chars=1)
      
      chr1 = srv1.characteristic(uuid=0x3001, properties=Bluetooth.PROP_READ | Bluetooth.PROP_NOTIFY, value=0)
      
      i = 1
      while i < 10:
          chr1.value(i)
          print('characteristic value = '+str(i))
          time.sleep(5)
          i+=1
      
      J A 2 Replies Last reply Reply Quote 0
      • J Offline
        jcaron @lmo
        last edited by

        @lmo not sure I ever played with the BLE stuff on the Pycom modules, but shouldn’t you need to wait for a connection before sending updates? Though it would seem legitimate for it to just cache the value and don’t send anything if there’s no connection.

        Does it throw on the first call, or after a few updates?

        1 Reply Last reply Reply Quote 0
        • L Offline
          lmo
          last edited by

          Thanks @jcaron, that was it. It would be nice if the characteristic could be set even if no client is connected, but I can probably work around that.

          1 Reply Last reply Reply Quote 0
          • A Offline
            Ajneal @lmo
            last edited by

            @lmo

            I have the same issue.

            Anyone have a fix for this problem?

            Thanks

            1 Reply Last reply Reply Quote 0
            • N Offline
              nowakowski912 Banned
              last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • W Offline
                wituwitu
                last edited by

                I also have this problem... I tried with another similar code, but the same error "OSError: Erorr while sending BLE indication/notification" is displayed on chr1.value(val).

                Anyone got a fix?

                J 1 Reply Last reply Reply Quote 0
                • J Offline
                  jcaron @wituwitu
                  last edited by

                  @wituwitu According to the answer from @lmo, you can only set the characteristic once you actually have a client connected. You'll get an error if you try to set it when there's no client.

                  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