|
1 | 1 | #!/usr/bin/env python2
|
2 | 2 |
|
3 |
| -# Copyright (c) 2016-2019, Pycom Limited. |
| 3 | +# Copyright (c) 2016-2020, Pycom Limited. |
4 | 4 | #
|
5 | 5 | # This software is licensed under the GNU GPL version 3 or any
|
6 | 6 | # later version, with permitted additional terms. For more information
|
@@ -751,10 +751,11 @@ def set_pycom_config(self, config_block, boot_fs_type=None):
|
751 | 751 | return self.set_pybytes_config(new_config_block, force_update=True)
|
752 | 752 |
|
753 | 753 | def print_cb(self, config_block):
|
754 |
| - for x in range(0, 30): |
755 |
| - print(binascii.hexlify(config_block[x * 32:x * 32 + 32])) |
| 754 | + if DEBUG: |
| 755 | + for x in range(0, 30): |
| 756 | + print(binascii.hexlify(config_block[x * 32:x * 32 + 32])) |
756 | 757 |
|
757 |
| - def set_pybytes_config(self, config_block, userid=None, device_token=None, mqttServiceAddress=None, network_preferences=None, extra_preferences=None, force_update=None): |
| 758 | + def set_pybytes_config(self, config_block, userid=None, device_token=None, mqttServiceAddress=None, network_preferences=None, extra_preferences=None, force_update=None, auto_start=None): |
758 | 759 | config_block = config_block.ljust(int(PARTITIONS.get('config')[1], 16), b'\x00')
|
759 | 760 | if device_token is not None:
|
760 | 761 | token = str(device_token)[0:39].ljust(40, b'\x00')
|
@@ -789,14 +790,23 @@ def set_pybytes_config(self, config_block, userid=None, device_token=None, mqttS
|
789 | 790 | else:
|
790 | 791 | fu = config_block[497]
|
791 | 792 |
|
| 793 | + if auto_start is not None: |
| 794 | + if auto_start: |
| 795 | + asf = b'\x01' |
| 796 | + else: |
| 797 | + asf = b'\x00' |
| 798 | + else: |
| 799 | + asf = config_block[498] |
| 800 | + |
792 | 801 | new_config_block = config_block[0:162] \
|
793 | 802 | +token \
|
794 | 803 | +address \
|
795 | 804 | +uid \
|
796 | 805 | +nwp \
|
797 | 806 | +ep \
|
798 | 807 | +fu \
|
799 | | - +config_block[498:] |
| 808 | + +asf \ |
| 809 | + +config_block[499:] |
800 | 810 |
|
801 | 811 | # self.print_cb(new_config_block)
|
802 | 812 | return new_config_block
|
@@ -972,7 +982,8 @@ def process_arguments():
|
972 | 982 | cmd_parser_pybytes.add_argument('--type', default=None, help='Set LTE type')
|
973 | 983 | cmd_parser_pybytes.add_argument('--cid', default=None, help='Set LTE cid')
|
974 | 984 | cmd_parser_pybytes.add_argument('--band', default=None, help='Set LTE band')
|
975 |
| - cmd_parser_pybytes.add_argument('--reset', default=None, help='Set LTE reset') |
| 985 | + cmd_parser_pybytes.add_argument('--lte_reset', default=None, type=str2bool, nargs='?', const=True, help='Set LTE reset') |
| 986 | + cmd_parser_pybytes.add_argument('--auto_start', default=None, type=str2bool, nargs='?', const=True, help='Set Pybytes auto_start') |
976 | 987 |
|
977 | 988 | cmd_parser_cb = subparsers.add_parser('cb', help='Read/Write config block')
|
978 | 989 | cmd_parser_cb.add_argument('-f', '--file', default=None, help='name of the backup file (default: <wmac>.cb)')
|
@@ -1444,16 +1455,16 @@ def progress_fs(msg):
|
1444 | 1455 | or (hasattr(args, "mqtt") and args.mqtt is not None) \
|
1445 | 1456 | or (hasattr(args, "uid") and args.uid is not None) \
|
1446 | 1457 | or (hasattr(args, "nwprefs") and args.nwprefs is not None) \
|
| 1458 | + or (hasattr(args, "auto_start") and args.auto_start is not None) \ |
1447 | 1459 | or (hasattr(args, "carrier") and args.carrier is not None) \
|
1448 | 1460 | or (hasattr(args, "apn") and args.apn is not None) \
|
1449 | 1461 | or (hasattr(args, "type") and args.type is not None) \
|
1450 | 1462 | or (hasattr(args, "cid") and args.cid is not None) \
|
1451 | 1463 | or (hasattr(args, "band") and args.band is not None) \
|
1452 |
| - or (hasattr(args, "reset") and args.reset is not None) \ |
| 1464 | + or (hasattr(args, "lte_reset") and args.lte_reset is not None) \ |
1453 | 1465 | or (hasattr(args, "extraprefs") and args.extraprefs is not None):
|
1454 |
| - new_config_block = nPy.set_pybytes_config(config_block, args.uid, args.token, args.mqtt, args.nwprefs, args.extraprefs, True) |
| 1466 | + new_config_block = nPy.set_pybytes_config(config_block, args.uid, args.token, args.mqtt, args.nwprefs, args.extraprefs, True, args.auto_start) |
1455 | 1467 | new_config_block = nPy.set_lte_config(new_config_block, args.carrier, args.apn, args.type, args.cid, args.band, args.reset)
|
1456 |
| - print(nPy.print_cb(new_config_block)) |
1457 | 1468 | nPy.write(int(PARTITIONS.get('config')[0], 16), new_config_block)
|
1458 | 1469 | sys.stdout = old_stdout
|
1459 | 1470 | else:
|
|
0 commit comments