diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abdf3f2..e8a3ee9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: which meshtastic meshtastic --version - name: Run pylint - run: pylint meshtastic + run: pylint meshtastic examples/ - name: Run tests with pytest run: pytest --cov=meshtastic - name: Generate coverage report diff --git a/Makefile b/Makefile index 2688ea1..14ad4d6 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ docs: # lint the codebase lint: - pylint meshtastic + pylint meshtastic examples # show the slowest unit tests slow: diff --git a/examples/info_example.py b/examples/info_example.py new file mode 100644 index 0000000..4b0a2af --- /dev/null +++ b/examples/info_example.py @@ -0,0 +1,23 @@ +"""Simple program to demo how to use meshtastic library. + To run: python examples/info.py +""" + +import meshtastic +import meshtastic.serial_interface + +iface = meshtastic.serial_interface.SerialInterface() + +# call showInfo() just to ensure values are populated +#info = iface.showInfo() + +if iface.myInfo: + #print(f'myInfo:{iface.myInfo}') + print(f'firmware_version:{iface.myInfo.firmware_version}') + +if iface.nodes: + for n in iface.nodes.values(): + if n['num'] == iface.myInfo.my_node_num: + print(n['user']['hwModel']) + break + +iface.close() diff --git a/examples/pub_sub_example.py b/examples/pub_sub_example.py index a58d83a..79d49cf 100644 --- a/examples/pub_sub_example.py +++ b/examples/pub_sub_example.py @@ -13,7 +13,7 @@ if len(sys.argv) < 2: print(f"usage: {sys.argv[0]} host") sys.exit(1) -def onConnection(interface, topic=pub.AUTO_TOPIC): +def onConnection(interface, topic=pub.AUTO_TOPIC): # pylint: disable=unused-argument """This is called when we (re)connect to the radio.""" print(interface.myInfo) interface.close() diff --git a/examples/pub_sub_example2.py b/examples/pub_sub_example2.py index b8ee60b..03edacd 100644 --- a/examples/pub_sub_example2.py +++ b/examples/pub_sub_example2.py @@ -14,11 +14,11 @@ if len(sys.argv) < 2: print(f"usage: {sys.argv[0]} host") sys.exit(1) -def onReceive(packet, interface): +def onReceive(packet, interface): # pylint: disable=unused-argument """called when a packet arrives""" print(f"Received: {packet}") -def onConnection(interface, topic=pub.AUTO_TOPIC): +def onConnection(interface, topic=pub.AUTO_TOPIC): # pylint: disable=unused-argument """called when we (re)connect to the radio""" # defaults to broadcast, specify a destination ID if you wish interface.sendText("hello mesh") diff --git a/examples/scan_for_devices.py b/examples/scan_for_devices.py index 6dc28c3..9971a93 100644 --- a/examples/scan_for_devices.py +++ b/examples/scan_for_devices.py @@ -3,7 +3,6 @@ """ import sys -import meshtastic from meshtastic.supported_device import get_unique_vendor_ids, active_ports_on_supported_devices from meshtastic.util import detect_supported_devices diff --git a/info/mac/rak11200.txt b/info/mac/rak11200.txt new file mode 100644 index 0000000..13d94b4 --- /dev/null +++ b/info/mac/rak11200.txt @@ -0,0 +1,52 @@ + + +% ioreg -p IOUSB > /tmp/a +# only a solid red light (pins GRND and BOOT0 jumpered) + +% ioreg -p IOUSB > /tmp/b +# solid red light and solid green light + +% ioreg -p IOUSB > /tmp/c +# nothing plugged in + + + +% diff /tmp/a /tmp/c +13c13 +< +-o AppleUSBXHCI Root Hub Simulation@14000000 +--- +> +-o AppleUSBXHCI Root Hub Simulation@14000000 +18d17 +< +-o USB Serial@14300000 + + +% diff /tmp/b /tmp/c +13c13 +< +-o AppleUSBXHCI Root Hub Simulation@14000000 +--- +> +-o AppleUSBXHCI Root Hub Simulation@14000000 +18d17 +< +-o USB Serial@14300000 + + + +system_profiler SPUSBDataType > /tmp/d +# red solid + + +system_profiler SPUSBDataType > /tmp/e +# nothing + + +% diff /tmp/d /tmp/e +38,48d37 +< USB Serial: +< +< Product ID: 0x7523 +< Vendor ID: 0x1a86 +< Version: 2.64 +< Speed: Up to 12 Mb/s +< Location ID: 0x14300000 / 33 +< Current Available (mA): 500 +< Current Required (mA): 98 +< Extra Operating Current (mA): 0 diff --git a/info/mac/techo.txt b/info/mac/techo.txt index ab2b12a..833bbda 100644 --- a/info/mac/techo.txt +++ b/info/mac/techo.txt @@ -30,3 +30,11 @@ drwxrwxrwx 1 bob staff 512 Feb 1 16:47 .fseventsd % diff /tmp/a /tmp/c > | +-o T-Echo v1@14300000 + +contents of: INFO_UF2.TXT + +UF2 Bootloader 0.6.1-2-g1224915 lib/nrfx (v2.0.0) lib/tinyusb (0.10.1-293-gaf8e5a90) lib/uf2 (remotes/origin/configupdate-9-gadbb8c7) +Model: LilyGo T-Echo +Board-ID: nRF52840-TEcho-v1 +SoftDevice: S140 version 6.1.1 +Date: Oct 13 2021 diff --git a/meshtastic/supported_device.py b/meshtastic/supported_device.py index 306355e..82c760e 100755 --- a/meshtastic/supported_device.py +++ b/meshtastic/supported_device.py @@ -66,6 +66,9 @@ heltec_v2_0 = SupportedDevice(name="Heltec", version="2.0", for_firmware="heltec heltec_v2_1 = SupportedDevice(name="Heltec", version="2.1", for_firmware="heltec-v2.1", baseport_on_linux="ttyUSB", baseport_on_mac="cu.usbserial-", usb_vendor_id_in_hex="10c4", usb_product_id_in_hex="ea60") +rak11200 = SupportedDevice(name="RAK 11200", version="", for_firmware="rak11200", + baseport_on_linux="ttyUSB", baseport_on_mac="cu.usbserial-", + usb_vendor_id_in_hex="1a86", usb_product_id_in_hex="7523") meshtastic_diy_v1 = SupportedDevice(name="Meshtastic DIY", version="1", for_firmware="meshtastic-diy-v1", baseport_on_linux="ttyUSB", baseport_on_mac="cu.usbserial-", usb_vendor_id_in_hex="10c4", usb_product_id_in_hex="ea60") @@ -86,7 +89,8 @@ rak4631_19003 = SupportedDevice(name="RAK 4631 19003", version="", for_firmware= supported_devices = [tbeam_v0_7, tbeam_v1_1, tbeam_M8N, tbeam_M8N_SX1262, tlora_v1_1, tlora_v1_3, tlora_v2_0, tlora_v2_1, tlora_v2_1_1_6, heltec_v1, heltec_v2_0, heltec_v2_1, - meshtastic_diy_v1, techo_1, rak4631_5005, rak4631_19003] + meshtastic_diy_v1, techo_1, rak4631_5005, rak4631_19003, + rak11200] def get_unique_vendor_ids():