Fix backend crash due to different states retrieved from the modem
I'm testing it on Quectel - EC20 modem with O2 SIM card.
If the interface is down, the call to API will fail with the following error:
ValidationError: 'disabled' is not one of ['locked', 'connected']
root@turris:/tmp/reforis-gsm# foris-client-wrapper -m lte -a get_settings
Traceback (most recent call last):
File "/usr/bin/foris-client", line 33, in <module>
sys.exit(load_entry_point('foris-client==1.0.4', 'console_scripts', 'foris-client')())
File "/usr/lib/python3.10/site-packages/foris_client/client/__main__.py", line 177, in main
File "/usr/lib/python3.10/site-packages/foris_client/buses/mqtt.py", line 358, in send
File "/usr/lib/python3.10/site-packages/foris_client/buses/mqtt.py", line 350, in process_resp
File "/usr/lib/python3.10/site-packages/foris_client/buses/base.py", line 69, in _raise_exception_on_error
foris_client.buses.base.ControllerError__lte__get_settings: Controller error(s) has occured:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/foris_controller/message_router.py", line 140, in process_message
self.validate(reply)
File "/usr/lib/python3.10/site-packages/foris_controller/message_router.py", line 40, in wrapper
res = function(*args, **kwargs)
File "/usr/lib/python3.10/site-packages/foris_controller/message_router.py", line 76, in validate
app_info["validator"].validate(message)
File "/usr/lib/python3.10/site-packages/foris_schema/validator.py", line 282, in validate
File "/usr/lib/python3.10/site-packages/jsonschema/validators.py", line 314, in validate
jsonschema.exceptions.ValidationError: 'disabled' is not one of ['locked', 'connected']
Failed validating 'enum' in schema['properties']['data']['properties']['devices']['items']['properties']['info']['properties']['state']:
{'enum': ['locked', 'connected']}
On instance['data']['devices'][0]['info']['state']:
'disabled'
Incorrect output. {'kind': 'reply', 'module': 'lte', 'action': 'get_settings', 'data': {'devices': [{'id': 'wwan0', 'apn': 'internet', 'auth': {'type': 'none'}, 'qmi_device': '/dev/cdc-wdm0', 'pin': 'unset', 'inf}
In my opinion, we should add a "disabled" state.
Edited by Aleksandr Gumroian