Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
调味师
arduino-esp32
提交
514d3f32
A
arduino-esp32
项目概览
调味师
/
arduino-esp32
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
arduino-esp32
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
514d3f32
编写于
4月 05, 2022
作者:
M
me-no-dev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Sample Discovery and Monitor scripts
上级
7dc8ca4e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
323 addition
and
0 deletion
+323
-0
platform.txt
platform.txt
+28
-0
tools/espnow-discovery.py
tools/espnow-discovery.py
+151
-0
tools/espnow-monitor.py
tools/espnow-monitor.py
+144
-0
未找到文件。
platform.txt
浏览文件 @
514d3f32
...
...
@@ -190,12 +190,40 @@ recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build
recipe.size.regex=^(?:\.iram0\.text|\.iram0\.vectors|\.dram0\.data|\.flash\.text|\.flash\.rodata|)\s+([0-9]+).*
recipe.size.regex.data=^(?:\.dram0\.data|\.dram0\.bss|\.noinit)\s+([0-9]+).*
## --------------------------------
## Pluggable Discovery and Monitors
## --------------------------------
## Required discoveries and monitors
## ---------------------------------
pluggable_discovery.required.0=builtin:serial-discovery
pluggable_discovery.required.1=builtin:mdns-discovery
pluggable_monitor.required.serial=builtin:serial-monitor
## release.json definition for custom discoveries and monitors
## -----------------------------------------------------------
## "discoveryDependencies": [
## { "packager": "espressif", "name": "espnow-discovery" }
## ],
## "monitorDependencies": [
## { "packager": "espressif", "name": "espnow-monitor" },
## { "packager": "espressif", "name": "espota-monitor" },
## ]
## platform.txt definition for custom discoveries and monitors
## -----------------------------------------------------------
## pluggable_discovery.required.2=espressif:espnow-discovery
## pluggable_monitor.required.espnow=espressif:espnow-monitor
## pluggable_monitor.required.network=espressif:espota-monitor
## Demo Pluggable Discovery
pluggable_discovery.espnow.pattern="{runtime.platform.path}/tools/espnow-discovery.py"
## Demo Pluggable Monitor
pluggable_monitor.pattern.espnow="/Users/ficeto/Documents/Arduino/hardware/espressif/esp32/tools/espnow-monitor.py"
## ------------------
## Upload/Debug tools
## ------------------
...
...
tools/espnow-discovery.py
0 → 100755
浏览文件 @
514d3f32
#!/opt/homebrew/bin/python3
import
sys
,
os
,
time
import
logging
# HELLO <PROTOCOL_VERSION> "<USER_AGENT>"
# {
# "eventType": "hello",
# "protocolVersion": 1,
# "message": "OK"
# }
# START
# {
# "eventType": "start",
# "message": "OK"
# }
# {
# "eventType": "start",
# "error": true,
# "message": "Permission error"
# }
# STOP
# {
# "eventType": "stop",
# "message": "OK"
# }
# {
# "eventType": "stop",
# "error": true,
# "message": "Resource busy"
# }
# QUIT
# {
# "eventType": "quit",
# "message": "OK"
# }
# LIST
# {
# "eventType": "list",
# "ports": [
# {
# "address": <-- THE ADDRESS OF THE PORT
# "label": <-- HOW THE PORT IS DISPLAYED ON THE GUI
# "protocol": <-- THE PROTOCOL USED BY THE BOARD
# "protocolLabel": <-- HOW THE PROTOCOL IS DISPLAYED ON THE GUI
# "properties": {
# <-- A LIST OF PROPERTIES OF THE PORT
# }
# },
# {
# ... <-- OTHER PORTS...
# }
# ]
# }
# {
# "eventType": "list",
# "error": true,
# "message": "Resource busy"
# }
# START_SYNC
# {
# "eventType": "start_sync",
# "message": "OK"
# }
# {
# "eventType": "start_sync",
# "error": true,
# "message": "Resource busy"
# }
# {
# "eventType": "add",
# "port": {
# "address": "/dev/ttyACM0",
# "label": "ttyACM0",
# "properties": {
# "pid": "0x804e",
# "vid": "0x2341",
# "serialNumber": "EBEABFD6514D32364E202020FF10181E",
# "name": "ttyACM0"
# },
# "protocol": "serial",
# "protocolLabel": "Serial Port (USB)"
# }
# }
# {
# "eventType": "remove",
# "port": {
# "address": "/dev/ttyACM0",
# "protocol": "serial"
# }
# }
# Invalid commands
# {
# "eventType": "command_error",
# "error": true,
# "message": "Unknown command XXXX"
# }
logging
.
basicConfig
(
filename
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
+
'/pluggable.log'
,
filemode
=
'a+'
,
encoding
=
'utf-8'
,
level
=
logging
.
DEBUG
)
log
=
logging
.
getLogger
(
'espnow-discovery'
)
discovery_hello
=
False
discovery_started
=
False
discovery_sync
=
False
def
send_msg
(
msg
):
sys
.
stdout
.
write
(
msg
)
sys
.
stdout
.
flush
()
log
.
debug
(
"TX: %s"
%
msg
)
if
__name__
==
"__main__"
:
try
:
while
True
:
for
line
in
sys
.
stdin
:
line
=
line
.
rstrip
()
log
.
debug
(
"RX: %s"
%
line
)
if
line
.
startswith
(
"HELLO 1"
):
discovery_hello
=
True
send_msg
(
'{"eventType": "hello", "protocolVersion": 1, "message": "OK"}'
)
elif
line
.
startswith
(
"LIST"
):
send_msg
(
'{"eventType": "list", "ports": [{"address": "aa:bb:cc:dd:ee:ff", "label": "ESP-NOW aa:bb:cc:dd:ee:ff", "protocol": "espnow", "protocolLabel": "ESP-NOW (WiFi)", "properties": {"channel": "1", "board": "esp32s2"}}]}'
)
elif
line
.
startswith
(
"START_SYNC"
):
discovery_sync
=
True
send_msg
(
'{"eventType": "start_sync", "message": "OK"}'
)
# time.sleep(5)
send_msg
(
'{"eventType": "add", "port": {"address": "aa:bb:cc:dd:ee:ff", "label": "ESP-NOW aa:bb:cc:dd:ee:ff", "protocol": "espnow", "protocolLabel": "ESP-NOW (WiFi)", "properties": {"channel": "1", "board": "esp32s2"}}}'
)
elif
line
.
startswith
(
"START"
):
discovery_started
=
True
send_msg
(
'{"eventType": "start", "message": "OK"}'
)
elif
line
.
startswith
(
"STOP"
):
discovery_started
=
False
discovery_sync
=
False
send_msg
(
'{"eventType": "stop", "message": "OK"}'
)
elif
line
.
startswith
(
"QUIT"
):
send_msg
(
'{"eventType": "quit", "message": "OK"}'
)
sys
.
exit
(
0
)
else
:
send_msg
(
'{"eventType": "command_error", "error": true, "message": "Unknown command XXXX"}'
)
time
.
sleep
(
0.1
)
except
Exception
as
e
:
sys
.
exit
(
1
)
sys
.
exit
(
0
)
tools/espnow-monitor.py
0 → 100755
浏览文件 @
514d3f32
#!/opt/homebrew/bin/python3
import
sys
,
os
,
time
import
logging
# HELLO <PROTOCOL_VERSION> "<USER_AGENT>"
# {
# "eventType": "hello",
# "protocolVersion": 1,
# "message": "OK"
# }
# QUIT
# {
# "eventType": "quit",
# "message": "OK"
# }
# Invalid commands
# {
# "eventType": "command_error",
# "error": true,
# "message": "Unknown command XXXX"
# }
# DESCRIBE
# {
# "eventType": "describe",
# "message": "ok",
# "port_description": {
# "protocol": "serial",
# "configuration_parameters": {
# "baudrate": {
# "label": "Baudrate",
# "type": "enum",
# "values": [
# "300", "600", "750", "1200", "2400", "4800", "9600",
# "19200", "38400", "57600", "115200", "230400", "460800",
# "500000", "921600", "1000000", "2000000"
# ],
# "selected": "9600"
# },
# "parity": {
# "label": "Parity",
# "type": "enum",
# "values": [ "N", "E", "O", "M", "S" ],
# "selected": "N"
# },
# "bits": {
# "label": "Data bits",
# "type": "enum",
# "values": [ "5", "6", "7", "8", "9" ],
# "selected": "8"
# },
# "stop_bits": {
# "label": "Stop bits",
# "type": "enum",
# "values": [ "1", "1.5", "2" ],
# "selected": "1"
# }
# }
# }
# }
# CONFIGURE <PARAMETER_NAME> <VALUE>
# {
# "eventType": "configure",
# "message": "ok"
# }
# {
# "eventType": "configure",
# "error": true,
# "message": "invalid value for parameter baudrate: 123456"
# }
# OPEN <CLIENT_TCPIP_ADDRESS> <BOARD_PORT>
# {
# "eventType": "open",
# "message": "ok"
# }
# {
# "eventType": "open",
# "error": true,
# "message": "unknown port /dev/ttyACM23"
# }
# {
# "eventType": "port_closed",
# "message": "serial port disappeared!"
# }
# CLOSE
# {
# "eventType": "close",
# "message": "ok"
# }
# {
# "eventType": "close",
# "error": true,
# "message": "port already closed"
# }
logging
.
basicConfig
(
filename
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
+
'/pluggable.log'
,
filemode
=
'a+'
,
encoding
=
'utf-8'
,
level
=
logging
.
DEBUG
)
log
=
logging
.
getLogger
(
'espnow-monitor'
)
monitor_hello
=
False
monitor_open
=
False
def
send_msg
(
msg
):
sys
.
stdout
.
write
(
msg
)
sys
.
stdout
.
flush
()
log
.
debug
(
"TX: %s"
%
msg
)
if
__name__
==
"__main__"
:
try
:
while
True
:
for
line
in
sys
.
stdin
:
line
=
line
.
rstrip
()
log
.
debug
(
"RX: %s"
%
line
)
if
line
.
startswith
(
"HELLO 1"
):
monitor_hello
=
True
send_msg
(
'{"eventType": "hello", "protocolVersion": 1, "message": "OK"}'
)
elif
line
.
startswith
(
"DESCRIBE"
):
send_msg
(
'{"eventType": "describe", "message": "ok", "port_description": {"protocol": "espnow", "configuration_parameters": {"baudrate": {"label": "Baudrate", "type": "enum", "values": ["9600", "19200", "38400", "57600", "115200", "230400", "460800", "921600"], "selected": "921600"}}}}'
)
elif
line
.
startswith
(
"CONFIGURE "
):
send_msg
(
'{"eventType": "configure", "message": "OK"}'
)
elif
line
.
startswith
(
"OPEN"
):
monitor_open
=
True
send_msg
(
'{"eventType": "open", "message": "OK"}'
)
elif
line
.
startswith
(
"CLOSE"
):
monitor_open
=
False
send_msg
(
'{"eventType": "close", "message": "OK"}'
)
elif
line
.
startswith
(
"QUIT"
):
send_msg
(
'{"eventType": "quit", "message": "OK"}'
)
sys
.
exit
(
0
)
else
:
send_msg
(
'{"eventType": "command_error", "error": true, "message": "Unknown command XXXX"}'
)
time
.
sleep
(
0.1
)
except
Exception
as
e
:
sys
.
exit
(
1
)
sys
.
exit
(
0
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录