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

    WiPy 2.0 Using boot.py to go into Station mode

    Scheduled Pinned Locked Moved WiPy 2&3
    11 Posts 5 Posters 3.5k 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.
    • J Offline
      jgmdavies
      last edited by jgmdavies

      Has anyone managed to create a boot.py that puts a WiPy 2 into Station mode, similar to section 3.2 in here ?

      Thanks,
      Jim

      1 Reply Last reply Reply Quote 0
      • J Offline
        jgmdavies
        last edited by

        I find it doesn't work if I attempt to set the IP address with something like:

        wlan.ifconfig(config=(IP, SUBNET, GATEWAY, DNS_SERVER))

        Also, is there a workaround for the non-availability of 'machine.SOFT_RESET'?

        Thanks,
        Jim

        1 Reply Last reply Reply Quote 0
        • D Offline
          dhallgb
          last edited by

          I got mine working by dropping that test. Instead of a fixed IP I used dynamic and gave a fixed address from my DHCP server, like so: wlan.ifconfig(config='dhcp'). I also thought that the wlan.init may have changed, I had to include the mode= as part of the function call. My full boot.py looks thusly:

          import os
          import machine
          from network import WLAN
          wlan = WLAN()
          wlan.init(mode=WLAN.STA)
          wlan.ifconfig(config='dhcp')
          
          if not wlan.isconnected():
              wlan.connect('xxxx', auth=(WLAN.WPA2, 'xxxx'), timeout=5000)
              while not wlan.isconnected():
                  machine.idle()
          
          from network import Server
          server = Server()
          server.deinit()
          server.init(login=('xxxx', 'xxxx'), timeout=6000)
          1 Reply Last reply Reply Quote 0
          • J Offline
            jgmdavies
            last edited by

            @dhallgb

            Many thanks.

            I got mine going in Station mode by dropping the 'wlan.ifconfig' completely, and accepting the IP address that it comes up with for now, so I can work fairly reliably in Station mode.

            By the way, I also got it to survive a soft reset (control+D) by changing the line that read:

            if machine.reset_cause() != machine.SOFT_RESET:

            for my boot.py for the WiPy 1.0 to simply:

            if wlan.mode() != wlan.STA:

            for the WiPy 2.0.

            As you say, there seem to be some differences in the calls, and I'm pretty sure the online docs aren't quite correct.

            And where on earth is 'machine.ADC' or its new equivalent?

            (And how are you doing your lovely code formatting please? I'm not used to this forum yet!)

            Jim

            1 Reply Last reply Reply Quote 0
            • A Offline
              AgriKinetics
              last edited by

              We had the problem with wlan.ifconfig failing until the latest firmware was installed correctly. Our quick and dirty boot.py now works fine thus:

              import machine# boot.py -- run on boot-up
              import os

              from machine import UART

              uart = UART(0, 115200)

              os.dupterm(uart)

              import machine

              from network import WLAN

              wlan = WLAN() # get current object, without changing the mode

              wlan.init(mode=WLAN.STA)

              wlan.ifconfig(config=('ip address', 'mask', 'gateway', 'dns'))

              wlan.connect('SSID', auth=(WLAN.WPA2, 'key'), timeout=5000)

              1 Reply Last reply Reply Quote 0
              • J Offline
                jgmdavies
                last edited by

                @AgriKinetics

                Thanks . That looks like what I was doing, in essence,, so I'll try again! I'm using firmware updated this morning.

                P 1 Reply Last reply Reply Quote 0
                • P Offline
                  pwest @jgmdavies
                  last edited by

                  I've been trying to get this to work, and it seems that no matter what changes I make to boot.py, the system boots into AP mode and appears with its telnet/ftp server running at 192.168.4.1.
                  I'm editing boot.py locally and then ftp'ing it up to the /flash directory. Under the ftp application, I can view the file and verify that my new file has been uploaded, but when I reboot, it's always back in AP mode.
                  Could it be the case that I'm running in one of the factory recovery modes instead of running the intended user code?

                  A 1 Reply Last reply Reply Quote 0
                  • A Offline
                    abilio @pwest
                    last edited by

                    @pwest, can you confirm the file content is still there after reboot? Did you upgrade your firmware to the last version?

                    P 1 Reply Last reply Reply Quote 0
                    • P Offline
                      pwest @abilio
                      last edited by

                      @abilio
                      I'm nearly certain that I've verified the file contents survives the reboot, but I'll re-verify tonight.

                      I certainly attempted to update the firmware to latest version (first attempt linux, fail, second attempt Windows 7, success), but HOW DO I VERIFY FIRMWARE VERSION, and what is the most recent?

                      Thanks,
                      Phil

                      A 1 Reply Last reply Reply Quote 0
                      • A Offline
                        abilio @pwest
                        last edited by

                        @pwest, if you connect to the board, you can do:

                        import os
                        os.uname()
                        

                        There you'll find the release number. Currently, the latest version is 0.9.2.b2.

                        P 1 Reply Last reply Reply Quote 0
                        • P Offline
                          pwest @abilio
                          last edited by

                          @abilio
                          I can confirm that my boot.py survives rebooting and that I'm running the most recent version of the firmware. Indeed, it appears that my boot.py is running, and that I had a syntax error on the line:
                          server = Server(login=('user', 'password'), timeout=60)
                          where I had specified a new user/pwd pair. I had thought that my boot.py wasn't running because the device came up with a server running with uid, pwd = 'micro', 'python', the default. Strange.

                          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