diff --git a/comms/Makefile b/comms/Makefile index 6a5b41fbee23..e812e40d8ca6 100644 --- a/comms/Makefile +++ b/comms/Makefile @@ -1,242 +1,243 @@ COMMENT = Communication utilities SUBDIR += acfax SUBDIR += airspy SUBDIR += airspyhf SUBDIR += aldo SUBDIR += amtterm SUBDIR += anyremote SUBDIR += apitran SUBDIR += aprsd SUBDIR += atslog SUBDIR += bfhist SUBDIR += bforce-kst SUBDIR += birda SUBDIR += bladerf SUBDIR += bluegps SUBDIR += bluez-firmware SUBDIR += bpl+ SUBDIR += chirp SUBDIR += chu SUBDIR += conserver-com SUBDIR += cqrlog SUBDIR += cubicsdr SUBDIR += cutecom SUBDIR += cwdaemon SUBDIR += cwstudio SUBDIR += cyclonedds SUBDIR += dcf77pi SUBDIR += deforaos-phone SUBDIR += dfu-programmer SUBDIR += dfu-util SUBDIR += digiham SUBDIR += direwolf SUBDIR += dsd SUBDIR += dump1090 SUBDIR += ebook2cw SUBDIR += ebusd SUBDIR += echolinux SUBDIR += emacs-eat SUBDIR += ems-flasher SUBDIR += fl_moxgen SUBDIR += flamp SUBDIR += flcluster SUBDIR += fldigi SUBDIR += fllog SUBDIR += flmsg SUBDIR += flrig SUBDIR += flwrap SUBDIR += freedv SUBDIR += gammu SUBDIR += gensio SUBDIR += gkermit SUBDIR += gnocky SUBDIR += gnokii SUBDIR += gnuradio SUBDIR += gpredict SUBDIR += gqrx SUBDIR += gr-osmosdr SUBDIR += grig SUBDIR += gstreamer1-plugins-spandsp SUBDIR += hackrf SUBDIR += hamlib SUBDIR += hcidump SUBDIR += hidapi SUBDIR += hydrasdr SUBDIR += ibp SUBDIR += iceoryx SUBDIR += inspectrum SUBDIR += iwmbt-firmware SUBDIR += java-simple-serial-connector SUBDIR += kermit SUBDIR += klog SUBDIR += libdc SUBDIR += libfap SUBDIR += libfec SUBDIR += libfobos SUBDIR += libimobiledevice SUBDIR += libimobiledevice-glue SUBDIR += libirman SUBDIR += libmodbus SUBDIR += librs232 SUBDIR += libsdr SUBDIR += libsdr-gui SUBDIR += libticables2 SUBDIR += libticalcs2 SUBDIR += libusbmuxd SUBDIR += libusbsio SUBDIR += limesuite SUBDIR += linrad SUBDIR += linux-rl9-qt5-qtconnectivity SUBDIR += linux-rl9-qt5-qtsensors SUBDIR += linux-rl9-qt5-qtserialbus SUBDIR += linux-rl9-qt5-qtserialport SUBDIR += liquid-dsp SUBDIR += lirc SUBDIR += locator SUBDIR += lrzsz SUBDIR += lysdr + SUBDIR += meshcore-cli SUBDIR += mbelib SUBDIR += mgetty+sendfax SUBDIR += minicom SUBDIR += morse SUBDIR += multimon-ng SUBDIR += nanovna-saver SUBDIR += nasawash SUBDIR += nec2c SUBDIR += nmealib SUBDIR += obexapp SUBDIR += opencbm SUBDIR += opencbm-kmod SUBDIR += opencbm-plugin-xa1541 SUBDIR += openobex SUBDIR += openzwave SUBDIR += owfs SUBDIR += p5-Cisco-UCS SUBDIR += p5-Device-Gsm SUBDIR += p5-Device-Modem SUBDIR += p5-Device-SerialPort SUBDIR += p5-Fax-Hylafax-Client SUBDIR += p5-Nexmo-SMS SUBDIR += p5-SMS-SMS77 SUBDIR += p5-SMS-Send SUBDIR += p5-SMS-Send-DeviceGsm SUBDIR += p5-SMS-Send-NexmoUnicode SUBDIR += p5-SMS-Send-TW-HiAir SUBDIR += p5-SMS-Send-TW-PChome SUBDIR += p5-SMS-Send-TW-Socket2Air SUBDIR += p5-SMS-Send-TW-chtsns SUBDIR += p5-SMS-Send-TW-emome SUBDIR += pear-Horde_ActiveSync SUBDIR += pear-Horde_SyncMl SUBDIR += picocom SUBDIR += pr SUBDIR += predict SUBDIR += py-ModbusTCP SUBDIR += py-adafruit-ampy SUBDIR += py-cayennelpp SUBDIR += py-elelabs-zigbee-ezsp-utility SUBDIR += py-esptool SUBDIR += py-fritzconnection SUBDIR += py-hid SUBDIR += py-hidapi SUBDIR += py-libimobiledevice SUBDIR += py-libscrc SUBDIR += py-libusbsio SUBDIR += py-meshcore SUBDIR += py-nkdfu SUBDIR += py-pylink-square SUBDIR += py-pymodbus SUBDIR += py-pynitrokey SUBDIR += py-pyocd SUBDIR += py-pyocd-pemicro SUBDIR += py-pyserial SUBDIR += py-pyserial-asyncio SUBDIR += py-pyserial-asyncio-fast SUBDIR += py-sdm_modbus SUBDIR += py-spsdk SUBDIR += py-streamdeck SUBDIR += py-xmodem SUBDIR += pyla SUBDIR += qico SUBDIR += qpage SUBDIR += qrq SUBDIR += qsstv SUBDIR += qt5-connectivity SUBDIR += qt5-sensors SUBDIR += qt5-serialbus SUBDIR += qt5-serialport SUBDIR += qt6-connectivity SUBDIR += qt6-sensors SUBDIR += qt6-serialbus SUBDIR += qt6-serialport SUBDIR += qtel SUBDIR += quisk SUBDIR += redsea SUBDIR += remserial SUBDIR += rtl-433 SUBDIR += rtl-sdr SUBDIR += rtlbt-firmware SUBDIR += rubygem-callsign SUBDIR += rubygem-ruby-termios SUBDIR += rubygem-serialport SUBDIR += rxtx SUBDIR += scmxx SUBDIR += scrcpy SUBDIR += sdr++ SUBDIR += ser2net SUBDIR += serialoverip SUBDIR += sigdigger SUBDIR += sigutils SUBDIR += smstools3 SUBDIR += snap7 SUBDIR += soapyairspy SUBDIR += soapybladerf SUBDIR += soapyplutosdr SUBDIR += soapyredpitaya SUBDIR += soapyremote SUBDIR += soapysdr-rtlsdr SUBDIR += soapysdrhackrf SUBDIR += soapyuhd SUBDIR += spandsp SUBDIR += splat SUBDIR += sredird SUBDIR += sunxi-tools SUBDIR += suscan SUBDIR += suwidgets SUBDIR += svxlink SUBDIR += syncterm SUBDIR += tcpser SUBDIR += thebridge SUBDIR += tilp2 SUBDIR += tio SUBDIR += tits SUBDIR += tkscanfax SUBDIR += tlf SUBDIR += trustedqsl SUBDIR += twpsk SUBDIR += uarduno SUBDIR += uhd SUBDIR += uird SUBDIR += ujprog SUBDIR += unixcw SUBDIR += usbmuxd SUBDIR += viewfax SUBDIR += vrflash SUBDIR += wsjtx SUBDIR += wsjtz SUBDIR += wwl SUBDIR += wy60 SUBDIR += xastir SUBDIR += xcwcp SUBDIR += xdemorse SUBDIR += xdx SUBDIR += xlog SUBDIR += xmorse SUBDIR += xnec2c SUBDIR += xnecview SUBDIR += yagiuda SUBDIR += yfklog SUBDIR += zigbee2mqtt .include diff --git a/comms/meshcore-cli/Makefile b/comms/meshcore-cli/Makefile new file mode 100644 index 000000000000..30c588b013f7 --- /dev/null +++ b/comms/meshcore-cli/Makefile @@ -0,0 +1,24 @@ +PORTNAME= meshcore_cli +PORTVERSION= 1.4.0 +CATEGORIES= comms python +MASTER_SITES= PYPI +PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} + +MAINTAINER= samm@FreeBSD.org +COMMENT= CLI interface to MeschCore companion app over TCP or Serial +WWW= https://github.com/meshcore-dev/meshcore-cli + +LICENSE= MIT +LICENSE_FILE= ${WRKSRC}/LICENSE + +BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}hatchling>0:devel/py-hatchling@${PY_FLAVOR} +RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}meshcore>0:comms/py-meshcore@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}prompt-toolkit>0:devel/py-prompt-toolkit@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}pycryptodome>0:security/py-pycryptodome@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}requests>0:www/py-requests@${PY_FLAVOR} + +USES= python:3.10+ +USE_PYTHON= autoplist concurrent pep517 +NO_ARCH= yes + +.include diff --git a/comms/meshcore-cli/distinfo b/comms/meshcore-cli/distinfo new file mode 100644 index 000000000000..3735881d081e --- /dev/null +++ b/comms/meshcore-cli/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1770719737 +SHA256 (meshcore_cli-1.4.0.tar.gz) = 93c6d7a75c91bfd2d16c4a1248df9c2d663b1a7463f66251133ce38ea4264fc6 +SIZE (meshcore_cli-1.4.0.tar.gz) = 44928 diff --git a/comms/meshcore-cli/files/patch-src_meshcore__cli_meshcore__cli.py b/comms/meshcore-cli/files/patch-src_meshcore__cli_meshcore__cli.py new file mode 100644 index 000000000000..1e4a332117b6 --- /dev/null +++ b/comms/meshcore-cli/files/patch-src_meshcore__cli_meshcore__cli.py @@ -0,0 +1,94 @@ +--- src/meshcore_cli/meshcore_cli.py.orig 2020-02-02 00:00:00 UTC ++++ src/meshcore_cli/meshcore_cli.py +@@ -9,8 +9,6 @@ import time, datetime + import getopt, json, shlex, re + import logging + import requests +-from bleak import BleakScanner, BleakClient +-from bleak.exc import BleakError, BleakDBusError + import serial.tools.list_ports + from pathlib import Path + import traceback +@@ -27,6 +25,13 @@ from prompt_toolkit.document import Document + from Crypto.Cipher import AES + from Crypto.Hash import HMAC, SHA256 + ++try: ++ from bleak import BleakScanner, BleakClient ++ from bleak.exc import BleakError, BleakDBusError ++ BLEAK_AVAILABLE = True ++except ImportError: ++ BLEAK_AVAILABLE = False ++ + import re + + from meshcore import MeshCore, EventType, logger +@@ -4307,16 +4312,17 @@ async def main(argv): + case "-q": # quiet (turns logger to ERROR only) + quiet = True + case "-l" : +- print("BLE devices:") +- try : +- devices = await BleakScanner.discover(timeout=timeout) +- if len(devices) == 0: +- print(" No ble device found") +- for d in devices : +- if not d.name is None and d.name.startswith("MeshCore-"): +- print(f" {d.address} {d.name}") +- except (BleakError, BleakDBusError): +- print(" No BLE HW") ++ if BLEAK_AVAILABLE: ++ print("BLE devices:") ++ try : ++ devices = await BleakScanner.discover(timeout=timeout) ++ if len(devices) == 0: ++ print(" No ble device found") ++ for d in devices : ++ if not d.name is None and d.name.startswith("MeshCore-"): ++ print(f" {d.address} {d.name}") ++ except (BleakError, BleakDBusError): ++ print(" No BLE HW") + print("\nSerial ports:") + ports = serial.tools.list_ports.comports() + for port, desc, hwid in sorted(ports): +@@ -4325,13 +4331,14 @@ async def main(argv): + case "-S" : + choices = [] + +- try : +- devices = await BleakScanner.discover(timeout=timeout) +- for d in devices: +- if not d.name is None and d.name.startswith("MeshCore-"): +- choices.append(({"type":"ble","device":d}, f"{d.address:<22} {d.name}")) +- except (BleakError, BleakDBusError): +- logger.info("No BLE Device") ++ if BLEAK_AVAILABLE: ++ try : ++ devices = await BleakScanner.discover(timeout=timeout) ++ for d in devices: ++ if not d.name is None and d.name.startswith("MeshCore-"): ++ choices.append(({"type":"ble","device":d}, f"{d.address:<22} {d.name}")) ++ except (BleakError, BleakDBusError): ++ logger.info("No BLE Device") + + ports = serial.tools.list_ports.comports() + for port, desc, hwid in sorted(ports): +@@ -4388,7 +4395,7 @@ async def main(argv): + mc = await MeshCore.create_tcp(host=hostname, port=port, debug=debug, only_error=json_output) + elif not serial_port is None : # connect via serial port + mc = await MeshCore.create_serial(port=serial_port, baudrate=baudrate, debug=debug, only_error=json_output) +- else : #connect via ble ++ elif BLEAK_AVAILABLE : #connect via ble + client = None + if device or address and len(address.split(":")) == 6 : + pass +@@ -4471,6 +4478,9 @@ async def main(argv): + f.write(device.address) + elif not address is None: + f.write(address) ++ ++ if mc is None: ++ return + + handle_message.mc = mc # connect meshcore to handle_message + handle_advert.mc = mc diff --git a/comms/meshcore-cli/pkg-descr b/comms/meshcore-cli/pkg-descr new file mode 100644 index 000000000000..e518ff9bb894 --- /dev/null +++ b/comms/meshcore-cli/pkg-descr @@ -0,0 +1,3 @@ +meshcore-cli is a tool that connects to companion radio node (meshcore client) +over BLE, TCP or Serial and lets you interact with it from a terminal using a +command line interface.