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

    BLE Error

    Scheduled Pinned Locked Moved LoPy
    ble
    3 Posts 2 Posters 883 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.
    • M Offline
      misterlisty
      last edited by

      Why would i be getting error on BLUE callack as below...

      Unhandled exception in callback handler
      Traceback (most recent call last):
      File "main.py", line 202, in char1_cb_handler
      TypeError: unsupported types for add: 'str', 'bytes'

      def char1_cb_handler(chr):
      logger("BLEADVERTISE::Read\Write request...")    
      global char1_read_counter
      global c_ssid
      global c_pwd
      global devicename
      global lastcommand
      events = chr.events()
      if  events & Bluetooth.CHAR_WRITE_EVENT:
          print("Write request[",char1_read_counter,"] with value = ",chr.value())
          if char1_read_counter==0:
              devicename=chr.value()
          elif char1_read_counter==1:
              c_ssid=chr.value()
          elif char1_read_counter==2:
              c_pwd=chr.value()
          elif char1_read_counter==5:
              lastcommand=chr.value()
              commander(chr.value().decode('utf-8'))
      else:
          char1_read_counter += 1
          if char1_read_counter > 5:
              char1_read_counter=0
          if char1_read_counter==0:
              return "devicename[" + devicename + "]"
          elif char1_read_counter==1:
              return "ssid[" + c_ssid + "]"
          elif char1_read_counter==2:
              return "pwd[" + c_pwd + "]"
          elif char1_read_counter==3:
              return "pwd[" + c_pwd + "]"
          elif char1_read_counter==4:
              if wl.isconnected():
                  return "IP[" + wl.ifconfig()[0] + "]"  
              else:
                  return "not connected"  #LINE 202 ERROR AS ABOVE
          elif char1_read_counter==5:
              return "lastcommand[" + lastcommand	+ "]"
      
      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jmarcelino @misterlisty
        last edited by

        @misterlisty

        The error is probably in:

        "lastcommand[" + lastcommand + "]"

        Try:

        "lastcommand[" + str(lastcommand) + "]"

        instead

        1 Reply Last reply Reply Quote 2
        • M Offline
          misterlisty
          last edited by

          Problem..solved due to your suggestion!

          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