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

    Callback system for WiFi events

    Scheduled Pinned Locked Moved LoPy
    5 Posts 2 Posters 261 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.
    • A Offline
      agicquel
      last edited by

      Hello folks,
      I just wanna know if it possible to create a callback system for WiFi events when WLAN is configured on AP mode. I need to get the list of connected devices in the WiFI network and their hostname or states. However I have no idea how it can be achieved without this feature.

      I was thinking of something similar to the LoRa callback system : https://docs.pycom.io/firmwareapi/pycom/network/lora/ (see lora.callback(trigger, handler=None, arg=None)).

      If it doesn't exist or no way to fulfill my needs, please share me a link to the firmware source code and the WLAN class.

      Thank you in advance for your time. ;-)

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

        @agicquel I'm not sure if a callback system is actually required, a function returning the currently connected devices should be enough (though "hostnames" is a topic by itself...), but that doesn't exist.

        The source of the WLAN module is here: https://github.com/pycom/pycom-micropython-sigfox/blob/Dev/esp32/mods/modwlan.c

        Interestingly... There seems to be an undocumented callback system in there. No idea if it works at all, though, nor if it would provide the data you want.

        Don't have a Pycom module at hand right now, so I'll let you try WLAN.callback(trigger, handler, arg) yourself :-)

        1 Reply Last reply Reply Quote 2
        • A Offline
          agicquel
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • A Offline
            agicquel
            last edited by

            Thank you for your help !

            This function and many others have changed since the last time I've flashed my LoPy4. So I updated my firmware and did a dir(network.WLAN) and got this :

            ['__class__', '__name__', 'AP', 'COUNTRY_POL_AUTO', 'COUNTRY_POL_MAN', 'Connected_ap_pwd', 'EVENT_PKT_ANY', 'EVENT_PKT_CTRL', 'EVENT_PKT_DATA', 'EVENT_PKT_DATA_AMPDU', 'EVENT_PKT_DATA_MPDU', 'EVENT_PKT_MGMT', 'EVENT_PKT_MISC', 'EXT_ANT', 'FILTER_CTRL_PKT_ACK', 'FILTER_CTRL_PKT_ALL', 'FILTER_CTRL_PKT_BA', 'FILTER_CTRL_PKT_BAR', 'FILTER_CTRL_PKT_CFEND', 'FILTER_CTRL_PKT_CFENDACK', 'FILTER_CTRL_PKT_CTS', 'FILTER_CTRL_PKT_PSPOLL', 'FILTER_CTRL_PKT_WRAPPER', 'HT20', 'HT40', 'INT_ANT', 'PHY_11_B', 'PHY_11_G', 'PHY_11_N', 'PHY_LOW_RATE', 'SCAN_ACTIVE', 'SCAN_PASSIVE', 'SECONDARY_CHN_ABOVE', 'SECONDARY_CHN_BELOW', 'SECONDARY_CHN_NONE', 'SMART_CONF_DONE', 'SMART_CONF_TIMEOUT', 'STA', 'STA_AP', 'WEP', 'WPA', 'WPA2', 'WPA2_ENT', 'antenna', 'ap_sta_list', 'auth', 'bandwidth', 'bssid', 'callback', 'channel', 'connect', 'country', 'ctrl_pkt_filter', 'deinit', 'disconnect', 'events', 'hostname', 'ifconfig', 'init', 'isconnected', 'joined_ap_info', 'mac', 'max_tx_power', 'mode', 'promiscuous', 'scan', 'send_raw', 'smartConfig', 'ssid', 'wifi_packet', 'wifi_protocol']
            

            The code isn't documented so tried some triggers like EVENT_PKT_* but did not get callback activity. Furthermore, the events() function returns always 0.

            I will go further in the next days to find a solution but if you have more info about those features I would be pleased. ;-)

            I've also found the ap_sta_list() function that returns the list of info on device connected (mac, rssi, wlan_protocol). It is not callback featured but could do the trick maybe ! I will post my progress during the next days too.

            1 Reply Last reply Reply Quote 1
            • A Offline
              agicquel
              last edited by

              Okay I've made a new function in the modwlan.c in the LoPy firmware that returns a tuple containing mac and ipv4 address for each connected devices.

              Here the GitHub PR link : https://github.com/pycom/pycom-micropython-sigfox/pull/415
              It may be useful for some people ! ;-)

              1 Reply Last reply Reply Quote 1

              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