micrOSDevToolKit 2.9.1__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/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-20241129-v1.24.1.bin → 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 +167 -163
- micrOS/source/Auth.py +37 -0
- micrOS/source/Common.py +361 -116
- micrOS/source/Config.py +32 -22
- micrOS/source/Debug.py +50 -94
- micrOS/source/Espnow.py +377 -100
- micrOS/source/Files.py +207 -0
- micrOS/source/Hooks.py +48 -20
- micrOS/source/InterConnect.py +126 -42
- micrOS/source/Interrupts.py +6 -6
- micrOS/source/Logger.py +63 -26
- micrOS/source/Network.py +41 -21
- micrOS/source/Notify.py +48 -22
- micrOS/source/Pacman.py +326 -0
- micrOS/source/Scheduler.py +14 -54
- micrOS/source/Server.py +67 -69
- micrOS/source/Shell.py +99 -91
- micrOS/source/Tasks.py +141 -95
- micrOS/source/Time.py +19 -18
- micrOS/source/Types.py +53 -9
- micrOS/source/Web.py +381 -76
- 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/config/_git.keep +0 -0
- micrOS/source/helpers.py +132 -0
- micrOS/source/micrOS.py +17 -7
- micrOS/source/micrOSloader.py +5 -12
- micrOS/source/microIO.py +44 -20
- micrOS/source/modules/IO_esp32c6.py +38 -0
- micrOS/source/{IO_esp32s3.py → modules/IO_esp32s3.py} +37 -1
- micrOS/source/{IO_m5stamp.py → modules/IO_m5stamp.py} +35 -1
- micrOS/source/{IO_qtpy.py → modules/IO_qtpy.py} +22 -17
- micrOS/source/{IO_tinypico.py → modules/IO_tinypico.py} +38 -0
- micrOS/source/modules/LM_L298N.py +161 -0
- {toolkit/workspace/precompiled → micrOS/source/modules}/LM_L9110_DCmotor.py +3 -3
- micrOS/source/{LM_OV2640.py → modules/LM_OV2640.py} +45 -27
- micrOS/source/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +3 -3
- micrOS/source/{LM_aht10.py → modules/LM_aht10.py} +2 -2
- micrOS/source/{LM_bme280.py → modules/LM_bme280.py} +3 -3
- micrOS/source/{LM_buzzer.py → modules/LM_buzzer.py} +18 -25
- micrOS/source/{LM_cct.py → modules/LM_cct.py} +17 -21
- micrOS/source/modules/LM_cluster.py +255 -0
- micrOS/source/{LM_co2.py → modules/LM_co2.py} +3 -3
- micrOS/source/{LM_dht11.py → modules/LM_dht11.py} +2 -2
- micrOS/source/{LM_dht22.py → modules/LM_dht22.py} +2 -2
- micrOS/source/{LM_dimmer.py → modules/LM_dimmer.py} +9 -9
- micrOS/source/{LM_distance.py → modules/LM_distance.py} +4 -6
- micrOS/source/{LM_ds18.py → modules/LM_ds18.py} +2 -2
- micrOS/source/{LM_esp32.py → modules/LM_esp32.py} +5 -0
- micrOS/source/modules/LM_espnow.py +53 -0
- micrOS/source/modules/LM_fileserver.py +265 -0
- micrOS/source/{LM_genIO.py → modules/LM_genIO.py} +52 -37
- micrOS/source/{LM_haptic.py → modules/LM_haptic.py} +2 -2
- {toolkit/workspace/precompiled → micrOS/source/modules}/LM_i2c.py +5 -4
- micrOS/source/{LM_i2s_mic.py → modules/LM_i2s_mic.py} +6 -7
- micrOS/source/{LM_ld2410.py → modules/LM_ld2410.py} +2 -2
- micrOS/source/{LM_light_sensor.py → modules/LM_light_sensor.py} +10 -21
- 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} +19 -23
- micrOS/source/{LM_oled.py → modules/LM_oled.py} +2 -2
- micrOS/source/{LM_oled_sh1106.py → modules/LM_oled_sh1106.py} +3 -3
- micrOS/source/{LM_oled_ui.py → modules/LM_oled_ui.py} +72 -64
- micrOS/source/modules/LM_pacman.py +320 -0
- micrOS/source/{LM_presence.py → modules/LM_presence.py} +11 -15
- micrOS/source/modules/LM_qmi8658.py +204 -0
- micrOS/source/{LM_rencoder.py → modules/LM_rencoder.py} +2 -2
- micrOS/source/{LM_rest.py → modules/LM_rest.py} +4 -6
- micrOS/source/{LM_rgb.py → modules/LM_rgb.py} +21 -29
- micrOS/source/{LM_roboarm.py → modules/LM_roboarm.py} +8 -8
- micrOS/source/modules/LM_robustness.py +137 -0
- micrOS/source/{LM_servo.py → modules/LM_servo.py} +3 -3
- micrOS/source/{LM_stepper.py → modules/LM_stepper.py} +5 -5
- micrOS/source/{LM_switch.py → modules/LM_switch.py} +11 -9
- micrOS/source/{LM_system.py → modules/LM_system.py} +38 -32
- micrOS/source/modules/LM_tcs3472.py +187 -0
- micrOS/source/{LM_telegram.py → modules/LM_telegram.py} +164 -116
- micrOS/source/{LM_trackball.py → modules/LM_trackball.py} +3 -3
- micrOS/source/{LM_veml7700.py → modules/LM_veml7700.py} +2 -2
- micrOS/source/modules/LM_web.py +38 -0
- micrOS/source/urequests.py +39 -15
- {toolkit/workspace/precompiled → micrOS/source/web}/dashboard.html +4 -0
- micrOS/source/web/editor.js +440 -0
- micrOS/source/web/filesui.html +178 -0
- micrOS/source/web/filesui.js +338 -0
- {toolkit/workspace/precompiled → micrOS/source/web}/index.html +44 -2
- micrOS/source/{uapi.js → web/uapi.js} +48 -7
- micrOS/source/{ustyle.css → web/ustyle.css} +6 -3
- micrOS/utests/__init__.py +0 -0
- micrOS/utests/test_scheduler.py +435 -0
- {micrOSDevToolKit-2.9.1.data → microsdevtoolkit-2.26.1.data}/scripts/devToolKit.py +33 -3
- {micrOSDevToolKit-2.9.1.dist-info → microsdevtoolkit-2.26.1.dist-info}/METADATA +327 -268
- microsdevtoolkit-2.26.1.dist-info/RECORD +396 -0
- {micrOSDevToolKit-2.9.1.dist-info → microsdevtoolkit-2.26.1.dist-info}/WHEEL +1 -1
- toolkit/DevEnvCompile.py +63 -33
- toolkit/DevEnvOTA.py +58 -22
- toolkit/DevEnvUSB.py +110 -55
- toolkit/Gateway.py +6 -6
- toolkit/LM_to_compile.dat +6 -4
- toolkit/MicrOSDevEnv.py +127 -57
- toolkit/WebRepl.py +73 -0
- toolkit/dashboard_apps/BackupRestore.py +20 -35
- 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 +1 -6
- 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 +202 -105
- toolkit/dashboard_apps/Template_app.py +11 -23
- 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 +4 -4
- 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 +6 -0
- toolkit/lib/micrOSClient.py +123 -50
- toolkit/lib/micrOSClientHistory.py +156 -0
- toolkit/lib/pip_package_installer.py +5 -2
- toolkit/micrOSdashboard.py +12 -17
- toolkit/micrOSlint.py +20 -8
- 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__/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/dht.py +1 -1
- toolkit/simulator_lib/framebuf.py +49 -1
- toolkit/simulator_lib/machine.py +17 -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 +137 -59
- toolkit/simulator_lib/uasyncio.py +33 -2
- toolkit/simulator_lib/uos.py +147 -0
- toolkit/simulator_lib/urandom.py +4 -0
- toolkit/socketClient.py +43 -23
- toolkit/user_data/webhooks/generic.py +1 -1
- toolkit/user_data/webhooks/macro.py +1 -1
- 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/{IO_esp32.mpy → modules/IO_esp32.mpy} +0 -0
- toolkit/workspace/precompiled/{IO_esp32c3.mpy → modules/IO_esp32c3.mpy} +0 -0
- toolkit/workspace/precompiled/modules/IO_esp32c6.mpy +0 -0
- toolkit/workspace/precompiled/{IO_esp32s2.mpy → 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 +3 -3
- toolkit/workspace/precompiled/modules/LM_OV2640.mpy +0 -0
- toolkit/workspace/precompiled/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +3 -3
- toolkit/workspace/precompiled/{LM_aht10.mpy → modules/LM_aht10.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_bme280.mpy → 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/{LM_co2.mpy → modules/LM_co2.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_dht11.mpy → modules/LM_dht11.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_dht22.mpy → 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/{LM_ds18.mpy → modules/LM_ds18.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_esp32.py → modules/LM_esp32.py} +5 -0
- 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/{LM_haptic.mpy → modules/LM_haptic.mpy} +0 -0
- {micrOS/source → toolkit/workspace/precompiled/modules}/LM_i2c.py +5 -4
- 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/{LM_oled.mpy → modules/LM_oled.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_oled_sh1106.mpy → 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} +2 -2
- 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_servo.mpy → modules/LM_servo.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_sound_event.mpy → 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/{LM_trackball.mpy → modules/LM_trackball.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_veml7700.mpy → 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 +4 -0
- toolkit/workspace/precompiled/web/editor.js +440 -0
- toolkit/workspace/precompiled/web/filesui.html +178 -0
- toolkit/workspace/precompiled/web/filesui.js +338 -0
- {micrOS/source → toolkit/workspace/precompiled/web}/index.html +44 -2
- toolkit/workspace/precompiled/{uapi.js → web/uapi.js} +48 -7
- toolkit/workspace/precompiled/{ustyle.css → web/ustyle.css} +6 -3
- micrOS/micropython/esp32-20241129-v1.24.1.bin +0 -0
- micrOS/micropython/esp32c3-20240222-v1.22.2.bin +0 -0
- micrOS/micropython/esp32s2-20240602-v1.23.0.bin +0 -0
- micrOS/micropython/esp32s2-LOLIN_MINI-20220618-v1.19.1.bin +0 -0
- micrOS/micropython/esp32s2-LOLIN_MINI-20240602-v1.23.0.bin +0 -0
- micrOS/micropython/esp32s3-20240105-v1.22.1.bin +0 -0
- micrOS/micropython/esp32s3_spiram_oct-20231005-v1.21.0.bin +0 -0
- micrOS/micropython/esp32s3_spiram_oct-20241129-v1.24.1.bin +0 -0
- micrOS/micropython/rpi-pico-w-20241129-v1.24.1.uf2 +0 -0
- micrOS/micropython/tinypico-20241129-v1.24.1.bin +0 -0
- micrOS/source/LM_L298N_DCmotor.py +0 -86
- micrOS/source/LM_catgame.py +0 -75
- micrOS/source/LM_dashboard_be.py +0 -37
- micrOS/source/LM_demo.py +0 -97
- micrOS/source/LM_espnow.py +0 -23
- micrOS/source/LM_intercon.py +0 -57
- micrOS/source/LM_keychain.py +0 -322
- micrOS/source/LM_lmpacman.py +0 -126
- micrOS/source/LM_neoeffects.py +0 -331
- micrOS/source/LM_oledui.py +0 -972
- micrOS/source/LM_pet_feeder.py +0 -78
- micrOS/source/LM_ph_sensor.py +0 -51
- micrOS/source/LM_robustness.py +0 -74
- micrOS/source/reset.py +0 -11
- micrOSDevToolKit-2.9.1.dist-info/RECORD +0 -365
- 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__/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_esp32s3.mpy +0 -0
- toolkit/workspace/precompiled/IO_m5stamp.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_catgame.py +0 -75
- toolkit/workspace/precompiled/LM_cct.mpy +0 -0
- toolkit/workspace/precompiled/LM_dashboard_be.py +0 -37
- toolkit/workspace/precompiled/LM_demo.py +0 -97
- toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
- toolkit/workspace/precompiled/LM_distance.mpy +0 -0
- toolkit/workspace/precompiled/LM_espnow.py +0 -23
- toolkit/workspace/precompiled/LM_genIO.mpy +0 -0
- 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_ui.mpy +0 -0
- toolkit/workspace/precompiled/LM_oledui.mpy +0 -0
- toolkit/workspace/precompiled/LM_pet_feeder.py +0 -78
- 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 -74
- 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/node_config.json +0 -1
- toolkit/workspace/precompiled/reset.mpy +0 -0
- /micrOS/source/{IO_esp32.py → modules/IO_esp32.py} +0 -0
- /micrOS/source/{IO_esp32c3.py → modules/IO_esp32c3.py} +0 -0
- /micrOS/source/{IO_esp32s2.py → modules/IO_esp32s2.py} +0 -0
- /micrOS/source/{IO_rp2.py → modules/IO_rp2.py} +0 -0
- /micrOS/source/{LM_gameOfLife.py → modules/LM_gameOfLife.py} +0 -0
- /micrOS/source/{LM_rgbcct.py → modules/LM_rgbcct.py} +0 -0
- /micrOS/source/{LM_rp2w.py → modules/LM_rp2w.py} +0 -0
- /micrOS/source/{LM_sdcard.py → modules/LM_sdcard.py} +0 -0
- /micrOS/source/{LM_sound_event.py → modules/LM_sound_event.py} +0 -0
- /micrOS/source/{LM_tinyrgb.py → modules/LM_tinyrgb.py} +0 -0
- /micrOS/source/{udashboard.js → web/udashboard.js} +0 -0
- /micrOS/source/{uwidgets.js → web/uwidgets.js} +0 -0
- /micrOS/source/{uwidgets_pro.js → web/uwidgets_pro.js} +0 -0
- {micrOSDevToolKit-2.9.1.dist-info → microsdevtoolkit-2.26.1.dist-info/licenses}/LICENSE +0 -0
- {micrOSDevToolKit-2.9.1.dist-info → microsdevtoolkit-2.26.1.dist-info}/top_level.txt +0 -0
- /toolkit/workspace/precompiled/{LM_rp2w.py → modules/LM_rp2w.py} +0 -0
- /toolkit/workspace/precompiled/{LM_sdcard.py → modules/LM_sdcard.py} +0 -0
- /toolkit/workspace/precompiled/{udashboard.js → web/udashboard.js} +0 -0
- /toolkit/workspace/precompiled/{uwidgets.js → web/uwidgets.js} +0 -0
- /toolkit/workspace/precompiled/{uwidgets_pro.js → web/uwidgets_pro.js} +0 -0
micrOS/source/Server.py
CHANGED
|
@@ -13,7 +13,7 @@ Designed by Marcell Ban aka BxNxM GitHub
|
|
|
13
13
|
import uasyncio as asyncio
|
|
14
14
|
from utime import ticks_ms, ticks_diff
|
|
15
15
|
from Config import cfgget
|
|
16
|
-
from Debug import console_write,
|
|
16
|
+
from Debug import console_write, syslog
|
|
17
17
|
from Network import ifconfig
|
|
18
18
|
from Tasks import Manager
|
|
19
19
|
from Shell import Shell
|
|
@@ -27,11 +27,20 @@ except:
|
|
|
27
27
|
if cfgget('webui'):
|
|
28
28
|
from Web import WebEngine
|
|
29
29
|
else:
|
|
30
|
-
# Create dummy web engine -
|
|
30
|
+
# Create dummy web engine - Lazy loading
|
|
31
31
|
class WebEngine:
|
|
32
32
|
__slots__ = []
|
|
33
33
|
def __init__(self, *args, **kwargs):
|
|
34
34
|
pass
|
|
35
|
+
@staticmethod
|
|
36
|
+
def register(*args, **kwargs) -> None:
|
|
37
|
+
"""Child class can implement"""
|
|
38
|
+
syslog(f"[WARN] webui disabled, skip register: {kwargs.get('endpoint')}")
|
|
39
|
+
@staticmethod
|
|
40
|
+
def web_mounts(*args, **kwargs) -> dict:
|
|
41
|
+
"""Child class can implement"""
|
|
42
|
+
syslog(f"[WARN] webui disabled, skip web_mounts: {kwargs.get('endpoint')}")
|
|
43
|
+
return {}
|
|
35
44
|
|
|
36
45
|
#########################################################
|
|
37
46
|
# SOCKET SERVER-CLIENT HANDLER CLASSES #
|
|
@@ -63,19 +72,25 @@ class Client:
|
|
|
63
72
|
console_write("|" + "-" * Client.INDENT + msg)
|
|
64
73
|
Client.INDENT += 1 if Client.INDENT < 50 else 0 # Auto indent
|
|
65
74
|
|
|
66
|
-
async def read(self):
|
|
75
|
+
async def read(self, decoding='utf8', timeout_seconds=0):
|
|
67
76
|
"""
|
|
68
77
|
[Base] Implements client read function, reader size: 2048
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
- exit command handling (stop: return True)
|
|
78
|
+
:return tuple: read_error, data
|
|
79
|
+
- read_error is set to true upon timeout or other exception
|
|
80
|
+
- data holds bytes or decoded string read from the socket
|
|
73
81
|
"""
|
|
74
82
|
Client.console(f"[Client] read {self.client_id}")
|
|
75
83
|
self.last_msg_t = ticks_ms()
|
|
76
84
|
try:
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
if timeout_seconds:
|
|
86
|
+
request = await asyncio.wait_for(self.reader.read(self.read_bytes), timeout_seconds)
|
|
87
|
+
else:
|
|
88
|
+
request = await self.reader.read(self.read_bytes)
|
|
89
|
+
if decoding:
|
|
90
|
+
request = request.decode(decoding)
|
|
91
|
+
except asyncio.TimeoutError:
|
|
92
|
+
Client.console(f"[Client] Stream read timeout ({self.client_id}), timeout={timeout_seconds}s")
|
|
93
|
+
return True, ''
|
|
79
94
|
except Exception as e:
|
|
80
95
|
Client.console(f"[Client] Stream read error ({self.client_id}): {e}")
|
|
81
96
|
collect() # gc collection: "fix" for memory allocation failed, allocating 2049 bytes
|
|
@@ -83,8 +98,6 @@ class Client:
|
|
|
83
98
|
|
|
84
99
|
# Input handling
|
|
85
100
|
Client.console(f"[Client] raw request ({self.client_id}): |{request}|")
|
|
86
|
-
if request in ('exit', ''):
|
|
87
|
-
return True, request
|
|
88
101
|
return False, request
|
|
89
102
|
|
|
90
103
|
async def a_send(self, response, encode='utf8'):
|
|
@@ -99,7 +112,7 @@ class Client:
|
|
|
99
112
|
except Exception as e:
|
|
100
113
|
# Maintain ACTIVE_CLIS - remove closed connection by peer.
|
|
101
114
|
await self.close()
|
|
102
|
-
|
|
115
|
+
syslog(f"[WARN] Client.a_send (auto-drop) {self.client_id}: {e}")
|
|
103
116
|
return # Abort async send (no drain)
|
|
104
117
|
# Send buffered data with async task - hacky
|
|
105
118
|
try:
|
|
@@ -114,7 +127,7 @@ class Client:
|
|
|
114
127
|
console_write("[Client] NoCon: response>dev/nul")
|
|
115
128
|
|
|
116
129
|
def send(self, response):
|
|
117
|
-
# Implement in child class - synchronous send method
|
|
130
|
+
# Optional - Implement in child class - synchronous send (all) method
|
|
118
131
|
pass
|
|
119
132
|
|
|
120
133
|
async def close(self):
|
|
@@ -142,7 +155,7 @@ class Client:
|
|
|
142
155
|
if Client.ACTIVE_CLIS.get(client_id, None) is not None:
|
|
143
156
|
Client.ACTIVE_CLIS.pop(client_id)
|
|
144
157
|
# Update server task output (? test ?)
|
|
145
|
-
Manager().
|
|
158
|
+
Manager().task_msg('server', ','.join(list(Client.ACTIVE_CLIS)))
|
|
146
159
|
|
|
147
160
|
def __del__(self):
|
|
148
161
|
"""Client GC collect"""
|
|
@@ -158,32 +171,23 @@ class WebCli(Client, WebEngine):
|
|
|
158
171
|
|
|
159
172
|
async def run_web(self):
|
|
160
173
|
# Update server task output
|
|
161
|
-
Manager().
|
|
174
|
+
Manager().task_msg('server', ','.join(list(Client.ACTIVE_CLIS)))
|
|
162
175
|
|
|
163
176
|
# Run async connection handling
|
|
164
177
|
while self.connected:
|
|
165
178
|
try:
|
|
166
179
|
# Read request msg from client
|
|
167
|
-
state, request = await self.read()
|
|
168
|
-
if state:
|
|
180
|
+
state, request = await self.read(decoding=None)
|
|
181
|
+
if state or not request:
|
|
182
|
+
break
|
|
183
|
+
if not await self.response(request):
|
|
169
184
|
break
|
|
170
|
-
await self.response(request)
|
|
171
185
|
except Exception as e:
|
|
172
|
-
|
|
186
|
+
syslog(f"[ERR] Client.run_web: {e}")
|
|
173
187
|
break
|
|
174
188
|
# Close connection
|
|
175
189
|
await self.close()
|
|
176
190
|
|
|
177
|
-
@staticmethod
|
|
178
|
-
def register(endpoint, callback):
|
|
179
|
-
# AUTO ENABLE webui when register (endpoint) called and webui is False
|
|
180
|
-
if not cfgget('webui'):
|
|
181
|
-
from Config import cfgput
|
|
182
|
-
if cfgput('webui', True): # SET webui to True
|
|
183
|
-
from machine import reset
|
|
184
|
-
reset() # HARD RESET (REBOOT)
|
|
185
|
-
WebEngine.REST_ENDPOINTS[endpoint] = callback
|
|
186
|
-
|
|
187
191
|
|
|
188
192
|
class ShellCli(Client, Shell):
|
|
189
193
|
|
|
@@ -196,7 +200,9 @@ class ShellCli(Client, Shell):
|
|
|
196
200
|
|
|
197
201
|
def send(self, response):
|
|
198
202
|
"""
|
|
199
|
-
|
|
203
|
+
Synchronous send function (with drain task)
|
|
204
|
+
- not used in Shell or ShellCli
|
|
205
|
+
- Note: it is a support function for synchronous scenarios: Server.reply_all
|
|
200
206
|
"""
|
|
201
207
|
if self.connected:
|
|
202
208
|
if self.prompt() != response:
|
|
@@ -209,7 +215,7 @@ class ShellCli(Client, Shell):
|
|
|
209
215
|
except:
|
|
210
216
|
# Maintain ACTIVE_CLIS - remove closed connection by peer.
|
|
211
217
|
Client.drop_client(self.client_id)
|
|
212
|
-
|
|
218
|
+
syslog(f"[WARN] ShellCli.send (auto-drop) {self.client_id}")
|
|
213
219
|
# Send buffered data with async task - hacky
|
|
214
220
|
if self.drain_event.is_set():
|
|
215
221
|
self.drain_event.clear() # set drain busy (False)
|
|
@@ -219,8 +225,7 @@ class ShellCli(Client, Shell):
|
|
|
219
225
|
|
|
220
226
|
async def __wait_for_drain(self):
|
|
221
227
|
"""
|
|
222
|
-
Handle drain serialization
|
|
223
|
-
- solve output data duplicate
|
|
228
|
+
Handle drain serialization - for synchronous send function
|
|
224
229
|
"""
|
|
225
230
|
try:
|
|
226
231
|
# send write buffer
|
|
@@ -233,55 +238,45 @@ class ShellCli(Client, Shell):
|
|
|
233
238
|
# set drain free
|
|
234
239
|
self.drain_event.set() # set drain free (True)
|
|
235
240
|
|
|
236
|
-
async def
|
|
237
|
-
Client.console(f"[ShellCli] Close connection {self.client_id}")
|
|
238
|
-
self.send("Bye!\n")
|
|
239
|
-
# Reset shell state machine
|
|
240
|
-
self.reset()
|
|
241
|
-
await asyncio.sleep_ms(50)
|
|
242
|
-
# Used from Client parent class
|
|
243
|
-
await super().close()
|
|
244
|
-
|
|
245
|
-
async def __shell_cmd(self, request):
|
|
241
|
+
async def a_send(self, response, encode='utf8'):
|
|
246
242
|
"""
|
|
247
|
-
|
|
243
|
+
Async send for Shell (new line + prompt$)
|
|
248
244
|
"""
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
state = self.shell(request)
|
|
254
|
-
if state:
|
|
255
|
-
return False # exit_loop
|
|
256
|
-
return True # exit_loop : Close session when shell returns False (auth Failed, etc.)
|
|
257
|
-
except Exception as e:
|
|
258
|
-
Client.console(f"[ShellCli] Shell exception: {e}")
|
|
259
|
-
if "ECONNRESET" in str(e):
|
|
260
|
-
return True # exit_loop
|
|
261
|
-
self.send("[HA] Critical error - disconnect & hard reset")
|
|
262
|
-
errlog_add("[ERR] Socket critical error - reboot")
|
|
263
|
-
self.reboot()
|
|
245
|
+
if self.prompt() != response:
|
|
246
|
+
# [format] Add new line if not prompt
|
|
247
|
+
response = f"{response}\n"
|
|
248
|
+
await super().a_send(response, encode)
|
|
264
249
|
|
|
265
250
|
async def run_shell(self):
|
|
266
251
|
# Update server task output
|
|
267
|
-
Manager().
|
|
252
|
+
Manager().task_msg('server', ','.join(list(Client.ACTIVE_CLIS)))
|
|
268
253
|
# Init prompt
|
|
269
|
-
self.
|
|
254
|
+
await self.a_send(self.prompt())
|
|
270
255
|
# Run async connection handling
|
|
256
|
+
_exit = False
|
|
271
257
|
while self.connected:
|
|
272
258
|
try:
|
|
273
259
|
# Read request msg from client
|
|
274
260
|
state, request = await self.read()
|
|
275
|
-
if state:
|
|
276
|
-
break
|
|
277
|
-
_exit = await self.__shell_cmd(request)
|
|
278
|
-
if _exit:
|
|
279
|
-
collect()
|
|
261
|
+
if state or request in ('exit', ''):
|
|
280
262
|
break
|
|
263
|
+
# Run micrOS shell with request string
|
|
264
|
+
Client.console("[ShellCli] --- #Run shell")
|
|
265
|
+
# Shell -> True (OK) or False (NOK) -> NOK->Close session (auth Failed, etc.)
|
|
266
|
+
_exit = not await self.shell(request)
|
|
281
267
|
except Exception as e:
|
|
282
|
-
|
|
268
|
+
syslog(f"[ERR] Shell client: {e}")
|
|
269
|
+
if "ECONNRESET" in str(e):
|
|
270
|
+
_exit = True # exit_loop
|
|
271
|
+
else:
|
|
272
|
+
await self.a_send("[HA] Critical error - disconnect & hard reset")
|
|
273
|
+
syslog("[ERR] Socket critical error - reboot")
|
|
274
|
+
await self.reboot()
|
|
275
|
+
if _exit:
|
|
276
|
+
collect()
|
|
283
277
|
break
|
|
284
278
|
# Close connection
|
|
279
|
+
await self.a_send("Bye!")
|
|
285
280
|
await self.close()
|
|
286
281
|
|
|
287
282
|
|
|
@@ -418,8 +413,11 @@ class Server:
|
|
|
418
413
|
"""
|
|
419
414
|
for _, cli in Client.ACTIVE_CLIS.items():
|
|
420
415
|
if cli.connected:
|
|
421
|
-
cli.send(msg)
|
|
416
|
+
cli.send(f"~~~ {msg}")
|
|
422
417
|
|
|
423
418
|
def __del__(self):
|
|
424
419
|
Client.console("[ socket server ] <<destructor>>")
|
|
425
|
-
self.server
|
|
420
|
+
if self.server:
|
|
421
|
+
self.server.close()
|
|
422
|
+
if self.web:
|
|
423
|
+
self.web.close()
|
micrOS/source/Shell.py
CHANGED
|
@@ -11,12 +11,12 @@ Designed by Marcell Ban aka BxNxM
|
|
|
11
11
|
#################################################################
|
|
12
12
|
# IMPORTS #
|
|
13
13
|
#################################################################
|
|
14
|
-
from os import listdir
|
|
15
14
|
from sys import modules
|
|
16
15
|
from machine import reset as hard_reset, soft_reset
|
|
17
16
|
from Config import cfgget, cfgput
|
|
17
|
+
from Files import OSPath, ilist_fs, path_join
|
|
18
18
|
from Tasks import lm_exec
|
|
19
|
-
from Debug import
|
|
19
|
+
from Debug import syslog
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
#################################################################
|
|
@@ -25,7 +25,7 @@ from Debug import errlog_add
|
|
|
25
25
|
|
|
26
26
|
class Shell:
|
|
27
27
|
__slots__ = ['__devfid', '__auth_mode', '__hwuid', '__auth_ok', '__conf_mode']
|
|
28
|
-
MICROS_VERSION = '2.
|
|
28
|
+
MICROS_VERSION = '2.26.1-0'
|
|
29
29
|
|
|
30
30
|
def __init__(self):
|
|
31
31
|
"""
|
|
@@ -43,57 +43,53 @@ class Shell:
|
|
|
43
43
|
try:
|
|
44
44
|
cfgput('version', Shell.MICROS_VERSION)
|
|
45
45
|
except Exception as e:
|
|
46
|
-
|
|
46
|
+
syslog(f"[ERR] micrOS version export failed (config): {e}")
|
|
47
47
|
|
|
48
|
-
def
|
|
49
|
-
"""
|
|
50
|
-
|
|
51
|
-
"""
|
|
52
|
-
pass
|
|
48
|
+
async def a_send(self, msg):
|
|
49
|
+
""" Must be defined by child class... """
|
|
50
|
+
raise NotImplementedError("Child class must implement a_send method")
|
|
53
51
|
|
|
54
52
|
def reset(self):
|
|
55
53
|
"""Reset shell state"""
|
|
56
54
|
self.__auth_ok = False
|
|
57
55
|
self.__conf_mode = False
|
|
58
56
|
|
|
59
|
-
def reboot(self, hard=False):
|
|
60
|
-
"""Reboot micropython VM"""
|
|
61
|
-
self.
|
|
62
|
-
self.send("Bye!")
|
|
57
|
+
async def reboot(self, hard=False):
|
|
58
|
+
""" Reboot micropython VM """
|
|
59
|
+
await self.a_send(f"{'[HARD] ' if hard else ''}Reboot micrOS system.\nBye!")
|
|
63
60
|
if hard:
|
|
64
61
|
hard_reset()
|
|
65
62
|
soft_reset()
|
|
66
63
|
|
|
67
64
|
def prompt(self):
|
|
68
|
-
"""Generate prompt"""
|
|
65
|
+
""" Generate prompt """
|
|
69
66
|
auth = "[password] " if self.__auth_mode and not self.__auth_ok else ""
|
|
70
67
|
mode = "[configure] " if self.__conf_mode else ""
|
|
71
68
|
return f"{auth}{mode}{self.__devfid} $ "
|
|
72
69
|
|
|
73
|
-
def __auth(self, msg_list):
|
|
74
|
-
"""Authorize user"""
|
|
70
|
+
async def __auth(self, msg_list):
|
|
71
|
+
""" Authorize user """
|
|
75
72
|
# Set user auth state
|
|
76
73
|
if self.__auth_mode and not self.__auth_ok:
|
|
77
74
|
# check password
|
|
78
|
-
|
|
79
|
-
if usrpwd == msg_list[0].strip():
|
|
75
|
+
if cfgget('appwd') == msg_list[0].strip():
|
|
80
76
|
self.__auth_ok = True
|
|
81
|
-
self.
|
|
77
|
+
await self.a_send("AuthOk")
|
|
82
78
|
return True, []
|
|
83
|
-
self.
|
|
79
|
+
await self.a_send("AuthFailed\nBye!")
|
|
84
80
|
return False, []
|
|
85
81
|
return True, msg_list
|
|
86
82
|
|
|
87
|
-
def shell(self, msg):
|
|
83
|
+
async def shell(self, msg):
|
|
88
84
|
"""
|
|
89
85
|
micrOS Shell main - input string handling
|
|
90
86
|
:param msg: incoming shell command (command or load module call)
|
|
91
87
|
"""
|
|
92
|
-
state = self.__shell(msg)
|
|
93
|
-
self.
|
|
88
|
+
state = await self.__shell(msg)
|
|
89
|
+
await self.a_send(self.prompt())
|
|
94
90
|
return state
|
|
95
91
|
|
|
96
|
-
def __shell(self, msg):
|
|
92
|
+
async def __shell(self, msg):
|
|
97
93
|
"""
|
|
98
94
|
Socket server - interpreter shell
|
|
99
95
|
:param msg: socket input string
|
|
@@ -109,6 +105,8 @@ class Shell:
|
|
|
109
105
|
# No msg to work with
|
|
110
106
|
return True
|
|
111
107
|
msg_list = msg.strip().split()
|
|
108
|
+
# INTERCON embedding: conf mode and remote call request check
|
|
109
|
+
is_local_cmd = self.__conf_mode or not msg_list[-1].startswith(">>")
|
|
112
110
|
|
|
113
111
|
##########################################
|
|
114
112
|
# [1] Handle built-in shell commands #
|
|
@@ -116,75 +114,80 @@ class Shell:
|
|
|
116
114
|
##########################################
|
|
117
115
|
|
|
118
116
|
# Hello message
|
|
119
|
-
if msg_list[0] == 'hello':
|
|
117
|
+
if is_local_cmd and msg_list[0] == 'hello':
|
|
120
118
|
# For low level device identification - hello msg
|
|
121
|
-
self.
|
|
119
|
+
await self.a_send(f"hello:{self.__devfid}:{self.__hwuid}")
|
|
122
120
|
return True
|
|
123
121
|
|
|
124
122
|
# [!] AUTH
|
|
125
|
-
state, msg_list = self.__auth(msg_list)
|
|
123
|
+
state, msg_list = await self.__auth(msg_list)
|
|
126
124
|
if not state:
|
|
127
125
|
return False
|
|
128
126
|
if len(msg_list) == 0:
|
|
129
127
|
return True
|
|
130
128
|
|
|
131
129
|
# Version handling
|
|
132
|
-
if msg_list[0] == 'version':
|
|
130
|
+
if is_local_cmd and msg_list[0] == 'version':
|
|
133
131
|
# For micrOS system version info
|
|
134
|
-
self.
|
|
132
|
+
await self.a_send(str(Shell.MICROS_VERSION))
|
|
135
133
|
return True
|
|
136
134
|
|
|
137
135
|
# Reboot micropython VM
|
|
138
|
-
if msg_list[0] == 'reboot':
|
|
136
|
+
if is_local_cmd and msg_list[0] == 'reboot':
|
|
139
137
|
hard = False
|
|
140
138
|
if len(msg_list) >= 2 and "-h" in msg_list[1]:
|
|
141
139
|
# reboot / reboot -h
|
|
142
140
|
hard = True
|
|
143
|
-
self.reboot(hard)
|
|
141
|
+
await self.reboot(hard)
|
|
144
142
|
|
|
145
|
-
if msg_list[0].startswith('webrepl'):
|
|
143
|
+
if is_local_cmd and msg_list[0].startswith('webrepl'):
|
|
146
144
|
if len(msg_list) == 2 and '-u' in msg_list[1]:
|
|
147
|
-
Shell.webrepl(msg_obj=self.
|
|
148
|
-
Shell.webrepl(msg_obj=self.
|
|
145
|
+
await Shell.webrepl(msg_obj=self.a_send, update=True)
|
|
146
|
+
return await Shell.webrepl(msg_obj=self.a_send)
|
|
149
147
|
|
|
150
148
|
# CONFIGURE MODE STATE: ACCESS FOR NODE_CONFIG.JSON
|
|
151
|
-
if msg_list[0].startswith('conf'):
|
|
149
|
+
if is_local_cmd and msg_list[0].startswith('conf'):
|
|
152
150
|
self.__conf_mode = True
|
|
153
151
|
return True
|
|
154
|
-
if msg_list[0].startswith('noconf'):
|
|
152
|
+
if is_local_cmd and msg_list[0].startswith('noconf'):
|
|
155
153
|
self.__conf_mode = False
|
|
156
154
|
return True
|
|
157
155
|
|
|
158
156
|
# HELP MSG
|
|
159
|
-
if msg_list[0] == "help":
|
|
160
|
-
self.
|
|
161
|
-
self.
|
|
162
|
-
self.
|
|
163
|
-
self.
|
|
164
|
-
self.
|
|
165
|
-
self.
|
|
166
|
-
self.
|
|
167
|
-
self.
|
|
168
|
-
self.
|
|
169
|
-
self.
|
|
170
|
-
self.
|
|
171
|
-
self.
|
|
172
|
-
self.
|
|
173
|
-
self.
|
|
174
|
-
self.
|
|
175
|
-
self.
|
|
176
|
-
self.
|
|
177
|
-
self.
|
|
178
|
-
self.
|
|
157
|
+
if is_local_cmd and msg_list[0] == "help":
|
|
158
|
+
await self.a_send("[MICROS]")
|
|
159
|
+
await self.a_send(" hello - hello msg - for device identification")
|
|
160
|
+
await self.a_send(" modules - show active Load Modules")
|
|
161
|
+
await self.a_send(" version - returns micrOS version")
|
|
162
|
+
await self.a_send(" exit - exit shell session")
|
|
163
|
+
await self.a_send(" reboot - system soft reboot (vm), hard reboot (hw): reboot -h")
|
|
164
|
+
await self.a_send(" webrepl - start webrepl, for file transfers use with --update")
|
|
165
|
+
await self.a_send("[CONF] Configuration mode")
|
|
166
|
+
await self.a_send(" conf - Enter conf mode")
|
|
167
|
+
await self.a_send(" dump - Dump all data, filter: dump <str>")
|
|
168
|
+
await self.a_send(" key - Get value")
|
|
169
|
+
await self.a_send(" key value - Set value")
|
|
170
|
+
await self.a_send(" noconf - Exit conf mode")
|
|
171
|
+
await self.a_send("[TASK] Task operations")
|
|
172
|
+
await self.a_send(" task list - list tasks by tags")
|
|
173
|
+
await self.a_send(" task kill <tag> - stop task")
|
|
174
|
+
await self.a_send(" task show <tag> - show task output")
|
|
175
|
+
await self.a_send("[EXEC] Command mode, syntax(...): <module> <function> <params> <postfix>")
|
|
176
|
+
await self.a_send(" Postfix hints:")
|
|
177
|
+
await self.a_send(" ... &<x> - start one-shot task")
|
|
178
|
+
await self.a_send(" ... &&<x> - start periodic task, where <x>: delay ms [x min: 20ms]")
|
|
179
|
+
await self.a_send(" ... >json - request json formatted output")
|
|
180
|
+
await self.a_send(" ... >>hostname - remote command execution (intercon)")
|
|
181
|
+
await self.a_send(" help lm - list ALL available LoadModules")
|
|
179
182
|
if "lm" in str(msg_list):
|
|
180
|
-
return Shell._show_lm_funcs(msg_obj=self.
|
|
181
|
-
return Shell._show_lm_funcs(msg_obj=self.
|
|
183
|
+
return await Shell._show_lm_funcs(msg_obj=self.a_send)
|
|
184
|
+
return await Shell._show_lm_funcs(msg_obj=self.a_send, active_only=True)
|
|
182
185
|
|
|
183
186
|
# [2] EXECUTE:
|
|
184
187
|
# @1 Configure mode
|
|
185
|
-
if self.__conf_mode and len(msg_list) > 0:
|
|
188
|
+
if is_local_cmd and self.__conf_mode and len(msg_list) > 0:
|
|
186
189
|
# Lock thread under config handling is threads available
|
|
187
|
-
return Shell._configure(self.
|
|
190
|
+
return await Shell._configure(self.a_send, msg_list)
|
|
188
191
|
# @2 Command mode
|
|
189
192
|
"""
|
|
190
193
|
INPUT MSG STRUCTURE
|
|
@@ -193,43 +196,43 @@ class Shell:
|
|
|
193
196
|
"""
|
|
194
197
|
try:
|
|
195
198
|
# Execute command via InterpreterCore
|
|
196
|
-
self.
|
|
199
|
+
await self.a_send(lm_exec(arg_list=msg_list)[1])
|
|
197
200
|
return True
|
|
198
201
|
except Exception as e:
|
|
199
|
-
self.
|
|
202
|
+
await self.a_send(f"[ERROR] shell.lm_exec internal error: {e}")
|
|
200
203
|
return False
|
|
201
204
|
|
|
202
205
|
#################################################################
|
|
203
206
|
# CONFIGURE MODE HANDLER #
|
|
204
207
|
#################################################################
|
|
205
208
|
@staticmethod
|
|
206
|
-
def _configure(msg_obj, msg_list):
|
|
209
|
+
async def _configure(msg_obj, msg_list):
|
|
207
210
|
"""
|
|
208
211
|
:param msg_obj: shell output stream function reference (write object)
|
|
209
212
|
:param msg_list: socket input param list
|
|
210
213
|
:return: execution status
|
|
211
214
|
"""
|
|
212
|
-
def dump():
|
|
215
|
+
async def dump():
|
|
213
216
|
nonlocal msg_obj, msg_list
|
|
214
217
|
if msg_list[0] == 'dump':
|
|
215
218
|
search = msg_list[1] if len(msg_list) == 2 else None
|
|
216
219
|
# DUMP DATA
|
|
217
220
|
for _key, value in cfgget().items():
|
|
218
221
|
if search is None or search in _key:
|
|
219
|
-
msg_obj(f" {_key}{' ' * (10 - len(_key))}:{' ' * 7} {value}")
|
|
222
|
+
await msg_obj(f" {_key}{' ' * (10 - len(_key))}:{' ' * 7} {value}")
|
|
220
223
|
return True
|
|
221
224
|
return False
|
|
222
225
|
|
|
223
226
|
# [CONFIG] Get value
|
|
224
227
|
if len(msg_list) == 1:
|
|
225
|
-
if dump(): # Simple dump without param filter
|
|
228
|
+
if await dump(): # Simple dump without param filter
|
|
226
229
|
return True
|
|
227
230
|
# GET SINGLE PARAMETER VALUE
|
|
228
|
-
msg_obj(cfgget(msg_list[0]))
|
|
231
|
+
await msg_obj(cfgget(msg_list[0]))
|
|
229
232
|
return True
|
|
230
233
|
# [CONFIG] Set value
|
|
231
234
|
if len(msg_list) >= 2:
|
|
232
|
-
if dump(): # Dump with search option
|
|
235
|
+
if await dump(): # Dump with search option
|
|
233
236
|
return True
|
|
234
237
|
# Deserialize params
|
|
235
238
|
key = msg_list[0]
|
|
@@ -237,68 +240,73 @@ class Shell:
|
|
|
237
240
|
try:
|
|
238
241
|
output = cfgput(key, " ".join(msg_list[1:]), type_check=True)
|
|
239
242
|
except Exception as e:
|
|
240
|
-
msg_obj(f"node_config write error: {e}")
|
|
243
|
+
await msg_obj(f"node_config write error: {e}")
|
|
241
244
|
output = False
|
|
242
245
|
# Evaluation and reply
|
|
243
|
-
msg_obj('Saved' if output else 'Invalid key' if cfgget(key) is None else 'Failed to save')
|
|
246
|
+
await msg_obj('Saved' if output else 'Invalid key' if cfgget(key) is None else 'Failed to save')
|
|
244
247
|
return True
|
|
245
248
|
|
|
246
249
|
#################################################################
|
|
247
250
|
# COMMAND MODE & LMS HANDLER #
|
|
248
251
|
#################################################################
|
|
249
252
|
@staticmethod
|
|
250
|
-
def _show_lm_funcs(msg_obj, active_only=False):
|
|
253
|
+
async def _show_lm_funcs(msg_obj, active_only=False):
|
|
251
254
|
"""
|
|
252
255
|
Dump LM modules with functions - in case of [py] files
|
|
253
256
|
Dump LM module with help function call - in case of [mpy] files
|
|
254
257
|
"""
|
|
255
|
-
def _help(
|
|
256
|
-
|
|
258
|
+
async def _help(mods):
|
|
259
|
+
nonlocal mpath
|
|
260
|
+
for lm_path in mods:
|
|
257
261
|
lm_name = lm_path.replace('LM_', '').split('.')[0]
|
|
258
262
|
try:
|
|
259
|
-
msg_obj(f"
|
|
263
|
+
await msg_obj(f" {lm_name}")
|
|
260
264
|
if lm_path.endswith('.mpy'):
|
|
261
|
-
msg_obj(f"
|
|
265
|
+
await msg_obj(f" {' ' * len(lm_path.replace('LM_', '').split('.')[0])}help")
|
|
262
266
|
continue
|
|
263
|
-
with open(lm_path, 'r') as f:
|
|
267
|
+
with open(path_join(mpath, lm_path), 'r') as f:
|
|
264
268
|
line = "micrOSisTheBest"
|
|
265
269
|
while line:
|
|
266
270
|
line = f.readline()
|
|
267
271
|
ldata = line.strip()
|
|
268
272
|
if ldata.startswith('def ') and not ldata.split()[1].startswith("_") and 'self' not in ldata:
|
|
269
|
-
msg_obj(f"
|
|
273
|
+
await msg_obj(f" {' ' * len(lm_name)}{ldata.replace('def ', '').split('(')[0]}")
|
|
270
274
|
except Exception as e:
|
|
271
|
-
msg_obj(f"[{lm_path}] SHOW LM PARSER WARNING: {e}")
|
|
275
|
+
await msg_obj(f"[{lm_path}] SHOW LM PARSER WARNING: {e}")
|
|
272
276
|
return False
|
|
273
277
|
return True
|
|
274
278
|
|
|
279
|
+
await msg_obj("")
|
|
275
280
|
# [1] list active modules (default in shell)
|
|
281
|
+
mpath = OSPath.MODULES
|
|
276
282
|
if active_only:
|
|
277
283
|
mod_keys = modules.keys()
|
|
278
|
-
active_modules = (dir_mod for dir_mod in
|
|
279
|
-
|
|
284
|
+
active_modules = (dir_mod for dir_mod in ilist_fs(path=mpath, type_filter='f', select="LM")
|
|
285
|
+
if dir_mod.split('.')[0] in mod_keys)
|
|
286
|
+
return await _help(active_modules)
|
|
280
287
|
# [2] list all LMs on file system (ALL - help lm) - manual
|
|
281
|
-
return _help(
|
|
288
|
+
return await _help(ilist_fs(path=mpath, type_filter='f', select="LM"))
|
|
282
289
|
|
|
283
290
|
@staticmethod
|
|
284
|
-
def webrepl(msg_obj, update=False):
|
|
291
|
+
async def webrepl(msg_obj, update=False):
|
|
285
292
|
from Network import ifconfig
|
|
286
293
|
|
|
287
|
-
msg_obj(" Start micropython WEBREPL - file transfer and debugging")
|
|
288
|
-
msg_obj(" [i] restart machine shortcut: import reset")
|
|
289
|
-
msg_obj(f" Connect over http://micropython.org/webrepl/#{ifconfig()[1][0]}:8266/")
|
|
290
|
-
msg_obj(f" \t[!] webrepl password: {cfgget('appwd')}")
|
|
294
|
+
await msg_obj(" Start micropython WEBREPL - file transfer and debugging")
|
|
295
|
+
await msg_obj(" [i] restart machine shortcut: import reset")
|
|
296
|
+
await msg_obj(f" Connect over http://micropython.org/webrepl/#{ifconfig()[1][0]}:8266/")
|
|
297
|
+
await msg_obj(f" \t[!] webrepl password: {cfgget('appwd')}")
|
|
291
298
|
if update:
|
|
292
|
-
msg_obj(" Restart node then start webrepl...")
|
|
293
|
-
msg_obj(" Bye!")
|
|
299
|
+
await msg_obj(" Restart node then start webrepl...")
|
|
300
|
+
await msg_obj(" Bye!")
|
|
294
301
|
# Set .if_mode->webrepl (start webrepl after reboot and poll update status...)
|
|
295
302
|
with open('.if_mode', 'w') as f:
|
|
296
303
|
f.write('webrepl')
|
|
297
304
|
hard_reset()
|
|
298
305
|
try:
|
|
299
306
|
import webrepl
|
|
300
|
-
msg_obj(webrepl.start(password=cfgget('appwd')))
|
|
307
|
+
await msg_obj(webrepl.start(password=cfgget('appwd')))
|
|
301
308
|
except Exception as e:
|
|
302
309
|
_err_msg = f"[ERR] while starting webrepl: {e}"
|
|
303
|
-
msg_obj(_err_msg)
|
|
304
|
-
|
|
310
|
+
await msg_obj(_err_msg)
|
|
311
|
+
syslog(_err_msg)
|
|
312
|
+
return True
|