2018-02-22 12:28 PM
HI,
I try to get mySPWF04SAworking with micropython only.
1) I want to be able to connect to my router and send information on MQTT when connected.
I have set the console_enables=2 and python_script=myscript.py in my variables.
Here my script to test:
from network import WLAN
from pyb import LED
w = WLAN(WLAN.STA)
l = LED(1)
l.off()
MySsid = 'MySSID'
print('INIT')
w.init(mode=WLAN.STA, ssid=MySsid, auth=(WLAN.WPA2, 'MYPassword'))
if w.isconnected():
print('connected');
l.on()
print(w.ifconfig())
print('END')�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
If I run this script with REPL, the connection is not working bu I see my traces.
If I run the script with the GPIO8 HIGH and reset the board, I don't see any traces on the uart. Is it possible to have the traces on the uart with only the upython working ?
2) When I do a scan with the AT command, AT+S.SCAN=d, I see all the network available on the output. If I do the same thing in the python repl like this
from network import WLAN
w = WLAN(WLAN.STA)
nets = w.scan()
for net in nets:
print(net)
�?�?�?�?�?�?�?�?�?�?�?
I don't see any networks.
I don't know what i'm doing wrong, but it's not clear what thing I need to do to get this working.
Here a sample of communication:
+WIND:1:Poweron:171117-0328fe3-SPWF04S
+WIND:13:Copyright (c) 2012-2017 STMicroelectronics, Inc. All rights Reserved:SPWF04SA
+WIND:0:Console active
+WIND:3:Watchdog Running:20
+WIND:32:WiFi Hardware Started
+WIND:19:WiFi Join:AC:86:74:23:BF:FA
+WIND:25:WiFi Association successful:AP-SSID
+WIND:51:WPA Handshake Complete
+WIND:24:WiFi Up:0:175
+WIND:24:WiFi Up::fe80:0:0:0:280:e1ff:febf:ef63
+WIND:84:NTP Server delivery:22:4:55
at+s.scan=d,
AT-S.Parsing Networks:11
1: BSS AC:86:74:23:BF:FA CHAN: 05 RSSI: -42 SSID: 'AP-SSID' CAPS: 0431 WPA WPA2
2: BSS AC:86:74:23:BF:FC CHAN: 05 RSSI: -43 SSID: 'AP-SSID-1' CAPS: 0431 WPA2
3: BSS AC:86:74:23:BF:FB CHAN: 05 RSSI: -42 SSID: '' CAPS: 0431 WPA WPA2
4: BSS 24:DE:C6:45:8E:81 CHAN: 06 RSSI: -46 SSID: 'AP-SSID-2' CAPS: 1431 WPA2
5: BSS 24:DE:C6:45:8E:82 CHAN: 06 RSSI: -47 SSID: 'AP-SSID-3' CAPS: 1421
6: BSS 24:DE:C6:45:8E:83 CHAN: 06 RSSI: -46 SSID: 'AP-SSID-4' CAPS: 1431 WPA2
7: BSS 24:DE:C6:45:8E:84 CHAN: 06 RSSI: -47 SSID: 'AP-SSID-5' CAPS: 1431 WPA2
8: BSS 24:DE:C6:45:8E:85 CHAN: 06 RSSI: -47 SSID: 'TestCP' CAPS: 1431 WPA2
9: BSS 24:DE:C6:45:8E:80 CHAN: 06 RSSI: -47 SSID: '' CAPS: 1431 WPA2
10: BSS AC:A3:1E:00:BB:84 CHAN: 06 RSSI: -87 SSID: 'AP-SSID-6' CAPS: 1431 WPA2
11: BSS AC:A3:1E:00:BB:85 CHAN: 06 RSSI: -87 SSID: 'AP-SSID-7' CAPS: 1431 WPA2
AT-S.OK
at+s.python
AT-S.OK
MicroPython v1.8.7-149-g476c672 on 2017-02-22; SPWF04Sx with STM32F439
Type 'help()' for more information.
>>> from network import WLAN
>>> w = WLAN()
>>> nets = w.scan()
>>> print(nets)
[]
>>>�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Regards
Jonathan
#micropython #wifi-spwf04sa2018-03-26 11:24 AM
Hi,
I had the same issue for your question 2, and the issue was with w.scan()
This function does not scan all the available network when it's called.
For me it was scanning only one network at a time and sometimes it may return None.
Try scanning in while loop see if it shows anything.
nets = w.scan()
while (True):
nets = w.scan()
print(nets)
Steve2018-03-27 05:27 AM
Hello Jonathan, Steve,
1) the following code redirect to UART1 (GPIO2). Please note that UART3 is not available in python only mode.
def print_on_uart1():
from pyb import UART
from uos import dupterm uart=UART(1,115200) uart.init(115200) dupterm(uart) print_on_uart1() # <---- uncomment this to have printouts on uart1 (GPIO2)2) WLAN().scan() behave exactly as 'AT+S.SCAN=s,'. If the system is running low on memory then you may get a truncated list, anyway you should get the same amount of parsed networks from both WLAN().scan() and AT+S.SCAN. In this case you have to reduce the size of RAM disk (ramdisk_memsize) and/or the size of python heap (python_memsize).
In FW 1.1.0 WLAN().scan() create a temporary file on ramdisk and for this reason a minimal ramdisk must be available (ramdisk_memsize>=2), otherwise an empty list will be returned. This restriction will be removed in the next FW release.