meshcore 2.1.13__tar.gz → 2.1.14__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.

Potentially problematic release.


This version of meshcore might be problematic. Click here for more details.

Files changed (61) hide show
  1. {meshcore-2.1.13 → meshcore-2.1.14}/PKG-INFO +1 -1
  2. {meshcore-2.1.13 → meshcore-2.1.14}/pyproject.toml +1 -1
  3. meshcore-2.1.14/src/meshcore/commands/.contact.py.swp +0 -0
  4. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/commands/contact.py +60 -20
  5. {meshcore-2.1.13 → meshcore-2.1.14}/.github/python-test.yml +0 -0
  6. {meshcore-2.1.13 → meshcore-2.1.14}/.gitignore +0 -0
  7. {meshcore-2.1.13 → meshcore-2.1.14}/LICENSE +0 -0
  8. {meshcore-2.1.13 → meshcore-2.1.14}/README.md +0 -0
  9. {meshcore-2.1.13 → meshcore-2.1.14}/examples/ble_chat.py +0 -0
  10. {meshcore-2.1.13 → meshcore-2.1.14}/examples/ble_pin_pairing_example.py +0 -0
  11. {meshcore-2.1.13 → meshcore-2.1.14}/examples/ble_private_key_export.py +0 -0
  12. {meshcore-2.1.13 → meshcore-2.1.14}/examples/ble_t1000_chan_msg.py +0 -0
  13. {meshcore-2.1.13 → meshcore-2.1.14}/examples/ble_t1000_custom_vars.py +0 -0
  14. {meshcore-2.1.13 → meshcore-2.1.14}/examples/ble_t1000_infos.py +0 -0
  15. {meshcore-2.1.13 → meshcore-2.1.14}/examples/ble_t1000_msg.py +0 -0
  16. {meshcore-2.1.13 → meshcore-2.1.14}/examples/ble_t1000_msg_retries.py +0 -0
  17. {meshcore-2.1.13 → meshcore-2.1.14}/examples/ble_t1000_set_cv.py +0 -0
  18. {meshcore-2.1.13 → meshcore-2.1.14}/examples/connection_events_example.py +0 -0
  19. {meshcore-2.1.13 → meshcore-2.1.14}/examples/mepo_mc_gps.py +0 -0
  20. {meshcore-2.1.13 → meshcore-2.1.14}/examples/pubsub_example.py +0 -0
  21. {meshcore-2.1.13 → meshcore-2.1.14}/examples/rf_packet_monitor.py +0 -0
  22. {meshcore-2.1.13 → meshcore-2.1.14}/examples/serial_battery_monitor.py +0 -0
  23. {meshcore-2.1.13 → meshcore-2.1.14}/examples/serial_channel_manager.py +0 -0
  24. {meshcore-2.1.13 → meshcore-2.1.14}/examples/serial_chat.py +0 -0
  25. {meshcore-2.1.13 → meshcore-2.1.14}/examples/serial_contacts.py +0 -0
  26. {meshcore-2.1.13 → meshcore-2.1.14}/examples/serial_infos.py +0 -0
  27. {meshcore-2.1.13 → meshcore-2.1.14}/examples/serial_msg.py +0 -0
  28. {meshcore-2.1.13 → meshcore-2.1.14}/examples/serial_repeater_status.py +0 -0
  29. {meshcore-2.1.13 → meshcore-2.1.14}/examples/serial_repeater_telemetry.py +0 -0
  30. {meshcore-2.1.13 → meshcore-2.1.14}/examples/serial_trace.py +0 -0
  31. {meshcore-2.1.13 → meshcore-2.1.14}/examples/tcp_chat.py +0 -0
  32. {meshcore-2.1.13 → meshcore-2.1.14}/examples/tcp_login_status.py +0 -0
  33. {meshcore-2.1.13 → meshcore-2.1.14}/examples/tcp_mchome_contacts.py +0 -0
  34. {meshcore-2.1.13 → meshcore-2.1.14}/examples/tcp_mchome_infos.py +0 -0
  35. {meshcore-2.1.13 → meshcore-2.1.14}/examples/tcp_mchome_msg.py +0 -0
  36. {meshcore-2.1.13 → meshcore-2.1.14}/examples/tcp_mchome_readmsgs.py +0 -0
  37. {meshcore-2.1.13 → meshcore-2.1.14}/pytest.ini +0 -0
  38. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/__init__.py +0 -0
  39. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/ble_cx.py +0 -0
  40. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/commands/__init__.py +0 -0
  41. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/commands/base.py +0 -0
  42. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/commands/binary.py +0 -0
  43. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/commands/device.py +0 -0
  44. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/commands/messaging.py +0 -0
  45. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/connection_manager.py +0 -0
  46. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/events.py +0 -0
  47. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/lpp_json_encoder.py +0 -0
  48. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/meshcore.py +0 -0
  49. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/packets.py +0 -0
  50. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/parsing.py +0 -0
  51. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/reader.py +0 -0
  52. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/serial_cx.py +0 -0
  53. {meshcore-2.1.13 → meshcore-2.1.14}/src/meshcore/tcp_cx.py +0 -0
  54. {meshcore-2.1.13 → meshcore-2.1.14}/tests/README.md +0 -0
  55. {meshcore-2.1.13 → meshcore-2.1.14}/tests/test_ble_connection.py +0 -0
  56. {meshcore-2.1.13 → meshcore-2.1.14}/tests/test_ble_pin_pairing.py +0 -0
  57. {meshcore-2.1.13 → meshcore-2.1.14}/tests/test_meshcore_ble_pin.py +0 -0
  58. {meshcore-2.1.13 → meshcore-2.1.14}/tests/unit/test_commands.py +0 -0
  59. {meshcore-2.1.13 → meshcore-2.1.14}/tests/unit/test_events.py +0 -0
  60. {meshcore-2.1.13 → meshcore-2.1.14}/tests/unit/test_private_key_export.py +0 -0
  61. {meshcore-2.1.13 → meshcore-2.1.14}/tests/unit/test_reader.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshcore
