build(boards): micropython板卡执行 npm run build:prod
This commit is contained in:
@@ -527,10 +527,11 @@
|
||||
"network",
|
||||
"base64",
|
||||
"urequests",
|
||||
"ussl"
|
||||
"ussl",
|
||||
"os"
|
||||
],
|
||||
"__file__": true,
|
||||
"__size__": 12396,
|
||||
"__size__": 12663,
|
||||
"__name__": "mixiot.py"
|
||||
},
|
||||
"mixpy": {
|
||||
@@ -755,7 +756,7 @@
|
||||
"espnow"
|
||||
],
|
||||
"__file__": true,
|
||||
"__size__": 5905,
|
||||
"__size__": 5545,
|
||||
"__name__": "radio.py"
|
||||
},
|
||||
"rc522": {
|
||||
|
||||
@@ -11,8 +11,10 @@ WILL_TOPIC = '9d634e1a156dc0c1611eb4c3cff57276'
|
||||
def wlan_connect(ssid='MYSSID', password='MYPASS', timeout=10):
|
||||
import network
|
||||
wlan = network.WLAN(network.STA_IF)
|
||||
if not wlan.active() or not wlan.isconnected():
|
||||
if not wlan.active():
|
||||
wlan.active(True)
|
||||
time.sleep(0.5)
|
||||
if not wlan.isconnected():
|
||||
print('connecting to:', ssid, end ="")
|
||||
try:
|
||||
wlan.connect(ssid, password)
|
||||
@@ -26,7 +28,11 @@ def wlan_connect(ssid='MYSSID', password='MYPASS', timeout=10):
|
||||
if _num > timeout:
|
||||
wlan.active(False)
|
||||
print('')
|
||||
raise RuntimeError("WiFi connection timeout, Please check only 2.4G supported name and password")
|
||||
import os
|
||||
if 'c5' in os.uname().machine.lower():
|
||||
raise RuntimeError("WiFi connection timeout. Please check the SSID and password")
|
||||
else:
|
||||
raise RuntimeError("WiFi connection timeout, Please check the SSID and password (only 2.4GHz networks are supported)")
|
||||
print('\nnetwork config:', wlan.ifconfig())
|
||||
return wlan
|
||||
|
||||
|
||||
@@ -15,16 +15,15 @@ from ubinascii import hexlify, unhexlify
|
||||
import network
|
||||
|
||||
class ESPNow(espnow.ESPNow):
|
||||
def __init__(self, channel=1, txpower=20):
|
||||
super().__init__()
|
||||
self.active(True)
|
||||
self._channel = channel
|
||||
self._txpower = txpower
|
||||
def __init__(self, channel=None, txpower=20):
|
||||
self._on_handle = {}
|
||||
self._once_irq = True
|
||||
self._nic = network.WLAN(network.STA_IF) #if version else network.WLAN(network.AP_IF)
|
||||
self._nic.active(True)
|
||||
self._nic.config(channel=self._channel, txpower=self._txpower)
|
||||
if channel is not None:
|
||||
self.set_channel(channel, txpower)
|
||||
super().__init__()
|
||||
self.active(True)
|
||||
|
||||
def encrypt(self, peer, pmk, add_peer=True):
|
||||
super().set_pmk((pmk + "0" *16)[:16].encode())
|
||||
@@ -46,11 +45,8 @@ class ESPNow(espnow.ESPNow):
|
||||
elif err.args[1] == 'ESP_ERR_ESPNOW_IF':
|
||||
self._nic.active(True)
|
||||
elif err.args[1] == 'ESP_ERR_ESPNOW_NOT_FOUND':
|
||||
super().add_peer(_peer, channel=self._channel)
|
||||
try:
|
||||
return super().send(_peer, str(msg))
|
||||
except:
|
||||
raise OSError("ESPNOW channel ({}) conflicts with WiFi channel ({})".format(self._channel, self.channel))
|
||||
super().add_peer(_peer, channel=self.channel)
|
||||
return super().send(_peer, str(msg))
|
||||
elif err.args[1] == 'ESP_ERR_ESPNOW_NO_MEM':
|
||||
raise OSError("internal ESP-NOW buffers are full")
|
||||
elif err.args[1] == 'ESP_ERR_ESPNOW_ARG':
|
||||
@@ -66,11 +62,11 @@ class ESPNow(espnow.ESPNow):
|
||||
else :
|
||||
return None,None
|
||||
|
||||
def set_channel(self, channel=None, txpower=None):
|
||||
self._channel = self._channel if channel is None else channel
|
||||
self._nic.config(channel=self._channel, txpower=self._txpower if txpower is None else txpower)
|
||||
if self._channel != self.channel:
|
||||
print("Warning: The set channel ({}) does not match the actual channel ({})".format(self._channel, self.channel))
|
||||
def set_channel(self, channel=1, txpower=20):
|
||||
if not self._nic.isconnected():
|
||||
self._nic.config(channel=channel, txpower=txpower)
|
||||
else:
|
||||
print("Warning: WiFi is connected, the actual espnow channel is {}".format(self.channel))
|
||||
|
||||
def _cb_handle0(self, event_code, data):
|
||||
'''Callback processing conversion'''
|
||||
|
||||
Reference in New Issue
Block a user