Skip to content

Commit f4ef505

Browse files
committed
muffle at detection error messages
1 parent 531e6ea commit f4ef505

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/nrfcredstore/command_interface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def detect_shell_mode(self):
100100
"""Detect if the device is in shell mode or not."""
101101
for _ in range(3):
102102
self.write_raw("at AT+CGSN")
103-
result, output = self.comms.expect_response("OK", "ERROR", "")
103+
result, output = self.comms.expect_response("OK", "ERROR", "", suppress_errors=True)
104104
if result and len(re.findall("[0-9]{15}", output)) > 0:
105105
self.set_shell_mode(True)
106106
return
@@ -110,15 +110,15 @@ def enable_error_codes(self):
110110
"""Enable error codes in the AT client"""
111111
self.at_command('AT+CMEE=1', wait_for_result=True)
112112

113-
def at_command(self, at_command, wait_for_result=False):
113+
def at_command(self, at_command, wait_for_result=False, suppress_errors=False):
114114
"""Write an AT command to the command interface. Optionally wait for OK"""
115115

116116
# AT commands are written directly as-is with the ATCommandInterface:
117117
at_cmd_prefix = 'at ' if self.shell else ''
118118
self.write_raw(f'{at_cmd_prefix}{at_command}')
119119

120120
if wait_for_result:
121-
result, _ = self.comms.expect_response("OK", "ERROR")
121+
result, _ = self.comms.expect_response("OK", "ERROR", suppress_errors=suppress_errors)
122122
return result
123123
else:
124124
return True

src/nrfcredstore/comms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def close(self):
331331
self.serial_api.close()
332332
self.serial_api = None
333333

334-
def expect_response(self, ok_str=None, error_str=None, store_str=None, timeout=15):
334+
def expect_response(self, ok_str=None, error_str=None, store_str=None, timeout=15, suppress_errors=False):
335335
'''
336336
Read lines until either ok_str or error_str is found or timeout (seconds) is reached.
337337
If store_str is in one of the lines, it will be returned as the output.
@@ -349,7 +349,8 @@ def expect_response(self, ok_str=None, error_str=None, store_str=None, timeout=1
349349
return (False, output)
350350
if line.startswith('+CME ERROR'):
351351
code = int(line.replace('+CME ERROR: ', ''))
352-
logging.error(f'AT command error: {ERR_CODE_TO_MSG.get(code, "Unknown error")}')
352+
if not suppress_errors:
353+
logging.error(f'AT command error: {ERR_CODE_TO_MSG.get(code, "Unknown error")}')
353354
return (False, output)
354355
if (store_str is not None) and store_str in line:
355356
output += line + '\r\n'

0 commit comments

Comments
 (0)