build(boards): micropython板卡执行 npm run build:prod

This commit is contained in:
王立帮
2026-01-20 18:10:33 +08:00
parent 0968a1c678
commit 6c34d392ae
300 changed files with 1376 additions and 685 deletions

View File

@@ -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'''