3
- Version: 2.1.13
3
+ Version: 2.1.14
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
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "meshcore"
7
- version = "2.1.13"
7
+ version = "2.1.14"
8
8
  authors = [
9
9
  { name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
10
10
  { name="Alex Wolden", email="awolden@gmail.com" },
@@ -1,7 +1,8 @@
1
1
  import logging
2
+ import asyncio
2
3
  from typing import Optional
3
4
 
4
- from ..events import Event, EventType
5
+ from ..events import Event, EventDispatcher, EventType
5
6
  from .base import CommandHandlerBase, DestinationType, _validate_destination
6
7
 
7
8
  logger = logging.getLogger("meshcore")
@@ -17,26 +18,65 @@ class ContactCommands(CommandHandlerBase):
17
18
  print("Fetching contacts ", end="", flush=True)
18
19
  # wait first event
19
20
  res = await self.send(data)
20
- while True:
21
- # wait next event
22
- res = await self.wait_for_events(
23
- [EventType.NEXT_CONTACT, EventType.CONTACTS, EventType.ERROR],
24
- timeout=5)
25
- if res is None: # Timeout
26
- if anim:
21
+ timeout = 5
22
+ # Inline wait for events to continue waiting for CONTACTS event
23
+ # while receiving NEXT_CONTACTs (or it might be missed over serial)
24
+ try:
25
+ # Create futures for all expected events
26
+ futures = []
27
+ for event_type in [EventType.ERROR, EventType.NEXT_CONTACT, EventType.CONTACTS] :
28
+ future = asyncio.create_task(
29
+ self.dispatcher.wait_for_event(event_type, {}, timeout)
30
+ )
31
+ futures.append(future)
32
+
33
+ while True:
34
+
35
+ # Wait for the first event to complete or all to timeout
36
+ done, pending = await asyncio.wait(
37
+ futures, timeout=timeout, return_when=asyncio.FIRST_COMPLETED
38
+ )
39
+
40
+ # Check if any future completed successfully
41
+ if len(done) == 0:
27
42
  print(" Timeout")
28
- return res
29
- if res.type == EventType.ERROR:
30
- if anim:
31
- print(" Error")
32
- return res
33
- elif res.type == EventType.CONTACTS:
34
- if anim:
35
- print(" Done")
36
- return res
37
- elif res.type == EventType.NEXT_CONTACT:
38
- if anim:
39
- print(".", end="", flush=True)
43
+ for future in pending: # cancel all futures
44
+ future.cancel()
45
+ return None
46
+
47
+ for future in done:
48
+ event = await future
49
+
50
+ if event:
51
+ if event.type == EventType.NEXT_CONTACT:
52
+ if anim:
53
+ print(".", end="", flush=True)
54
+ else: # Done or Error ... cancel pending and return
55
+ if anim:
56
+ print(" Done" if event.type == EventType.CONTACTS else " Error")
57
+ for future in pending:
58
+ future.cancel()
59
+ return event
60
+
61
+ futures = []
62
+ for future in pending: # put back pending
63
+ futures.append(future)
64
+
65
+ future = asyncio.create_task( # and recreate NEXT_CONTACT
66
+ self.dispatcher.wait_for_event(EventType.NEXT_CONTACT, {}, timeout)
67
+ )
68
+ futures.append(future)
69
+
70
+ except asyncio.TimeoutError:
71
+ logger.debug(f"Timeout receiving contacts")
72
+ if anim:
73
+ print(" Timeout")
74
+ return None
75
+ except Exception as e:
76
+ logger.debug(f"Command error: {e}")
77
+ if anim:
78
+ print(" Error")
79
+ return Event(EventType.ERROR, {"error": str(e)})
40
80
 
41
81
  async def reset_path(self, key: DestinationType) -> Event:
42
82
  key_bytes = _validate_destination(key, prefix_length=32)
File without changes
File without changes
File without changes
File without changes
File without changes