Skip to content

Issues with combining micropython-async (Encoder) and mqtt_as #15281

Discussion options

You must be logged in to vote

Hello,

There are two possible approaches to fix this:

Use a callback for publish:
Instead of using await, modify the local_input function to take a callback function as an argument. This callback can be called after the publishing is complete (if the library supports it). Here's an example:

`def local_input(data1, data2, publish_callback):
print ('****', data1, data2)
Call publish in a separate thread or use a callback if supported
publish_callback healthinsurancemarket ('Result', '{}'.format(data1), qos = 0)

rest of your code

def publish_message(topic, message, qos):
client.publish(topic, message, qos)
Handle any errors here

enc = Encoder(px, py, div=4, callback=lambda d1, d2: local_inpu…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@IanW6374
Comment options

Answer selected by IanW6374
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants