Skip to content

Commit

Permalink
revert local changes
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Feb 14, 2024
1 parent e9f410f commit b0e42e4
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions samples/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def on_resubscribe_complete(resubscribe_future):

# Callback when the subscribed topic receives a message
def on_message_received(topic, payload, dup, qos, retain, **kwargs):
print("Received message from topic '{}' with {}: {}".format(topic, qos, payload))
global received_count
received_count += 1
if received_count == cmdData.input_count:
Expand Down Expand Up @@ -91,8 +90,7 @@ def on_connection_closed(connection, callback_data):
on_connection_resumed=on_connection_resumed,
client_id=cmdData.input_clientId,
clean_session=False,
keep_alive_secs=10,
ping_timeout_ms=500,
keep_alive_secs=30,
http_proxy_options=proxy_options,
on_connection_success=on_connection_success,
on_connection_failure=on_connection_failure,
Expand Down Expand Up @@ -136,16 +134,10 @@ def on_connection_closed(connection, callback_data):
message = "{} [{}]".format(message_string, publish_count)
print("Publishing message to topic '{}': {}".format(message_topic, message))
message_json = json.dumps(message)
if(publish_count % 2 == 0):
mqtt_connection.publish(
topic=message_topic,
payload=message_json,
qos=mqtt.QoS.AT_LEAST_ONCE)
else:
mqtt_connection.publish(
topic=message_topic,
payload=message_json,
qos=mqtt.QoS.AT_MOST_ONCE)
mqtt_connection.publish(
topic=message_topic,
payload=message_json,
qos=mqtt.QoS.AT_LEAST_ONCE)
time.sleep(1)
publish_count += 1

Expand Down

0 comments on commit b0e42e4

Please sign in to comment.