🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    TypeError: argument should be bytes, buffer or ASCII string, not 'NoneType'

    Micropython
    2
    10
    12.1k
    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.
    • ajb2k3A
      ajb2k3
      last edited by

      Trying to connect to Azure but getting TypeError: argument should be bytes, buffer or ASCII string, not 'NoneType'
      for the sas key

      UIFlow, so easy an adult can learn it!
      If I don't know it, be patient!
      I've ether not learned it or am too drunk to remember it!
      Author of the WIP UIFlow Handbook!
      M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

      1 Reply Last reply Reply Quote 0
      • IAMLIUBOI
        IAMLIUBO
        last edited by

        Hi,

        Could you paste your code?

        1 Reply Last reply Reply Quote 0
        • ajb2k3A
          ajb2k3
          last edited by ajb2k3

          @IAMLIUBO
          This is the simple code that generates the error:

          0_1644387547710_Screenshot 2022-02-09 at 06.18.33.png

          from m5stack import *
          from m5stack_ui import *
          from uiflow import *
          from IoTcloud.Azure import IoT_Hub
          
          screen = M5Screen()
          screen.clean_screen()
          screen.set_screen_bg_color(0xFFFFFF)
          
          azure = IoT_Hub(connection_string='HostName=UIFlow.azure-devices.net;DeviceId=M5Stack_AWS;SharedAccessSignature=SharedAccessSignature sr=UIFlow.azure-devices.net%2Fdevices%2FM5Stack_AWS&sig=R22UG%2Bf6uGEIq4Z0Rty1QCU9OWVq5R3%2FUrOUN9ogGgE%3D&se=1644387423')
          

          And don't worry as the string has already been locked.

          UIFlow, so easy an adult can learn it!
          If I don't know it, be patient!
          I've ether not learned it or am too drunk to remember it!
          Author of the WIP UIFlow Handbook!
          M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

          IAMLIUBOI 1 Reply Last reply Reply Quote 0
          • IAMLIUBOI
            IAMLIUBO @ajb2k3
            last edited by

            Hi @ajb2k3

            Please try use Primary Connection String:
            0_1644388364784_6b767f55-22a2-4ca0-bbb4-069bafa1033c-image.png

            1 Reply Last reply Reply Quote 0
            • ajb2k3A
              ajb2k3
              last edited by

              Thanks I have been trying to use an sas key instead of the pcs key as that what the label says. Please change sas to pcs

              UIFlow, so easy an adult can learn it!
              If I don't know it, be patient!
              I've ether not learned it or am too drunk to remember it!
              Author of the WIP UIFlow Handbook!
              M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

              IAMLIUBOI 1 Reply Last reply Reply Quote 0
              • IAMLIUBOI
                IAMLIUBO @ajb2k3
                last edited by

                @ajb2k3

                Actually SAS is a authentication type, we use Primary Connection String calculate the sas_token, supports passing two parameters "connection_string" and "sas_token", but "sas_token" can be calculated by "connection_string", so block omits the second parameter, but connection_string is essential.
                0_1644398677740_e3026aba-5cee-46db-a93a-1ec3c3376572-image.png

                e.g.

                azure = IoT_Hub(connection_string="xxxxxxx", sas_token="xxxxxxx")
                
                ajb2k3A 1 Reply Last reply Reply Quote 0
                • ajb2k3A
                  ajb2k3 @IAMLIUBO
                  last edited by ajb2k3

                  @iamliubo yeh I managed to work out that SAS stands for Secure Access String buts it’s confusing for new people to label the block as SAS when it’s actually the PCS code that has to be typed in. I’ll try the primary key tonight when I get back to the shop.

                  UIFlow, so easy an adult can learn it!
                  If I don't know it, be patient!
                  I've ether not learned it or am too drunk to remember it!
                  Author of the WIP UIFlow Handbook!
                  M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                  IAMLIUBOI 1 Reply Last reply Reply Quote 0
                  • IAMLIUBOI
                    IAMLIUBO @ajb2k3
                    last edited by

                    @ajb2k3

                    Is this better?
                    0_1644404506540_432de5e5-4245-4eef-aa72-21b27cd22a2c-image.png

                    ajb2k3A 1 Reply Last reply Reply Quote 1
                    • ajb2k3A
                      ajb2k3 @IAMLIUBO
                      last edited by

                      @iamliubo Much, much better thank you!

                      UIFlow, so easy an adult can learn it!
                      If I don't know it, be patient!
                      I've ether not learned it or am too drunk to remember it!
                      Author of the WIP UIFlow Handbook!
                      M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                      1 Reply Last reply Reply Quote 0
                      • ajb2k3A
                        ajb2k3
                        last edited by

                        So I loose the error but have no sign that its connecting, I have a monitor running is VSCode but it show no sign of the core connecting.

                        UIFlow, so easy an adult can learn it!
                        If I don't know it, be patient!
                        I've ether not learned it or am too drunk to remember it!
                        Author of the WIP UIFlow Handbook!
                        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post