Meshtastic python程式送訊息範例 --- 可以參照我之前的可攜python環境寫一個批次來跑 [Meshtastic Python 的基礎可攜環境製作](https://hackmd.io/4RhEkBKSSjmRZtN_NQ67cg) 寫一個範例 mesh_send_example.py > 範例也是通訊介面為COM3來測試。 import meshtastic import meshtastic.serial_interface from pubsub import pub import threading import time try: interface = meshtastic.serial_interface.SerialInterface(devPath="COM3") print("連線成功") except Exception as e: print(f"連線失敗:{e}") try: interface.sendText("python example", wantAck=True, channelIndex=1) except Exception as e: print("發送錯誤", f"發送訊息失敗: {e}") if interface: interface.close() ### 範例中送訊息方式: ##### 送訊息至頻道 index 1 > 之前的篇章有講過,主要看要送哪個頻道在設備上的index數字 interface.sendText("python example", wantAck=True, channelIndex=1) ##### 如果要送指定裝置ID給!12345678 interface.sendText("python example", wantAck=True, destinationId="!12345678") ### 執行 python.exe mesh_send_example.py