Pymate fails to setup boot.py with the right known net
I'm using a LoPy and the Pymate app. I can add my LoPy in the Pymate device manager, and it is copying a number of files to the LoPy, including a new boot.py.
I presume that the known_nets list should contain my home_ssid and password, but it is not.
# boot.py -- run on boot-up # can run arbitrary Python, but best to keep it minimal import machine import os import time uart = machine.UART(0, 115200) os.dupterm(uart) if machine.reset_cause() != machine.SOFT_RESET: from network import WLAN known_nets = [('Pycom','G01nv3nt!')] wl = WLAN() original_ssid = wl.ssid() original_auth = wl.auth() wl.mode(WLAN.STA) available_nets = wl.scan() nets = frozenset([e.ssid for e in available_nets]) known_nets_names = frozenset([e for e in known_nets]) net_to_use = list(nets & known_nets_names) try: net_to_use = net_to_use pwd = dict(known_nets)[net_to_use] sec = [e.sec for e in available_nets if e.ssid == net_to_use] wl.connect(net_to_use, (sec, pwd), timeout=10000) except: wl.init(mode=WLAN.AP, ssid=original_ssid, auth=original_auth, channel=6, antenna=WLAN.INT_ANT) time.sleep(5) execfile('/flash/lib/pymate_basic.py')
I tried changing the line
known_nets = [('Pycom','Go1nv3nt!')]to use my home_ssid and password instead, but then the LoPy froze after displaying
dhcp server start:(ip: 192.168.4.1, mask: 255.255.255.0, gw: 192.168.4.1). I've not tried another time to verify if I entered the credentials right though. I'll try that again later.
I'm using Pymate on a iPad pro (just in case it makes a difference). I'll try from my iPhone tomorrow. No time today. :-(
Great @kurt im glad to know that things are working on your side. Thanks for all the input
@Roberto Yes, thank you, I got it working on the lopy as well. My wipy 1.0 is still resisting, but I'm not sure if this device is healthy. I try it again when I have more patience for it. Cheers!
Thanks I got it to work now. I think I just didn't save it properly when switching from digital 4 to 11.
@Xykon I did the same test in my end and it works. To be clear, yes, the pins used by the apps are the expansion board pins (G 11) in you case.
- Go to the device list and refresh using the refresh button to make sure that the device is connected.
- Once int he dashboard (widgets) long click on the button widget to edit. Make sure is of type button, and that is set the the right pin (11). As an output pin.
- Once back in the dashboard make sure you press the Plat button on the top. This will send the configuration of the pin to the device and allow you to use the button widget.
Make sure you do this before doing any code input in your device (for test propose) and check if the LED Turns on.
One last thing The User LED on the expansion board is the pin 16 G16. You can test with this Led first to make sure that everything is working as it should.
@Roberto I gave this a quick test... the installation works OK now, the LoPy connects to my AP and I can see it go online and show the firmware version in Pymate.
I created a button in Pymate and told it to use digital pin 4.. I have an LED connected from P4 -> 1k resistor -> LED -> GND.
When I switch the button ON/OFF in Pymate the LED stays at a dim level.
When I bypass
from machine import Pin; p_out = Pin('P4', mode=Pin.OUT); p_out(1)then the LED lights up bright and turns off with
I thought maybe Pymate is using expansion board numbers for digital pins so I also tried digital port 11 but I don't see any change.
We have fixed this issue and updated some files in the server.
You will need to go to the setup stage again, delete your device by swiping it left and add it again.
To make sure that everything works properly please boot your device in safe mode
and remove the connection between 3v3 and G28 (P12) when Pymate asks you to reset the device.
@kurt Thanks, so we could agree that the problem is in pycom site? Hey, Pycom (@daniel) can you provide us with some information that Pymate is even working or not?
@Xykon Meanwhile got my WiPy 1.0 working and upgraded it to the most recent firmware. But the result in regards to the Pymate is almost the same.
... Error: error connecting to the pymate server, connection closed Error: error connecting to the pymate server, connection closed Error: error connecting to the pymate server, connection closed Error: error connecting to the pymate server, connection closed Error: error connecting to the pymate server, connection closed Traceback (most recent call last): File "boot.py", line 39, in <module> File "/flash/lib/pymate_basic.py", line 13, in <module> File "/flash/lib/pymate_library.py", line 354, in run KeyboardInterrupt: MicroPython v1.8.5-121-g5c3d75c on 2016-11-06; WiPy with CC3200 Type "help()" for more information. ```
The server mqtt.pycom.io does not listen on port 1883.
nmap -p 1883 mqtt.pycom.io Starting Nmap 7.01 ( https://nmap.org ) at 2016-11-06 14:35 GMT Nmap scan report for mqtt.pycom.io (220.127.116.11) Host is up (0.022s latency). PORT STATE SERVICE 1883/tcp closed unknown Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds
@Xykon Yes, this confirms OSError 104 ECONNRESET 104 /* Connection reset by peer */
I also tried
>>> socket.getaddrinfo('mqtt.pycom.io', 1883) [(2, 1, 0, '', ('18.104.22.168', 1883))]
A pleasant surprise, as socket.getaddrinfo() did not work last week.
What's next? Why is the server resetting the connection? Timeout, wrong data...?
My current plan is to get my WiPy working. It has a bad safe boot pin and I need to compile the firmware for another pin before trying Pymate on it...
@microman7k I'm trying to follow the code through a connect. One thing that sticks out is the MQTTClient using the select library for polling. But the Micropython documentation for the lopy says:
Current objects that support polling are: pyb.UART, pyb.USB_VCP.
So, maybe the LoPy is not ready yet for the Pymate?
I ran a remote wireshark capture on my Wifi AP... after correcting the credentials in boot.py I can see the LoPy get its IP via DHCP, resolve mqtt.pycom.io as 22.214.171.124 and attempt to connect to port 1883.
However the server replies with RST, ACK so the connection is reset. That's why the script is failing.
I have the same problem. I think the problem is with the pycom servers?
OK, I got the lopy connecting to the router again by manually changing the line defining the known_nets in boot.py. Yesterday it did not work because I wrote the boot.py back without line endings. Don't ask me how.
Nevertheless, Pymate and the lopy still do not connect with each other. The lopy resets, connects to the network, and then issues an error:
Traceback (most recent call last): File "boot.py", line 39, in <module> File "/flash/lib/pymate_basic.py", line 13, in <module> File "/flash/lib/pymate_library.py", line 356, in run File "/flash/lib/pymate_library.py", line 331, in _close File "/flash/lib/simple.py", line 109, in disconnect OSError: 104
"/flash/lib/pymate_library.py" does not have 356 lines as stated in the traceback, at least not on my lopy. The last three lines are:
343 # Keep receiving and sending data while connected 344 while self._connect: 345 self.__connection.wait_msg()
The whole reset sequence is this:
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0x00 clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:QIO, clock div:2 load:0x3fff9010,len:8 load:0x3fff9018,len:312 load:0x40078000,len:2348 ho 0 tail 12 room 4 load:0x4009f000,len:1364 entry 0x4009f2f8 frc2_timer_task_hdl:3ffd87a0, prio:22, stack:2048 tcpip_task_hdlxxx : 3ffdc538, prio:18,stack:2048 pp_task_hdl : 3ffde0d0, prio:23, stack:8192 mode : softAP(24:0a:c4:00:11:c9) dhcp server start:(ip: 192.168.4.1, mask: 255.255.255.0, gw: 192.168.4.1) dhcp server start:(ip: 192.168.4.1, mask: 255.255.255.0, gw: 192.168.4.1) mode : sta(24:0a:c4:00:11:c8) n:1 1, o:6 0, ap:255 255, sta:1 1, prof:6 state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 Traceback (most recent call last): File "boot.py", line 39, in <module> File "/flash/lib/pymate_basic.py", line 13, in <module> File "/flash/lib/pymate_library.py", line 356, in run File "/flash/lib/pymate_library.py", line 331, in _close File "/flash/lib/simple.py", line 109, in disconnect OSError: 104 MicroPython 7713d55 on 2016-10-28; LoPy with ESP32 Type "help()" for more information. >>> rbk
Things I plan to do:
- update the firmware to the b2 version
- installing Pymate on my iPhone and try from there (instead of the iPad)
- unpacking my other lopy, which is still untouched, and try Pymate on iPhone with the virgin lopy (after firmware upgrade).
Sorry for the long post. I'm still trying to figure out how all this is meant to work. Mqtt is new to me, and I have not even started with lorawan.