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

    Adhoc WiFi broadcast?

    Scheduled Pinned Locked Moved GPy
    gpywlan
    3 Posts 2 Posters 310 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.
    • K Offline
      kjm
      last edited by kjm

      I was hopeful of using a simple http server to send diagnostic messages from code running on a gpy to a browser on my mobile phone via the default adhoc network the gpy sets up on power up. The idea works but the code on the gpy stops running if the phone looses it's connection to the gpy wlan. Is there some sort of wifi broadcast mode whereby the gpy could belt out diagnostics regardless of if a device is connected or not?

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

        @kjm Are you sure the code on the GPy actually stops? That would seem surprising.

        How do you "send" the messages from the GPy to the browser? Unless you are using web sockets (not sure if there's an implementation for this on micropython?), it's more probably the browser polling the GPy, and you just need to make sure it continues to do so after a disconnect/reconnect.

        Can you share details of you actual setup, including the relevant code, and any errors, logs and traces (both on the GPy and in the browser)?

        1 Reply Last reply Reply Quote 0
        • K Offline
          kjm
          last edited by kjm

          That's the problem, I tried to use sockets but the wrong way. I think I should be trying for a UDP broadcast? So the diagnostics go out regardless of the phone being connected or not

          import socket; import time
          addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
          s = socket.socket(); s.bind(addr); s.listen(1)
          print('listening on', addr)
          while 1:
            cl, addr = s.accept()
            print('client connected from', addr)
            cl.send('a diagnostic print \r')
            time.sleep(2)
            cl.send('another diagnostic print \r')
            time.sleep(2)
            cl.close()
          

          If the phone looses the adhoc wifi connection the program just sits there waiting for a client to connect.

          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