micrOSDevToolKit 2.13.1__py3-none-any.whl → 2.17.0__py3-none-any.whl

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 micrOSDevToolKit might be problematic. Click here for more details.

Files changed (220) hide show
  1. micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +125 -121
  2. micrOS/source/Common.py +48 -26
  3. micrOS/source/Config.py +13 -5
  4. micrOS/source/Espnow.py +100 -58
  5. micrOS/source/Files.py +77 -41
  6. micrOS/source/Hooks.py +18 -34
  7. micrOS/source/Logger.py +2 -7
  8. micrOS/source/Network.py +36 -16
  9. micrOS/source/Server.py +22 -8
  10. micrOS/source/Shell.py +9 -6
  11. micrOS/source/Tasks.py +34 -13
  12. micrOS/source/Web.py +69 -31
  13. micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
  14. micrOS/source/__pycache__/Files.cpython-312.pyc +0 -0
  15. micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
  16. micrOS/source/__pycache__/Server.cpython-312.pyc +0 -0
  17. micrOS/source/config/_git.keep +0 -0
  18. micrOS/source/micrOS.py +7 -0
  19. micrOS/source/micrOSloader.py +2 -10
  20. micrOS/source/microIO.py +2 -2
  21. micrOS/source/modules/IO_esp32c6.py +38 -0
  22. micrOS/source/modules/LM_L298N.py +161 -0
  23. micrOS/source/modules/LM_cluster.py +250 -0
  24. {toolkit/workspace/precompiled → micrOS/source/modules}/LM_esp32.py +5 -0
  25. micrOS/source/modules/LM_espnow.py +36 -0
  26. micrOS/source/{LM_i2c.py → modules/LM_i2c.py} +1 -1
  27. micrOS/source/{LM_light_sensor.py → modules/LM_light_sensor.py} +2 -2
  28. micrOS/source/modules/LM_mqtt_client.py +246 -0
  29. micrOS/source/{LM_neoeffects.py → modules/LM_neoeffects.py} +14 -4
  30. micrOS/source/{LM_neomatrix.py → modules/LM_neomatrix.py} +140 -38
  31. micrOS/source/{LM_oled_ui.py → modules/LM_oled_ui.py} +2 -2
  32. micrOS/source/{LM_oledui.py → modules/LM_oledui.py} +2 -2
  33. micrOS/source/{LM_pacman.py → modules/LM_pacman.py} +74 -29
  34. micrOS/source/{LM_presence.py → modules/LM_presence.py} +2 -2
  35. micrOS/source/{LM_robustness.py → modules/LM_robustness.py} +49 -2
  36. micrOS/source/{LM_tcs3472.py → modules/LM_tcs3472.py} +4 -6
  37. micrOS/source/web/dashboard.html +2 -0
  38. micrOS/source/web/matrix_draw.html +390 -0
  39. micrOS/source/web/uapi.js +9 -6
  40. {microsdevtoolkit-2.13.1.dist-info → microsdevtoolkit-2.17.0.dist-info}/METADATA +30 -37
  41. {microsdevtoolkit-2.13.1.dist-info → microsdevtoolkit-2.17.0.dist-info}/RECORD +200 -190
  42. toolkit/DevEnvCompile.py +21 -12
  43. toolkit/DevEnvOTA.py +27 -16
  44. toolkit/DevEnvUSB.py +35 -21
  45. toolkit/LM_to_compile.dat +3 -1
  46. toolkit/MicrOSDevEnv.py +37 -21
  47. toolkit/dashboard_apps/QMI8685_GYRO.py +1 -1
  48. toolkit/dashboard_apps/SystemTest.py +8 -5
  49. toolkit/{MicrosFiles.py → lib/MicrosFiles.py} +24 -4
  50. toolkit/micrOSdashboard.py +2 -2
  51. toolkit/micrOSlint.py +17 -7
  52. toolkit/simulator_lib/__pycache__/simulator.cpython-312.pyc +0 -0
  53. toolkit/simulator_lib/__pycache__/uos.cpython-312.pyc +0 -0
  54. toolkit/simulator_lib/mqtt_as/Note.md +15 -0
  55. toolkit/simulator_lib/mqtt_as/__init__.py +950 -0
  56. toolkit/simulator_lib/mqtt_as/__pycache__/__init__.cpython-312.pyc +0 -0
  57. toolkit/simulator_lib/mqtt_as/clean.py +69 -0
  58. toolkit/simulator_lib/mqtt_as/mqtt_v5_properties.py +239 -0
  59. toolkit/simulator_lib/mqtt_as/range.py +90 -0
  60. toolkit/simulator_lib/mqtt_as/range_ex.py +119 -0
  61. toolkit/simulator_lib/simulator.py +14 -1
  62. toolkit/simulator_lib/uos.py +2 -0
  63. toolkit/workspace/precompiled/Common.mpy +0 -0
  64. toolkit/workspace/precompiled/Config.mpy +0 -0
  65. toolkit/workspace/precompiled/Espnow.mpy +0 -0
  66. toolkit/workspace/precompiled/Files.mpy +0 -0
  67. toolkit/workspace/precompiled/Hooks.mpy +0 -0
  68. toolkit/workspace/precompiled/Logger.mpy +0 -0
  69. toolkit/workspace/precompiled/Network.mpy +0 -0
  70. toolkit/workspace/precompiled/Server.mpy +0 -0
  71. toolkit/workspace/precompiled/Shell.mpy +0 -0
  72. toolkit/workspace/precompiled/Tasks.mpy +0 -0
  73. toolkit/workspace/precompiled/Web.mpy +0 -0
  74. toolkit/workspace/precompiled/config/_git.keep +0 -0
  75. toolkit/workspace/precompiled/micrOS.mpy +0 -0
  76. toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
  77. toolkit/workspace/precompiled/microIO.mpy +0 -0
  78. toolkit/workspace/precompiled/{IO_esp32.mpy → modules/IO_esp32.mpy} +0 -0
  79. toolkit/workspace/precompiled/{IO_esp32c3.mpy → modules/IO_esp32c3.mpy} +0 -0
  80. toolkit/workspace/precompiled/modules/IO_esp32c6.mpy +0 -0
  81. toolkit/workspace/precompiled/{IO_esp32s2.mpy → modules/IO_esp32s2.mpy} +0 -0
  82. toolkit/workspace/precompiled/{IO_esp32s3.mpy → modules/IO_esp32s3.mpy} +0 -0
  83. toolkit/workspace/precompiled/{IO_m5stamp.mpy → modules/IO_m5stamp.mpy} +0 -0
  84. toolkit/workspace/precompiled/{IO_qtpy.mpy → modules/IO_qtpy.mpy} +0 -0
  85. toolkit/workspace/precompiled/modules/IO_rp2.mpy +0 -0
  86. toolkit/workspace/precompiled/modules/IO_s3matrix.mpy +0 -0
  87. toolkit/workspace/precompiled/{IO_tinypico.mpy → modules/IO_tinypico.mpy} +0 -0
  88. toolkit/workspace/precompiled/modules/LM_L298N.mpy +0 -0
  89. toolkit/workspace/precompiled/{LM_OV2640.mpy → modules/LM_OV2640.mpy} +0 -0
  90. toolkit/workspace/precompiled/{LM_aht10.mpy → modules/LM_aht10.mpy} +0 -0
  91. toolkit/workspace/precompiled/{LM_bme280.mpy → modules/LM_bme280.mpy} +0 -0
  92. toolkit/workspace/precompiled/{LM_buzzer.mpy → modules/LM_buzzer.mpy} +0 -0
  93. toolkit/workspace/precompiled/{LM_cct.mpy → modules/LM_cct.mpy} +0 -0
  94. toolkit/workspace/precompiled/modules/LM_cluster.mpy +0 -0
  95. toolkit/workspace/precompiled/{LM_co2.mpy → modules/LM_co2.mpy} +0 -0
  96. toolkit/workspace/precompiled/{LM_dht11.mpy → modules/LM_dht11.mpy} +0 -0
  97. toolkit/workspace/precompiled/{LM_dht22.mpy → modules/LM_dht22.mpy} +0 -0
  98. toolkit/workspace/precompiled/{LM_dimmer.mpy → modules/LM_dimmer.mpy} +0 -0
  99. toolkit/workspace/precompiled/{LM_distance.mpy → modules/LM_distance.mpy} +0 -0
  100. toolkit/workspace/precompiled/{LM_ds18.mpy → modules/LM_ds18.mpy} +0 -0
  101. {micrOS/source → toolkit/workspace/precompiled/modules}/LM_esp32.py +5 -0
  102. toolkit/workspace/precompiled/modules/LM_espnow.py +36 -0
  103. toolkit/workspace/precompiled/{LM_gameOfLife.mpy → modules/LM_gameOfLife.mpy} +0 -0
  104. toolkit/workspace/precompiled/{LM_genIO.mpy → modules/LM_genIO.mpy} +0 -0
  105. toolkit/workspace/precompiled/{LM_haptic.mpy → modules/LM_haptic.mpy} +0 -0
  106. toolkit/workspace/precompiled/{LM_i2c.py → modules/LM_i2c.py} +1 -1
  107. toolkit/workspace/precompiled/{LM_i2s_mic.mpy → modules/LM_i2s_mic.mpy} +0 -0
  108. toolkit/workspace/precompiled/{LM_keychain.mpy → modules/LM_keychain.mpy} +0 -0
  109. toolkit/workspace/precompiled/{LM_ld2410.mpy → modules/LM_ld2410.mpy} +0 -0
  110. toolkit/workspace/precompiled/modules/LM_light_sensor.mpy +0 -0
  111. toolkit/workspace/precompiled/modules/LM_mqtt_client.mpy +0 -0
  112. toolkit/workspace/precompiled/{LM_neoeffects.mpy → modules/LM_neoeffects.mpy} +0 -0
  113. toolkit/workspace/precompiled/modules/LM_neomatrix.mpy +0 -0
  114. toolkit/workspace/precompiled/{LM_neopixel.mpy → modules/LM_neopixel.mpy} +0 -0
  115. toolkit/workspace/precompiled/{LM_oled.mpy → modules/LM_oled.mpy} +0 -0
  116. toolkit/workspace/precompiled/{LM_oled_sh1106.mpy → modules/LM_oled_sh1106.mpy} +0 -0
  117. toolkit/workspace/precompiled/modules/LM_oled_ui.mpy +0 -0
  118. toolkit/workspace/precompiled/modules/LM_oledui.mpy +0 -0
  119. toolkit/workspace/precompiled/modules/LM_pacman.mpy +0 -0
  120. toolkit/workspace/precompiled/modules/LM_presence.mpy +0 -0
  121. toolkit/workspace/precompiled/{LM_rest.mpy → modules/LM_rest.mpy} +0 -0
  122. toolkit/workspace/precompiled/{LM_rgb.mpy → modules/LM_rgb.mpy} +0 -0
  123. toolkit/workspace/precompiled/{LM_rgbcct.mpy → modules/LM_rgbcct.mpy} +0 -0
  124. toolkit/workspace/precompiled/{LM_roboarm.mpy → modules/LM_roboarm.mpy} +0 -0
  125. toolkit/workspace/precompiled/{LM_robustness.py → modules/LM_robustness.py} +49 -2
  126. toolkit/workspace/precompiled/{LM_servo.mpy → modules/LM_servo.mpy} +0 -0
  127. toolkit/workspace/precompiled/{LM_sound_event.mpy → modules/LM_sound_event.mpy} +0 -0
  128. toolkit/workspace/precompiled/{LM_stepper.mpy → modules/LM_stepper.mpy} +0 -0
  129. toolkit/workspace/precompiled/{LM_switch.mpy → modules/LM_switch.mpy} +0 -0
  130. toolkit/workspace/precompiled/{LM_system.mpy → modules/LM_system.mpy} +0 -0
  131. toolkit/workspace/precompiled/{LM_tcs3472.py → modules/LM_tcs3472.py} +4 -6
  132. toolkit/workspace/precompiled/{LM_telegram.mpy → modules/LM_telegram.mpy} +0 -0
  133. toolkit/workspace/precompiled/{LM_tinyrgb.mpy → modules/LM_tinyrgb.mpy} +0 -0
  134. toolkit/workspace/precompiled/{LM_trackball.mpy → modules/LM_trackball.mpy} +0 -0
  135. toolkit/workspace/precompiled/{LM_veml7700.mpy → modules/LM_veml7700.mpy} +0 -0
  136. toolkit/workspace/precompiled/web/dashboard.html +2 -0
  137. toolkit/workspace/precompiled/web/matrix_draw.html +390 -0
  138. toolkit/workspace/precompiled/web/uapi.js +9 -6
  139. micrOS/source/IO_esp32c6.py +0 -16
  140. micrOS/source/LM_L298N_DCmotor.py +0 -86
  141. micrOS/source/LM_espnow.py +0 -57
  142. micrOS/source/LM_mqtt_pro.py +0 -211
  143. toolkit/lib/file_extensions.py +0 -22
  144. toolkit/workspace/precompiled/Common.cpython-312.pyc +0 -0
  145. toolkit/workspace/precompiled/IO_esp32c6.mpy +0 -0
  146. toolkit/workspace/precompiled/IO_rp2.mpy +0 -0
  147. toolkit/workspace/precompiled/IO_s3matrix.mpy +0 -0
  148. toolkit/workspace/precompiled/LM_L298N_DCmotor.mpy +0 -0
  149. toolkit/workspace/precompiled/LM_espnow.py +0 -57
  150. toolkit/workspace/precompiled/LM_light_sensor.mpy +0 -0
  151. toolkit/workspace/precompiled/LM_mqtt_pro.py +0 -211
  152. toolkit/workspace/precompiled/LM_neomatrix.mpy +0 -0
  153. toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
  154. toolkit/workspace/precompiled/LM_oledui.mpy +0 -0
  155. toolkit/workspace/precompiled/LM_pacman.mpy +0 -0
  156. toolkit/workspace/precompiled/LM_presence.mpy +0 -0
  157. toolkit/workspace/precompiled/Logger.cpython-312.pyc +0 -0
  158. toolkit/workspace/precompiled/Server.cpython-312.pyc +0 -0
  159. /micrOS/source/{IO_esp32.py → modules/IO_esp32.py} +0 -0
  160. /micrOS/source/{IO_esp32c3.py → modules/IO_esp32c3.py} +0 -0
  161. /micrOS/source/{IO_esp32s2.py → modules/IO_esp32s2.py} +0 -0
  162. /micrOS/source/{IO_esp32s3.py → modules/IO_esp32s3.py} +0 -0
  163. /micrOS/source/{IO_m5stamp.py → modules/IO_m5stamp.py} +0 -0
  164. /micrOS/source/{IO_qtpy.py → modules/IO_qtpy.py} +0 -0
  165. /micrOS/source/{IO_rp2.py → modules/IO_rp2.py} +0 -0
  166. /micrOS/source/{IO_s3matrix.py → modules/IO_s3matrix.py} +0 -0
  167. /micrOS/source/{IO_tinypico.py → modules/IO_tinypico.py} +0 -0
  168. /micrOS/source/{LM_L9110_DCmotor.py → modules/LM_L9110_DCmotor.py} +0 -0
  169. /micrOS/source/{LM_OV2640.py → modules/LM_OV2640.py} +0 -0
  170. /micrOS/source/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +0 -0
  171. /micrOS/source/{LM_aht10.py → modules/LM_aht10.py} +0 -0
  172. /micrOS/source/{LM_bme280.py → modules/LM_bme280.py} +0 -0
  173. /micrOS/source/{LM_buzzer.py → modules/LM_buzzer.py} +0 -0
  174. /micrOS/source/{LM_cct.py → modules/LM_cct.py} +0 -0
  175. /micrOS/source/{LM_co2.py → modules/LM_co2.py} +0 -0
  176. /micrOS/source/{LM_dashboard_be.py → modules/LM_dashboard_be.py} +0 -0
  177. /micrOS/source/{LM_dht11.py → modules/LM_dht11.py} +0 -0
  178. /micrOS/source/{LM_dht22.py → modules/LM_dht22.py} +0 -0
  179. /micrOS/source/{LM_dimmer.py → modules/LM_dimmer.py} +0 -0
  180. /micrOS/source/{LM_distance.py → modules/LM_distance.py} +0 -0
  181. /micrOS/source/{LM_ds18.py → modules/LM_ds18.py} +0 -0
  182. /micrOS/source/{LM_gameOfLife.py → modules/LM_gameOfLife.py} +0 -0
  183. /micrOS/source/{LM_genIO.py → modules/LM_genIO.py} +0 -0
  184. /micrOS/source/{LM_haptic.py → modules/LM_haptic.py} +0 -0
  185. /micrOS/source/{LM_i2s_mic.py → modules/LM_i2s_mic.py} +0 -0
  186. /micrOS/source/{LM_keychain.py → modules/LM_keychain.py} +0 -0
  187. /micrOS/source/{LM_ld2410.py → modules/LM_ld2410.py} +0 -0
  188. /micrOS/source/{LM_neopixel.py → modules/LM_neopixel.py} +0 -0
  189. /micrOS/source/{LM_oled.py → modules/LM_oled.py} +0 -0
  190. /micrOS/source/{LM_oled_sh1106.py → modules/LM_oled_sh1106.py} +0 -0
  191. /micrOS/source/{LM_pet_feeder.py → modules/LM_pet_feeder.py} +0 -0
  192. /micrOS/source/{LM_qmi8658.py → modules/LM_qmi8658.py} +0 -0
  193. /micrOS/source/{LM_rencoder.py → modules/LM_rencoder.py} +0 -0
  194. /micrOS/source/{LM_rest.py → modules/LM_rest.py} +0 -0
  195. /micrOS/source/{LM_rgb.py → modules/LM_rgb.py} +0 -0
  196. /micrOS/source/{LM_rgbcct.py → modules/LM_rgbcct.py} +0 -0
  197. /micrOS/source/{LM_roboarm.py → modules/LM_roboarm.py} +0 -0
  198. /micrOS/source/{LM_rp2w.py → modules/LM_rp2w.py} +0 -0
  199. /micrOS/source/{LM_sdcard.py → modules/LM_sdcard.py} +0 -0
  200. /micrOS/source/{LM_servo.py → modules/LM_servo.py} +0 -0
  201. /micrOS/source/{LM_sound_event.py → modules/LM_sound_event.py} +0 -0
  202. /micrOS/source/{LM_stepper.py → modules/LM_stepper.py} +0 -0
  203. /micrOS/source/{LM_switch.py → modules/LM_switch.py} +0 -0
  204. /micrOS/source/{LM_system.py → modules/LM_system.py} +0 -0
  205. /micrOS/source/{LM_telegram.py → modules/LM_telegram.py} +0 -0
  206. /micrOS/source/{LM_tinyrgb.py → modules/LM_tinyrgb.py} +0 -0
  207. /micrOS/source/{LM_trackball.py → modules/LM_trackball.py} +0 -0
  208. /micrOS/source/{LM_veml7700.py → modules/LM_veml7700.py} +0 -0
  209. {microsdevtoolkit-2.13.1.data → microsdevtoolkit-2.17.0.data}/scripts/devToolKit.py +0 -0
  210. {microsdevtoolkit-2.13.1.dist-info → microsdevtoolkit-2.17.0.dist-info}/WHEEL +0 -0
  211. {microsdevtoolkit-2.13.1.dist-info → microsdevtoolkit-2.17.0.dist-info}/licenses/LICENSE +0 -0
  212. {microsdevtoolkit-2.13.1.dist-info → microsdevtoolkit-2.17.0.dist-info}/top_level.txt +0 -0
  213. /toolkit/workspace/precompiled/{LM_L9110_DCmotor.py → modules/LM_L9110_DCmotor.py} +0 -0
  214. /toolkit/workspace/precompiled/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +0 -0
  215. /toolkit/workspace/precompiled/{LM_dashboard_be.py → modules/LM_dashboard_be.py} +0 -0
  216. /toolkit/workspace/precompiled/{LM_pet_feeder.py → modules/LM_pet_feeder.py} +0 -0
  217. /toolkit/workspace/precompiled/{LM_qmi8658.py → modules/LM_qmi8658.py} +0 -0
  218. /toolkit/workspace/precompiled/{LM_rencoder.py → modules/LM_rencoder.py} +0 -0
  219. /toolkit/workspace/precompiled/{LM_rp2w.py → modules/LM_rp2w.py} +0 -0
  220. /toolkit/workspace/precompiled/{LM_sdcard.py → modules/LM_sdcard.py} +0 -0
@@ -1,86 +0,0 @@
1
- from machine import Pin, PWM
2
- from microIO import bind_pin, pinmap_search
3
-
4
- #########################################
5
- # ANALOG DIMMER CONTROLLER PARAMS #
6
- #########################################
7
- __L298N_OBJS = []
8
- # DATA: SPEED (PWM obj), dir pin1, dir pin2
9
-
10
-
11
- #########################################
12
- # ANALOG DIMMER WITH PWM #
13
- #########################################
14
-
15
- def __l298n_init():
16
- global __L298N_OBJS
17
- if len(__L298N_OBJS) == 0:
18
- __L298N_OBJS.append(PWM(Pin(bind_pin('l298speed')), freq=50))
19
- __L298N_OBJS.append(Pin(bind_pin('l298dir_1'), Pin.OUT))
20
- __L298N_OBJS.append(Pin(bind_pin('l298dir_2'), Pin.OUT))
21
- __L298N_OBJS[0].duty(0) # Set default speed (PWM)
22
- __L298N_OBJS[1].value(0) # Set default direction for dc motor1
23
- __L298N_OBJS[2].value(1) # Set default direction for dc motor1
24
- return __L298N_OBJS
25
-
26
-
27
- def m1_control(direc=None, speed=None):
28
- out = {}
29
- if direc is not None:
30
- out = set_direction(direc)
31
- if speed is not None:
32
- out.update(set_speed(speed))
33
- return out
34
-
35
-
36
- def set_speed(speed=100):
37
- if 0 <= speed <= 1000:
38
- print(__l298n_init())
39
- __l298n_init()[0].duty(speed)
40
- return {'speed': speed}
41
- return {'speed': 'value range error'}
42
-
43
-
44
- def stop():
45
- return set_speed(0)
46
-
47
-
48
- def set_direction(direc=0):
49
- """
50
- direc (direction) values:
51
- 0: forward
52
- 1: backward
53
- """
54
- objlist = __l298n_init()
55
- if direc == 0:
56
- objlist[1].value(1)
57
- objlist[2].value(0)
58
- return {'direction': 'forward'}
59
- objlist[1].value(0)
60
- objlist[2].value(1)
61
- return {'direction': 'backward'}
62
-
63
-
64
- #######################
65
- # LM helper functions #
66
- #######################
67
-
68
- def pinmap():
69
- """
70
- [i] micrOS LM naming convention
71
- Shows logical pins - pin number(s) used by this Load module
72
- - info which pins to use for this application
73
- :return dict: pin name (str) - pin value (int) pairs
74
- """
75
- return pinmap_search(['l298speed', 'l298dir_1', 'l298dir_2'])
76
-
77
-
78
- def help(widgets=False):
79
- """
80
- [i] micrOS LM naming convention - built-in help message
81
- :return tuple:
82
- (widgets=False) list of functions implemented by this application
83
- (widgets=True) list of widget json for UI generation
84
- """
85
- return 'm1_control direc=<0/1> speed=<0-1023>', 'set_speed <0-1023>',\
86
- 'set_direction <0-1>', 'stop', 'pinmap'
@@ -1,57 +0,0 @@
1
- import Espnow
2
-
3
- def load():
4
- """
5
- OBSOLETE - remove
6
- [DEBUG ONLY] ENABLE ESPNOW IN NODE CONFIG INSTEAD OF HERE!
7
- Initialize ESPNOW protocal
8
- """
9
- return Espnow.initialize()
10
-
11
- def start_server():
12
- """
13
- OBSOLETE - remove
14
- [DEBUG ONLY] ENABLE ESPNOW IN NODE CONFIG INSTEAD OF HERE!
15
- Start ESPNOW server/listener
16
- - this can receive espnow messages
17
- - it includes Load Module execution logic (beta)
18
- """
19
- now = Espnow.initialize()
20
- return now.start_server()
21
-
22
-
23
- def send(peer:bytes|str, msg:str='modules'):
24
- """
25
- Send message to peer (by mac address)
26
- :param peer: mac address of espnow device
27
- :param msg: message string/load module call
28
- """
29
- now = Espnow.initialize()
30
- return now.send(peer, msg)
31
-
32
- def stats():
33
- """
34
- Get ESPNOW stats
35
- """
36
- now = Espnow.initialize()
37
- return now.stats()
38
-
39
- def add_peer(peer:bytes, dev_name:str=None):
40
- """
41
- Add ESPNOW peer to known hosts
42
- - It is needed before first send(...)
43
- """
44
- now = Espnow.initialize()
45
- return now.add_peer(peer, dev_name)
46
-
47
- def mac_address():
48
- """
49
- Get ESPNOW compatible mac address
50
- """
51
- return Espnow.mac_address()
52
-
53
- def help():
54
- """
55
- [beta] ESPNOW sender/receiver with LM execution
56
- """
57
- return 'load', 'send <peer> "ping"', 'start_server', 'add_peer <peer> dev_name=None', 'stats', 'mac_address'
@@ -1,211 +0,0 @@
1
- # async_message.py Test of asynchronous mqtt client with async Broker class
2
- # (C) Copyright Peter Hinch 2024.
3
- # Released under the MIT licence.
4
- # Public brokers https://github.com/mqtt/mqtt.github.io/wiki/public_brokers
5
- # mip command: ???
6
-
7
- from Config import cfgget
8
- from mqtt_as import MQTTClient, config
9
- from Common import micro_task, console, syslog, exec_cmd
10
-
11
-
12
- # Set up MQTT
13
- class MQTT:
14
- CLIENT:MQTTClient = None # MQTT Client (broker) instance
15
- TOPIC = "micros" # Default topic
16
- TOPIC_COMMAND_LUT = {} # Lookup table for command/topic pairs
17
- # Example:
18
- # {"topic1": ["mod func", "mod2 func"], "topic2": []}
19
-
20
-
21
- async def _receiver(task):
22
- """
23
- MQTT AS receiver loop
24
- """
25
- async for topic, msg, retained in MQTT.CLIENT.queue:
26
- topic, msg = topic.decode(), msg.decode()
27
- console(f'Topic: "{topic}" Message: "{msg}" Retained: {retained}')
28
-
29
- # Command execution... use MQTT.TOPIC_COMMAND_LUT
30
- topic_commands:list = MQTT.TOPIC_COMMAND_LUT.get(topic, None)
31
- output_struct:list = []
32
- if topic_commands is None:
33
- syslog(f"[WARN] mqtt Unknown topic: {topic}")
34
- elif len(topic_commands) == 0:
35
- syslog(f"[WARN] mqtt No commands for {topic}")
36
- else:
37
- task.out = f"Handle topic: {topic}"
38
- for cmd in topic_commands:
39
- single_command = cmd.split()
40
- if len(single_command) > 0:
41
- state, output = exec_cmd(single_command, jsonify=True, skip_check=True)
42
- output_struct.append({"state": state, "result": output, "cmd": cmd})
43
- if len(output_struct) > 0:
44
- console(f'\tMQTT Publish: {output_struct}')
45
- task.out = f"Publish {topic}"
46
- MQTT.CLIENT.publish(topic, str(output_struct))
47
- else:
48
- task.out = f"Nothing to publish {topic}"
49
- task.feed()
50
-
51
-
52
- async def _subscribe():
53
- """
54
- MQTT AS Topic subscribe towards server
55
- """
56
- with micro_task(tag="mqtt.subscribe") as my_task:
57
- my_task.out = "Started"
58
- try:
59
- for t in MQTT.TOPIC_COMMAND_LUT:
60
- console(f"Subscribe topic: {t}")
61
- await MQTT.CLIENT.subscribe(t, 1)
62
- my_task.out = "Done"
63
- except Exception as e:
64
- my_task.out = f"Error: {e}"
65
-
66
-
67
- async def _publish(message, topic):
68
- """
69
- Send message to topic with mqtt
70
- """
71
- tag = f"mqtt.publish.{topic}"
72
- with micro_task(tag=tag) as my_task:
73
- console(f"mqtt send: [{topic}] {message}")
74
- await MQTT.CLIENT.publish(topic, message, qos=1)
75
- my_task.out = "Sent"
76
-
77
-
78
- async def _up():
79
- """
80
- UP Listener - resubscribe
81
- """
82
- with micro_task(tag="mqtt.up") as my_task:
83
- while True:
84
- # Wait for UP Event - (re)subscribe
85
- my_task.out = "Wait"
86
- await MQTT.CLIENT.up.wait()
87
- MQTT.CLIENT.up.clear()
88
- micro_task(tag="mqtt.subscribe", task=_subscribe())
89
- my_task.out = "Re-Subscription"
90
- my_task.feed()
91
-
92
-
93
- async def _init_client(topic:str=None, commands:str=None, raw_dict:dict|None=None):
94
- """
95
- Initialize main mqtt receiver and topics
96
- :param topic: topic string, ex.: 'lights'
97
- :param commands: semicolon separated commands. ex.: 'rgb toggle; cct toggle'
98
- OR
99
- :param raw_dict: python dict string for multi topic subscription, ex.: {"lights": ["rgb toggle", "cct toggle"], ...}
100
- """
101
- with micro_task(tag="mqtt.client") as my_task:
102
- try:
103
- await MQTT.CLIENT.connect()
104
- my_task.out = "Connection successful."
105
- except OSError:
106
- my_task.out = "Connection failed."
107
- return
108
- # Wait for mqtt client connected successfully
109
- await MQTT.CLIENT.up.wait()
110
- MQTT.CLIENT.up.clear()
111
- # Initialize mqtt topics, ha
112
- subscribe(topic, commands, raw_dict)
113
- micro_task(tag="mqtt.up", task=_up())
114
- # Async listener loop
115
- await _receiver(my_task)
116
- my_task.out = "Receiver closed"
117
- # Close when listener exits
118
- MQTT.CLIENT.close()
119
-
120
- #########################################
121
- # PUBLIC FUNCTIONS #
122
- #########################################
123
-
124
- def publish(message:str, topic:str=MQTT.TOPIC):
125
- """
126
- Publish message
127
- :param message: string to be sent
128
- :param topic: topic for message
129
- """
130
- state = micro_task(tag=f"mqtt.publish.{topic}", task=_publish(message, topic))
131
- state = "starting" if state else "already running"
132
- return f"Message send, {state}"
133
-
134
-
135
- def subscribe(topic:str=None, commands:str=None, raw_dict:dict|None=None):
136
- """
137
- Subscribe for single topics and set callback function(s) aka command(s)
138
- :param topic: topic string, ex.: 'lights'
139
- :param commands: semicolon separated commands. ex.: 'rgb toggle; cct toggle'
140
- OR
141
- :param raw_dict: python dict string for multi topic subscription, ex.: {"lights": ["rgb toggle", "cct toggle"], ...}
142
-
143
- return: all or selected topics command
144
- """
145
- updated = False
146
- topic = topic.strip()
147
- # Register single topic
148
- if topic and commands:
149
- # raw commands structure: 'rgb toggle; cct toggle'
150
- commands = [ c.strip() for c in commands.split(";") ]
151
- # commands: Topic LUT structure: {'topic': ['mod func'], ..., 'lights': ['rgb toggle', 'cct toggle']}
152
- updated = True if MQTT.TOPIC_COMMAND_LUT.get(topic, None) is None else False
153
- MQTT.TOPIC_COMMAND_LUT[topic] = commands
154
- # Register multiple topics at once
155
- elif isinstance(raw_dict, dict):
156
- updated = True
157
- MQTT.TOPIC_COMMAND_LUT.update(raw_dict)
158
- # Start subscribe task
159
- if updated:
160
- state = micro_task(tag="mqtt.subscribe", task=_subscribe())
161
- state = "starting" if state else "already running"
162
- return f"Subscribe, {state}"
163
-
164
- # Return handling
165
- if topic is not None:
166
- # Return selected topic commands
167
- return MQTT.TOPIC_COMMAND_LUT.get(topic, None)
168
- # Return registered topics
169
- return MQTT.TOPIC_COMMAND_LUT
170
-
171
-
172
- def _configure(server_ip:str, username:str, password:str):
173
- # Define configuration
174
- config["keepalive"] = 120
175
- config["queue_len"] = 1 # Use event interface with default queue
176
- # Define configuration
177
- config['client_id'] = cfgget("devfid")
178
- config['ssid'] = cfgget("staessid")
179
- config['wifi_pw'] = cfgget("stapwd")
180
- config['port'] = 1883 # expose????
181
- config['server'] = server_ip # '172.20.10.2'
182
- config['user'] = username # test
183
- config['password'] = password # '12345'
184
- return config
185
-
186
-
187
- def load(server_ip:str, username:str, password:str, topic:str=None, commands:str=None, raw_dict:dict|None=None):
188
- """
189
- Load MQTT_AS receiver...
190
- :param server_ip: server IP address
191
- :param username: server user
192
- :param password: server user password
193
-
194
- :param topic: topic string, ex.: 'lights'
195
- :param commands: semicolon separated commands. ex.: 'rgb toggle; cct toggle'
196
- OR
197
- :param raw_dict: python dict string for multi topic subscription, ex.: {"lights": ["rgb toggle", "cct toggle"], ...}
198
- """
199
- MQTTClient.DEBUG = True
200
- MQTT.CLIENT = MQTTClient(_configure(server_ip, username, password))
201
-
202
- state = micro_task(tag="mqtt.client", task=_init_client(topic, commands, raw_dict))
203
- return "Starting" if state else "Already running"
204
-
205
-
206
- def help():
207
- return ("load <server_ip> <username> <password> topic='micros', commands='rgb toggle; cct toggle'",
208
- "subscribe topic='micros', commands='rgb toggle; cct toggle'",
209
- "subscribe #without params dumps the topic-command data structure",
210
- "publish message='hello' topic='micros'",
211
- "HINT: task show mqtt.*")
@@ -1,22 +0,0 @@
1
-
2
- PYTHON_EXTENSIONS = ('py', 'mpy')
3
- WEB_ONLY = ('js', 'html', 'css', 'json', 'ico', 'jpeg', 'png')
4
- ENABLED_EXTENSIONS = PYTHON_EXTENSIONS + WEB_ONLY
5
-
6
- def check_all_extensions(path):
7
- extension = path.split('.')[-1]
8
- if extension in ENABLED_EXTENSIONS:
9
- return True
10
- return False
11
-
12
- def check_web_extensions(path):
13
- extension = path.split('.')[-1]
14
- if extension in WEB_ONLY:
15
- return True
16
- return False
17
-
18
- def check_python_extensions(path):
19
- extension = path.split('.')[-1]
20
- if extension in PYTHON_EXTENSIONS:
21
- return True
22
- return False
Binary file
@@ -1,57 +0,0 @@
1
- import Espnow
2
-
3
- def load():
4
- """
5
- OBSOLETE - remove
6
- [DEBUG ONLY] ENABLE ESPNOW IN NODE CONFIG INSTEAD OF HERE!
7
- Initialize ESPNOW protocal
8
- """
9
- return Espnow.initialize()
10
-
11
- def start_server():
12
- """
13
- OBSOLETE - remove
14
- [DEBUG ONLY] ENABLE ESPNOW IN NODE CONFIG INSTEAD OF HERE!
15
- Start ESPNOW server/listener
16
- - this can receive espnow messages
17
- - it includes Load Module execution logic (beta)
18
- """
19
- now = Espnow.initialize()
20
- return now.start_server()
21
-
22
-
23
- def send(peer:bytes|str, msg:str='modules'):
24
- """
25
- Send message to peer (by mac address)
26
- :param peer: mac address of espnow device
27
- :param msg: message string/load module call
28
- """
29
- now = Espnow.initialize()
30
- return now.send(peer, msg)
31
-
32
- def stats():
33
- """
34
- Get ESPNOW stats
35
- """
36
- now = Espnow.initialize()
37
- return now.stats()
38
-
39
- def add_peer(peer:bytes, dev_name:str=None):
40
- """
41
- Add ESPNOW peer to known hosts
42
- - It is needed before first send(...)
43
- """
44
- now = Espnow.initialize()
45
- return now.add_peer(peer, dev_name)
46
-
47
- def mac_address():
48
- """
49
- Get ESPNOW compatible mac address
50
- """
51
- return Espnow.mac_address()
52
-
53
- def help():
54
- """
55
- [beta] ESPNOW sender/receiver with LM execution
56
- """
57
- return 'load', 'send <peer> "ping"', 'start_server', 'add_peer <peer> dev_name=None', 'stats', 'mac_address'
@@ -1,211 +0,0 @@
1
- # async_message.py Test of asynchronous mqtt client with async Broker class
2
- # (C) Copyright Peter Hinch 2024.
3
- # Released under the MIT licence.
4
- # Public brokers https://github.com/mqtt/mqtt.github.io/wiki/public_brokers
5
- # mip command: ???
6
-
7
- from Config import cfgget
8
- from mqtt_as import MQTTClient, config
9
- from Common import micro_task, console, syslog, exec_cmd
10
-
11
-
12
- # Set up MQTT
13
- class MQTT:
14
- CLIENT:MQTTClient = None # MQTT Client (broker) instance
15
- TOPIC = "micros" # Default topic
16
- TOPIC_COMMAND_LUT = {} # Lookup table for command/topic pairs
17
- # Example:
18
- # {"topic1": ["mod func", "mod2 func"], "topic2": []}
19
-
20
-
21
- async def _receiver(task):
22
- """
23
- MQTT AS receiver loop
24
- """
25
- async for topic, msg, retained in MQTT.CLIENT.queue:
26
- topic, msg = topic.decode(), msg.decode()
27
- console(f'Topic: "{topic}" Message: "{msg}" Retained: {retained}')
28
-
29
- # Command execution... use MQTT.TOPIC_COMMAND_LUT
30
- topic_commands:list = MQTT.TOPIC_COMMAND_LUT.get(topic, None)
31
- output_struct:list = []
32
- if topic_commands is None:
33
- syslog(f"[WARN] mqtt Unknown topic: {topic}")
34
- elif len(topic_commands) == 0:
35
- syslog(f"[WARN] mqtt No commands for {topic}")
36
- else:
37
- task.out = f"Handle topic: {topic}"
38
- for cmd in topic_commands:
39
- single_command = cmd.split()
40
- if len(single_command) > 0:
41
- state, output = exec_cmd(single_command, jsonify=True, skip_check=True)
42
- output_struct.append({"state": state, "result": output, "cmd": cmd})
43
- if len(output_struct) > 0:
44
- console(f'\tMQTT Publish: {output_struct}')
45
- task.out = f"Publish {topic}"
46
- MQTT.CLIENT.publish(topic, str(output_struct))
47
- else:
48
- task.out = f"Nothing to publish {topic}"
49
- task.feed()
50
-
51
-
52
- async def _subscribe():
53
- """
54
- MQTT AS Topic subscribe towards server
55
- """
56
- with micro_task(tag="mqtt.subscribe") as my_task:
57
- my_task.out = "Started"
58
- try:
59
- for t in MQTT.TOPIC_COMMAND_LUT:
60
- console(f"Subscribe topic: {t}")
61
- await MQTT.CLIENT.subscribe(t, 1)
62
- my_task.out = "Done"
63
- except Exception as e:
64
- my_task.out = f"Error: {e}"
65
-
66
-
67
- async def _publish(message, topic):
68
- """
69
- Send message to topic with mqtt
70
- """
71
- tag = f"mqtt.publish.{topic}"
72
- with micro_task(tag=tag) as my_task:
73
- console(f"mqtt send: [{topic}] {message}")
74
- await MQTT.CLIENT.publish(topic, message, qos=1)
75
- my_task.out = "Sent"
76
-
77
-
78
- async def _up():
79
- """
80
- UP Listener - resubscribe
81
- """
82
- with micro_task(tag="mqtt.up") as my_task:
83
- while True:
84
- # Wait for UP Event - (re)subscribe
85
- my_task.out = "Wait"
86
- await MQTT.CLIENT.up.wait()
87
- MQTT.CLIENT.up.clear()
88
- micro_task(tag="mqtt.subscribe", task=_subscribe())
89
- my_task.out = "Re-Subscription"
90
- my_task.feed()
91
-
92
-
93
- async def _init_client(topic:str=None, commands:str=None, raw_dict:dict|None=None):
94
- """
95
- Initialize main mqtt receiver and topics
96
- :param topic: topic string, ex.: 'lights'
97
- :param commands: semicolon separated commands. ex.: 'rgb toggle; cct toggle'
98
- OR
99
- :param raw_dict: python dict string for multi topic subscription, ex.: {"lights": ["rgb toggle", "cct toggle"], ...}
100
- """
101
- with micro_task(tag="mqtt.client") as my_task:
102
- try:
103
- await MQTT.CLIENT.connect()
104
- my_task.out = "Connection successful."
105
- except OSError:
106
- my_task.out = "Connection failed."
107
- return
108
- # Wait for mqtt client connected successfully
109
- await MQTT.CLIENT.up.wait()
110
- MQTT.CLIENT.up.clear()
111
- # Initialize mqtt topics, ha
112
- subscribe(topic, commands, raw_dict)
113
- micro_task(tag="mqtt.up", task=_up())
114
- # Async listener loop
115
- await _receiver(my_task)
116
- my_task.out = "Receiver closed"
117
- # Close when listener exits
118
- MQTT.CLIENT.close()
119
-
120
- #########################################
121
- # PUBLIC FUNCTIONS #
122
- #########################################
123
-
124
- def publish(message:str, topic:str=MQTT.TOPIC):
125
- """
126
- Publish message
127
- :param message: string to be sent
128
- :param topic: topic for message
129
- """
130
- state = micro_task(tag=f"mqtt.publish.{topic}", task=_publish(message, topic))
131
- state = "starting" if state else "already running"
132
- return f"Message send, {state}"
133
-
134
-
135
- def subscribe(topic:str=None, commands:str=None, raw_dict:dict|None=None):
136
- """
137
- Subscribe for single topics and set callback function(s) aka command(s)
138
- :param topic: topic string, ex.: 'lights'
139
- :param commands: semicolon separated commands. ex.: 'rgb toggle; cct toggle'
140
- OR
141
- :param raw_dict: python dict string for multi topic subscription, ex.: {"lights": ["rgb toggle", "cct toggle"], ...}
142
-
143
- return: all or selected topics command
144
- """
145
- updated = False
146
- topic = topic.strip()
147
- # Register single topic
148
- if topic and commands:
149
- # raw commands structure: 'rgb toggle; cct toggle'
150
- commands = [ c.strip() for c in commands.split(";") ]
151
- # commands: Topic LUT structure: {'topic': ['mod func'], ..., 'lights': ['rgb toggle', 'cct toggle']}
152
- updated = True if MQTT.TOPIC_COMMAND_LUT.get(topic, None) is None else False
153
- MQTT.TOPIC_COMMAND_LUT[topic] = commands
154
- # Register multiple topics at once
155
- elif isinstance(raw_dict, dict):
156
- updated = True
157
- MQTT.TOPIC_COMMAND_LUT.update(raw_dict)
158
- # Start subscribe task
159
- if updated:
160
- state = micro_task(tag="mqtt.subscribe", task=_subscribe())
161
- state = "starting" if state else "already running"
162
- return f"Subscribe, {state}"
163
-
164
- # Return handling
165
- if topic is not None:
166
- # Return selected topic commands
167
- return MQTT.TOPIC_COMMAND_LUT.get(topic, None)
168
- # Return registered topics
169
- return MQTT.TOPIC_COMMAND_LUT
170
-
171
-
172
- def _configure(server_ip:str, username:str, password:str):
173
- # Define configuration
174
- config["keepalive"] = 120
175
- config["queue_len"] = 1 # Use event interface with default queue
176
- # Define configuration
177
- config['client_id'] = cfgget("devfid")
178
- config['ssid'] = cfgget("staessid")
179
- config['wifi_pw'] = cfgget("stapwd")
180
- config['port'] = 1883 # expose????
181
- config['server'] = server_ip # '172.20.10.2'
182
- config['user'] = username # test
183
- config['password'] = password # '12345'
184
- return config
185
-
186
-
187
- def load(server_ip:str, username:str, password:str, topic:str=None, commands:str=None, raw_dict:dict|None=None):
188
- """
189
- Load MQTT_AS receiver...
190
- :param server_ip: server IP address
191
- :param username: server user
192
- :param password: server user password
193
-
194
- :param topic: topic string, ex.: 'lights'
195
- :param commands: semicolon separated commands. ex.: 'rgb toggle; cct toggle'
196
- OR
197
- :param raw_dict: python dict string for multi topic subscription, ex.: {"lights": ["rgb toggle", "cct toggle"], ...}
198
- """
199
- MQTTClient.DEBUG = True
200
- MQTT.CLIENT = MQTTClient(_configure(server_ip, username, password))
201
-
202
- state = micro_task(tag="mqtt.client", task=_init_client(topic, commands, raw_dict))
203
- return "Starting" if state else "Already running"
204
-
205
-
206
- def help():
207
- return ("load <server_ip> <username> <password> topic='micros', commands='rgb toggle; cct toggle'",
208
- "subscribe topic='micros', commands='rgb toggle; cct toggle'",
209
- "subscribe #without params dumps the topic-command data structure",
210
- "publish message='hello' topic='micros'",
211
- "HINT: task show mqtt.*")
Binary file
Binary file
File without changes
File without changes
File without changes
File without changes