maixpy boot.py and fm/board_info


#1

I recently got my maix go kit and I’m trying to automatically connect to a WiFi AP on boot. I can connect with the sample code in the network module but when I try to put that in my boot.py it fails because fm and board_info objects aren’t available. What do I need to import to access these?

It also seems that globals in boot.py might not really be globals. I worked around the above by added a function to boot.py “def init_network(fm, board_info)” which includes a “global uart,net” line. I connect when I “import boot; boot.init_network(fm, board_info)” but then the net object seems to go out of scope and shuts down the wifi connection.


#2

I think you can write these code in your boot.py or _boot.py
from board import board_info
from fpioa_manager import *
import network
from machine import UART
fm.register(board_info.WIFI_RX,fm.fpioa.UART2_TX)
fm.register(board_info.WIFI_TX,fm.fpioa.UART2_RX)
uart = UART(UART.UART2,115200,timeout=1000, read_buf_len=4096)
nic=network.ESP8285(uart)
nic.connect(“your_uuid”,“you_password.”)
nic.ifconfig()
nic.isconnected()


#3

board_info import didn’t work but with fm available I was able to use the pin numbers instead of enums.


#4

@retrev
would you be king to detail with pin numbers?
Thanks in advance


#5

You can get them by printing the enum values.

 fm.register(7, 67)  # WIFI_RX -> UART2_TX
 fm.register(6, 66)  # WIFI_TX -> UART2_RX

#6

Thanks! I notice, that time-to-time symbolic names works. Now I’m trying to find correct conditions.


#7

@retrev
one more question
I found the only definitions of RX pins only in one place, i.e. in Maix_fpioa.c:
{MP_ROM_QSTR(MP_QSTR_UART2_RX ), MP_ROM_INT(66 )},
{MP_ROM_QSTR(MP_QSTR_UART2_TX ), MP_ROM_INT(67 )},

i.e. RX pins definitions does not apear in .py modules at all.

And WIFI pins are defined in board.py:
self.WIFI_TX = 6
self.WIFI_RX = 7

but using of WIFI_TX/WIFI_RX results in error, while using UART2_TX/UART2_RX does not(e.g. fm.register(7, fm.fpioa.UART2_TX))

It is quite unlogical things.