-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmcci_catena_provision_actility.py
1115 lines (855 loc) · 29 KB
/
mcci_catena_provision_actility.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
##############################################################################
#
# Module: mcci_catena_provision_actility.py
#
# Function:
# Provision a catena device through Actility API
#
# Copyright and License:
# This file copyright (c) 2021 by
#
# MCCI Corporation
# 3520 Krums Corners Road
# Ithaca, NY 14850
#
# See accompanying LICENSE file for copyright and license information.
#
# Author:
# Sivaprakash Veluthambi, MCCI May 2021
#
##############################################################################
# Built-in imports
import argparse
import json
import os
import re
import subprocess
import sys
# Lib imports
import requests
import ruamel.yaml
import serial
from serial.tools import list_ports
class AppContext:
'''
class contains common attributes and default values
'''
def __init__(self):
self.nWarnings = 0
self.nErrors = 0
self.fVerbose = False
self.fWerror = False
self.fDebug = False
self.sPort = None
self.nBaudRate = 115200
self.fWriteEnable = True
self.fEcho = False
self.fInfo = False
self.fPermissive = False
self.fRegister = False
self.dVariables = {
'APPEUI': None,
'APPKEY': None,
'DEVEUI': None,
'APPID' : None,
'BASENAME' : None,
'SYSEUI' : None,
'MODEL': None,
}
def warning(self, msg):
'''
Display warning message
Args:
msg: receives warning messages
Returns:
No explicit result
'''
self.nWarnings = self.nWarnings + 1
print (msg, end='\n')
def error(self, msg):
'''
Display error message
Args:
msg: receives error messages
Returns:
No explicit result
'''
self.nErrors = self.nErrors + 1
print (msg, end='\n')
def fatal(self, msg):
'''
Display error message and exit
Args:
msg: receives error messages
Returns:
No explicit result
'''
self.error(msg)
sys.exit(1)
def debug(self, msg):
'''
Display debug message
Args:
msg: receives debug messages
Returns:
No explicit result
'''
if (self.fDebug):
print (msg, end='\n')
def verbose(self, msg):
'''
Display verbose message
Args:
msg: receives verbose message
Returns:
No explicit result
'''
if (self.fVerbose):
print (msg, end='\n')
def getnumerrors(self):
'''
Get the error count
Args:
NA
Returns:
Number of errors occured
'''
nErrors = self.nErrors
if (self.fWerror):
nErrors = nErrors + self.nWarnings
return nErrors
def exitchecks(self):
'''
Display total errors detected
Args:
NA
Returns:
0 if no errors occured or 1 otherwise
'''
errCount = self.getnumerrors()
if (errCount > 0):
self.error("{} errors detected".format(errCount))
return 1
else:
self.debug("No errors detected")
return 0
##############################################################################
#
# Provisioning Functions
#
##############################################################################
def openport(sPortName):
'''
Open serial port
Args:
sPortName: serial port name
Returns:
True if port opens or None otherwise
'''
# Check port is available
listPort = []
listPort = list(list_ports.comports())
portAvail = [p.device for p in listPort if p.device == sPortName]
if not portAvail:
oAppContext.error("Port {} is unavailable".format(sPortName))
return None
# Open port
if not comPort.is_open:
try:
comPort.open()
if comPort.is_open:
oAppContext.debug("Port {} opened"
.format(sPortName)
)
return True
except Exception as err:
oAppContext.fatal("Can't open port {0} : {1}"
.format(sPortName, err)
)
return None
else:
oAppContext.warning("Port {} is already opened".format(sPortName))
return True
def writecommand(sCommand):
'''
Transfer command to catena and receive result.
It sends `sCommand` (followed by a new line) to the port. It then reads
up to 1k characters until a timeout occurs (which is one second). It
then tries to parse the normal catena response which ends either with
"\nOK\n" or "\n?<error>\n"
Args:
sCommand: catena command
Returns:
catena result if success; None and error message if fail.
'''
oAppContext.debug(">>> {}".format(sCommand))
if comPort.in_waiting != 0:
comPort.reset_input_buffer()
try:
comPort.write(sCommand.encode())
oAppContext.verbose("Command sent: {}".format(sCommand))
except Exception as err:
oAppContext.error("Can't write command {0} : {1}".format(
sCommand,
err)
)
return None
try:
result = comPort.read(1024)
sResult = result.decode()
comPort.reset_input_buffer()
except Exception as err:
oAppContext.error("Can't read command response : {}".format(err))
return None
if sResult:
debugMsg = '<<< ' + sResult.replace('\r', '')
oAppContext.debug(debugMsg)
sResult = '\n'.join(sResult.splitlines())
sResult = sResult + '\n'
# Parse the results
d= {'code': 'timed out', 'msg': None}
sResult = re.search(
r'^([\s\S]*)^\n([OK]*[\s\S]*)\n$',
sResult,
re.MULTILINE)
if sResult:
d['msg'] = sResult.group(1)
d['code'] = sResult.group(2)
else:
oAppContext.error("Error parsing catena response")
if 'OK' in d['code']:
return d['msg']
else:
return None, d['code'], d['msg']
def setechooff():
'''
To turn off the system echo
Args:
NA
Returns:
True; None if fails
'''
sEchoOffCommand = "system echo off\n"
sEcho = writecommand(sEchoOffCommand)
if type(sEcho) is tuple and sEcho[0] is None:
oAppContext.fatal("Can't turn off echo: {}".format(sEcho[1]))
else:
return True
def getversion():
'''
Get the identity of the attached device.
Args:
NA
Returns:
A dict containing the catena version info; None if fails
'''
sVersionCommand = "system version\n"
sVersion = writecommand(sVersionCommand)
if type(sVersion) is tuple and sVersion[0] is None:
dResult = {'Board': '?', 'Platform-Version': '?'}
return dResult
sVersion = re.sub(r'\n', '\n\r', sVersion, re.MULTILINE)
sVersionWrap = '\r' + sVersion + '\n'
oAppContext.verbose("sVersionWrap: {}".format(sVersionWrap))
sVersionWrap = re.findall(
r'\r(\S+): ([ \S]+)\n',
sVersionWrap,
re.MULTILINE)
dResult = dict(sVersionWrap)
if ('Board' in dResult and 'Platform-Version' in dResult):
return dResult
else:
oAppContext.error("Unrecognized version response: {}".format(sVersion))
return None
def getsyseui(fPermissive):
'''
Get the system EUI for the attached device.
The device is queried to get the system EUI, which is returned as a
16-character hex string.
Args:
fPermissive: boolean value
Returns:
A dict containing the system EUI info; None if error occurs
'''
sEuiCommand = "system configure syseui\n"
lenEui = 64 / 4
kLenEuiStr = int(lenEui + (lenEui / 2))
sEUI = writecommand(sEuiCommand)
if (type(sEUI) is tuple) and (sEUI[0] is None):
if not fPermissive:
oAppContext.error("Error getting syseui: {}".format(sEUI[1]))
else:
oAppContext.warning("Error getting syseui: {}".format(sEUI[1]))
return None
hexmatch = re.match(r'^(([0-9A-Fa-f]{2})-){7}([0-9A-Fa-f]{2})', sEUI)
if (len(sEUI) != kLenEuiStr) or hexmatch is None:
oAppContext.error("Unrecognized EUI response: {}".format(sEUI))
return None
else:
sEUI = re.sub(r'-', '', sEUI)
return sEUI
def checkcomms(fPermissive):
'''
Try to recognize the attached device, and verify that comms are
working.
The device is queried to get the system EUI, which is returned as a
16-character hex string, as well as the firmware version.
${SYSEUI} (aka oAppContext.dVariables['SYSEUI']) is set to the fetched
syseui.
oAppContext.tVersion is set to the fetched version
Args:
fPermissive: boolean value
Returns:
A dict containing the information; True if success or False if fails
'''
oAppContext.debug("CheckComms")
tVersion = getversion()
if tVersion is not None:
sEUI = getsyseui(fPermissive)
else:
sEUI = None
if (tVersion is not None) and (sEUI is None) and fPermissive:
sEUI = '{syseui-not-set}'
if (tVersion is not None) and (sEUI is not None):
oAppContext.verbose(
"\n Catena Type: {0}\
\n Platform Version: {1}\n SysEUI: {2}"
.format(
tVersion['Board'],
tVersion['Platform-Version'],
sEUI
)
)
if oAppContext.fInfo:
oAppContext.verbose(
"\n Catena Type: {0}\
\n Platform Version: {1}\n SysEUI: {2}"
.format(
tVersion['Board'],
tVersion['Platform-Version'],
sEUI
)
)
oAppContext.dVariables['SYSEUI'] = sEUI.upper()
oAppContext.tVersion = tVersion
return True
elif (tVersion is not None) and (sEUI is None):
oAppContext.fatal("SysEUI not set")
return False
def verify_response(rType, stat, resp):
'''
It will verify the response of API result whether it is success or not
Args:
rType: request type
stat: response code
resp: api result
Returns:
True if success
'''
requestType = rType
responseCode = stat
apiResponse = resp
if requestType == 'get_token' and responseCode == 200:
oAppContext.verbose("\nResponse Code: {}\n".format(responseCode))
elif requestType == 'create_device' and responseCode == 201:
oAppContext.verbose("\nResponse Code: {}\n".format(responseCode))
elif requestType == 'get_req' and responseCode == 200:
oAppContext.verbose("\nResponse Code: {}\n".format(responseCode))
else:
oAppContext.verbose("\nResponse Code: {}\n".format(responseCode))
oAppContext.verbose("\nResponse: \n{}\n".format(apiResponse))
oAppContext.fatal("Error: API Requset Failed")
return True
def get_request(url, header):
'''
It will perform GET request
Args:
url: request url
header: header information
Returns:
return API response if success
'''
gUrl = url
gHeader = header
reqType = 'get_req'
response = requests.get(gUrl, headers=gHeader)
oAppContext.verbose("\nRequest Header:\n\n{}\n".format(
response.request.headers)
)
responseCode = response.status_code
result = response.json()
verify_response(reqType, responseCode, result)
return result
def post_request(url, header, data):
'''
It will perform POST request
Args:
url: request url
header: header information
data: POST data
Returns:
return API response if success
'''
pUrl = url
pHeader = header
pData = data
reqType = None
if pHeader['Content-Type'] == 'application/json':
pData = json.dumps(pData)
if 'token' in pUrl:
reqType = 'get_token'
if 'devices' in pUrl:
reqType = 'create_device'
response = requests.post(pUrl, headers=pHeader, data=pData)
oAppContext.verbose("\nRequest Header:\n\n{}\n".format(
response.request.headers)
)
oAppContext.verbose("\nRequest Body:\n\n{}\n".format(
response.request.body)
)
responseCode = response.status_code
result = response.json()
verify_response(reqType, responseCode, result)
return result
def get_token(url, tconfiginfo):
'''
Get token configuration details and send it to post request for
receive token result
Args:
url: request url
tconfiginfo: config dict
Returns:
token details if success
'''
reqUrl = url
dConfig = tconfiginfo
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json'
}
pResult = post_request(reqUrl, headers, dConfig)
oAppContext.debug("Access Token Generated: \n{}\n".format(pResult))
return pResult
def get_appinfo(url, token):
'''
Send request to receive application information
Args:
url: request url
token: access token
Returns:
application information if success
'''
reqUrl = url
authToken = token
appInfo = dict()
headers = {
'Accept': 'application/json',
'Authorization': None
}
headers['Authorization'] = authToken
appResult = get_request(reqUrl, headers)
oAppContext.verbose("Application Info Result: \n{}\n".format(appResult))
for i in range(len(appResult)):
appInfo[appResult[i]['ref']] = appResult[i]['name']
return appInfo
def create_device(dUrl, rUrl, authtoken, dProfId):
'''
Get device creation information and send post request for create a
new device. It also verify the device configuration details before
sending post request
Args:
dUrl: device creation request url
rUrl: application info request url
authtoken: access token
dProfId: device profile id dict
Returns:
created device result if success
'''
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': None
}
dCreateDevConfig = {
'name': None,
'EUI': None,
'activationType': 'OTAA',
'deviceProfileId': None,
'applicationEUI': None,
'applicationKey': None
}
reqUrl = dUrl
routeUrl = rUrl
headers['Authorization'] = authtoken
if ((not oAppContext.dVariables['SYSEUI']) or
(oAppContext.dVariables['SYSEUI'] == 'SYSEUI-NOT-SET')):
while True:
devEUI = input('Enter Device EUI: ')
if re.match(r'[0-9A-F]{16}', devEUI):
oAppContext.dVariables['SYSEUI'] = devEUI.replace('\n', '')
dCreateDevConfig['EUI'] = devEUI.replace('\n', '')
oAppContext.dVariables['DEVEUI'] = devEUI.replace('\n', '')
break
else:
print('Invalid device EUI entered.')
else:
devEUI = oAppContext.dVariables['SYSEUI']
dCreateDevConfig['EUI'] = devEUI.replace('\n', '')
oAppContext.dVariables['DEVEUI'] = devEUI.replace('\n', '')
devName = oAppContext.dVariables['BASENAME']
devNameExChar = oAppContext.dVariables['DEVEUI']
devNameResult = devName + devNameExChar[-4:]
dCreateDevConfig['name'] = devNameResult
if (not oAppContext.dVariables['MODEL']):
for k, v in dProfId.items():
for idx, val in enumerate(v):
print("{0}. {1}\n".format(idx+1, val))
while True:
modIp = input('Select Device Profile ID (Enter 1 or 2): ')
if modIp == 1:
oAppContext.dVariables['MODEL'] = dProfId['profile_id'][modIp-1]
dCreateDevConfig['deviceProfileId'] = dProfId['profile_id'][modIp-1]
break
elif modIp == 2:
oAppContext.dVariables['MODEL'] = dProfId['profile_id'][modIp-1]
dCreateDevConfig['deviceProfileId'] = dProfId['profile_id'][modIp-1]
break
else:
print('Invalid number entered.')
else:
dCreateDevConfig['deviceProfileId'] = oAppContext.dVariables['MODEL']
if (not oAppContext.dVariables['APPEUI']):
while True:
appEUI = input('Enter App EUI: ')
if re.match(r'[0-9A-F]{16}', appEUI):
oAppContext.dVariables['APPEUI'] = appEUI
dCreateDevConfig['applicationEUI'] = appEUI
break
else:
print('Invalid application EUI entered.')
else:
dCreateDevConfig['applicationEUI'] = oAppContext.dVariables['APPEUI']
if (not oAppContext.dVariables['APPKEY']):
while True:
appKey = input('Enter App Key: ')
if re.match(r'[0-9A-F]{32}', appKey):
oAppContext.dVariables['APPKEY'] = appKey
dCreateDevConfig['applicationKey'] = appKey
break
else:
print("Invalid application key entered.")
else:
dCreateDevConfig['applicationKey'] = oAppContext.dVariables['APPKEY']
if (not oAppContext.dVariables['APPID']):
appIdResult = get_appinfo(routeUrl, authtoken)
appIdList = []
print("\nAPP ID APPLICATION NAME")
print("\n==========================")
for rId, rName in appIdResult.items():
print("\n{} - {}".format(rId, rName))
while True:
appId = input('\nEnter App ID: ')
if re.match(r'[0-9]{5}',appId):
appId = str(appId)
appIdList.append(appId)
oAppContext.dVariables['APPID'] = appIdResult[appId]
dCreateDevConfig['routeRefs'] = appIdList
break
else:
print("Invalid application id entered.")
else:
appIdList = []
appFlag = 0
appName = oAppContext.dVariables['APPID']
appIdResult = get_appinfo(routeUrl, authtoken)
for rId, rName in appIdResult.items():
if (rName == appName):
appFlag = 1
appId = rId
if (appFlag == 1):
appIdList.append(appId)
dCreateDevConfig['routeRefs'] = appIdList
else:
oAppContext.fatal("Invalid APPID Received")
pResult = post_request(reqUrl, headers, dCreateDevConfig)
oAppContext.debug("Device Created: \n{}\n".format(pResult))
return pResult
def get_deviceinfo(url, refId, authtoken):
'''
Get device info and send request to receive created device information
Args:
url: request url
refId: device reference id
authtoken: access token
Returns:
created device information result if success
'''
headers = {
'Accept': 'application/json',
'Authorization': None
}
devId = refId
reqUrl = url + devId
headers['Authorization'] = authtoken
gResult = get_request(reqUrl, headers)
oAppContext.debug("Device Info: \n{}\n".format(gResult))
return gResult
def expand(sLine):
'''
Perform macro expansion on a line of text
This function is looking for strings of the form "${name}" in sLine. If
${name} was written, and name was found in the dict, name's value is
used.
Args:
sLine: catena command line from cat file
Returns:
String suitably expanded
'''
sResult = re.search(r'^([a-z ]+)\$(\{.*\})$', sLine)
if not sResult:
return sLine
if sResult:
sPrefix = sResult.group(1)
sWord = re.search(r'\$\{(.*)\}', sLine)
sName = sWord.group(1)
if not sName in oAppContext.dVariables:
oAppContext.error("Unknown macro {}".format(sName))
sValue = '{' + sName + '}'
else:
sValue = oAppContext.dVariables[sName]
sResult = sPrefix + sValue
oAppContext.verbose("Expansion of {0}: {1}".format(sLine, sResult))
return sResult
def doscript(sFileName):
'''
Perform macro expansion on a line of text.
The file is opened and read line by line.
Blank lines are ignored. Any text after a '#' character is treated as a
comment and discarded. Variables of the form ${name} are expanded. Any
error causes the script to stop.
Args:
sFileName: script name
Returns:
True for script success, False for failure
'''
oAppContext.debug("DoScript: {}".format(sFileName))
try:
with open(sFileName, 'r') as rFile:
rFile = rFile.readlines()
except EnvironmentError as e:
oAppContext.error("Can't open file: {}".format(e))
return False
if not rFile:
oAppContext.error("Empty file")
return False
for line in rFile:
line = re.sub('\n$', '', line)
line = re.sub(r'^\s*#.*$', '', line)
line = expand(line)
if (re.sub(r'^\s*$', '', line) != ''):
if (oAppContext.fEcho):
sys.stdout.write(line + '\n')
if (oAppContext.fWriteEnable):
sResult = writecommand((re.sub('\n$', '', line)) + '\n')
if not (type(sResult) is tuple and sResult[0] is None):
continue
else:
oAppContext.error("Line: {0}\nError: \n{1}".format(
line,
sResult[1])
)
return False
return True
def closeport(sPortName):
'''
Close serial port
Args:
sPortName: serial port name
Returns:
True if closed or None otherwise
'''
if comPort.is_open:
comPort.reset_input_buffer()
comPort.reset_output_buffer()
comPort.close()
oAppContext.debug('Port {} closed'.format(sPortName))
return True
else:
oAppContext.error('Port {} already closed'.format(sPortName))
return None
##############################################################################
#
# main
#
##############################################################################
if __name__ == '__main__':
pName = os.path.basename(__file__)
pDir = os.path.dirname(os.path.abspath(__file__))
oAppContext = AppContext()
optparser = argparse.ArgumentParser(
description='MCCI Catena Provisioning')
optparser.add_argument(
'-baud',
action='store',
nargs='?',
dest='baudrate',
type=int,
help='Specify the baud rate as a number. Default is 115200')
optparser.add_argument(
'-port',
action='store',
nargs=1,
dest='portname',
type=str,
required=True,
help='Specify the COM port name. This is system specific')
optparser.add_argument(
'-D',
action='store_true',
default=False,
dest='debug',
help='Operate in debug mode. Causes more output to be produced')
optparser.add_argument(
'-info',
action='store_true',
default=False,
dest='info',
help='Display the Catena info')
optparser.add_argument(
'-v',
action='store_true',
default=False,
dest='verbose',
help='Operate in verbose mode')
optparser.add_argument(
'-echo',
action='store_true',
default=False,
dest='echo',
help='Echo all device operations')
optparser.add_argument(
'-V',
action='append',
dest='vars',
help='Specify ttn config info in name=value format')
optparser.add_argument(
'-nowrite',
action='store_false',
default=True,
dest='writeEnable',
help='Disable writes to the device')
optparser.add_argument(
'-permissive',
action='store_true',
default=False,
dest='permissive',
help='Don\'t give up if SYSEUI isn\'t set.')
optparser.add_argument(
'-r',
action='store_true',
default=False,
dest='register',
help='Register the device in actility network')
optparser.add_argument(
'-Werror',
action='store_true',
default=False,
dest='warning',
help='Warning messages become error messages')
optparser.add_argument(
'-s',
action='store',
nargs=1,
dest='script',
type=str,
help='Specify script name to load catena info')