meshcore-cli 1.4.5__tar.gz → 1.4.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {meshcore_cli-1.4.5 → meshcore_cli-1.4.7}/PKG-INFO +2 -3
- meshcore_cli-1.4.7/REPEATER_COMMANDS.md +292 -0
- {meshcore_cli-1.4.5 → meshcore_cli-1.4.7}/flake.nix +3 -2
- {meshcore_cli-1.4.5 → meshcore_cli-1.4.7}/pyproject.toml +3 -4
- {meshcore_cli-1.4.5 → meshcore_cli-1.4.7}/src/meshcore_cli/meshcore_cli.py +29 -98
- {meshcore_cli-1.4.5 → meshcore_cli-1.4.7}/.gitignore +0 -0
- {meshcore_cli-1.4.5 → meshcore_cli-1.4.7}/LICENSE +0 -0
- {meshcore_cli-1.4.5 → meshcore_cli-1.4.7}/README.md +0 -0
- {meshcore_cli-1.4.5 → meshcore_cli-1.4.7}/flake.lock +0 -0
- {meshcore_cli-1.4.5 → meshcore_cli-1.4.7}/src/meshcore_cli/__init__.py +0 -0
- {meshcore_cli-1.4.5 → meshcore_cli-1.4.7}/src/meshcore_cli/__main__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meshcore-cli
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.7
|
|
4
4
|
Summary: Command line interface to meshcore companion radios and repeaters
|
|
5
5
|
Project-URL: Homepage, https://github.com/fdlamotte/meshcore-cli
|
|
6
6
|
Project-URL: Issues, https://github.com/fdlamotte/meshcore-cli/issues
|
|
@@ -11,9 +11,8 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Requires-Python: >=3.10
|
|
13
13
|
Requires-Dist: bleak>=0.22
|
|
14
|
-
Requires-Dist: meshcore>=2.2.
|
|
14
|
+
Requires-Dist: meshcore>=2.2.20
|
|
15
15
|
Requires-Dist: prompt-toolkit>=3.0.50
|
|
16
|
-
Requires-Dist: pycryptodome
|
|
17
16
|
Requires-Dist: requests>=2.28.0
|
|
18
17
|
Description-Content-Type: text/markdown
|
|
19
18
|
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# Repeater Commands Reference
|
|
2
|
+
|
|
3
|
+
meshcore-cli can interact with repeaters through two fundamentally different paths, each exposing a different set of commands.
|
|
4
|
+
|
|
5
|
+
## Connection Paths
|
|
6
|
+
|
|
7
|
+
### Serial direct (`-r -s <port>`)
|
|
8
|
+
|
|
9
|
+
Connects USB directly to the repeater hardware. The CLI talks to the firmware's text CLI — raw text in, raw text out over UART. This gives access to the firmware's full serial command set.
|
|
10
|
+
|
|
11
|
+
### Client mode (`to <repeater>`)
|
|
12
|
+
|
|
13
|
+
Connects to your companion client node (via BLE, TCP or serial without `-r`), then sends commands to the repeater over the mesh radio network using encrypted MeshCore `cmd` messages. The repeater firmware processes these through its mesh command handler, which is more limited than the serial interface.
|
|
14
|
+
|
|
15
|
+
The transport between you and your companion node (BLE, TCP or serial) does not matter — all three use the same MeshCore API and the same mesh protocol to reach the repeater.
|
|
16
|
+
|
|
17
|
+
<pre>
|
|
18
|
+
+------------------+
|
|
19
|
+
-r -s (serial) ------->| Firmware text CLI | (raw UART)
|
|
20
|
+
| on repeater |
|
|
21
|
+
+------------------+
|
|
22
|
+
|
|
23
|
+
+--------------+ +-------------------+
|
|
24
|
+
BLE -----+ | | mesh | Firmware mesh cmd |
|
|
25
|
+
TCP -----+--> MeshCore --> Companion +------->| handler on |
|
|
26
|
+
Serial --+ (same API) | node | radio | repeater |
|
|
27
|
+
+--------------+ +-------------------+
|
|
28
|
+
</pre>
|
|
29
|
+
|
|
30
|
+
## Commands Available in Both Modes
|
|
31
|
+
|
|
32
|
+
The following commands work regardless of how you connect to the repeater. In serial mode they are sent as raw text. In client mode they are wrapped in a `cmd` message and sent over the mesh.
|
|
33
|
+
|
|
34
|
+
### Information
|
|
35
|
+
|
|
36
|
+
<pre>
|
|
37
|
+
ver - Firmware version
|
|
38
|
+
board - Board name
|
|
39
|
+
clock - Show current time
|
|
40
|
+
</pre>
|
|
41
|
+
|
|
42
|
+
### Statistics
|
|
43
|
+
|
|
44
|
+
<pre>
|
|
45
|
+
stats-core - Core stats (uptime, battery, queue)
|
|
46
|
+
stats-radio - Radio stats (RSSI, SNR, noise floor)
|
|
47
|
+
stats-packets - Packet statistics (sent/recv counts)
|
|
48
|
+
clear stats - Reset all statistics
|
|
49
|
+
</pre>
|
|
50
|
+
|
|
51
|
+
### Network
|
|
52
|
+
|
|
53
|
+
<pre>
|
|
54
|
+
neighbors - Show neighboring repeaters (zero-hop)
|
|
55
|
+
neighbor.remove <n> - Remove a specific neighbor
|
|
56
|
+
discover.neighbors - Actively discover neighbors
|
|
57
|
+
advert - Send advertisement now
|
|
58
|
+
</pre>
|
|
59
|
+
|
|
60
|
+
### Logging
|
|
61
|
+
|
|
62
|
+
<pre>
|
|
63
|
+
log start - Enable packet logging
|
|
64
|
+
log stop - Disable packet logging
|
|
65
|
+
</pre>
|
|
66
|
+
|
|
67
|
+
Note: after `log start` in client mode, log data streams back as `RX_LOG_DATA` events and is processed with rich packet parsing (headers, routes, paths, channel/advert echoes). In serial mode, log data is printed as raw firmware text.
|
|
68
|
+
|
|
69
|
+
### Configuration (get/set)
|
|
70
|
+
|
|
71
|
+
<pre>
|
|
72
|
+
get name - Node name
|
|
73
|
+
get role - Node role
|
|
74
|
+
get radio - Radio params (freq,bw,sf,cr)
|
|
75
|
+
get freq - Frequency
|
|
76
|
+
get tx - TX power (dBm)
|
|
77
|
+
get af - Antenna factor
|
|
78
|
+
get repeat - Repeat mode on/off
|
|
79
|
+
get public.key - Node public key
|
|
80
|
+
get lat - Latitude
|
|
81
|
+
get lon - Longitude
|
|
82
|
+
get advert.interval - Advertisement interval (minutes)
|
|
83
|
+
get flood.advert.interval - Flood advertisement interval
|
|
84
|
+
get flood.max - Maximum flood hops
|
|
85
|
+
get guest.password - Guest password
|
|
86
|
+
get allow.read.only - Read-only access mode
|
|
87
|
+
get owner.info - Owner information
|
|
88
|
+
get acl - Access control list
|
|
89
|
+
get rxdelay - RX delay
|
|
90
|
+
get txdelay - TX delay
|
|
91
|
+
get direct.txdelay - Direct TX delay
|
|
92
|
+
|
|
93
|
+
set name <name> - Set node name
|
|
94
|
+
set radio f,bw,sf,cr - Set radio params (reboot to apply)
|
|
95
|
+
set freq <freq> - Set frequency
|
|
96
|
+
set tx <power> - Set TX power (dBm)
|
|
97
|
+
set af <value> - Set antenna factor
|
|
98
|
+
set repeat on|off - Enable/disable repeating
|
|
99
|
+
set lat <value> - Set latitude
|
|
100
|
+
set lon <value> - Set longitude
|
|
101
|
+
set advert.interval <min> - Set advert interval (60-240 min)
|
|
102
|
+
set flood.advert.interval <min> - Set flood advert interval
|
|
103
|
+
set flood.max <value> - Set max flood hops
|
|
104
|
+
set guest.password <pwd> - Set guest password
|
|
105
|
+
set allow.read.only on|off - Set read-only access
|
|
106
|
+
set owner.info <info> - Set owner information
|
|
107
|
+
set rxdelay <value> - Set RX delay
|
|
108
|
+
set txdelay <value> - Set TX delay
|
|
109
|
+
set direct.txdelay <val> - Set direct TX delay
|
|
110
|
+
</pre>
|
|
111
|
+
|
|
112
|
+
### Bridge Configuration (get/set)
|
|
113
|
+
|
|
114
|
+
<pre>
|
|
115
|
+
get bridge.enabled - Bridge enabled state
|
|
116
|
+
get bridge.delay - Bridge delay
|
|
117
|
+
get bridge.source - Bridge source
|
|
118
|
+
get bridge.baud - Bridge baud rate
|
|
119
|
+
get bridge.secret - Bridge secret
|
|
120
|
+
|
|
121
|
+
set bridge.enabled on|off - Enable/disable bridge
|
|
122
|
+
set bridge.delay <value> - Set bridge delay
|
|
123
|
+
set bridge.source <value> - Set bridge source
|
|
124
|
+
set bridge.baud <value> - Set bridge baud rate
|
|
125
|
+
set bridge.secret <value> - Set bridge secret
|
|
126
|
+
</pre>
|
|
127
|
+
|
|
128
|
+
### Region Management
|
|
129
|
+
|
|
130
|
+
<pre>
|
|
131
|
+
region - Display currently configured regions
|
|
132
|
+
region save - Save current region config to flash
|
|
133
|
+
region home - Get/set home region
|
|
134
|
+
region get - Get info (and parent) for a region
|
|
135
|
+
region put - Add or update a region
|
|
136
|
+
region remove - Remove a region definition
|
|
137
|
+
region allowf - Give flood permission to a region
|
|
138
|
+
region denyf - Remove flood permission from a region
|
|
139
|
+
</pre>
|
|
140
|
+
|
|
141
|
+
### GPS
|
|
142
|
+
|
|
143
|
+
<pre>
|
|
144
|
+
gps on|off - Enable/disable GPS
|
|
145
|
+
gps sync - Sync GPS
|
|
146
|
+
gps setloc - Set location from GPS
|
|
147
|
+
gps advert none|share|prefs - GPS advertisement mode
|
|
148
|
+
</pre>
|
|
149
|
+
|
|
150
|
+
### Sensors
|
|
151
|
+
|
|
152
|
+
<pre>
|
|
153
|
+
sensor list - List sensors
|
|
154
|
+
sensor get - Get sensor value
|
|
155
|
+
sensor set - Set sensor value
|
|
156
|
+
</pre>
|
|
157
|
+
|
|
158
|
+
### Other
|
|
159
|
+
|
|
160
|
+
<pre>
|
|
161
|
+
password <pwd> - Set admin password
|
|
162
|
+
powersaving on|off - Toggle power saving mode
|
|
163
|
+
setperm <key> <perm> - Set permissions for a node
|
|
164
|
+
time <epoch> - Set time to given epoch
|
|
165
|
+
reboot - Reboot device
|
|
166
|
+
erase - Erase filesystem
|
|
167
|
+
</pre>
|
|
168
|
+
|
|
169
|
+
## Commands Available Only in Serial Mode (`-r`)
|
|
170
|
+
|
|
171
|
+
These commands only work over the serial text CLI. They return "Unknown command" when sent via mesh `cmd`.
|
|
172
|
+
|
|
173
|
+
### Logging (serial only)
|
|
174
|
+
|
|
175
|
+
<pre>
|
|
176
|
+
log - Dump stored log file to console
|
|
177
|
+
log erase - Erase log file
|
|
178
|
+
</pre>
|
|
179
|
+
|
|
180
|
+
The bare `log` command streams stored log data over the serial output, which doesn't fit the mesh command request/response model. `log erase` is similarly a serial-only operation.
|
|
181
|
+
|
|
182
|
+
### Region File Transfer (serial only)
|
|
183
|
+
|
|
184
|
+
These are meshcore-cli convenience commands that handle file I/O over the serial link:
|
|
185
|
+
|
|
186
|
+
<pre>
|
|
187
|
+
region upload <file> - Upload regions config from local file to node
|
|
188
|
+
region load <file> - Alias for region upload
|
|
189
|
+
region download <file> - Download regions config from node to local file
|
|
190
|
+
region list - List allowed/denied regions
|
|
191
|
+
</pre>
|
|
192
|
+
|
|
193
|
+
### Other Serial-Only Commands
|
|
194
|
+
|
|
195
|
+
<pre>
|
|
196
|
+
tempradio - Temporary radio configuration
|
|
197
|
+
script <file> - Execute a local script file (lines sent one by one)
|
|
198
|
+
clock sync - Sync repeater clock to host time (alias: st, sync_time)
|
|
199
|
+
</pre>
|
|
200
|
+
|
|
201
|
+
Note: `clock sync` in serial mode is intercepted by meshcore-cli, which reads the host clock and sends `time <epoch>` to the firmware. In client mode, `clock sync` is available as a meshcore-cli command on the companion node (not sent to the repeater).
|
|
202
|
+
|
|
203
|
+
## Commands Available Only in Client Mode (`to <repeater>`)
|
|
204
|
+
|
|
205
|
+
These are meshcore-cli commands that use the MeshCore protocol to query repeaters. They are not raw firmware commands — they use dedicated binary protocol messages.
|
|
206
|
+
|
|
207
|
+
### Repeater Management
|
|
208
|
+
|
|
209
|
+
<pre>
|
|
210
|
+
login <pwd> - Log into repeater with password l
|
|
211
|
+
logout - Log out of repeater
|
|
212
|
+
req_status - Request status from repeater rs
|
|
213
|
+
req_neighbours - Request neighbours in binary form rn
|
|
214
|
+
req_regions - Request regions list rr
|
|
215
|
+
req_owner - Request owner information ro
|
|
216
|
+
req_clock - Request repeater timestamp (for sync)
|
|
217
|
+
req_acl - Request access control list ra
|
|
218
|
+
trace - Run a trace to this repeater tr
|
|
219
|
+
dtrace - Discover path and trace dt
|
|
220
|
+
</pre>
|
|
221
|
+
|
|
222
|
+
### Contact Operations (on the repeater contact)
|
|
223
|
+
|
|
224
|
+
<pre>
|
|
225
|
+
contact_info - Print contact info for this repeater ci
|
|
226
|
+
path - Display path to this repeater
|
|
227
|
+
disc_path - Discover new path and display dp
|
|
228
|
+
reset_path - Reset path to flood rp
|
|
229
|
+
change_path <path> - Change the path to this repeater cp
|
|
230
|
+
change_flags <flags> - Change contact flags cf
|
|
231
|
+
share_contact - Share this repeater's contact sc
|
|
232
|
+
export_contact - Export this repeater's URI ec
|
|
233
|
+
req_telemetry - Request telemetry data rt
|
|
234
|
+
forget_password - Remove stored password for repeater fp
|
|
235
|
+
set timeout <value> - Set command timeout for this repeater
|
|
236
|
+
get timeout - Get command timeout for this repeater
|
|
237
|
+
</pre>
|
|
238
|
+
|
|
239
|
+
### Special Operations
|
|
240
|
+
|
|
241
|
+
<pre>
|
|
242
|
+
clkreboot - Clock-aware reboot
|
|
243
|
+
start ota - Start OTA (over-the-air) update
|
|
244
|
+
get telemetry - Alias for req_telemetry
|
|
245
|
+
get status - Alias for req_status
|
|
246
|
+
get acl - Alias for req_acl
|
|
247
|
+
</pre>
|
|
248
|
+
|
|
249
|
+
### Prefix Shortcuts
|
|
250
|
+
|
|
251
|
+
<pre>
|
|
252
|
+
: <cmd> - Force send as raw cmd (e.g. ":ver")
|
|
253
|
+
send <msg> / "<msg> - Send a text message to repeater (room)
|
|
254
|
+
</pre>
|
|
255
|
+
|
|
256
|
+
## Quick Reference Table
|
|
257
|
+
|
|
258
|
+
| Command | Serial (`-r`) | Client (`to`) | Notes |
|
|
259
|
+
| --- | :---: | :---: | --- |
|
|
260
|
+
| ver, board, clock | Yes | Yes | |
|
|
261
|
+
| stats-core/radio/packets | Yes | Yes | |
|
|
262
|
+
| clear stats | Yes | Yes | |
|
|
263
|
+
| neighbors | Yes | Yes | |
|
|
264
|
+
| neighbor.remove | Yes | Yes | |
|
|
265
|
+
| discover.neighbors | Yes | Yes | |
|
|
266
|
+
| advert | Yes | Yes | |
|
|
267
|
+
| log start / log stop | Yes | Yes | Client receives data via RX_LOG_DATA events |
|
|
268
|
+
| log (dump) | Yes | **No** | Serial streaming, no mesh equivalent |
|
|
269
|
+
| log erase | Yes | **No** | Serial only |
|
|
270
|
+
| get/set (all params) | Yes | Yes | |
|
|
271
|
+
| region (get/put/remove/save/home/allowf/denyf) | Yes | Yes | |
|
|
272
|
+
| region upload/download | Yes | **No** | Requires serial file transfer |
|
|
273
|
+
| region list | Yes | **No** | Serial only |
|
|
274
|
+
| gps | Yes | Yes | |
|
|
275
|
+
| sensor | Yes | Yes | |
|
|
276
|
+
| password | Yes | Yes | |
|
|
277
|
+
| powersaving | Yes | Yes | |
|
|
278
|
+
| setperm | Yes | Yes | Client mode resolves contact names to keys |
|
|
279
|
+
| time, reboot, erase | Yes | Yes | |
|
|
280
|
+
| tempradio | Yes | **No** | Serial only |
|
|
281
|
+
| clock sync | Yes | **No** | CLI intercepts and sends `time <epoch>` |
|
|
282
|
+
| script | Yes | **No** | Reads local file, sends lines over serial |
|
|
283
|
+
| login/logout | **No** | Yes | MeshCore protocol commands |
|
|
284
|
+
| req_status | **No** | Yes | Binary protocol request |
|
|
285
|
+
| req_neighbours | **No** | Yes | Binary protocol request |
|
|
286
|
+
| req_regions | **No** | Yes | Binary protocol request |
|
|
287
|
+
| req_owner | **No** | Yes | Binary protocol request |
|
|
288
|
+
| req_clock | **No** | Yes | Binary protocol request |
|
|
289
|
+
| req_acl | **No** | Yes | Binary protocol request |
|
|
290
|
+
| trace/dtrace | **No** | Yes | Path tracing via mesh |
|
|
291
|
+
| contact management | **No** | Yes | CLI-level operations on companion node |
|
|
292
|
+
| clkreboot, start ota | **No** | Yes | Mesh protocol commands |
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
|
|
18
18
|
meshcore = python3Packages.buildPythonPackage rec {
|
|
19
19
|
pname = "meshcore";
|
|
20
|
-
version = "2.2.
|
|
20
|
+
version = "2.2.20";
|
|
21
21
|
pyproject = true;
|
|
22
22
|
|
|
23
23
|
src = python3Packages.fetchPypi {
|
|
24
24
|
inherit pname version;
|
|
25
|
-
sha256 = "sha256-
|
|
25
|
+
sha256 = "sha256-Dx9aarXciLxUqANXHMgCAXjMuyozevfX0qA4KFHE5UQ=";
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
build-system = [ python3Packages.hatchling ];
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
python3Packages.bleak
|
|
32
32
|
python3Packages.pycayennelpp
|
|
33
33
|
python3Packages.pyserial-asyncio-fast
|
|
34
|
+
python3Packages.pycryptodome
|
|
34
35
|
];
|
|
35
36
|
|
|
36
37
|
pythonImportsCheck = [ "meshcore" ];
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "meshcore-cli"
|
|
7
|
-
version = "1.4.
|
|
7
|
+
version = "1.4.7"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
|
10
10
|
]
|
|
@@ -17,11 +17,10 @@ classifiers = [
|
|
|
17
17
|
]
|
|
18
18
|
license = "MIT"
|
|
19
19
|
license-files = ["LICEN[CS]E*"]
|
|
20
|
-
dependencies = [ "meshcore >= 2.2.
|
|
20
|
+
dependencies = [ "meshcore >= 2.2.20",
|
|
21
21
|
"bleak >= 0.22",
|
|
22
22
|
"prompt_toolkit >= 3.0.50",
|
|
23
|
-
"requests >= 2.28.0"
|
|
24
|
-
"pycryptodome" ]
|
|
23
|
+
"requests >= 2.28.0" ]
|
|
25
24
|
|
|
26
25
|
[project.urls]
|
|
27
26
|
Homepage = "https://github.com/fdlamotte/meshcore-cli"
|
|
@@ -22,8 +22,6 @@ from prompt_toolkit.key_binding import KeyBindings
|
|
|
22
22
|
from prompt_toolkit.shortcuts import radiolist_dialog
|
|
23
23
|
from prompt_toolkit.completion.word_completer import WordCompleter
|
|
24
24
|
from prompt_toolkit.document import Document
|
|
25
|
-
from Crypto.Cipher import AES
|
|
26
|
-
from Crypto.Hash import HMAC, SHA256
|
|
27
25
|
|
|
28
26
|
try:
|
|
29
27
|
from bleak import BleakScanner, BleakClient
|
|
@@ -37,7 +35,8 @@ import re
|
|
|
37
35
|
from meshcore import MeshCore, EventType, logger
|
|
38
36
|
|
|
39
37
|
# Version
|
|
40
|
-
VERSION = "v1.4.
|
|
38
|
+
VERSION = "v1.4.7"
|
|
39
|
+
|
|
41
40
|
|
|
42
41
|
# default ble address is stored in a config file
|
|
43
42
|
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
|
|
@@ -232,88 +231,25 @@ process_event_message.timestamp=""
|
|
|
232
231
|
async def handle_log_rx(event):
|
|
233
232
|
mc = handle_log_rx.mc
|
|
234
233
|
|
|
235
|
-
|
|
236
|
-
pbuf = io.BytesIO(pkt)
|
|
237
|
-
header = pbuf.read(1)[0]
|
|
238
|
-
route_type = header & 0x03
|
|
239
|
-
payload_type = (header & 0x3c) >> 2
|
|
240
|
-
payload_ver = (header & 0xc0) >> 6
|
|
241
|
-
|
|
242
|
-
transport_code = None
|
|
243
|
-
if route_type == 0x00 or route_type == 0x03: # has transport code
|
|
244
|
-
transport_code = pbuf.read(4) # discard transport code
|
|
245
|
-
|
|
246
|
-
path_byte = pbuf.read(1)[0]
|
|
247
|
-
path_hash_size = ((path_byte & 0xC0) >> 6) + 1
|
|
248
|
-
path_len = (path_byte & 0x3F)
|
|
249
|
-
# here path_len is number of hops, not number of bytes
|
|
250
|
-
|
|
251
|
-
path = pbuf.read(path_len*path_hash_size).hex() # Beware of traces where pathes are mixed
|
|
252
|
-
|
|
253
|
-
try :
|
|
254
|
-
route_typename = ROUTE_TYPENAMES[route_type]
|
|
255
|
-
except IndexError:
|
|
256
|
-
logger.debug(f"Unknown route type {route_type}")
|
|
257
|
-
route_typename = "UNK"
|
|
258
|
-
|
|
259
|
-
try :
|
|
260
|
-
payload_typename = PAYLOAD_TYPENAMES[payload_type]
|
|
261
|
-
except IndexError:
|
|
262
|
-
logger.debug(f"Unknown payload type {payload_type}")
|
|
263
|
-
payload_typename = "UNK"
|
|
264
|
-
|
|
265
|
-
pkt_payload = pbuf.read()
|
|
266
|
-
|
|
267
|
-
event.payload["header"] = header
|
|
268
|
-
event.payload["route_type"] = route_type
|
|
269
|
-
event.payload["route_typename"] = route_typename
|
|
270
|
-
event.payload["payload_type"] = payload_type
|
|
271
|
-
event.payload["payload_typename"]= payload_typename
|
|
272
|
-
|
|
273
|
-
event.payload["payload_ver"] = payload_ver
|
|
274
|
-
|
|
275
|
-
if not transport_code is None:
|
|
276
|
-
event.payload["transport_code"] = transport_code.hex()
|
|
277
|
-
|
|
278
|
-
event.payload["path_len"] = path_len
|
|
279
|
-
event.payload["path_hash_size"] = path_hash_size
|
|
280
|
-
event.payload["path"] = path
|
|
281
|
-
|
|
282
|
-
event.payload["pkt_payload"] = pkt_payload.hex()
|
|
234
|
+
payload_type = event.payload["payload_type"]
|
|
283
235
|
|
|
284
236
|
if payload_type == 0x05: # flood msg / channel
|
|
285
237
|
if handle_log_rx.channel_echoes:
|
|
286
|
-
pk_buf = io.BytesIO(pkt_payload)
|
|
287
|
-
chan_hash = pk_buf.read(1).hex()
|
|
288
|
-
cipher_mac = pk_buf.read(2)
|
|
289
|
-
msg = pk_buf.read() # until the end of buffer
|
|
290
|
-
|
|
291
|
-
channel = None
|
|
292
|
-
for c in await get_channels(mc):
|
|
293
|
-
if c["channel_hash"] == chan_hash : # validate against MAC
|
|
294
|
-
h = HMAC.new(bytes.fromhex(c["channel_secret"]), digestmod=SHA256)
|
|
295
|
-
h.update(msg)
|
|
296
|
-
if h.digest()[0:2] == cipher_mac:
|
|
297
|
-
channel = c
|
|
298
|
-
break
|
|
299
238
|
|
|
300
239
|
chan_name = ""
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
chan_name = channel["channel_name"]
|
|
308
|
-
aes_key = bytes.fromhex(channel["channel_secret"])
|
|
309
|
-
cipher = AES.new(aes_key, AES.MODE_ECB)
|
|
310
|
-
message = cipher.decrypt(msg)[5:].decode("utf-8", "ignore").strip("\x00")
|
|
240
|
+
if "message" in event.payload :
|
|
241
|
+
chan_name = event.payload["chan_name"]
|
|
242
|
+
message = event.payload["message"]
|
|
243
|
+
elif handle_log_rx.echo_unk_chans:
|
|
244
|
+
chan_name = event.payload["chan_hash"]
|
|
245
|
+
message = event.payload["crypted"]
|
|
311
246
|
|
|
312
247
|
if chan_name != "" :
|
|
313
248
|
width = os.get_terminal_size().columns
|
|
314
|
-
cars = width - 13 - len(path) - len(chan_name) - 1
|
|
249
|
+
cars = width - 13 - len(event.payload["path"]) - len(chan_name) - 1
|
|
315
250
|
dispmsg = message.replace("\n","")[0:cars]
|
|
316
|
-
txt = f"{ANSI_LIGHT_GRAY}{chan_name} {ANSI_DGREEN}{dispmsg+(cars-len(dispmsg))*' '} {ANSI_YELLOW}[{path}]{ANSI_LIGHT_GRAY}{event.payload['snr']:6,.2f}{event.payload['rssi']:4}{ANSI_END}"
|
|
251
|
+
txt = f"{ANSI_LIGHT_GRAY}{chan_name} {ANSI_DGREEN}{dispmsg+(cars-len(dispmsg))*' '} {ANSI_YELLOW}[{event.payload['path']}]{ANSI_LIGHT_GRAY}{event.payload['snr']:6,.2f}{event.payload['rssi']:4}{ANSI_END}"
|
|
252
|
+
|
|
317
253
|
if handle_message.above:
|
|
318
254
|
print_above(txt)
|
|
319
255
|
else:
|
|
@@ -321,25 +257,20 @@ async def handle_log_rx(event):
|
|
|
321
257
|
|
|
322
258
|
elif payload_type == 0x04: # Advert
|
|
323
259
|
if handle_log_rx.advert_echoes:
|
|
324
|
-
|
|
325
|
-
adv_key =
|
|
326
|
-
adv_timestamp =
|
|
327
|
-
signature =
|
|
328
|
-
flags =
|
|
329
|
-
adv_type =
|
|
330
|
-
adv_lat = None
|
|
331
|
-
adv_lon = None
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
adv_feat2 = pk_buf.read(2).hex()
|
|
339
|
-
if flags & 0x80 > 0: #has name
|
|
340
|
-
adv_name = pk_buf.read().decode("utf-8", "ignore").strip("\x00")
|
|
341
|
-
|
|
342
|
-
if adv_name is None:
|
|
260
|
+
|
|
261
|
+
adv_key = event.payload["adv_key"]
|
|
262
|
+
adv_timestamp = event.payload["adv_timestamp"]
|
|
263
|
+
signature = event.payload["signature"]
|
|
264
|
+
flags = event.payload["adv_flags"]
|
|
265
|
+
adv_type = event.payload["adv_type"]
|
|
266
|
+
adv_lat = event.payload["adv_lat"] if "adv_lat" in event.payload else None
|
|
267
|
+
adv_lon = event.payload["adv_lon"] if "adv_lon" in event.payload else None
|
|
268
|
+
adv_feat1 = event.payload["adv_feat1"] if "adv_feat1" in event.payload else None
|
|
269
|
+
adv_feat2 = event.payload["adv_feat2"] if "adv_feat2" in event.payload else None
|
|
270
|
+
|
|
271
|
+
if "adv_name" in event.payload:
|
|
272
|
+
adv_name = event.payload["adv_name"]
|
|
273
|
+
else:
|
|
343
274
|
# try to get the name from the contact
|
|
344
275
|
ct = handle_log_rx.mc.get_contact_by_key_prefix(adv_key)
|
|
345
276
|
if ct is None:
|
|
@@ -362,13 +293,14 @@ async def handle_log_rx(event):
|
|
|
362
293
|
txt = f"{ANSI_LIGHT_GRAY}Advert for{ANSI_END} {adv_name}{ANSI_GREEN}/{CONTACT_TYPENAMES[adv_type]}{ts_str}{ANSI_END}"
|
|
363
294
|
if not adv_lat is None:
|
|
364
295
|
txt += f" {ANSI_LIGHT_GRAY}coords: {adv_lat},{adv_lon}"
|
|
365
|
-
txt += f" {ANSI_YELLOW}path: [{path}] {ANSI_LIGHT_GRAY}snr: {event.payload['snr']:.2f}dB{ANSI_END}"
|
|
296
|
+
txt += f" {ANSI_YELLOW}path: [{event.payload['path']}] {ANSI_LIGHT_GRAY}snr: {event.payload['snr']:.2f}dB{ANSI_END}"
|
|
366
297
|
|
|
367
298
|
if handle_message.above:
|
|
368
299
|
print_above(txt)
|
|
369
300
|
else:
|
|
370
301
|
print(txt)
|
|
371
302
|
|
|
303
|
+
event.payload["pkt_payload"] = event.payload["pkt_payload"].hex() # convert for json serialization
|
|
372
304
|
|
|
373
305
|
if handle_log_rx.json_log_rx: # json mode ... raw dump
|
|
374
306
|
msg = json.dumps(event.payload)
|
|
@@ -1717,7 +1649,6 @@ async def set_channel (mc, chan, name, key=None):
|
|
|
1717
1649
|
return None
|
|
1718
1650
|
|
|
1719
1651
|
info = res.payload
|
|
1720
|
-
info["channel_hash"] = SHA256.new(info["channel_secret"]).hexdigest()[0:2]
|
|
1721
1652
|
info["channel_secret"] = info["channel_secret"].hex()
|
|
1722
1653
|
|
|
1723
1654
|
if hasattr(mc,'channels') :
|
|
@@ -1806,7 +1737,6 @@ async def get_channels (mc, anim=False) :
|
|
|
1806
1737
|
if res.type == EventType.ERROR:
|
|
1807
1738
|
break
|
|
1808
1739
|
info = res.payload
|
|
1809
|
-
info["channel_hash"] = SHA256.new(info["channel_secret"]).hexdigest()[0:2]
|
|
1810
1740
|
info["channel_secret"] = info["channel_secret"].hex()
|
|
1811
1741
|
mc.channels.append(info)
|
|
1812
1742
|
ch = ch + 1
|
|
@@ -4585,6 +4515,7 @@ async def main(argv):
|
|
|
4585
4515
|
mc.subscribe(EventType.RX_LOG_DATA, handle_log_rx)
|
|
4586
4516
|
|
|
4587
4517
|
mc.auto_update_contacts = True
|
|
4518
|
+
mc.set_decrypt_channel_logs = True
|
|
4588
4519
|
|
|
4589
4520
|
res = await mc.commands.send_device_query()
|
|
4590
4521
|
if res.type == EventType.ERROR :
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|