meshcore 1.9.8.dev5__tar.gz → 1.9.9__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-1.9.8.dev5 → meshcore-1.9.9}/PKG-INFO +1 -1
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/pyproject.toml +1 -1
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/src/meshcore/commands.py +35 -10
- meshcore-1.9.9/src/meshcore/lpp_json_encoder.py +56 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/src/meshcore/reader.py +4 -2
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/.gitignore +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/LICENSE +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/README.md +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/ble_chat.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/ble_t1000_chan_msg.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/ble_t1000_custom_vars.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/ble_t1000_infos.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/ble_t1000_msg.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/ble_t1000_set_cv.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/mepo_mc_gps.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/pubsub_example.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/rf_packet_monitor.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/serial_battery_monitor.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/serial_chat.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/serial_contacts.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/serial_infos.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/serial_msg.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/serial_repeater_status.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/serial_repeater_telemetry.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/serial_trace.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/tcp_chat.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/tcp_login_status.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/tcp_mchome_contacts.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/tcp_mchome_infos.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/tcp_mchome_msg.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/examples/tcp_mchome_readmsgs.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/pytest.ini +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/src/meshcore/__init__.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/src/meshcore/ble_cx.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/src/meshcore/events.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/src/meshcore/meshcore.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/src/meshcore/packets.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/src/meshcore/serial_cx.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/src/meshcore/tcp_cx.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/tests/README.md +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/tests/unit/test_commands.py +0 -0
- {meshcore-1.9.8.dev5 → meshcore-1.9.9}/tests/unit/test_events.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meshcore
|
|
3
|
-
Version: 1.9.
|
|
3
|
+
Version: 1.9.9
|
|
4
4
|
Summary: Base classes for communicating with meshcore companion radios
|
|
5
5
|
Project-URL: Homepage, https://github.com/fdlamotte/meshcore_py
|
|
6
6
|
Project-URL: Issues, https://github.com/fdlamotte/meshcore_py/issues
|
|
@@ -196,8 +196,8 @@ class CommandHandler:
|
|
|
196
196
|
+ int(0).to_bytes(1, 'little')\
|
|
197
197
|
+ int(0).to_bytes(1, 'little'), [EventType.OK, EventType.ERROR])
|
|
198
198
|
|
|
199
|
-
async def set_other_params(self, manual_add_contacts : bool, telemetry_mode_base : int, telemetry_mode_loc : int) :
|
|
200
|
-
telemetry_mode = (telemetry_mode_base & 0b11) | ((telemetry_mode_loc & 0b11) << 2)
|
|
199
|
+
async def set_other_params(self, manual_add_contacts : bool, telemetry_mode_base : int, telemetry_mode_loc : int, telemetry_mode_env : int) :
|
|
200
|
+
telemetry_mode = (telemetry_mode_base & 0b11) | ((telemetry_mode_loc & 0b11) << 2) | ((telemetry_mode_env & 0b11) << 4)
|
|
201
201
|
data = b"\x26" + manual_add_contacts.to_bytes(1) + telemetry_mode.to_bytes(1)
|
|
202
202
|
return await self.send(data, [EventType.OK, EventType.ERROR])
|
|
203
203
|
|
|
@@ -206,21 +206,32 @@ class CommandHandler:
|
|
|
206
206
|
return await self.set_other_params(
|
|
207
207
|
infos["manual_add_contacts"],
|
|
208
208
|
telemetry_mode_base,
|
|
209
|
-
infos["telemetry_mode_loc"]
|
|
209
|
+
infos["telemetry_mode_loc"],
|
|
210
|
+
infos["telemetry_mode_env"])
|
|
210
211
|
|
|
211
212
|
async def set_telemetry_mode_loc(self, telemetry_mode_loc : int) :
|
|
212
213
|
infos = (await self.send_appstart()).payload
|
|
213
214
|
return await self.set_other_params(
|
|
214
215
|
infos["manual_add_contacts"],
|
|
215
216
|
infos["telemetry_mode_base"],
|
|
216
|
-
telemetry_mode_loc
|
|
217
|
+
telemetry_mode_loc,
|
|
218
|
+
infos["telemetry_mode_env"])
|
|
219
|
+
|
|
220
|
+
async def set_telemetry_mode_env(self, telemetry_mode_env : int) :
|
|
221
|
+
infos = (await self.send_appstart()).payload
|
|
222
|
+
return await self.set_other_params(
|
|
223
|
+
infos["manual_add_contacts"],
|
|
224
|
+
infos["telemetry_mode_base"],
|
|
225
|
+
infos["telemetry_mode_loc"],
|
|
226
|
+
telemetry_mode_env)
|
|
217
227
|
|
|
218
228
|
async def set_manual_add_contacts(self, manual_add_contacts:bool) :
|
|
219
229
|
infos = (await self.send_appstart()).payload
|
|
220
230
|
return await self.set_other_params(
|
|
221
231
|
manual_add_contacts,
|
|
222
232
|
infos["telemetry_mode_base"],
|
|
223
|
-
infos["telemetry_mode_loc"]
|
|
233
|
+
infos["telemetry_mode_loc"],
|
|
234
|
+
infos["telemetry_mode_env"])
|
|
224
235
|
|
|
225
236
|
async def set_devicepin(self, pin: int) -> Event:
|
|
226
237
|
logger.debug(f"Setting device PIN to: {pin}")
|
|
@@ -262,17 +273,25 @@ class CommandHandler:
|
|
|
262
273
|
logger.debug(f"Removing contact: {key_bytes.hex()}")
|
|
263
274
|
data = b"\x0f" + key_bytes
|
|
264
275
|
return await self.send(data, [EventType.OK, EventType.ERROR])
|
|
265
|
-
|
|
266
|
-
async def
|
|
267
|
-
|
|
268
|
-
|
|
276
|
+
|
|
277
|
+
async def update_contact (self, contact, path=None, flags=None) -> Event:
|
|
278
|
+
if path is None :
|
|
279
|
+
out_path_hex = contact["out_path"]
|
|
280
|
+
out_path_len = contact["out_path_len"]
|
|
281
|
+
else :
|
|
282
|
+
out_path_hex = path
|
|
283
|
+
out_path_len = int(len(path) / 2)
|
|
269
284
|
out_path_hex = out_path_hex + (128-len(out_path_hex)) * "0"
|
|
285
|
+
|
|
286
|
+
if flags is None :
|
|
287
|
+
flags = contact["flags"]
|
|
288
|
+
|
|
270
289
|
adv_name_hex = contact["adv_name"].encode().hex()
|
|
271
290
|
adv_name_hex = adv_name_hex + (64-len(adv_name_hex)) * "0"
|
|
272
291
|
data = b"\x09" \
|
|
273
292
|
+ bytes.fromhex(contact["public_key"])\
|
|
274
293
|
+ contact["type"].to_bytes(1)\
|
|
275
|
-
+
|
|
294
|
+
+ flags.to_bytes(1)\
|
|
276
295
|
+ out_path_len.to_bytes(1, 'little', signed=True)\
|
|
277
296
|
+ bytes.fromhex(out_path_hex)\
|
|
278
297
|
+ bytes.fromhex(adv_name_hex)\
|
|
@@ -280,6 +299,12 @@ class CommandHandler:
|
|
|
280
299
|
+ int(contact["adv_lat"]*1e6).to_bytes(4, 'little', signed=True)\
|
|
281
300
|
+ int(contact["adv_lon"]*1e6).to_bytes(4, 'little', signed=True)
|
|
282
301
|
return await self.send(data, [EventType.OK, EventType.ERROR])
|
|
302
|
+
|
|
303
|
+
async def change_contact_path (self, contact, path) -> Event:
|
|
304
|
+
return await self.update_contact(contact, path)
|
|
305
|
+
|
|
306
|
+
async def change_contact_flags (self, contact, flags) -> Event:
|
|
307
|
+
return await self.update_contact(contact, flags=flags)
|
|
283
308
|
|
|
284
309
|
async def get_msg(self, timeout: Optional[float] = 1) -> Event:
|
|
285
310
|
logger.debug("Requesting pending messages")
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from cayennelpp import LppFrame, LppData
|
|
2
|
+
from cayennelpp.lpp_type import LppType
|
|
3
|
+
|
|
4
|
+
# Format : type name "how to display value"
|
|
5
|
+
# display : None: (use lib default), []: only one value to display, ["field1", "field2" ...]: meaning of each field
|
|
6
|
+
my_lpp_types = {
|
|
7
|
+
0: ('digital input', []),
|
|
8
|
+
1: ('digital output', []),
|
|
9
|
+
2: ('analog input', []),
|
|
10
|
+
3: ('analog output', []),
|
|
11
|
+
100: ('generic sensor', []),
|
|
12
|
+
101: ('illuminance', []),
|
|
13
|
+
102: ('presence', []),
|
|
14
|
+
103: ('temperature', []),
|
|
15
|
+
104: ('humidity', []),
|
|
16
|
+
113: ('accelerometer', ["acc_x", "acc_y", "acc_z"]),
|
|
17
|
+
115: ('barometer', []),
|
|
18
|
+
116: ('voltage', []),
|
|
19
|
+
117: ('current', []),
|
|
20
|
+
118: ('frequency', []),
|
|
21
|
+
120: ('percentage', []),
|
|
22
|
+
121: ('altitude', []),
|
|
23
|
+
122: ('load', []),
|
|
24
|
+
125: ('concentration', []),
|
|
25
|
+
128: ('power', []),
|
|
26
|
+
130: ('distance', []),
|
|
27
|
+
131: ('energy', []),
|
|
28
|
+
132: ('direction', None),
|
|
29
|
+
133: ('time', []),
|
|
30
|
+
134: ('gyrometer', None),
|
|
31
|
+
135: ('colour', ["red", "green", "blue"]),
|
|
32
|
+
136: ('gps', ["latitude", "longitude", "altitude"]),
|
|
33
|
+
142: ('switch', []),
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
def lpp_json_encoder (obj, types = my_lpp_types) :
|
|
37
|
+
"""Encode LppType, LppData, and LppFrame to JSON."""
|
|
38
|
+
if isinstance(obj, LppFrame):
|
|
39
|
+
return obj.data
|
|
40
|
+
if isinstance(obj, LppType):
|
|
41
|
+
return my_lpp_types[obj.type][0]
|
|
42
|
+
if isinstance(obj, LppData):
|
|
43
|
+
d = {"channel" : obj.channel, "type" : obj.type}
|
|
44
|
+
if my_lpp_types[obj.type.type][1] is None :
|
|
45
|
+
d["value"] = obj.value
|
|
46
|
+
elif len(my_lpp_types[obj.type.type][1]) == 0 :
|
|
47
|
+
d["value"] = obj.value[0]
|
|
48
|
+
else :
|
|
49
|
+
val_dict = {}
|
|
50
|
+
i = 0
|
|
51
|
+
for t in my_lpp_types[obj.type.type][1] :
|
|
52
|
+
val_dict[t] = obj.value[i]
|
|
53
|
+
i = i + 1
|
|
54
|
+
d["value"] = val_dict
|
|
55
|
+
return d
|
|
56
|
+
raise TypeError(repr(obj) + " is not JSON serialized")
|
|
@@ -2,10 +2,11 @@ import sys
|
|
|
2
2
|
import logging
|
|
3
3
|
import asyncio
|
|
4
4
|
import json
|
|
5
|
-
from cayennelpp import LppFrame, LppData
|
|
5
|
+
from cayennelpp import LppFrame, LppData
|
|
6
6
|
from typing import Any, Optional, Dict
|
|
7
7
|
from .events import Event, EventType, EventDispatcher
|
|
8
8
|
from .packets import PacketType
|
|
9
|
+
from meshcore.lpp_json_encoder import lpp_json_encoder
|
|
9
10
|
|
|
10
11
|
logger = logging.getLogger("meshcore")
|
|
11
12
|
|
|
@@ -73,6 +74,7 @@ class MessageReader:
|
|
|
73
74
|
self_info["public_key"] = data[4:36].hex()
|
|
74
75
|
self_info["adv_lat"] = int.from_bytes(data[36:40], byteorder='little', signed=True)/1e6
|
|
75
76
|
self_info["adv_lon"] = int.from_bytes(data[40:44], byteorder='little', signed=True)/1e6
|
|
77
|
+
self_info["telemetry_mode_env"] = (data[46] >> 4) & 0b11
|
|
76
78
|
self_info["telemetry_mode_loc"] = (data[46] >> 2) & 0b11
|
|
77
79
|
self_info["telemetry_mode_base"] = (data[46]) & 0b11
|
|
78
80
|
self_info["manual_add_contacts"] = data[47] > 0
|
|
@@ -408,7 +410,7 @@ class MessageReader:
|
|
|
408
410
|
data.append(lppdata)
|
|
409
411
|
i = i + len(lppdata)
|
|
410
412
|
|
|
411
|
-
lpp = json.loads(json.dumps(LppFrame(data), default=
|
|
413
|
+
lpp = json.loads(json.dumps(LppFrame(data), default=lpp_json_encoder))
|
|
412
414
|
|
|
413
415
|
res["lpp"] = lpp
|
|
414
416
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|