| @@ -38,8 +38,6 @@ from lora_comms import make_pktbuf | |||||
| import multicast | import multicast | ||||
| from util import * | from util import * | ||||
| domain = b'com.funkthat.lora.irrigation.shared.v0.0.1' | |||||
| # Response to command will be the CMD and any arguments if needed. | # Response to command will be the CMD and any arguments if needed. | ||||
| # The command is encoded as an unsigned byte | # The command is encoded as an unsigned byte | ||||
| CMD_TERMINATE = 1 # no args: terminate the sesssion, reply confirms | CMD_TERMINATE = 1 # no args: terminate the sesssion, reply confirms | ||||
| @@ -55,11 +53,13 @@ CMD_CLEAR = 7 # arg: (): clears all future commands, but keeps current running | |||||
| class LORANode(object): | class LORANode(object): | ||||
| '''Implement a LORANode initiator.''' | '''Implement a LORANode initiator.''' | ||||
| SHARED_DOMAIN = b'com.funkthat.lora.irrigation.shared.v0.0.1' | |||||
| MAC_LEN = 8 | MAC_LEN = 8 | ||||
| def __init__(self, syncdatagram, shared=None): | def __init__(self, syncdatagram, shared=None): | ||||
| self.sd = syncdatagram | self.sd = syncdatagram | ||||
| self.st = Strobe(domain, F=KeccakF(800)) | |||||
| self.st = Strobe(self.SHARED_DOMAIN, F=KeccakF(800)) | |||||
| if shared is not None: | if shared is not None: | ||||
| self.st.key(shared) | self.st.key(shared) | ||||
| @@ -80,7 +80,7 @@ class LORANode(object): | |||||
| origstate = self.st.copy() | origstate = self.st.copy() | ||||
| while True: | while True: | ||||
| resp = await self.sd.sendtillrecv(msg, .25) | |||||
| resp = await self.sd.sendtillrecv(msg, .50) | |||||
| #_debprint('got:', resp) | #_debprint('got:', resp) | ||||
| # skip empty messages | # skip empty messages | ||||
| @@ -601,6 +601,8 @@ class TestSequencing(unittest.IsolatedAsyncioTestCase): | |||||
| self.assertEqual(col, list(range(1, 7))) | self.assertEqual(col, list(range(1, 7))) | ||||
| class TestLORANode(unittest.IsolatedAsyncioTestCase): | class TestLORANode(unittest.IsolatedAsyncioTestCase): | ||||
| shared_domain = b'com.funkthat.lora.irrigation.shared.v0.0.1' | |||||
| @timeout(2) | @timeout(2) | ||||
| async def test_lora(self): | async def test_lora(self): | ||||
| _self = self | _self = self | ||||
| @@ -625,7 +627,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase): | |||||
| return resp | return resp | ||||
| async def runner(self): | async def runner(self): | ||||
| l = Strobe(domain, F=KeccakF(800)) | |||||
| l = Strobe(TestLORANode.shared_domain, F=KeccakF(800)) | |||||
| l.key(shared_key) | l.key(shared_key) | ||||