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

    Import of variables from boot.py

    Scheduled Pinned Locked Moved MicroPython
    boot.py
    9 Posts 4 Posters 2.3k Views 4 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.
    • A Offline
      alidaf
      last edited by

      I'm not sure of the scope of boot.py from within main.py.

      Can variables set up in boot.py be accessed from main.py?
      Can for e.g. boot.py be used to connect to a wi-fi and set up bluetooth, and then those services used from within main.py to check connectivity, etc.

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @alidaf
        last edited by

        @alidaf Why don't you just give it a try. Create a global symbol in boot.py and try to access it in main.py. Then you know.

        robert-hhR S 2 Replies Last reply Reply Quote 0
        • A Offline
          alidaf
          last edited by

          That's how I would normally, but I've got to the stage where I've written quite a bit and the process of carving it up is a bit fraught.
          I'm new to Python but there seems to be some rigour in the way things are done, with terms like 'Pythonic'. I guess I'm trying to adapt to external principals rather than just go about things my normal, hacky way.
          I'll create a few small tests and go about discovering.
          Thanks.
          But in the meantime, I would appreciate knowing if there are any advanced uses of boot.py that anyone has tried.

          1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @robert-hh
            last edited by robert-hh

            @robert-hh About your question about WiFI and Bluetooth:
            yes, you can set up wifi and bluetooth in Boot.py or main.py and use it then in other scripts. Boot.py and main.py are started by the firmware in the same context one after the other. Besides their names, there is no real difference in what you can do in the scripts. Only you can name in boot.py a different script which will be started instead of main.py.

            A 1 Reply Last reply Reply Quote 0
            • A Offline
              alidaf @robert-hh
              last edited by

              @robert-hh Brilliant. Thank you for that information.

              1 Reply Last reply Reply Quote 0
              • S Offline
                stefan85e
                last edited by

                @robert-hh Hi .. I was woundering if you know how that would work? I want to have the bluetooth to run when i reset the lopy decive....

                1 Reply Last reply Reply Quote 0
                • S Offline
                  stefan85e @robert-hh
                  last edited by

                  @robert-hh @alidaf

                  0_1524736575916_839eaca4-11a0-42ca-bec0-004e0055dffb-image.png

                  0_1524736586155_8ce74b6a-3e41-4e2d-8106-3865f1058f99-image.png

                  1 Reply Last reply Reply Quote 0
                  • P Offline
                    PeterB
                    last edited by

                    We found indeed the behaviour that instances created in boot.py also work in main.py without recreating the instances. That works e.g. if you use it standalone witout atom connected, but as soon as as atom is connected it starts to complain an instance which was created in boot.py does not exist in main.py when called.

                    Any idea why?

                    robert-hhR 1 Reply Last reply Reply Quote 0
                    • robert-hhR Offline
                      robert-hh @PeterB
                      last edited by

                      @PeterB I'm not using the pymakr plug-in, but form the discussion i recall, that there is an option to run safe boot before upload. Safe boot bypasses boot.py and main.py. In that case the objects defined in boot.py to not exist.

                      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