Skip to content
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

Bumped version of paho-mqtt 2.1.0 + extra features #36

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions mqtt-pub/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,13 @@
KEEP_ALIVE_INTERVAL = 45


def on_connect(client, userdata, rc):
if rc != 0:
def on_connect(mqttc, obj, flags, reason_code, properties):
if reason_code != 0:
print("Unable to connect to MQTT Broker...")
else:
print("Connected with MQTT Broker: ", str(MQTT_BROKER))


def on_publish(client, userdata, mid):
pass


def on_disconnect(client, userdata, rc):
pass


# faking
def prepare_data():
# return "100"
Expand All @@ -57,10 +49,8 @@ def publish_fake_data():
threading.Timer(3.0, publish_fake_data).start()
publish_now(prepare_data())

mqttc = mqtt.Client()
mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
mqttc.on_connect = on_connect
mqttc.on_disconnect = on_disconnect
mqttc.on_publish = on_publish

try:
mqttc.connect(MQTT_BROKER, int(MQTT_PORT), int(KEEP_ALIVE_INTERVAL))
Expand Down
Loading