Skip to content

[Question] Error when performing a firmware update #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JeromeJalkh opened this issue Sep 29, 2022 · 1 comment
Open

[Question] Error when performing a firmware update #31

JeromeJalkh opened this issue Sep 29, 2022 · 1 comment

Comments

@JeromeJalkh
Copy link

Hello,

I am using the TBDeviceMqttClient class from the "tb_device_mqtt.py".

I am getting this error when launching a firmware update:
File "/home/ubuntu/.local/lib/python3.8/site-packages/tb_device_mqtt.py", line 324, in _on_decoded_message callback = self._attr_request_dict.pop(req_id) KeyError: 1

My question concerns the messages received by the client:

  • The client receives all the update details (fw_title, fw_version, fw_tag, fw_size, fw_checksum_algorithm, fw_checksum) on the "v1/devices/me/attributes" topic
  • Then if the versions are different the client sends a request and it receives the update on "v2/fw/request/${requestId}/chunk/${chunk}" topic
  • The client receives also a message on the "v1/devices/me/attributes/response/+" topic which includes all the changed shared attributes related to the update

When the client receives a message on the "v1/devices/me/attributes/response/+" topic, it has to get the callback function: callback = self._attr_request_dict.pop(req_id)
However, the self._attr_request_dict is updated (and thus the callback is added to the dict) when the user calls the request_attributes function which calls the _add_attr_request_callback.
In the case of a firmware update, no callback function was added or defined to be called when a message is received on the "v1/devices/me/attributes/response/+" topic, and as a consequence, the error is raised.

Is there any problem in the client script or am I missing something?

@Nielesonimusso
Copy link

I am also having this issue, preventing me from using the firmware updating feature entirely. I could resort to directly using an MQTT client, but that defeats the purpose of this SDK.

It seems indeed that the implementation of _on_decoded_message() contains conflicting blocks for handling request_attributes() and get_firmware_update() server responses (both check whether the incoming message topic contains the attribute response topic). The incoming messages are always handled as coming from a request_attributes() call, causing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants