Skip to content

Commit 9fa106d

Browse files
committed
Fix unhandled CME error code 0 and update docs
Fixes #8 Signed-off-by: Gregers Gram Rygg <[email protected]>
1 parent 1be240b commit 9fa106d

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ usage: nrfcredstore [--baudrate BAUDRATE] [--timeout TIMEOUT] dev delete SECURE_
8080

8181
### generate subcommand
8282

83+
> [!IMPORTANT]
84+
> This command requires modem firmware version greater than or equal to 1.3.0.
85+
8386
Generate a private key in the modem and output a certificate signing request.
8487

8588
```

src/nrfcredstore/at_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from nrfcredstore.exceptions import ATCommandError, NoATClientException
22

33
ERR_CODE_TO_MSG = {
4+
0: 'AT command not supported by firmware version. Upgrade modem firmware?',
45
513: 'Not found',
56
514: 'Not allowed',
67
515: 'Memory full',

tests/test_at_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def error_resp(self, at_client):
3838
def error_code_resp(self, at_client):
3939
self.serial.readline.return_value = '+CME ERROR: 514\r\n'.encode('utf-8')
4040

41+
@pytest.fixture
42+
def error_code_0_resp(self, at_client):
43+
self.serial.readline.return_value = '+CME ERROR: 0\r\n'.encode('utf-8')
44+
4145
@pytest.fixture
4246
def error_ok_resp(self, at_client):
4347
self.serial.readline.side_effect = [b'ERROR', b'OK']
@@ -110,6 +114,11 @@ def test_at_command_error_code_maps_to_message(self, at_client, error_code_resp)
110114
at_client.at_command('AT')
111115
assert 'Not allowed' in str(excinfo.value)
112116

117+
def test_unsupported_cmd_error_code(self, at_client, error_code_0_resp):
118+
with pytest.raises(ATCommandError) as excinfo:
119+
at_client.at_command('AT')
120+
assert 'AT command not supported by firmware version' in str(excinfo.value)
121+
113122
def test_at_command_with_single_line_response(self, at_client):
114123
self.serial.readline.side_effect = [b'single', b'OK']
115124
assert at_client.at_command('AT+CGSN') == ['single']

0 commit comments

Comments
 (0)