Skip to content

Fix bugs in shadow sample. #204

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

Merged
merged 1 commit into from
Jun 1, 2021
Merged
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
22 changes: 11 additions & 11 deletions samples/shadow.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def user_input_thread_fn():
http_proxy_options=proxy_options,
ca_filepath=args.root_ca,
client_id=args.client_id,
clean_session=False,
clean_session=True,
keep_alive_secs=6)

else:
Expand All @@ -256,7 +256,7 @@ def user_input_thread_fn():
client_bootstrap=client_bootstrap,
ca_filepath=args.root_ca,
client_id=args.client_id,
clean_session=False,
clean_session=True,
keep_alive_secs=6,
http_proxy_options=proxy_options)

Expand All @@ -279,15 +279,6 @@ def user_input_thread_fn():
# Subscribe to necessary topics.
# Note that is **is** important to wait for "accepted/rejected" subscriptions
# to succeed before publishing the corresponding "request".
print("Subscribing to Delta events...")
delta_subscribed_future, _ = shadow_client.subscribe_to_shadow_delta_updated_events(
request=iotshadow.ShadowDeltaUpdatedSubscriptionRequest(thing_name=args.thing_name),
qos=mqtt.QoS.AT_LEAST_ONCE,
callback=on_shadow_delta_updated)

# Wait for subscription to succeed
delta_subscribed_future.result()

print("Subscribing to Update responses...")
update_accepted_subscribed_future, _ = shadow_client.subscribe_to_update_shadow_accepted(
request=iotshadow.UpdateShadowSubscriptionRequest(thing_name=args.thing_name),
Expand Down Expand Up @@ -318,6 +309,15 @@ def user_input_thread_fn():
get_accepted_subscribed_future.result()
get_rejected_subscribed_future.result()

print("Subscribing to Delta events...")
delta_subscribed_future, _ = shadow_client.subscribe_to_shadow_delta_updated_events(
request=iotshadow.ShadowDeltaUpdatedSubscriptionRequest(thing_name=args.thing_name),
qos=mqtt.QoS.AT_LEAST_ONCE,
callback=on_shadow_delta_updated)

# Wait for subscription to succeed
delta_subscribed_future.result()

# The rest of the sample runs asyncronously.

# Issue request for shadow's current state.
Expand Down