-
Notifications
You must be signed in to change notification settings - Fork 10
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
python: fix issues 198 & 203 #204
python: fix issues 198 & 203 #204
Conversation
Some modems will report partial cellular connection details, especially during the startup phase, at which point the modem considers the connection to be established, but does not yet report what techniology is used. Fixes: Orange-OpenSource#198 Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Commit c482cb1 (python/vehicle: use iot3.core.mqtt) introduced a regression in the propagation of messages from the remote broker to the local one. The API for the IoT3 Core SDK extensively uses keywords rather than positional parameters, and although this was properly accounted when publishing messages on the remote broker, this was overlooked when publishing messages on the local broker. Such an issue would have raised an exception, and we would have caught it quite easily. Alas, in an attempt at being robust when decoding the received messages, we decided for a blanket coverage of all exceptions, no matter what. This indeed hid the TypeError exception that is raised when improperly calling the SDK... So, now, we could just catch KeyError when looking up the source_uuid field, but that would assume the message was decoded as a dict, which we have no guarantee it was. If that were not the case, i.e.e the message is not an ITS message, and contains any other JSON object that is not a dictionary, that would _also_ raise TypeError, so we would have to catch it anyway to ignore it. And we would not have been able to notice the TypeError raised by improperly calling the SDK either anyway... Sigh... For now, just fix calling the SDK; we'll handle the rest later (Famous Last Words™)... Fixes: Orange-OpenSource#203 Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
@@ -193,7 +193,7 @@ def msg_cb( | |||
payload_d.get("source_uuid", None) != self.cfg["instance-id"] | |||
or self.cfg["mirror-self"] | |||
): | |||
self.mqtt_mirror.publish(topic, payload) | |||
self.mqtt_mirror.publish(topic=topic, payload=payload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it really fix something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does. As the commit log mentions, the API expects keyword-only arguments, not positional arguments.
And this fix is the one that fixes propagating messages to the local broker (issue #203).
Changes:
How to test:
Expected results: