micrOSDevToolKit 2.1.5__py3-none-any.whl → 2.26.1__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.
Files changed (400) hide show
  1. env/driver_cp210x/.DS_Store +0 -0
  2. env/driver_cp210x/macOS_VCP_Driver/SiLabsUSBDriverDisk.dmg +0 -0
  3. env/driver_cp210x/macOS_VCP_Driver/macOS_VCP_Driver_Release_Notes.txt +17 -1
  4. micrOS/micropython/esp32-20251209-v1.27.0.bin +0 -0
  5. micrOS/micropython/esp32c3-20251209-v1.27.0.bin +0 -0
  6. micrOS/micropython/esp32c6-20251209-v1.27.0.bin +0 -0
  7. micrOS/micropython/esp32s2-20251209-v1.27.0.bin +0 -0
  8. micrOS/micropython/esp32s2-LOLIN_MINI-20251209-v1.27.0.bin +0 -0
  9. micrOS/micropython/esp32s3-4MBflash-20241129-v1.24.1.bin +0 -0
  10. micrOS/micropython/esp32s3-8MBflash-20251209-v1.27.0.bin +0 -0
  11. micrOS/micropython/esp32s3_spiram_oct-20251209-v1.27.0.bin +0 -0
  12. micrOS/micropython/rpi-pico-w-20251209-v1.27.0.uf2 +0 -0
  13. micrOS/micropython/tinypico-20251209-v1.27.0.bin +0 -0
  14. micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +191 -151
  15. micrOS/source/Auth.py +37 -0
  16. micrOS/source/Common.py +376 -102
  17. micrOS/source/Config.py +55 -25
  18. micrOS/source/Debug.py +54 -193
  19. micrOS/source/Espnow.py +404 -0
  20. micrOS/source/Files.py +207 -0
  21. micrOS/source/Hooks.py +88 -16
  22. micrOS/source/InterConnect.py +130 -46
  23. micrOS/source/Interrupts.py +8 -8
  24. micrOS/source/Logger.py +131 -0
  25. micrOS/source/Network.py +41 -21
  26. micrOS/source/Notify.py +74 -198
  27. micrOS/source/Pacman.py +326 -0
  28. micrOS/source/Scheduler.py +18 -55
  29. micrOS/source/Server.py +84 -217
  30. micrOS/source/Shell.py +103 -93
  31. micrOS/source/Tasks.py +239 -173
  32. micrOS/source/Time.py +21 -22
  33. micrOS/source/Types.py +89 -54
  34. micrOS/source/Web.py +485 -0
  35. micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
  36. micrOS/source/__pycache__/Debug.cpython-312.pyc +0 -0
  37. micrOS/source/__pycache__/Files.cpython-312.pyc +0 -0
  38. micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
  39. micrOS/source/__pycache__/Scheduler.cpython-312.pyc +0 -0
  40. micrOS/source/__pycache__/Server.cpython-312.pyc +0 -0
  41. micrOS/source/__pycache__/Shell.cpython-312.pyc +0 -0
  42. micrOS/source/__pycache__/replhelper.cpython-312.pyc +0 -0
  43. micrOS/source/helpers.py +132 -0
  44. micrOS/source/micrOS.py +25 -21
  45. micrOS/source/micrOSloader.py +14 -23
  46. micrOS/source/microIO.py +94 -57
  47. toolkit/simulator_lib/LP_darwin.py → micrOS/source/modules/IO_esp32.py +22 -11
  48. micrOS/source/{IO_esp32c3.py → modules/IO_esp32c3.py} +6 -1
  49. micrOS/source/modules/IO_esp32c6.py +38 -0
  50. micrOS/source/{IO_esp32s2.py → modules/IO_esp32s2.py} +6 -1
  51. micrOS/source/{IO_esp32s3.py → modules/IO_esp32s3.py} +43 -2
  52. micrOS/source/modules/IO_m5stamp.py +86 -0
  53. micrOS/source/{IO_qtpy.py → modules/IO_qtpy.py} +28 -18
  54. micrOS/source/{IO_tinypico.py → modules/IO_tinypico.py} +48 -3
  55. micrOS/source/modules/LM_L298N.py +161 -0
  56. {toolkit/workspace/precompiled → micrOS/source/modules}/LM_L9110_DCmotor.py +4 -4
  57. micrOS/source/{LM_OV2640.py → modules/LM_OV2640.py} +53 -42
  58. micrOS/source/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +5 -5
  59. micrOS/source/{LM_aht10.py → modules/LM_aht10.py} +12 -4
  60. micrOS/source/{LM_bme280.py → modules/LM_bme280.py} +13 -25
  61. micrOS/source/{LM_buzzer.py → modules/LM_buzzer.py} +42 -40
  62. micrOS/source/{LM_cct.py → modules/LM_cct.py} +22 -27
  63. micrOS/source/modules/LM_cluster.py +255 -0
  64. micrOS/source/{LM_co2.py → modules/LM_co2.py} +13 -6
  65. micrOS/source/{LM_dht11.py → modules/LM_dht11.py} +13 -29
  66. micrOS/source/{LM_dht22.py → modules/LM_dht22.py} +13 -28
  67. micrOS/source/{LM_dimmer.py → modules/LM_dimmer.py} +19 -16
  68. micrOS/source/modules/LM_distance.py +135 -0
  69. micrOS/source/{LM_ds18.py → modules/LM_ds18.py} +12 -4
  70. micrOS/source/{LM_esp32.py → modules/LM_esp32.py} +16 -4
  71. micrOS/source/modules/LM_espnow.py +53 -0
  72. micrOS/source/modules/LM_fileserver.py +265 -0
  73. micrOS/source/{LM_gameOfLife.py → modules/LM_gameOfLife.py} +5 -5
  74. micrOS/source/{LM_genIO.py → modules/LM_genIO.py} +49 -35
  75. micrOS/source/modules/LM_haptic.py +111 -0
  76. micrOS/source/modules/LM_i2c.py +61 -0
  77. micrOS/source/{LM_i2s_mic.py → modules/LM_i2s_mic.py} +20 -23
  78. micrOS/source/{LM_ld2410.py → modules/LM_ld2410.py} +3 -3
  79. micrOS/source/{LM_light_sensor.py → modules/LM_light_sensor.py} +22 -26
  80. micrOS/source/modules/LM_mh_z19c.py +198 -0
  81. micrOS/source/modules/LM_neoeffects.py +284 -0
  82. micrOS/source/{LM_neopixel.py → modules/LM_neopixel.py} +26 -31
  83. micrOS/source/{LM_oled.py → modules/LM_oled.py} +28 -20
  84. micrOS/source/{LM_oled_sh1106.py → modules/LM_oled_sh1106.py} +28 -24
  85. micrOS/source/{LM_oled_ui.py → modules/LM_oled_ui.py} +132 -174
  86. micrOS/source/modules/LM_pacman.py +320 -0
  87. micrOS/source/{LM_presence.py → modules/LM_presence.py} +24 -36
  88. micrOS/source/modules/LM_qmi8658.py +204 -0
  89. micrOS/source/{LM_rencoder.py → modules/LM_rencoder.py} +40 -11
  90. micrOS/source/modules/LM_rest.py +81 -0
  91. micrOS/source/{LM_rgb.py → modules/LM_rgb.py} +25 -34
  92. micrOS/source/{LM_rgbcct.py → modules/LM_rgbcct.py} +5 -5
  93. micrOS/source/{LM_roboarm.py → modules/LM_roboarm.py} +37 -45
  94. micrOS/source/modules/LM_robustness.py +137 -0
  95. micrOS/source/{LM_rp2w.py → modules/LM_rp2w.py} +3 -0
  96. micrOS/source/{LM_sdcard.py → modules/LM_sdcard.py} +3 -0
  97. micrOS/source/{LM_servo.py → modules/LM_servo.py} +4 -4
  98. micrOS/source/modules/LM_sound_event.py +751 -0
  99. micrOS/source/{LM_stepper.py → modules/LM_stepper.py} +8 -8
  100. micrOS/source/{LM_switch.py → modules/LM_switch.py} +21 -18
  101. micrOS/source/{LM_system.py → modules/LM_system.py} +96 -59
  102. micrOS/source/modules/LM_tcs3472.py +187 -0
  103. micrOS/source/modules/LM_telegram.py +388 -0
  104. micrOS/source/modules/LM_trackball.py +287 -0
  105. micrOS/source/modules/LM_veml7700.py +159 -0
  106. micrOS/source/modules/LM_web.py +38 -0
  107. micrOS/source/urequests.py +204 -91
  108. {toolkit/workspace/precompiled → micrOS/source/web}/dashboard.html +9 -4
  109. micrOS/source/web/editor.js +440 -0
  110. micrOS/source/web/filesui.html +178 -0
  111. micrOS/source/web/filesui.js +338 -0
  112. micrOS/source/{index.html → web/index.html} +44 -2
  113. micrOS/source/web/uapi.js +103 -0
  114. micrOS/source/web/udashboard.js +129 -0
  115. micrOS/source/web/ustyle.css +55 -0
  116. micrOS/source/web/uwidgets.js +172 -0
  117. micrOS/source/web/uwidgets_pro.js +99 -0
  118. micrOS/utests/__init__.py +0 -0
  119. micrOS/utests/test_scheduler.py +435 -0
  120. {micrOSDevToolKit-2.1.5.data → microsdevtoolkit-2.26.1.data}/scripts/devToolKit.py +47 -4
  121. {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/METADATA +392 -279
  122. microsdevtoolkit-2.26.1.dist-info/RECORD +396 -0
  123. {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/WHEEL +1 -1
  124. toolkit/DevEnvCompile.py +63 -33
  125. toolkit/DevEnvOTA.py +72 -22
  126. toolkit/DevEnvUSB.py +147 -77
  127. toolkit/Gateway.py +9 -9
  128. toolkit/LM_to_compile.dat +12 -4
  129. toolkit/MicrOSDevEnv.py +129 -51
  130. toolkit/WebRepl.py +73 -0
  131. toolkit/dashboard_apps/BackupRestore.py +171 -0
  132. toolkit/dashboard_apps/CCTDemo.py +12 -17
  133. toolkit/dashboard_apps/CCTTest.py +20 -24
  134. toolkit/dashboard_apps/CamStream.py +2 -6
  135. toolkit/dashboard_apps/CatGame.py +14 -16
  136. toolkit/dashboard_apps/Dimmer.py +11 -21
  137. toolkit/dashboard_apps/GetVersion.py +11 -19
  138. toolkit/dashboard_apps/MicrophoneTest.py +2 -7
  139. toolkit/dashboard_apps/NeoEffectsDemo.py +22 -35
  140. toolkit/dashboard_apps/NeopixelTest.py +20 -25
  141. toolkit/dashboard_apps/PresenceTest.py +2 -8
  142. toolkit/dashboard_apps/QMI8685_GYRO.py +68 -0
  143. toolkit/dashboard_apps/RGBTest.py +20 -24
  144. toolkit/dashboard_apps/RoboArm.py +24 -32
  145. toolkit/dashboard_apps/SED_test.py +10 -14
  146. toolkit/dashboard_apps/SensorsTest.py +61 -0
  147. toolkit/dashboard_apps/SystemTest.py +219 -117
  148. toolkit/dashboard_apps/Template_app.py +12 -19
  149. toolkit/dashboard_apps/_app_base.py +34 -0
  150. toolkit/dashboard_apps/_gyro_visualizer.py +78 -0
  151. toolkit/dashboard_apps/uLightDemo.py +15 -24
  152. toolkit/index.html +6 -5
  153. toolkit/lib/LocalMachine.py +6 -1
  154. toolkit/lib/MicrosFiles.py +46 -0
  155. toolkit/lib/Repository.py +64 -0
  156. toolkit/lib/TerminalColors.py +4 -0
  157. toolkit/lib/macroScript.py +371 -0
  158. toolkit/lib/micrOSClient.py +124 -51
  159. toolkit/lib/micrOSClientHistory.py +156 -0
  160. toolkit/lib/pip_package_installer.py +31 -4
  161. toolkit/micrOSdashboard.py +16 -21
  162. toolkit/micrOSlint.py +28 -10
  163. toolkit/simulator_lib/.DS_Store +0 -0
  164. micrOS/source/IO_esp32.py → toolkit/simulator_lib/IO_darwin.py +3 -0
  165. toolkit/simulator_lib/__pycache__/IO_darwin.cpython-312.pyc +0 -0
  166. toolkit/simulator_lib/__pycache__/aioespnow.cpython-312.pyc +0 -0
  167. toolkit/simulator_lib/__pycache__/camera.cpython-312.pyc +0 -0
  168. toolkit/simulator_lib/__pycache__/framebuf.cpython-312.pyc +0 -0
  169. toolkit/simulator_lib/__pycache__/machine.cpython-312.pyc +0 -0
  170. toolkit/simulator_lib/__pycache__/micropython.cpython-312.pyc +0 -0
  171. toolkit/simulator_lib/__pycache__/mip.cpython-312.pyc +0 -0
  172. toolkit/simulator_lib/__pycache__/neopixel.cpython-312.pyc +0 -0
  173. toolkit/simulator_lib/__pycache__/network.cpython-312.pyc +0 -0
  174. toolkit/simulator_lib/__pycache__/sim_common.cpython-312.pyc +0 -0
  175. toolkit/simulator_lib/__pycache__/simgc.cpython-312.pyc +0 -0
  176. toolkit/simulator_lib/__pycache__/simulator.cpython-312.pyc +0 -0
  177. toolkit/simulator_lib/__pycache__/uasyncio.cpython-312.pyc +0 -0
  178. toolkit/simulator_lib/__pycache__/uos.cpython-312.pyc +0 -0
  179. toolkit/simulator_lib/__pycache__/urandom.cpython-312.pyc +0 -0
  180. toolkit/simulator_lib/__pycache__/usocket.cpython-312.pyc +0 -0
  181. toolkit/simulator_lib/__pycache__/ussl.cpython-312.pyc +0 -0
  182. toolkit/simulator_lib/aioespnow.py +28 -0
  183. toolkit/simulator_lib/camera.py +84 -0
  184. toolkit/simulator_lib/dht.py +1 -1
  185. toolkit/simulator_lib/framebuf.py +49 -1
  186. toolkit/simulator_lib/machine.py +32 -2
  187. toolkit/simulator_lib/micropython.py +3 -3
  188. toolkit/simulator_lib/mip.py +165 -0
  189. toolkit/simulator_lib/neopixel.py +3 -2
  190. toolkit/simulator_lib/network.py +2 -1
  191. toolkit/simulator_lib/node_config.json +2 -3
  192. toolkit/simulator_lib/ntptime.py +1 -1
  193. toolkit/simulator_lib/{sim_console.py → sim_common.py} +2 -3
  194. toolkit/simulator_lib/simgc.py +6 -2
  195. toolkit/simulator_lib/simulator.py +138 -46
  196. toolkit/simulator_lib/uasyncio.py +34 -3
  197. toolkit/simulator_lib/uos.py +147 -0
  198. toolkit/simulator_lib/urandom.py +4 -0
  199. toolkit/simulator_lib/usocket.py +5 -1
  200. toolkit/simulator_lib/view01.jpg +0 -0
  201. toolkit/simulator_lib/view02.jpg +0 -0
  202. toolkit/socketClient.py +43 -23
  203. toolkit/user_data/webhooks/generic.py +1 -1
  204. toolkit/user_data/webhooks/macro.py +44 -0
  205. toolkit/user_data/webhooks/template.macro +20 -0
  206. toolkit/user_data/webhooks/template.py +1 -1
  207. toolkit/workspace/precompiled/Auth.mpy +0 -0
  208. toolkit/workspace/precompiled/Common.mpy +0 -0
  209. toolkit/workspace/precompiled/Config.mpy +0 -0
  210. toolkit/workspace/precompiled/Debug.mpy +0 -0
  211. toolkit/workspace/precompiled/Espnow.mpy +0 -0
  212. toolkit/workspace/precompiled/Files.mpy +0 -0
  213. toolkit/workspace/precompiled/Hooks.mpy +0 -0
  214. toolkit/workspace/precompiled/InterConnect.mpy +0 -0
  215. toolkit/workspace/precompiled/Interrupts.mpy +0 -0
  216. toolkit/workspace/precompiled/Logger.mpy +0 -0
  217. toolkit/workspace/precompiled/Network.mpy +0 -0
  218. toolkit/workspace/precompiled/Notify.mpy +0 -0
  219. toolkit/workspace/precompiled/Pacman.mpy +0 -0
  220. toolkit/workspace/precompiled/Scheduler.mpy +0 -0
  221. toolkit/workspace/precompiled/Server.mpy +0 -0
  222. toolkit/workspace/precompiled/Shell.mpy +0 -0
  223. toolkit/workspace/precompiled/Tasks.mpy +0 -0
  224. toolkit/workspace/precompiled/Time.mpy +0 -0
  225. toolkit/workspace/precompiled/Types.mpy +0 -0
  226. toolkit/workspace/precompiled/Web.mpy +0 -0
  227. toolkit/workspace/precompiled/_mpy.version +1 -1
  228. toolkit/workspace/precompiled/config/_git.keep +0 -0
  229. toolkit/workspace/precompiled/helpers.mpy +0 -0
  230. toolkit/workspace/precompiled/micrOS.mpy +0 -0
  231. toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
  232. toolkit/workspace/precompiled/microIO.mpy +0 -0
  233. toolkit/workspace/precompiled/modules/IO_esp32.mpy +0 -0
  234. toolkit/workspace/precompiled/modules/IO_esp32c3.mpy +0 -0
  235. toolkit/workspace/precompiled/modules/IO_esp32c6.mpy +0 -0
  236. toolkit/workspace/precompiled/modules/IO_esp32s2.mpy +0 -0
  237. toolkit/workspace/precompiled/modules/IO_esp32s3.mpy +0 -0
  238. toolkit/workspace/precompiled/modules/IO_m5stamp.mpy +0 -0
  239. toolkit/workspace/precompiled/modules/IO_qtpy.mpy +0 -0
  240. toolkit/workspace/precompiled/modules/IO_rp2.mpy +0 -0
  241. toolkit/workspace/precompiled/modules/IO_tinypico.mpy +0 -0
  242. toolkit/workspace/precompiled/modules/LM_L298N.mpy +0 -0
  243. {micrOS/source → toolkit/workspace/precompiled/modules}/LM_L9110_DCmotor.py +4 -4
  244. toolkit/workspace/precompiled/modules/LM_OV2640.mpy +0 -0
  245. toolkit/workspace/precompiled/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +5 -5
  246. toolkit/workspace/precompiled/modules/LM_aht10.mpy +0 -0
  247. toolkit/workspace/precompiled/modules/LM_bme280.mpy +0 -0
  248. toolkit/workspace/precompiled/{LM_buzzer.mpy → modules/LM_buzzer.mpy} +0 -0
  249. toolkit/workspace/precompiled/modules/LM_cct.mpy +0 -0
  250. toolkit/workspace/precompiled/modules/LM_cluster.mpy +0 -0
  251. toolkit/workspace/precompiled/modules/LM_co2.mpy +0 -0
  252. toolkit/workspace/precompiled/modules/LM_dht11.mpy +0 -0
  253. toolkit/workspace/precompiled/modules/LM_dht22.mpy +0 -0
  254. toolkit/workspace/precompiled/modules/LM_dimmer.mpy +0 -0
  255. toolkit/workspace/precompiled/modules/LM_distance.mpy +0 -0
  256. toolkit/workspace/precompiled/modules/LM_ds18.mpy +0 -0
  257. toolkit/workspace/precompiled/{LM_esp32.py → modules/LM_esp32.py} +16 -4
  258. toolkit/workspace/precompiled/modules/LM_espnow.py +53 -0
  259. toolkit/workspace/precompiled/modules/LM_fileserver.mpy +0 -0
  260. toolkit/workspace/precompiled/{LM_gameOfLife.mpy → modules/LM_gameOfLife.mpy} +0 -0
  261. toolkit/workspace/precompiled/modules/LM_genIO.mpy +0 -0
  262. toolkit/workspace/precompiled/modules/LM_haptic.mpy +0 -0
  263. toolkit/workspace/precompiled/modules/LM_i2c.py +61 -0
  264. toolkit/workspace/precompiled/modules/LM_i2s_mic.mpy +0 -0
  265. toolkit/workspace/precompiled/{LM_ld2410.mpy → modules/LM_ld2410.mpy} +0 -0
  266. toolkit/workspace/precompiled/modules/LM_light_sensor.mpy +0 -0
  267. toolkit/workspace/precompiled/modules/LM_mh_z19c.py +198 -0
  268. toolkit/workspace/precompiled/modules/LM_neoeffects.mpy +0 -0
  269. toolkit/workspace/precompiled/modules/LM_neopixel.mpy +0 -0
  270. toolkit/workspace/precompiled/modules/LM_oled.mpy +0 -0
  271. toolkit/workspace/precompiled/modules/LM_oled_sh1106.mpy +0 -0
  272. toolkit/workspace/precompiled/modules/LM_oled_ui.mpy +0 -0
  273. toolkit/workspace/precompiled/modules/LM_pacman.mpy +0 -0
  274. toolkit/workspace/precompiled/modules/LM_presence.mpy +0 -0
  275. toolkit/workspace/precompiled/modules/LM_qmi8658.py +204 -0
  276. toolkit/workspace/precompiled/{LM_rencoder.py → modules/LM_rencoder.py} +40 -11
  277. toolkit/workspace/precompiled/modules/LM_rest.mpy +0 -0
  278. toolkit/workspace/precompiled/modules/LM_rgb.mpy +0 -0
  279. toolkit/workspace/precompiled/{LM_rgbcct.mpy → modules/LM_rgbcct.mpy} +0 -0
  280. toolkit/workspace/precompiled/modules/LM_roboarm.mpy +0 -0
  281. toolkit/workspace/precompiled/modules/LM_robustness.py +137 -0
  282. toolkit/workspace/precompiled/{LM_rp2w.py → modules/LM_rp2w.py} +3 -0
  283. toolkit/workspace/precompiled/{LM_sdcard.py → modules/LM_sdcard.py} +3 -0
  284. toolkit/workspace/precompiled/{LM_servo.mpy → modules/LM_servo.mpy} +0 -0
  285. toolkit/workspace/precompiled/modules/LM_sound_event.mpy +0 -0
  286. toolkit/workspace/precompiled/{LM_stepper.mpy → modules/LM_stepper.mpy} +0 -0
  287. toolkit/workspace/precompiled/modules/LM_switch.mpy +0 -0
  288. toolkit/workspace/precompiled/modules/LM_system.mpy +0 -0
  289. toolkit/workspace/precompiled/modules/LM_tcs3472.py +187 -0
  290. toolkit/workspace/precompiled/modules/LM_telegram.mpy +0 -0
  291. toolkit/workspace/precompiled/{LM_tinyrgb.mpy → modules/LM_tinyrgb.mpy} +0 -0
  292. toolkit/workspace/precompiled/modules/LM_trackball.mpy +0 -0
  293. toolkit/workspace/precompiled/modules/LM_veml7700.mpy +0 -0
  294. toolkit/workspace/precompiled/modules/LM_web.mpy +0 -0
  295. toolkit/workspace/precompiled/urequests.mpy +0 -0
  296. {micrOS/source → toolkit/workspace/precompiled/web}/dashboard.html +9 -4
  297. toolkit/workspace/precompiled/web/editor.js +440 -0
  298. toolkit/workspace/precompiled/web/filesui.html +178 -0
  299. toolkit/workspace/precompiled/web/filesui.js +338 -0
  300. toolkit/workspace/precompiled/{index.html → web/index.html} +44 -2
  301. toolkit/workspace/precompiled/web/uapi.js +103 -0
  302. toolkit/workspace/precompiled/web/udashboard.js +129 -0
  303. toolkit/workspace/precompiled/web/ustyle.css +55 -0
  304. toolkit/workspace/precompiled/web/uwidgets.js +172 -0
  305. toolkit/workspace/precompiled/web/uwidgets_pro.js +99 -0
  306. env/driver_cp210x/CH34XSER_MAC/CH34X_DRV_INSTALL_INSTRUCTIONS.pdf +0 -0
  307. env/driver_cp210x/CH34XSER_MAC/CH34xVCPDriver.pkg +0 -0
  308. micrOS/micropython/esp32-20231005-v1.21.0.bin +0 -0
  309. micrOS/micropython/esp32c3-GENERIC-20240105-v1.22.1.bin +0 -0
  310. micrOS/micropython/esp32c3-GENERIC-20240222-v1.22.2.bin +0 -0
  311. micrOS/micropython/esp32s2-GENERIC-20240105-v1.22.1.bin +0 -0
  312. micrOS/micropython/esp32s2-LOLIN_MINI-20220618-v1.19.1.bin +0 -0
  313. micrOS/micropython/esp32s3-GENERIC-20240105-v1.22.1.bin +0 -0
  314. micrOS/micropython/esp32s3_spiram_oct-20231005-v1.21.0.bin +0 -0
  315. micrOS/micropython/rpi-pico-w-20231005-v1.21.0.uf2 +0 -0
  316. micrOS/micropython/tinypico-20231005-v1.21.0.bin +0 -0
  317. micrOS/micropython/tinypico-usbc-UM-20240105-v1.22.1.bin +0 -0
  318. micrOS/source/LM_L298N_DCmotor.py +0 -86
  319. micrOS/source/LM_catgame.py +0 -74
  320. micrOS/source/LM_dashboard_be.py +0 -37
  321. micrOS/source/LM_demo.py +0 -85
  322. micrOS/source/LM_distance.py +0 -88
  323. micrOS/source/LM_i2c.py +0 -44
  324. micrOS/source/LM_intercon.py +0 -57
  325. micrOS/source/LM_keychain.py +0 -318
  326. micrOS/source/LM_lmpacman.py +0 -126
  327. micrOS/source/LM_neoeffects.py +0 -327
  328. micrOS/source/LM_pet_feeder.py +0 -76
  329. micrOS/source/LM_ph_sensor.py +0 -51
  330. micrOS/source/LM_rest.py +0 -40
  331. micrOS/source/LM_robustness.py +0 -73
  332. micrOS/source/LM_telegram.py +0 -96
  333. micrOS/source/reset.py +0 -11
  334. micrOS/source/uapi.js +0 -76
  335. micrOS/source/udashboard.js +0 -137
  336. micrOS/source/ustyle.css +0 -28
  337. micrOS/source/uwidgets.js +0 -179
  338. micrOSDevToolKit-2.1.5.dist-info/RECORD +0 -337
  339. toolkit/dashboard_apps/AirQualityBME280.py +0 -36
  340. toolkit/dashboard_apps/AirQualityDHT22_CO2.py +0 -36
  341. toolkit/lib/file_extensions.py +0 -16
  342. toolkit/simulator_lib/__pycache__/LP_darwin.cpython-312.pyc +0 -0
  343. toolkit/simulator_lib/__pycache__/LP_darwin.cpython-38.pyc +0 -0
  344. toolkit/simulator_lib/__pycache__/LP_darwin.cpython-39.pyc +0 -0
  345. toolkit/simulator_lib/__pycache__/sim_console.cpython-312.pyc +0 -0
  346. toolkit/simulator_lib/__pycache__/sim_console.cpython-38.pyc +0 -0
  347. toolkit/simulator_lib/__pycache__/sim_console.cpython-39.pyc +0 -0
  348. toolkit/workspace/precompiled/IO_esp32.mpy +0 -0
  349. toolkit/workspace/precompiled/IO_esp32c3.mpy +0 -0
  350. toolkit/workspace/precompiled/IO_esp32s2.mpy +0 -0
  351. toolkit/workspace/precompiled/IO_esp32s3.mpy +0 -0
  352. toolkit/workspace/precompiled/IO_qtpy.mpy +0 -0
  353. toolkit/workspace/precompiled/IO_rp2.mpy +0 -0
  354. toolkit/workspace/precompiled/IO_tinypico.mpy +0 -0
  355. toolkit/workspace/precompiled/LM_L298N_DCmotor.mpy +0 -0
  356. toolkit/workspace/precompiled/LM_OV2640.mpy +0 -0
  357. toolkit/workspace/precompiled/LM_aht10.mpy +0 -0
  358. toolkit/workspace/precompiled/LM_bme280.mpy +0 -0
  359. toolkit/workspace/precompiled/LM_catgame.py +0 -74
  360. toolkit/workspace/precompiled/LM_cct.mpy +0 -0
  361. toolkit/workspace/precompiled/LM_co2.mpy +0 -0
  362. toolkit/workspace/precompiled/LM_dashboard_be.py +0 -37
  363. toolkit/workspace/precompiled/LM_demo.py +0 -85
  364. toolkit/workspace/precompiled/LM_dht11.mpy +0 -0
  365. toolkit/workspace/precompiled/LM_dht22.mpy +0 -0
  366. toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
  367. toolkit/workspace/precompiled/LM_distance.py +0 -88
  368. toolkit/workspace/precompiled/LM_ds18.mpy +0 -0
  369. toolkit/workspace/precompiled/LM_genIO.mpy +0 -0
  370. toolkit/workspace/precompiled/LM_i2c.py +0 -44
  371. toolkit/workspace/precompiled/LM_i2s_mic.mpy +0 -0
  372. toolkit/workspace/precompiled/LM_intercon.mpy +0 -0
  373. toolkit/workspace/precompiled/LM_keychain.mpy +0 -0
  374. toolkit/workspace/precompiled/LM_light_sensor.mpy +0 -0
  375. toolkit/workspace/precompiled/LM_lmpacman.mpy +0 -0
  376. toolkit/workspace/precompiled/LM_neoeffects.mpy +0 -0
  377. toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
  378. toolkit/workspace/precompiled/LM_oled.mpy +0 -0
  379. toolkit/workspace/precompiled/LM_oled_sh1106.mpy +0 -0
  380. toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
  381. toolkit/workspace/precompiled/LM_pet_feeder.py +0 -76
  382. toolkit/workspace/precompiled/LM_ph_sensor.py +0 -51
  383. toolkit/workspace/precompiled/LM_presence.mpy +0 -0
  384. toolkit/workspace/precompiled/LM_rest.mpy +0 -0
  385. toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
  386. toolkit/workspace/precompiled/LM_roboarm.mpy +0 -0
  387. toolkit/workspace/precompiled/LM_robustness.py +0 -73
  388. toolkit/workspace/precompiled/LM_switch.mpy +0 -0
  389. toolkit/workspace/precompiled/LM_system.mpy +0 -0
  390. toolkit/workspace/precompiled/LM_telegram.mpy +0 -0
  391. toolkit/workspace/precompiled/reset.mpy +0 -0
  392. toolkit/workspace/precompiled/uapi.js +0 -76
  393. toolkit/workspace/precompiled/udashboard.js +0 -137
  394. toolkit/workspace/precompiled/ustyle.css +0 -28
  395. toolkit/workspace/precompiled/uwidgets.js +0 -179
  396. /toolkit/user_data/node_config_archive/.include → /micrOS/source/config/_git.keep +0 -0
  397. /micrOS/source/{IO_rp2.py → modules/IO_rp2.py} +0 -0
  398. /micrOS/source/{LM_tinyrgb.py → modules/LM_tinyrgb.py} +0 -0
  399. {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info/licenses}/LICENSE +0 -0
  400. {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/top_level.txt +0 -0
micrOS/source/Network.py CHANGED
@@ -19,7 +19,8 @@ from utime import sleep_ms
19
19
  from network import AP_IF, STA_IF, WLAN
20
20
  from machine import unique_id
21
21
  from Config import cfgget, cfgput
22
- from Debug import console_write, errlog_add
22
+ from Debug import console_write, syslog
23
+ from microIO import detect_platform
23
24
 
24
25
 
25
26
  class NW:
@@ -48,23 +49,36 @@ def ifconfig():
48
49
 
49
50
 
50
51
  def set_dev_uid():
52
+ if detect_platform() == "esp32c6":
53
+ # ESP32-C6: unique_id() not unique (can return same ID on different boards)
54
+ try:
55
+ sta = WLAN(STA_IF)
56
+ was = sta.active()
57
+ if not was: sta.active(True)
58
+ uid = hexlify(sta.config('mac')).decode()
59
+ if not was: sta.active(False)
60
+ cfgput('hwuid', f"micr{uid}OS")
61
+ return
62
+ except Exception as e:
63
+ syslog(f"[ERR] set_dev_uid (esp32c6): {e}")
64
+ # Legacy micrOS device UID generation (+fallback)
51
65
  try:
52
66
  cfgput('hwuid', f'micr{hexlify(unique_id()).decode("utf-8")}OS')
53
67
  except Exception as e:
54
- errlog_add(f"[ERR] set_dev_uid error: {e}")
68
+ syslog(f"[ERR] set_dev_uid: {e}")
55
69
 
56
70
 
57
71
  def get_mac():
58
- return hexlify(WLAN().config('mac'), ':').decode()
72
+ """ Get AP/STA mac address as raw binary data"""
73
+ return NW.NIF.config('mac')
59
74
 
60
75
  #################################################################
61
76
  # SET WIFI STA MODE #
62
77
  #################################################################
63
78
 
64
79
 
65
- def __select_available_wifi_nw(sta_if, raw_essid, raw_pwd):
80
+ def _select_available_wifi_nw(raw_essid:str, raw_pwd:str):
66
81
  """
67
- raw_essid: essid parameter, in case of multiple values separator is ;
68
82
  raw_pwd: essid pwd parameter, in case of multiple values separator is ;
69
83
  return detected essid with corresponding password
70
84
  """
@@ -72,18 +86,18 @@ def __select_available_wifi_nw(sta_if, raw_essid, raw_pwd):
72
86
  essid = essid.strip()
73
87
  # Scan wifi network - retry workaround
74
88
  for _ in range(0, 2):
75
- if essid in (wifispot[0].decode('utf-8') for wifispot in sta_if.scan()):
89
+ if essid in (wifispot[0].decode('utf-8') for wifispot in NW.NIF.scan()):
76
90
  console_write(f'\t| - [NW: STA] ESSID WAS FOUND: {essid}')
77
91
  try:
78
92
  return essid, str(raw_pwd.split(';')[idx]).strip()
79
93
  except Exception as e:
80
- errlog_add(f'[ERR][SET STA] stapwd config error: {e}')
94
+ syslog(f'[ERR][SET STA] stapwd config error: {e}')
81
95
  sleep_ms(400)
82
96
  return None, ''
83
97
 
84
98
 
85
- def set_wifi(essid, pwd, timeout=60):
86
- console_write(f'[NW: STA] SET WIFI STA NW {essid}')
99
+ def set_wifi(essid:str, pwd:str, timeout=60):
100
+ console_write('[NW: STA] Enable')
87
101
 
88
102
  # Disable AP mode
89
103
  ap_if = WLAN(AP_IF)
@@ -94,18 +108,25 @@ def set_wifi(essid, pwd, timeout=60):
94
108
  # Set STA and Connect
95
109
  sta_if = WLAN(STA_IF)
96
110
  sta_if.active(True)
111
+ NW.NIF = sta_if
97
112
  # Handle rsp2-w limitation (try)
98
113
  try:
99
114
  # Set custom DHCP hostname for dhcp name resolve
100
115
  sta_if.config(dhcp_hostname=cfgget('devfid'))
101
116
  except Exception as e:
102
- console_write(f"dhcp_hostname conf error: {e}")
117
+ syslog(f"[ERR] STA dhcp_hostname: {e}")
118
+ if cfgget("espnow"):
119
+ try:
120
+ # prevents Wi-Fi PS from dropping ESP-NOW frames while STA is connected.
121
+ sta_if.config(pm=sta_if.PM_NONE)
122
+ except Exception as e:
123
+ syslog(f"[ERR] ESPNow STA PM_NONE: {e}")
103
124
  # Check are we already connected
104
125
  if sta_if.isconnected():
105
126
  console_write(f"\t| [NW: STA] ALREADY CONNECTED TO {essid}")
106
127
  else:
107
128
  # Multiple essid and pwd handling with retry mechanism
108
- essid, pwd = __select_available_wifi_nw(sta_if, essid, pwd)
129
+ essid, pwd = _select_available_wifi_nw(essid, pwd)
109
130
 
110
131
  # Connect to the located wifi network
111
132
  if essid is not None:
@@ -118,7 +139,7 @@ def set_wifi(essid, pwd, timeout=60):
118
139
  timeout -= 1
119
140
  sleep_ms(500)
120
141
  # Set static IP - here because some data comes from connection. (subnet, etc.)
121
- if sta_if.isconnected() and __set_wifi_dev_static_ip(sta_if):
142
+ if sta_if.isconnected() and _set_wifi_dev_static_ip(sta_if):
122
143
  sta_if.disconnect()
123
144
  del sta_if
124
145
  return set_wifi(essid, pwd)
@@ -131,11 +152,10 @@ def set_wifi(essid, pwd, timeout=60):
131
152
  # Store STA IP (make it static ip)
132
153
  cfgput("devip", str(sta_if.ifconfig()[0]))
133
154
  set_dev_uid()
134
- NW.NIF = sta_if
135
155
  return sta_if.isconnected()
136
156
 
137
157
 
138
- def __set_wifi_dev_static_ip(sta_if):
158
+ def _set_wifi_dev_static_ip(sta_if:STA_IF):
139
159
  console_write("[NW: STA] Set device static IP.")
140
160
  stored_ip = cfgget('devip')
141
161
  if 'n/a' not in stored_ip.lower() and '.' in stored_ip:
@@ -149,7 +169,7 @@ def __set_wifi_dev_static_ip(sta_if):
149
169
  sta_if.ifconfig(tuple(conn_ips))
150
170
  return True # was reconfigured
151
171
  except Exception as e:
152
- errlog_add(f"[ERR][STA] StaticIP conf failed: {e}")
172
+ syslog(f"[ERR][STA] StaticIP conf failed: {e}")
153
173
  else:
154
174
  console_write(f"[NW: STA][SKIP] StaticIP conf.: {stored_ip} ? {conn_ips[0]}")
155
175
  else:
@@ -162,7 +182,7 @@ def __set_wifi_dev_static_ip(sta_if):
162
182
  #################################################################
163
183
 
164
184
 
165
- def set_access_point(_essid, _pwd, _authmode=3):
185
+ def set_access_point(_essid:str, _pwd:str, _authmode:int=3):
166
186
  console_write(f"[NW: AP] SET AP MODE: {_essid} - {_pwd} - auth mode: {_authmode} (if possible)")
167
187
 
168
188
  sta_if = WLAN(STA_IF)
@@ -171,6 +191,7 @@ def set_access_point(_essid, _pwd, _authmode=3):
171
191
 
172
192
  ap_if = WLAN(AP_IF)
173
193
  ap_if.active(True)
194
+ NW.NIF = ap_if
174
195
  # Set WiFi access point name (formally known as ESSID) and WiFi authmode (3): WPA2-PSK
175
196
  try:
176
197
  # Config #1 (esp)
@@ -184,12 +205,11 @@ def set_access_point(_essid, _pwd, _authmode=3):
184
205
  # Config #2 (rp2-w)???
185
206
  ap_if.config(essid=_essid, password=_pwd)
186
207
  except Exception as e2:
187
- errlog_add(f"[ERR][AP] config failed: {e2}")
208
+ syslog(f"[ERR][AP] config failed: {e2}")
188
209
  if not (ap_if.active() and str(ap_if.config('essid')) == str(_essid)):
189
- errlog_add("[ERR][AP] error")
210
+ syslog("[ERR][AP] error")
190
211
  console_write(f"\t|\t| [NW: AP] network config: {str(ap_if.ifconfig())}")
191
212
  set_dev_uid()
192
- NW.NIF = ap_if
193
213
  return ap_if.active()
194
214
 
195
215
  #################################################################
@@ -228,7 +248,7 @@ def sta_high_avail():
228
248
  raw_essid = cfgget("staessid")
229
249
  wifi_avail = False
230
250
  # [CHECK 2] check known network is available
231
- for idx, essid in enumerate(raw_essid.split(';')):
251
+ for essid in raw_essid.split(';'):
232
252
  essid = essid.strip()
233
253
  # Scan wifi network - retry workaround
234
254
  for _ in range(0, 2):
@@ -241,7 +261,7 @@ def sta_high_avail():
241
261
  if wifi_avail or not ap_if.active():
242
262
  # ACTION: Restart micrOS node (boot phase automatically detects nw mode)
243
263
  from machine import reset
244
- console_write("[Restart] network repair")
264
+ syslog("[WARN] Restart, network repair")
245
265
  reset()
246
266
  return f'{cfgget("nwmd")} mode NOK, wifi avail: {wifi_avail}'
247
267
  return f'{cfgget("nwmd")} mode OK'
micrOS/source/Notify.py CHANGED
@@ -1,226 +1,102 @@
1
- from sys import modules
2
- import urequests
1
+ """
2
+ Module is responsible for Notification handling
3
+ Common:
4
+ - notifications None/True/False
5
+ - notify 'text'
6
+ - lm_execute
7
+ Supported notification subscribers (add_subscriber)
8
+ - LM_telegram
9
+ - LM_mqtt_client
10
+ Designed by Marcell Ban aka BxNxM
11
+ """
12
+
3
13
  from Config import cfgget
4
14
  from Tasks import lm_exec, lm_is_loaded
5
- from Debug import console_write
15
+ from Debug import syslog
6
16
 
7
17
  #########################################
8
18
  # micrOS Notifications #
9
19
  # with Telegram Class #
10
20
  #########################################
11
-
12
-
13
- class Telegram:
14
- # Telegram bot token and chat ID
15
- # https://core.telegram.org/bots/api
16
- _TOKEN = None
17
- _CHAT_IDS = set() # Telegram bot chat IDs - multi group support - persistent caching
18
- _API_PARAMS = "?offset=-1&limit=1&timeout=2" # Generic API params - optimization
19
- _DEVFID = cfgget('devfid') # For reply message (pre text)
20
- _IN_MSG_ID = None
21
+ class Notify:
22
+ GLOBAL_NOTIFY = True # Enable Global notifications
23
+ _DEVFID = cfgget('devfid') # For reply message (pre text)
24
+ _SUBSCRIBERS = set() # Store set of notification objects: send_msg
21
25
 
22
26
  @staticmethod
23
- def __id_cache(mode):
27
+ def add_subscriber(instance):
24
28
  """
25
- pds - persistent data structure
26
- modes:
27
- r - recover, s - save
29
+ Add Notification agent like: Telegram
28
30
  """
29
- if mode == 's':
30
- # SAVE CACHE
31
- console_write("[NTFY] Save chatIDs cache...")
32
- with open('telegram.pds', 'w') as f:
33
- f.write(','.join([str(k) for k in Telegram._CHAT_IDS]))
34
- return
35
- try:
36
- # RESTORE CACHE
37
- console_write("[NTFY] Restore chatIDs cache...")
38
- with open('telegram.pds', 'r') as f:
39
- # set() comprehension
40
- Telegram._CHAT_IDS = {int(k) for k in f.read().strip().split(',')}
41
- except:
42
- pass
31
+ if isinstance(instance, Notify):
32
+ Notify._SUBSCRIBERS.add(instance)
33
+ return True
34
+ raise Exception("Subscribe error, Notify parent missing")
43
35
 
44
36
  @staticmethod
45
- def __bot_token():
46
- """Get bot token"""
47
- if Telegram._TOKEN is None:
48
- token = cfgget('telegram')
49
- if token is None or token == 'n/a':
50
- return None
51
- Telegram._TOKEN = token
52
- return Telegram._TOKEN
53
-
54
- @staticmethod
55
- def send_msg(text, reply_to=None, chat_id=None):
37
+ def send_msg(text, *args, **kwargs):
56
38
  """
57
- Send a message to the Telegram chat by chat_id
58
- :param text: text to send
59
- :param reply_to: reply to specific message, if None, simple reply
60
- :param chat_id: chat_id to reply on, if None, reply to all known
61
- RETURN None when telegram bot token is missing
39
+ This method has to be implemented by the child class
62
40
  """
63
- def _send(chid):
64
- """Send message to chat_id (chid)"""
65
- data = {"chat_id": chid, "text": f"{Telegram._DEVFID}⚙️\n{text}"}
66
- if isinstance(reply_to, int):
67
- data['reply_to_message_id'] = reply_to
68
- Telegram._IN_MSG_ID = reply_to
69
- _, _resp = urequests.post(url, headers={"Content-Type": "application/json"}, json=data, jsonify=True, sock_size=128)
70
- console_write(f"\tSend message:\n{data}\nresponse:\n{_resp}")
71
- return _resp
72
-
73
- def _get_chat_ids():
74
- """Return chat ID or None (in case of no token or cannot get ID)"""
75
- if len(Telegram._CHAT_IDS) == 0:
76
- Telegram.get_msg() # It will update the Telegram.CHAT_IDS
77
- console_write(f"\tGet chatIDs: {Telegram._CHAT_IDS}")
78
- return Telegram._CHAT_IDS
79
-
80
- # --------------------- FUNCTION MAIN ------------------------ #
81
- console_write("[NTFY] SEND MESSAGE")
82
- # Check bot token
83
- bot_token = Telegram.__bot_token()
84
- if bot_token is None:
85
- return None
86
- url = f"https://api.telegram.org/bot{bot_token}/sendMessage{Telegram._API_PARAMS}"
87
-
88
- verdict = ""
89
- # Reply to ALL (notification) - chat_id was not provided
90
- if chat_id is None:
91
- console_write("\tREPLY ALL")
92
- for _chat_id in _get_chat_ids():
93
- resp_json = _send(chid=_chat_id)
94
- verdict += f'Sent{_chat_id};' if resp_json['ok'] else str(resp_json)
95
- else:
96
- console_write(f"\tREPLY TO {chat_id}")
97
- # Direct reply to chat_id
98
- resp_json = _send(chid=chat_id)
99
- verdict = f'Sent{chat_id}' if resp_json['ok'] else str(resp_json)
100
- return verdict
41
+ raise NotImplementedError("Child class must implement send_msg method")
101
42
 
102
43
  @staticmethod
103
- def get_msg():
44
+ def message(text, *args, **kwargs):
104
45
  """
105
- Get the last message from the Telegram chat.
106
- RETURN None when telegram bot token is missing
46
+ Send message to all subscribers - Notify send_msg(text, ...) agents
47
+ :param text: text message to send
48
+ :param channels (optional): select communication interface(s) by class name
49
+ e.g. "Telegram", "MQTT" or an iterable of these.
50
+ If omitted or empty, sends over all available channels.
51
+ Telegram params (optional):
52
+ reply_to: message id to reply to (optional) - default: None
53
+ chat_id: chat identifier - default: None -> auto resolve in child class
54
+ MQTT client params (optional):
55
+ topic: mqtt topic to send the message - default: None -> auto resolve in child class
56
+ return: verdict and metrics
107
57
  """
108
-
109
- def _update_chat_ids():
110
- """
111
- Update known chat_id-s and cache them
112
- - return active chat_id frm resp_json
113
- """
114
- console_write("[NTFY GET] update chatIDs")
115
- _cid = None
116
- if resp_json.get("ok", None) and len(resp_json["result"]) > 0:
117
- _cid = resp_json["result"][-1]["message"]["chat"]["id"]
118
- # LIMIT Telegram._CHAT_IDS NOTIFICATION CACHE TO 3 IDs
119
- if len(Telegram._CHAT_IDS) < 4:
120
- _ids = len(Telegram._CHAT_IDS)
121
- Telegram._CHAT_IDS.add(_cid)
122
- if len(Telegram._CHAT_IDS) - _ids > 0: # optimized save (slow storage access)
123
- Telegram.__id_cache('s')
124
- else:
125
- Telegram.__id_cache('r')
126
- if len(Telegram._CHAT_IDS) == 0:
127
- error_message = resp_json.get("description", "Unknown error")
128
- raise Exception(f"Error retrieving chat ID: {error_message}")
129
- return _cid
130
-
131
- # --------------------- FUNCTION MAIN ------------------------ #
132
- console_write("[NTFY] GET MESSAGE")
133
- bot_token = Telegram.__bot_token()
134
- if bot_token is None:
135
- return None
136
- response = {'sender': None, 'text': None, 'm_id': -1, 'c_id': None}
137
- url = f"https://api.telegram.org/bot{bot_token}/getUpdates{Telegram._API_PARAMS}"
138
- console_write(f"\t1/2[GET] request: {url}")
139
- _, resp_json = urequests.get(url, jsonify=True, sock_size=128)
140
- if len(resp_json["result"]) > 0:
141
- response['c_id'] = _update_chat_ids()
142
- resp = resp_json["result"][-1]["message"]
143
- response['sender'] = f"{resp['chat']['first_name']}{resp['chat']['last_name']}" if resp['chat'].get('username', None) is None else resp['chat']['username']
144
- response['text'], response['m_id'] = resp['text'], resp['message_id']
145
- console_write(f"\t2/2[GET] response: {response}")
146
- return response
58
+ errors, channels, interfaces = 0, kwargs.get("channels", ()), set()
59
+ channels = (channels,) if isinstance(channels, str) else tuple(channels)
60
+ for s in Notify._SUBSCRIBERS:
61
+ name = s.__class__.__name__
62
+ try:
63
+ if len(channels) == 0 or name in channels:
64
+ s.send_msg(text, *args, **kwargs)
65
+ interfaces.add(name)
66
+ except Exception as e:
67
+ syslog(f"[ERR] Notify.{name}: {e}")
68
+ errors+=1
69
+ return (f"Sent over {', '.join(interfaces)} ({len(interfaces)}/{len(Notify._SUBSCRIBERS)}) client(s)"
70
+ f" - errors: ({errors})")
147
71
 
148
72
  @staticmethod
149
- def receive_eval():
73
+ def notifications(state=None):
150
74
  """
151
- READ - VALIDATE - EXECUTE - REPLY LOOP
152
- - can be used in async loop
153
- RETURN None when telegram bot token is missing
75
+ Setter for disable/enable notification messages (over LM_system)
76
+ :param state: True/False/ None(default) - show current state
154
77
  """
155
-
156
- console_write("[NTFY] REC&EVAL sequence")
157
-
158
- # Return data structure template
159
- verdict = None
160
-
161
- def lm_execute(cmd_args):
162
- nonlocal verdict
163
- if lm_is_loaded(cmd_args[0]):
164
- verdict = f'[UP] Exec: {" ".join(cmd_args[0])}'
165
- try:
166
- _, out = lm_exec(cmd_args)
167
- except Exception as e:
168
- out = str(e)
169
- Telegram.send_msg(out, reply_to=m_id)
170
- else:
171
- verdict = f'[UP] NoAccess: {cmd_args[0]}'
172
- Telegram._IN_MSG_ID = m_id
173
-
174
- # -------------------------- FUNCTION MAIN -------------------------- #
175
- # Poll telegram chat
176
- data = Telegram.get_msg()
177
- if data is None:
178
- return data
179
- # Get msg, msg_id, chat_id as main input data source
180
- msg_in, m_id, c_id = data['text'], data['m_id'], data['c_id']
181
- if msg_in is not None and m_id != Telegram._IN_MSG_ID:
182
- # replace single/double quotation to apostrophe (str syntax for repl interpretation)
183
- msg_in = msg_in.replace('‘', "'").replace('’', "'").replace('“', '"').replace('”', '"')
184
- # [TELEGRAM CMD] /PING - Get auto reply from node - loaded modules
185
- # Example: /ping
186
- if msg_in.startswith('/ping'):
187
- # Parse loaded modules
188
- _loaded_mods = [lm.replace('LM_', '') for lm in modules if lm.startswith('LM_')] + ['task']
189
- Telegram.send_msg(', '.join(_loaded_mods), reply_to=m_id, chat_id=c_id)
190
- # [TELEGRAM CMD] /CMD_SELECT - Load Module execution handling - SELECTED DEV. MODE
191
- # Example: /cmd_select device module func param(s)
192
- elif msg_in.startswith('/cmd_select'):
193
- cmd_lm = msg_in.replace('/cmd_select', '').strip().split()
194
- # [Compare] cmd selected device param with DEVFID (device/prompt name)
195
- if cmd_lm[0] in Telegram._DEVFID:
196
- lm_execute(cmd_lm[1:])
197
- else:
198
- verdict = f'[UP] NoSelected: {cmd_lm[0]}'
199
- # [TELEGRAM CMD] /CMD - Load Module execution handling - ALL mode
200
- # Example: /cmd module func param(s)
201
- elif msg_in.startswith('/cmd'):
202
- cmd_lm = msg_in.replace('/cmd', '').strip().split()
203
- lm_execute(cmd_lm)
204
- else:
205
- verdict = "[UP] NoExec"
206
- console_write(f"\tREC&EVAL: {verdict}")
207
- return verdict
78
+ if isinstance(state, bool):
79
+ Notify.GLOBAL_NOTIFY = state
80
+ targets = ", ".join(s.__class__.__name__ for s in Notify._SUBSCRIBERS)
81
+ return f"Notifications[{targets}]: {'enabled' if Notify.GLOBAL_NOTIFY else 'disabled'}"
208
82
 
209
83
  @staticmethod
210
- def set_commands():
84
+ def notify(text, *args, **kwargs):
211
85
  """
212
- Set Custom Commands to the Telegram chat.
213
- RETURN None when telegram bot token is missing
86
+ Notification sender for Load Modules
214
87
  """
88
+ if Notify.GLOBAL_NOTIFY:
89
+ return Notify.message(text, *args, **kwargs)
90
+ return "Notifications disabled"
215
91
 
216
- console_write("[NTFY] SET DEFAULT COMMANDS")
217
- bot_token = Telegram.__bot_token()
218
- if bot_token is None:
219
- return None
220
- url = f"https://api.telegram.org/bot{bot_token}/setMyCommands{Telegram._API_PARAMS}"
221
- data = {"commands": [{"command": "ping", "description": "Ping All endpoints, return active modules."},
222
- {"command": "cmd", "description": "Command to All endpoints (only loaded modules)."},
223
- {"command": "cmd_select", "description": "Command to Selected endpoints: device module func"},
224
- ]}
225
- _, resp_json = urequests.post(url, headers={"Content-Type": "application/json"}, json=data, jsonify=True, sock_size=128)
226
- return 'Custom commands was set' if resp_json['ok'] else str(resp_json)
92
+ @staticmethod
93
+ def lm_execute(cmd_args, jsonify=False, secure=True):
94
+ """Load Module Executor with basic access handling"""
95
+ state = False
96
+ if secure and not lm_is_loaded(cmd_args[0]):
97
+ return state, f"NotAllowed {cmd_args[0]}"
98
+ try:
99
+ state, out = lm_exec(cmd_args, jsonify)
100
+ except Exception as e:
101
+ out = str(e)
102
+ return state, out