Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Commit

Permalink
added --miner as arg with default set to miner:4467
Browse files Browse the repository at this point in the history
  • Loading branch information
gradoj committed Mar 30, 2022
1 parent 1976fa8 commit ea2e7b3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ This is a client to run discovery(disco) mode on a Helium hotspots. Disco mode s
# how to run it
This disco client runs in parallel with the helium miner on the hotspot. When invoked it acts as a lorawan network server while it delivers the disco packet to the forwarder at which point this code is complete and exits. It only responds the the PULL_DATA when polled by the packet forwarder. If you want to run the miner and this disco client some kind of packet multiplexer is required to handle running a single packet forwarder with the miner and this client. The chirpstack packet multiplexer or the helium middleman software both should work but chirpstack is preferred as it does not alter the packet metadata.

Add your port and hotspot address to the disco.json configuration file. The port is used to listed to the forwarder(multiplexer) on so make sure that matches the chirpstack multiplexer config. Leave the disco id field empty and that will automatically be filled out by when the code runs.
Add your listening port to the disco.json configuration file. The port is used to listed to the forwarder(multiplexer) on so make sure that matches the chirpstack multiplexer config. You can leave the disco id and hotspot_addr fields empty and that will automatically be filled out by when the code runs.

# how it works
The server discomode.io generates and provides packets for the client(this software) running on the hotspot. Disco mode uses standard LoRaWAN packets and infrastrure to collect and report the packets transmitted by the hotspot. Discoclient acts as a bridge between discomode.io and the lorawan packet forwarder running on the hotspots so is responsible for getting a disco id, obtaining the disco packet, and conveying that packet to the forwarder to be transmitted.
The server discomode.io generates and provides packets for the client(this software) running on the hotspot. Disco mode uses standard LoRaWAN packets and infrastrure to collect and report the packets transmitted by the hotspot. Discoclient acts as a bridge between discomode.io and the lorawan packet forwarder running on the hotspots so is responsible for getting a disco id(lorawan sensor id), obtaining the disco packet, and conveying that packet to the forwarder to be transmitted.

## get id
discomode.io/api/id?hs_addr=your_hotspot_address
Expand All @@ -21,6 +21,9 @@ discomode.io/api/disco?id=your_disco_id&payload=deadbeef
The payload to be transmitted can be optionally be passed in as hex strings. This isn't really complete yet as it isn't encrypted as per lorawan specs with the appskey nor is there any way to retrieve it.

## view results

dash.discomode.io

All data packets are paid for through the Helium router and collected. The disco results can be view through a visual map view or json list of hotspots.

### Map view
Expand Down
12 changes: 7 additions & 5 deletions disco.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,18 +290,20 @@ def check_msgs(id):
if __name__ == "__main__":
parser = argparse.ArgumentParser("disco mode client", add_help=True)

parser.add_argument('-n', '--number', help='number of packets to send, default:6', default=1, type=int)
parser.add_argument('-d', '--delay', help='delay in seconds between packets, default:5', default=1, type=int)
parser.add_argument('-p', '--payload', help='payload to be sent as string, default:30', default='30', type=str)
parser.add_argument('-i', '--interval', help='polling interval in seconds to check for commands, default:0',default=60,type=int)
parser.add_argument('-n', '--number', help='number of packets to send, default=6', default=1, type=int)
parser.add_argument('-d', '--delay', help='delay in seconds between packets, default=5', default=1, type=int)
parser.add_argument('-p', '--payload', help='payload to be sent as string, default=30', default='30', type=str)
parser.add_argument('-i', '--interval', help='polling interval in seconds to check for commands, default=0',default=60,type=int)
parser.add_argument('-m', '--miner', help='name of the docker container or ip and port of miner, default=miner:4467',default='miner:4467',type=str)

args = parser.parse_args()
packet_num=args.number
packet_delay=args.delay
payload=args.payload
poll=int(args.interval)
miner=str(args.miner)

miner_rpc = mrpc.mrpc()
miner_rpc = mrpc.mrpc(miner)

# open json config file for config
with open('disco.json') as json_file:
Expand Down
4 changes: 2 additions & 2 deletions mrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
commands=('info_height','info_name','info_block_age','info_p2p_status','info_region','info_summary','info_location','info_version','peer_addr')

class mrpc:
def __init__(self):
def __init__(self,miner):
self.session = requests.Session()
self.host = 'http://miner:4467'
self.host = 'http://'+miner
self.header = {'Content-type': 'application/json'}
self.payload = {"jsonrpc":"2.0",
"id":1,
Expand Down

0 comments on commit ea2e7b3

Please sign in to comment.