Skip to content

Commit 4314156

Browse files
committed
further enhancements for activation
1 parent 139f61d commit 4314156

File tree

7 files changed

+268
-165
lines changed

7 files changed

+268
-165
lines changed

omni.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ def read_pdm_address(args, pa):
4141

4242

4343
def new_pod(args, pa):
44-
pa["id_lot"] = args.id_lot
45-
pa["id_t"] = args.id_t
44+
45+
if args.id_lot is not None:
46+
pa["id_lot"] = args.id_lot
47+
if args.id_t is not None:
48+
pa["id_t"] = args.id_t
4649
if args.radio_address is not None:
4750
if str(args.radio_address).lower().startswith("0x"):
4851
pa["radio_address"] = int(args.radio_address[2:], 16)
@@ -83,6 +86,10 @@ def activate(args, pa):
8386
call_api(args.url, REST_URL_ACTIVATE_POD, pa)
8487

8588

89+
def archive(args, pa):
90+
call_api(args.url, REST_URL_ARCHIVE_POD, pa)
91+
92+
8693
def start(args, pa):
8794
for i in range(0,48):
8895
pa["h" + str(i)] = args.basalrate
@@ -107,8 +114,8 @@ def main():
107114
subparser.set_defaults(func=read_pdm_address)
108115

109116
subparser = subparsers.add_parser("newpod", help="newpod -h")
110-
subparser.add_argument("id_lot", type=int, help="Lot number of the pod")
111-
subparser.add_argument("id_t", type=int, help="Serial number of the pod")
117+
subparser.add_argument("id_lot", type=int, help="Lot number of the pod", default=None, nargs="?")
118+
subparser.add_argument("id_t", type=int, help="Serial number of the pod", default=None, nargs="?")
112119
subparser.add_argument("radio_address", help="Radio radio_address of the pod", default=None, nargs="?")
113120
subparser.set_defaults(func=new_pod)
114121

@@ -147,6 +154,9 @@ def main():
147154
subparser = subparsers.add_parser("restart", help="restart -h")
148155
subparser.set_defaults(func=restart)
149156

157+
subparser = subparsers.add_parser("archive", help="archive -h")
158+
subparser.set_defaults(func=archive)
159+
150160
args = parser.parse_args()
151161
pa = get_auth_params()
152162
args.func(args, pa)

podcomm/manchester.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
def encodeSingleByte(d):
55
e = 0
66
for i in range(0, 8):
7-
e = e << 2
7+
8+
e = e >> 2
89
if d & 0x01 == 0:
9-
e |= 2
10+
e |= 0x8000
1011
else:
11-
e |= 1
12+
e |= 0x4000
1213
d = d >> 1
1314
return bytes([(e >> 8), e & 0xff])
1415

1516
class ManchesterCodec:
1617
def __init__(self):
17-
self.preamble = bytes([0x66,0x65]) * 200 + bytes([0xa5, 0x5a])
18+
#self.preamble = bytes([0x65,0x66]) * 20 + bytes([0xa5, 0x5a])
19+
self.preamble = bytes()
1820
self.decode_dict = dict()
1921
self.encode_dict = dict()
2022
for i in range(0, 256):
@@ -27,7 +29,7 @@ def __init__(self):
2729
self.noiseLines = []
2830
for x in range(0, 32):
2931
noiseLine = "f"
30-
for i in range(0, 159):
32+
for i in range(0, 79):
3133
noiseLine += random.choice(noiseNibbles)
3234
self.noiseLines.append(bytearray.fromhex(noiseLine))
3335

@@ -48,13 +50,5 @@ def encode(self, data):
4850
encoded += self.noiseLines[self.noiseSeq]
4951
self.noiseSeq += 1
5052
self.noiseSeq %= 32
51-
52-
minPreamble = 4
53-
minNoise = 2
54-
available = 512 - len(data) - minPreamble - minNoise
55-
dataIndex = len(self.preamble)
56-
portion = int(available / 2)
57-
preambleIncluded = minPreamble + portion
58-
noiseIncluded = minNoise + available - portion
59-
return encoded[dataIndex - preambleIncluded: dataIndex + noiseIncluded]
53+
return encoded[0:80]
6054

0 commit comments

Comments
 (0)