This repository has been archived on 2019-08-15. You can view files and clone it, but cannot push or open issues or pull requests.
TheThingsNetworkGateway/send_msg.py

31 lines
903 B
Python
Raw Normal View History

2018-11-15 18:21:45 +00:00
#!/usr/bin/env python3
import argparse
import logging
from lora_single_chan_gateway.board_config import LoraBoardDraguino
logging.basicConfig(level=logging.DEBUG)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('message', type=str, help='message to send')
# http://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF95.html "packet format"
parser.add_argument('--from', type=int, default=0xFF)
parser.add_argument('--to', type=int, default=0xFF)
parser.add_argument('--id', type=int, default=0x00)
parser.add_argument('--flags', type=int, default=0x00)
args = parser.parse_args()
GATEWAY_HEADER = bytes([args.to, args.__dict__['from'], args.id, args.flags])
with LoraBoardDraguino(433300000, 7) as board:
msg = GATEWAY_HEADER + args.message.encode('utf-8')
print(msg)
board.send_package(msg)