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.
- env/driver_cp210x/.DS_Store +0 -0
- env/driver_cp210x/macOS_VCP_Driver/SiLabsUSBDriverDisk.dmg +0 -0
- env/driver_cp210x/macOS_VCP_Driver/macOS_VCP_Driver_Release_Notes.txt +17 -1
- micrOS/micropython/esp32-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/esp32c3-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/esp32c6-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/esp32s2-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/esp32s2-LOLIN_MINI-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/esp32s3-4MBflash-20241129-v1.24.1.bin +0 -0
- micrOS/micropython/esp32s3-8MBflash-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/esp32s3_spiram_oct-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/rpi-pico-w-20251209-v1.27.0.uf2 +0 -0
- micrOS/micropython/tinypico-20251209-v1.27.0.bin +0 -0
- micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +191 -151
- micrOS/source/Auth.py +37 -0
- micrOS/source/Common.py +376 -102
- micrOS/source/Config.py +55 -25
- micrOS/source/Debug.py +54 -193
- micrOS/source/Espnow.py +404 -0
- micrOS/source/Files.py +207 -0
- micrOS/source/Hooks.py +88 -16
- micrOS/source/InterConnect.py +130 -46
- micrOS/source/Interrupts.py +8 -8
- micrOS/source/Logger.py +131 -0
- micrOS/source/Network.py +41 -21
- micrOS/source/Notify.py +74 -198
- micrOS/source/Pacman.py +326 -0
- micrOS/source/Scheduler.py +18 -55
- micrOS/source/Server.py +84 -217
- micrOS/source/Shell.py +103 -93
- micrOS/source/Tasks.py +239 -173
- micrOS/source/Time.py +21 -22
- micrOS/source/Types.py +89 -54
- micrOS/source/Web.py +485 -0
- micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Debug.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Files.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Scheduler.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Server.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Shell.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/replhelper.cpython-312.pyc +0 -0
- micrOS/source/helpers.py +132 -0
- micrOS/source/micrOS.py +25 -21
- micrOS/source/micrOSloader.py +14 -23
- micrOS/source/microIO.py +94 -57
- toolkit/simulator_lib/LP_darwin.py → micrOS/source/modules/IO_esp32.py +22 -11
- micrOS/source/{IO_esp32c3.py → modules/IO_esp32c3.py} +6 -1
- micrOS/source/modules/IO_esp32c6.py +38 -0
- micrOS/source/{IO_esp32s2.py → modules/IO_esp32s2.py} +6 -1
- micrOS/source/{IO_esp32s3.py → modules/IO_esp32s3.py} +43 -2
- micrOS/source/modules/IO_m5stamp.py +86 -0
- micrOS/source/{IO_qtpy.py → modules/IO_qtpy.py} +28 -18
- micrOS/source/{IO_tinypico.py → modules/IO_tinypico.py} +48 -3
- micrOS/source/modules/LM_L298N.py +161 -0
- {toolkit/workspace/precompiled → micrOS/source/modules}/LM_L9110_DCmotor.py +4 -4
- micrOS/source/{LM_OV2640.py → modules/LM_OV2640.py} +53 -42
- micrOS/source/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +5 -5
- micrOS/source/{LM_aht10.py → modules/LM_aht10.py} +12 -4
- micrOS/source/{LM_bme280.py → modules/LM_bme280.py} +13 -25
- micrOS/source/{LM_buzzer.py → modules/LM_buzzer.py} +42 -40
- micrOS/source/{LM_cct.py → modules/LM_cct.py} +22 -27
- micrOS/source/modules/LM_cluster.py +255 -0
- micrOS/source/{LM_co2.py → modules/LM_co2.py} +13 -6
- micrOS/source/{LM_dht11.py → modules/LM_dht11.py} +13 -29
- micrOS/source/{LM_dht22.py → modules/LM_dht22.py} +13 -28
- micrOS/source/{LM_dimmer.py → modules/LM_dimmer.py} +19 -16
- micrOS/source/modules/LM_distance.py +135 -0
- micrOS/source/{LM_ds18.py → modules/LM_ds18.py} +12 -4
- micrOS/source/{LM_esp32.py → modules/LM_esp32.py} +16 -4
- micrOS/source/modules/LM_espnow.py +53 -0
- micrOS/source/modules/LM_fileserver.py +265 -0
- micrOS/source/{LM_gameOfLife.py → modules/LM_gameOfLife.py} +5 -5
- micrOS/source/{LM_genIO.py → modules/LM_genIO.py} +49 -35
- micrOS/source/modules/LM_haptic.py +111 -0
- micrOS/source/modules/LM_i2c.py +61 -0
- micrOS/source/{LM_i2s_mic.py → modules/LM_i2s_mic.py} +20 -23
- micrOS/source/{LM_ld2410.py → modules/LM_ld2410.py} +3 -3
- micrOS/source/{LM_light_sensor.py → modules/LM_light_sensor.py} +22 -26
- micrOS/source/modules/LM_mh_z19c.py +198 -0
- micrOS/source/modules/LM_neoeffects.py +284 -0
- micrOS/source/{LM_neopixel.py → modules/LM_neopixel.py} +26 -31
- micrOS/source/{LM_oled.py → modules/LM_oled.py} +28 -20
- micrOS/source/{LM_oled_sh1106.py → modules/LM_oled_sh1106.py} +28 -24
- micrOS/source/{LM_oled_ui.py → modules/LM_oled_ui.py} +132 -174
- micrOS/source/modules/LM_pacman.py +320 -0
- micrOS/source/{LM_presence.py → modules/LM_presence.py} +24 -36
- micrOS/source/modules/LM_qmi8658.py +204 -0
- micrOS/source/{LM_rencoder.py → modules/LM_rencoder.py} +40 -11
- micrOS/source/modules/LM_rest.py +81 -0
- micrOS/source/{LM_rgb.py → modules/LM_rgb.py} +25 -34
- micrOS/source/{LM_rgbcct.py → modules/LM_rgbcct.py} +5 -5
- micrOS/source/{LM_roboarm.py → modules/LM_roboarm.py} +37 -45
- micrOS/source/modules/LM_robustness.py +137 -0
- micrOS/source/{LM_rp2w.py → modules/LM_rp2w.py} +3 -0
- micrOS/source/{LM_sdcard.py → modules/LM_sdcard.py} +3 -0
- micrOS/source/{LM_servo.py → modules/LM_servo.py} +4 -4
- micrOS/source/modules/LM_sound_event.py +751 -0
- micrOS/source/{LM_stepper.py → modules/LM_stepper.py} +8 -8
- micrOS/source/{LM_switch.py → modules/LM_switch.py} +21 -18
- micrOS/source/{LM_system.py → modules/LM_system.py} +96 -59
- micrOS/source/modules/LM_tcs3472.py +187 -0
- micrOS/source/modules/LM_telegram.py +388 -0
- micrOS/source/modules/LM_trackball.py +287 -0
- micrOS/source/modules/LM_veml7700.py +159 -0
- micrOS/source/modules/LM_web.py +38 -0
- micrOS/source/urequests.py +204 -91
- {toolkit/workspace/precompiled → micrOS/source/web}/dashboard.html +9 -4
- micrOS/source/web/editor.js +440 -0
- micrOS/source/web/filesui.html +178 -0
- micrOS/source/web/filesui.js +338 -0
- micrOS/source/{index.html → web/index.html} +44 -2
- micrOS/source/web/uapi.js +103 -0
- micrOS/source/web/udashboard.js +129 -0
- micrOS/source/web/ustyle.css +55 -0
- micrOS/source/web/uwidgets.js +172 -0
- micrOS/source/web/uwidgets_pro.js +99 -0
- micrOS/utests/__init__.py +0 -0
- micrOS/utests/test_scheduler.py +435 -0
- {micrOSDevToolKit-2.1.5.data → microsdevtoolkit-2.26.1.data}/scripts/devToolKit.py +47 -4
- {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/METADATA +392 -279
- microsdevtoolkit-2.26.1.dist-info/RECORD +396 -0
- {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/WHEEL +1 -1
- toolkit/DevEnvCompile.py +63 -33
- toolkit/DevEnvOTA.py +72 -22
- toolkit/DevEnvUSB.py +147 -77
- toolkit/Gateway.py +9 -9
- toolkit/LM_to_compile.dat +12 -4
- toolkit/MicrOSDevEnv.py +129 -51
- toolkit/WebRepl.py +73 -0
- toolkit/dashboard_apps/BackupRestore.py +171 -0
- toolkit/dashboard_apps/CCTDemo.py +12 -17
- toolkit/dashboard_apps/CCTTest.py +20 -24
- toolkit/dashboard_apps/CamStream.py +2 -6
- toolkit/dashboard_apps/CatGame.py +14 -16
- toolkit/dashboard_apps/Dimmer.py +11 -21
- toolkit/dashboard_apps/GetVersion.py +11 -19
- toolkit/dashboard_apps/MicrophoneTest.py +2 -7
- toolkit/dashboard_apps/NeoEffectsDemo.py +22 -35
- toolkit/dashboard_apps/NeopixelTest.py +20 -25
- toolkit/dashboard_apps/PresenceTest.py +2 -8
- toolkit/dashboard_apps/QMI8685_GYRO.py +68 -0
- toolkit/dashboard_apps/RGBTest.py +20 -24
- toolkit/dashboard_apps/RoboArm.py +24 -32
- toolkit/dashboard_apps/SED_test.py +10 -14
- toolkit/dashboard_apps/SensorsTest.py +61 -0
- toolkit/dashboard_apps/SystemTest.py +219 -117
- toolkit/dashboard_apps/Template_app.py +12 -19
- toolkit/dashboard_apps/_app_base.py +34 -0
- toolkit/dashboard_apps/_gyro_visualizer.py +78 -0
- toolkit/dashboard_apps/uLightDemo.py +15 -24
- toolkit/index.html +6 -5
- toolkit/lib/LocalMachine.py +6 -1
- toolkit/lib/MicrosFiles.py +46 -0
- toolkit/lib/Repository.py +64 -0
- toolkit/lib/TerminalColors.py +4 -0
- toolkit/lib/macroScript.py +371 -0
- toolkit/lib/micrOSClient.py +124 -51
- toolkit/lib/micrOSClientHistory.py +156 -0
- toolkit/lib/pip_package_installer.py +31 -4
- toolkit/micrOSdashboard.py +16 -21
- toolkit/micrOSlint.py +28 -10
- toolkit/simulator_lib/.DS_Store +0 -0
- micrOS/source/IO_esp32.py → toolkit/simulator_lib/IO_darwin.py +3 -0
- toolkit/simulator_lib/__pycache__/IO_darwin.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/aioespnow.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/camera.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/framebuf.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/machine.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/micropython.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/mip.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/neopixel.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/network.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/sim_common.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/simgc.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/simulator.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/uasyncio.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/uos.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/urandom.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/usocket.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/ussl.cpython-312.pyc +0 -0
- toolkit/simulator_lib/aioespnow.py +28 -0
- toolkit/simulator_lib/camera.py +84 -0
- toolkit/simulator_lib/dht.py +1 -1
- toolkit/simulator_lib/framebuf.py +49 -1
- toolkit/simulator_lib/machine.py +32 -2
- toolkit/simulator_lib/micropython.py +3 -3
- toolkit/simulator_lib/mip.py +165 -0
- toolkit/simulator_lib/neopixel.py +3 -2
- toolkit/simulator_lib/network.py +2 -1
- toolkit/simulator_lib/node_config.json +2 -3
- toolkit/simulator_lib/ntptime.py +1 -1
- toolkit/simulator_lib/{sim_console.py → sim_common.py} +2 -3
- toolkit/simulator_lib/simgc.py +6 -2
- toolkit/simulator_lib/simulator.py +138 -46
- toolkit/simulator_lib/uasyncio.py +34 -3
- toolkit/simulator_lib/uos.py +147 -0
- toolkit/simulator_lib/urandom.py +4 -0
- toolkit/simulator_lib/usocket.py +5 -1
- toolkit/simulator_lib/view01.jpg +0 -0
- toolkit/simulator_lib/view02.jpg +0 -0
- toolkit/socketClient.py +43 -23
- toolkit/user_data/webhooks/generic.py +1 -1
- toolkit/user_data/webhooks/macro.py +44 -0
- toolkit/user_data/webhooks/template.macro +20 -0
- toolkit/user_data/webhooks/template.py +1 -1
- toolkit/workspace/precompiled/Auth.mpy +0 -0
- toolkit/workspace/precompiled/Common.mpy +0 -0
- toolkit/workspace/precompiled/Config.mpy +0 -0
- toolkit/workspace/precompiled/Debug.mpy +0 -0
- toolkit/workspace/precompiled/Espnow.mpy +0 -0
- toolkit/workspace/precompiled/Files.mpy +0 -0
- toolkit/workspace/precompiled/Hooks.mpy +0 -0
- toolkit/workspace/precompiled/InterConnect.mpy +0 -0
- toolkit/workspace/precompiled/Interrupts.mpy +0 -0
- toolkit/workspace/precompiled/Logger.mpy +0 -0
- toolkit/workspace/precompiled/Network.mpy +0 -0
- toolkit/workspace/precompiled/Notify.mpy +0 -0
- toolkit/workspace/precompiled/Pacman.mpy +0 -0
- toolkit/workspace/precompiled/Scheduler.mpy +0 -0
- toolkit/workspace/precompiled/Server.mpy +0 -0
- toolkit/workspace/precompiled/Shell.mpy +0 -0
- toolkit/workspace/precompiled/Tasks.mpy +0 -0
- toolkit/workspace/precompiled/Time.mpy +0 -0
- toolkit/workspace/precompiled/Types.mpy +0 -0
- toolkit/workspace/precompiled/Web.mpy +0 -0
- toolkit/workspace/precompiled/_mpy.version +1 -1
- toolkit/workspace/precompiled/config/_git.keep +0 -0
- toolkit/workspace/precompiled/helpers.mpy +0 -0
- toolkit/workspace/precompiled/micrOS.mpy +0 -0
- toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
- toolkit/workspace/precompiled/microIO.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_esp32.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_esp32c3.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_esp32c6.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_esp32s2.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_esp32s3.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_m5stamp.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_qtpy.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_rp2.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_tinypico.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_L298N.mpy +0 -0
- {micrOS/source → toolkit/workspace/precompiled/modules}/LM_L9110_DCmotor.py +4 -4
- toolkit/workspace/precompiled/modules/LM_OV2640.mpy +0 -0
- toolkit/workspace/precompiled/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +5 -5
- toolkit/workspace/precompiled/modules/LM_aht10.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_bme280.mpy +0 -0
- toolkit/workspace/precompiled/{LM_buzzer.mpy → modules/LM_buzzer.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_cct.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_cluster.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_co2.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_dht11.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_dht22.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_dimmer.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_distance.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_ds18.mpy +0 -0
- toolkit/workspace/precompiled/{LM_esp32.py → modules/LM_esp32.py} +16 -4
- toolkit/workspace/precompiled/modules/LM_espnow.py +53 -0
- toolkit/workspace/precompiled/modules/LM_fileserver.mpy +0 -0
- toolkit/workspace/precompiled/{LM_gameOfLife.mpy → modules/LM_gameOfLife.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_genIO.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_haptic.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_i2c.py +61 -0
- toolkit/workspace/precompiled/modules/LM_i2s_mic.mpy +0 -0
- toolkit/workspace/precompiled/{LM_ld2410.mpy → modules/LM_ld2410.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_light_sensor.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_mh_z19c.py +198 -0
- toolkit/workspace/precompiled/modules/LM_neoeffects.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_neopixel.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_oled.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_oled_sh1106.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_oled_ui.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_pacman.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_presence.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_qmi8658.py +204 -0
- toolkit/workspace/precompiled/{LM_rencoder.py → modules/LM_rencoder.py} +40 -11
- toolkit/workspace/precompiled/modules/LM_rest.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_rgb.mpy +0 -0
- toolkit/workspace/precompiled/{LM_rgbcct.mpy → modules/LM_rgbcct.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_roboarm.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_robustness.py +137 -0
- toolkit/workspace/precompiled/{LM_rp2w.py → modules/LM_rp2w.py} +3 -0
- toolkit/workspace/precompiled/{LM_sdcard.py → modules/LM_sdcard.py} +3 -0
- toolkit/workspace/precompiled/{LM_servo.mpy → modules/LM_servo.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_sound_event.mpy +0 -0
- toolkit/workspace/precompiled/{LM_stepper.mpy → modules/LM_stepper.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_switch.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_system.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_tcs3472.py +187 -0
- toolkit/workspace/precompiled/modules/LM_telegram.mpy +0 -0
- toolkit/workspace/precompiled/{LM_tinyrgb.mpy → modules/LM_tinyrgb.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_trackball.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_veml7700.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_web.mpy +0 -0
- toolkit/workspace/precompiled/urequests.mpy +0 -0
- {micrOS/source → toolkit/workspace/precompiled/web}/dashboard.html +9 -4
- toolkit/workspace/precompiled/web/editor.js +440 -0
- toolkit/workspace/precompiled/web/filesui.html +178 -0
- toolkit/workspace/precompiled/web/filesui.js +338 -0
- toolkit/workspace/precompiled/{index.html → web/index.html} +44 -2
- toolkit/workspace/precompiled/web/uapi.js +103 -0
- toolkit/workspace/precompiled/web/udashboard.js +129 -0
- toolkit/workspace/precompiled/web/ustyle.css +55 -0
- toolkit/workspace/precompiled/web/uwidgets.js +172 -0
- toolkit/workspace/precompiled/web/uwidgets_pro.js +99 -0
- env/driver_cp210x/CH34XSER_MAC/CH34X_DRV_INSTALL_INSTRUCTIONS.pdf +0 -0
- env/driver_cp210x/CH34XSER_MAC/CH34xVCPDriver.pkg +0 -0
- micrOS/micropython/esp32-20231005-v1.21.0.bin +0 -0
- micrOS/micropython/esp32c3-GENERIC-20240105-v1.22.1.bin +0 -0
- micrOS/micropython/esp32c3-GENERIC-20240222-v1.22.2.bin +0 -0
- micrOS/micropython/esp32s2-GENERIC-20240105-v1.22.1.bin +0 -0
- micrOS/micropython/esp32s2-LOLIN_MINI-20220618-v1.19.1.bin +0 -0
- micrOS/micropython/esp32s3-GENERIC-20240105-v1.22.1.bin +0 -0
- micrOS/micropython/esp32s3_spiram_oct-20231005-v1.21.0.bin +0 -0
- micrOS/micropython/rpi-pico-w-20231005-v1.21.0.uf2 +0 -0
- micrOS/micropython/tinypico-20231005-v1.21.0.bin +0 -0
- micrOS/micropython/tinypico-usbc-UM-20240105-v1.22.1.bin +0 -0
- micrOS/source/LM_L298N_DCmotor.py +0 -86
- micrOS/source/LM_catgame.py +0 -74
- micrOS/source/LM_dashboard_be.py +0 -37
- micrOS/source/LM_demo.py +0 -85
- micrOS/source/LM_distance.py +0 -88
- micrOS/source/LM_i2c.py +0 -44
- micrOS/source/LM_intercon.py +0 -57
- micrOS/source/LM_keychain.py +0 -318
- micrOS/source/LM_lmpacman.py +0 -126
- micrOS/source/LM_neoeffects.py +0 -327
- micrOS/source/LM_pet_feeder.py +0 -76
- micrOS/source/LM_ph_sensor.py +0 -51
- micrOS/source/LM_rest.py +0 -40
- micrOS/source/LM_robustness.py +0 -73
- micrOS/source/LM_telegram.py +0 -96
- micrOS/source/reset.py +0 -11
- micrOS/source/uapi.js +0 -76
- micrOS/source/udashboard.js +0 -137
- micrOS/source/ustyle.css +0 -28
- micrOS/source/uwidgets.js +0 -179
- micrOSDevToolKit-2.1.5.dist-info/RECORD +0 -337
- toolkit/dashboard_apps/AirQualityBME280.py +0 -36
- toolkit/dashboard_apps/AirQualityDHT22_CO2.py +0 -36
- toolkit/lib/file_extensions.py +0 -16
- toolkit/simulator_lib/__pycache__/LP_darwin.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/LP_darwin.cpython-38.pyc +0 -0
- toolkit/simulator_lib/__pycache__/LP_darwin.cpython-39.pyc +0 -0
- toolkit/simulator_lib/__pycache__/sim_console.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/sim_console.cpython-38.pyc +0 -0
- toolkit/simulator_lib/__pycache__/sim_console.cpython-39.pyc +0 -0
- toolkit/workspace/precompiled/IO_esp32.mpy +0 -0
- toolkit/workspace/precompiled/IO_esp32c3.mpy +0 -0
- toolkit/workspace/precompiled/IO_esp32s2.mpy +0 -0
- toolkit/workspace/precompiled/IO_esp32s3.mpy +0 -0
- toolkit/workspace/precompiled/IO_qtpy.mpy +0 -0
- toolkit/workspace/precompiled/IO_rp2.mpy +0 -0
- toolkit/workspace/precompiled/IO_tinypico.mpy +0 -0
- toolkit/workspace/precompiled/LM_L298N_DCmotor.mpy +0 -0
- toolkit/workspace/precompiled/LM_OV2640.mpy +0 -0
- toolkit/workspace/precompiled/LM_aht10.mpy +0 -0
- toolkit/workspace/precompiled/LM_bme280.mpy +0 -0
- toolkit/workspace/precompiled/LM_catgame.py +0 -74
- toolkit/workspace/precompiled/LM_cct.mpy +0 -0
- toolkit/workspace/precompiled/LM_co2.mpy +0 -0
- toolkit/workspace/precompiled/LM_dashboard_be.py +0 -37
- toolkit/workspace/precompiled/LM_demo.py +0 -85
- toolkit/workspace/precompiled/LM_dht11.mpy +0 -0
- toolkit/workspace/precompiled/LM_dht22.mpy +0 -0
- toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
- toolkit/workspace/precompiled/LM_distance.py +0 -88
- toolkit/workspace/precompiled/LM_ds18.mpy +0 -0
- toolkit/workspace/precompiled/LM_genIO.mpy +0 -0
- toolkit/workspace/precompiled/LM_i2c.py +0 -44
- toolkit/workspace/precompiled/LM_i2s_mic.mpy +0 -0
- toolkit/workspace/precompiled/LM_intercon.mpy +0 -0
- toolkit/workspace/precompiled/LM_keychain.mpy +0 -0
- toolkit/workspace/precompiled/LM_light_sensor.mpy +0 -0
- toolkit/workspace/precompiled/LM_lmpacman.mpy +0 -0
- toolkit/workspace/precompiled/LM_neoeffects.mpy +0 -0
- toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
- toolkit/workspace/precompiled/LM_oled.mpy +0 -0
- toolkit/workspace/precompiled/LM_oled_sh1106.mpy +0 -0
- toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
- toolkit/workspace/precompiled/LM_pet_feeder.py +0 -76
- toolkit/workspace/precompiled/LM_ph_sensor.py +0 -51
- toolkit/workspace/precompiled/LM_presence.mpy +0 -0
- toolkit/workspace/precompiled/LM_rest.mpy +0 -0
- toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
- toolkit/workspace/precompiled/LM_roboarm.mpy +0 -0
- toolkit/workspace/precompiled/LM_robustness.py +0 -73
- toolkit/workspace/precompiled/LM_switch.mpy +0 -0
- toolkit/workspace/precompiled/LM_system.mpy +0 -0
- toolkit/workspace/precompiled/LM_telegram.mpy +0 -0
- toolkit/workspace/precompiled/reset.mpy +0 -0
- toolkit/workspace/precompiled/uapi.js +0 -76
- toolkit/workspace/precompiled/udashboard.js +0 -137
- toolkit/workspace/precompiled/ustyle.css +0 -28
- toolkit/workspace/precompiled/uwidgets.js +0 -179
- /toolkit/user_data/node_config_archive/.include → /micrOS/source/config/_git.keep +0 -0
- /micrOS/source/{IO_rp2.py → modules/IO_rp2.py} +0 -0
- /micrOS/source/{LM_tinyrgb.py → modules/LM_tinyrgb.py} +0 -0
- {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info/licenses}/LICENSE +0 -0
- {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,
|
|
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
|
-
|
|
68
|
+
syslog(f"[ERR] set_dev_uid: {e}")
|
|
55
69
|
|
|
56
70
|
|
|
57
71
|
def get_mac():
|
|
58
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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 =
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
208
|
+
syslog(f"[ERR][AP] config failed: {e2}")
|
|
188
209
|
if not (ap_if.active() and str(ap_if.config('essid')) == str(_essid)):
|
|
189
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
|
15
|
+
from Debug import syslog
|
|
6
16
|
|
|
7
17
|
#########################################
|
|
8
18
|
# micrOS Notifications #
|
|
9
19
|
# with Telegram Class #
|
|
10
20
|
#########################################
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
#
|
|
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
|
|
27
|
+
def add_subscriber(instance):
|
|
24
28
|
"""
|
|
25
|
-
|
|
26
|
-
modes:
|
|
27
|
-
r - recover, s - save
|
|
29
|
+
Add Notification agent like: Telegram
|
|
28
30
|
"""
|
|
29
|
-
if
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
44
|
+
def message(text, *args, **kwargs):
|
|
104
45
|
"""
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
|
73
|
+
def notifications(state=None):
|
|
150
74
|
"""
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
|
84
|
+
def notify(text, *args, **kwargs):
|
|
211
85
|
"""
|
|
212
|
-
|
|
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
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return
|
|
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
|