Page 1 of 1

Force network.WLAN module to disconnect?

Posted: Mon Jul 25, 2022 10:08 pm
by Jibun no kage
How to force network.WLAN module to disconnect?

Code: Select all

    # Client/Station Mode...
    theInterface=network.WLAN(network.STA_IF)
    if theInterface is None:
        #
        raise Exception('No Network?')
    # Over kill?
    theInterface.active(True)
    theNetworks=theInterface.scan()
    
    theInterface.disconnect()
    theInterface.active(False)
    
The last line in the code example, does not seem to work. If watch the connection it remains. The documentation states that the link state should change to 'down' if False is passed. But that does not seem to be working. This a bug?

Re: Force network.WLAN module to disconnect?

Posted: Thu Jul 28, 2022 2:55 pm
by karfas
Jibun no kage wrote:
Mon Jul 25, 2022 10:08 pm
How to force network.WLAN module to disconnect?
The last line in the code example, does not seem to work. If watch the connection it remains. The documentation states that the link state should change to 'down' if False is passed. But that does not seem to be working.
You don't have any "connection", as you never call wlan.connect(). Where do you see that the interface is still active ?

Re: Force network.WLAN module to disconnect?

Posted: Sat Jul 30, 2022 3:51 pm
by Jibun no kage
If you set active to true, the link state is up, right? That means the interface is visible to the network. Link state on, will be sniffed out if searched for. Connect is higher in the OSI/ISO stack true, but I recall at work our security team could find devices by link state alone, since the connecting switch or router could 'see' link state of an end-node device. Is there something about link state, that is different with the specific driver used via network.WLAN?

Re: Force network.WLAN module to disconnect?

Posted: Sat Jul 30, 2022 3:53 pm
by Jibun no kage
Forgot to mention... when I did set to False, and watched my router, finally the device dropped of the connection list, so not sure if my router is just slow to show change of state, or what.

Re: Force network.WLAN module to disconnect?

Posted: Sat Jul 30, 2022 6:19 pm
by curt
I don't believe there is any requirement for network.WLAN to inform the router it's going away. You should see similar behaviour if you just unplugged the device.

Curt

Re: Force network.WLAN module to disconnect?

Posted: Tue Aug 02, 2022 2:18 am
by Jibun no kage
Yeah, it may just be the router is doing a very low level state check,, or gives up on port that has gone inactive.