Page 1 of 1

Please,How do I solve the network problem?

Posted: Sat Feb 08, 2020 1:45 pm
by ws28422863
Image

You cannot interrupt and enter instructions in putty, it will continuously repeat the content on the picture

This is my wifi connection

Code: Select all

import network
def connectAP(ssid, pwd):
    
    wlan = network.WLAN(network.STA_IF)
    if not wlan.isconnected():
        wlan.active(True)
        wlan.connect(ssid, pwd)
        
        while not wlan.isconnected():
            pass
    print('network config:', wlan.ifconfig())

thank you!

Re: Please,How do I solve the network problem?

Posted: Sat Feb 08, 2020 3:29 pm
by kevinkk525
Apparently it doesn't find your AP so it never connects?
Therefore it doesn't stop printing those messages, unless you issue wlan.active(False)

A small note, use this instead of a busy loop:

Code: Select all

while not wlan.isconnected():
            time.sleep_ms(50)

Re: Please,How do I solve the network problem?

Posted: Sun Feb 09, 2020 10:12 am
by ws28422863
kevinkk525 wrote:
Sat Feb 08, 2020 3:29 pm
Apparently it doesn't find your AP so it never connects?
Therefore it doesn't stop printing those messages, unless you issue wlan.active(False)

A small note, use this instead of a busy loop:

Code: Select all

while not wlan.isconnected():
            time.sleep_ms(50)
Thanks for your reply
So if time.sleep_ms (50) is used, will it not be infinitely reincarnation?
Because I want to test without finding the AP

Re: Please,How do I solve the network problem?

Posted: Sun Feb 09, 2020 11:07 am
by kevinkk525
No, time.sleep() doesn't change the behaviour. It is just the recommended way.

The messages in the repl are just debug messages, you can ignore them in your program. if you are writing to the repl, use wifi.active(False) to disable your wifi and they will go away.
There should be a command for disabling the esp-idf debug messages (something like esp.debug....) but I forgot the command, sorry.

Re: Please,How do I solve the network problem?

Posted: Sun Feb 09, 2020 1:30 pm
by kevinkk525
jimmo wrote:
Sun Feb 09, 2020 1:28 pm
The log messages come from the ESP32 IDF.
I think some of these messages can't be turned off due to bugs with the way the IDF log level checking works, but there is some control of this using esp.osdebug

e.g.

Code: Select all

import esp
esp.osdebug(esp.LOG_NONE)
I don't normally use esp32 other than when I was working on BLE support. I remember I found the logging fairly inconsistent. I'll double check when I check the write truncation tomorrow.
This might be it

Re: Please,How do I solve the network problem?

Posted: Sun Feb 09, 2020 1:32 pm
by jimmo
It's esp.osdebug -- I just happened to mention to look that up for a different thread, see viewtopic.php?f=18&t=7719#p44072

(But like I said there, the IDF logging doesn't always check the value of this option...)

(Ah, sorry Kevin, looks like you just beat me to it :) )