10000 Print client_id when creating MQTT client (#2007) · cseed/python-docs-samples@1d4e988 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1d4e988

Browse files
lwandergguuss
authored andcommitted
Print client_id when creating MQTT client (GoogleCloudPlatform#2007)
This will help to make it clear when you're missing a parameter :)
1 parent bfcc9dc commit 1d4e988

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

iot/api-client/mqtt_example/cloudiot_mqtt_example.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,11 @@ def get_client(
126126
algorithm, ca_certs, mqtt_bridge_hostname, mqtt_bridge_port):
127127
"""Create our MQTT client. The client_id is a unique string that identifies
128128
this device. For Google Cloud IoT Core, it must be in the format below."""
129-
client = mqtt.Client(
130-
client_id=('projects/{}/locations/{}/registries/{}/devices/{}'
131-
.format(
132-
project_id,
133-
cloud_region,
134-
registry_id,
135-
device_id)))
129+
client_id = 'projects/{}/locations/{}/registries/{}/devices/{}'.format(
130+
project_id, cloud_region, registry_id, device_id)
131+
print('Device client_id is \'{}\''.format(client_id))
132+
133+
client = mqtt.Client(client_id=client_id)
136134

137135
# With Google Cloud IoT Core, the username field is ignored, and the
138136
# password field is used to transmit a JWT to authorize the device.

0 commit comments

Comments
 (0)
0