關於 LoRa,既不是 WiFi 無線網路,也不是依附在電信業者的行動通訊協定。 LoRa 是開源的 Mesh 無線通訊系統!
意思就是,架個基地台、裝好天線,和周邊的裝置進行通訊。 有點像是在玩無線電。
Raspberry Pi
│
│ Serial / USB
▼
Meshtastic Node A
│
│ LoRa
▼
Meshtastic Node B
│
▼
Mobile Phone
import meshtastic.serial_interface
interface = (
meshtastic.serial_interface
.SerialInterface(
devPath="/dev/ttyACM0"
)
)
interface.sendText(
"beggarFridge online"
)
interface.close()
剛剛提到,因為頻寬較低,傳輸的資料,重點應該放在什麼資料數值多少,如果包含太多字如 Json 的括號等,會大幅降低效率。
{
"items": 12,
"expiring": 2,
"expired": 0,
"server": "online"
}
FG I:12 E:2 X:0 S:OK
def build_mesh_message(status):
return (
f"FG "
f"I:{status['items']} "
f"E:{status['expiring']} "
f"X:{status['expired']} "
f"S:{status['server']}"
)
def send_fridge_status():
status = (
fridge_status_service
.get_status()
)
message = (
build_mesh_message(
status
)
)
mesh_service.send(
message
)