ublox-gsm-config: Improve check of bridge and ecm modes
BugzID: 57325
This commit is contained in:
parent
4f7c0fece9
commit
331ff2291b
|
|
@ -30,8 +30,7 @@ def default_parser(output):
|
|||
x = re.search('(.*)\n.*\nOK',output)
|
||||
return x.group(1)
|
||||
|
||||
def read_config(ser, config_file, full_config_file, cmd, label='', parser=default_parser):
|
||||
|
||||
def execute_command(ser, cmd):
|
||||
while True:
|
||||
try:
|
||||
ser.flushInput()
|
||||
|
|
@ -45,6 +44,13 @@ def read_config(ser, config_file, full_config_file, cmd, label='', parser=defaul
|
|||
print("Exception : " + str(e))
|
||||
time.sleep(1)
|
||||
continue
|
||||
return s
|
||||
|
||||
def read_config(ser, config_file, full_config_file, cmd, label='', parser=default_parser):
|
||||
s = execute_command(ser, cmd)
|
||||
if s is None:
|
||||
print('Failed to execute command : ' + str(cmd))
|
||||
return
|
||||
|
||||
full_conf = label + '\n' + s.decode('utf-8').strip("OK")
|
||||
conf = (label + ':').ljust(20) + parser(s.decode('utf-8')) + '\n'
|
||||
|
|
@ -65,4 +71,19 @@ def dump_modem_config(ser):
|
|||
|
||||
read_config(ser, config_file, full_config_file, b'AT+UCGDFLT?', 'Default APN', apn_parser)
|
||||
read_config(ser, config_file, full_config_file, b'AT+UBMCONF?', 'Mode', mode_parser)
|
||||
read_config(ser, config_file, full_config_file, b'AT+UUSBCONF?', 'USBprofile', usb_profile_parser)
|
||||
read_config(ser, config_file, full_config_file, b'AT+UUSBCONF?', 'USBprofile', usb_profile_parser)
|
||||
|
||||
def get_usb_profile(ser):
|
||||
s = execute_command(ser, b'AT+UUSBCONF?')
|
||||
if s is None:
|
||||
print('Failed to get UUSBCONF')
|
||||
return None
|
||||
|
||||
return usb_profile_parser(s.decode('utf-8'))
|
||||
|
||||
def get_mode(ser):
|
||||
s = execute_command(ser, b'AT+UBMCONF?')
|
||||
if s is None:
|
||||
print('Failed to get UBMCONF')
|
||||
return None
|
||||
return mode_parser(s.decode('utf-8'))
|
||||
|
|
|
|||
|
|
@ -144,14 +144,19 @@ def main():
|
|||
ser = serial.Serial(SERIAL_DEV, 115200, timeout=0.5)
|
||||
|
||||
rst = False
|
||||
if not os.path.exists(WWAN_DEV):
|
||||
|
||||
if 'Bridge' != config_dump.get_mode(ser):
|
||||
print("Setting up bridge mode")
|
||||
execute_and_check(ser, b'AT+UBMCONF=2')
|
||||
rst = True
|
||||
|
||||
if 'ECM' != config_dump.get_usb_profile(ser):
|
||||
print("Setting up USB mode to ECM")
|
||||
execute_and_check(ser, b'AT+UUSBCONF=2,"ECM",0')
|
||||
rst = True
|
||||
|
||||
rst = sim_config(ser) or rst
|
||||
|
||||
if rst:
|
||||
print("Resetting modem")
|
||||
ser.write(b'AT+CFUN=16\r')
|
||||
|
|
|
|||
Loading…
Reference in New Issue