From 74da7ee616b95ec2e1b42e28e9060fe5e5e50481 Mon Sep 17 00:00:00 2001 From: oberon Date: Tue, 3 Feb 2026 11:46:46 +0100 Subject: [PATCH] first commit --- .DS_Store | Bin 0 -> 6148 bytes README.md | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 .DS_Store create mode 100644 README.md diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 (Currently this project can send only one advertising telegram the same time - so only one hub can be controlled, all others will go in timeout-mode till next telegram with their device address is sent.) + +## Setting the address of the Hub +To switch the Hub's device address to the next one (device 0, device 1, device 2) just press the button on the hub. + +> i.E.: If the script runs with **mkcontrol(2,0,1)** (-> device2, channel0, full speed forward) and nothing is happening, you have to short-press the button, perhaps again...) + +# usage +Start the script [consoletest.py](https://github.com/J0EK3R/mkconnect-python/blob/main/consoletest.py) on your raspberry: +``` +pi@devpi:~/dev/mkconnect-python $ sudo python -i consoletest.py +``` + +## mkbtstop() - stop bluetooth advertising +``` +Ready to execute commands + +>>> mkbtstop() +``` + +## mkconnect() - switch hubs in bluetooth mode +If you power-on the hubs they will listen to telegrams to the **first device by default**. +Call mkconnect() to switch all hubs in Bluetooth mode. +By short-pressing the button on MK6.0 Hubs you can choose the hubId: +* hubId=0 - one Led flash +* hubId=1 - two Led flashs +* hubId=2 - three Led flashs +``` +Ready to execute commands + +>>> mkconnect() +``` + +## mkcontrol(deviceId, channel, power and powerAndDirection) +i.E.: mkcontrol(0, 0, 1) - on first device (deviceId=0) run channel A (channel=0) with fullspeed (powerAndDirection=1) +``` +Ready to execute commands + +>>> mkcontrol(0, 0, 1) +``` + +## mkstop(deviceId) +Set all channels of device to zero +``` +Ready to execute commands + +>>> mkstop(0) +``` + +--- +# old stuff + +There is a testscript [consoletest.py](https://github.com/J0EK3R/mkconnect-python/blob/main/consoletest.py) where (on raspberry pi) **hcitool** is used to advertise telegrams over bluetooth. + +Maybe you habe to **sudo** the command: +``` +pi@devpi:~/dev/mkconnect-python $ sudo python -i consoletest.py + +Ready to execute commands + +For connecting: mkconnect(hubId) ex: mkconnect(0) or mkconnect(1) for the second hub + + Available commands: mkconnect(hubId) + mkstop(hubId) + mkcontrol(deviceId, channel, powerAndDirection) + +ex: mkcontrol(0, 0, 0.5) ; mkcontrol(0, 'B', -1) + the minus sign - indicate reverse motor direction +``` + + + + + +Just look in [main.py](https://github.com/J0EK3R/mkconnect-python/blob/main/main.py) for current usage... + +Current output in [https://wokwi.com/projects/new/micropython-pi-pico](https://wokwi.com/projects/398314618803830785) +...looks very good! :) +``` +connect-telegram +rawdata: 6d 7b a7 80 80 80 80 92 +crypted: 6d b6 43 cf 7e 8f 47 11 88 66 59 38 d1 7a aa 26 49 5e 13 14 15 16 17 18 + +stop-telegram +rawdata: 61 7b a7 80 80 80 80 80 80 9e +crypted: 6d b6 43 cf 7e 8f 47 11 84 66 59 38 d1 7a aa 34 67 4a 55 bf 15 16 17 18 + +C1: fullspeed forwards +rawdata: 61 7b a7 ff 80 80 80 80 80 9e +crypted: 6d b6 43 cf 7e 8f 47 11 84 66 59 47 d1 7a aa 34 67 4a ed b7 15 16 17 18 + +C1: halfspeed forwards +rawdata: 61 7b a7 bf 80 80 80 80 80 9e +crypted: 6d b6 43 cf 7e 8f 47 11 84 66 59 07 d1 7a aa 34 67 4a eb 70 15 16 17 18 + +C1: halfspeed backwards +rawdata: 61 7b a7 40 80 80 80 80 80 9e +crypted: 6d b6 43 cf 7e 8f 47 11 84 66 59 f8 d1 7a aa 34 67 4a 4e fe 15 16 17 18 + +C2: halfspeed backwards +rawdata: 61 7b a7 40 40 80 80 80 80 9e +crypted: 6d b6 43 cf 7e 8f 47 11 84 66 59 f8 11 7a aa 34 67 4a 3d f9 15 16 17 18 +MicroPython v1.22.0 on 2023-12-27; Raspberry Pi Pico with RP2040 +Type "help()" for more information. +>>> +raw REPL; CTRL-B to exit +> +```