@@ -76,48 +76,117 @@ To run this sample:
76
76
77
77
$ python cloudiot_mqtt_example.py
78
78
79
- usage: cloudiot_mqtt_example.py [-h] [--project_id PROJECT_ID] --registry_id
80
- REGISTRY_ID --device_id DEVICE_ID
81
- --private_key_file PRIVATE_KEY_FILE
82
- --algorithm {RS256,ES256}
83
- [--cloud_region CLOUD_REGION]
79
+ usage: cloudiot_mqtt_example.py [-h] --algorithm {RS256,ES256}
84
80
[--ca_certs CA_CERTS]
85
- [--num_messages NUM_MESSAGES]
81
+ [--cloud_region CLOUD_REGION] [--data DATA]
82
+ --device_id DEVICE_ID
83
+ [--gateway_id GATEWAY_ID]
84
+ [--jwt_expires_minutes JWT_EXPIRES_MINUTES]
85
+ [--listen_dur LISTEN_DUR]
86
86
[--message_type {event,state}]
87
87
[--mqtt_bridge_hostname MQTT_BRIDGE_HOSTNAME]
88
88
[--mqtt_bridge_port {8883,443}]
89
- [--jwt_expires_minutes JWT_EXPIRES_MINUTES]
90
-
89
+ [--num_messages NUM_MESSAGES]
90
+ --private_key_file PRIVATE_KEY_FILE
91
+ [--project_id PROJECT_ID] --registry_id
92
+ REGISTRY_ID
93
+ [--service_account_json SERVICE_ACCOUNT_JSON]
94
+ {device_demo,gateway_send,gateway_listen} ...
95
+
91
96
Example Google Cloud IoT Core MQTT device connection code.
92
-
97
+
98
+ positional arguments:
99
+ {device_demo,gateway_send,gateway_listen}
100
+ device_demo Connects a device, sends data, and receives data.
101
+ gateway_send Sends data from a gateway on behalf of a device that
102
+ is bound to it.
103
+ gateway_listen Listens for messages sent to the gateway and bound
104
+ devices.
105
+
93
106
optional arguments:
94
107
-h, --help show this help message and exit
95
- --project_id PROJECT_ID
96
- GCP cloud project name
97
- --registry_id REGISTRY_ID
98
- Cloud IoT Core registry id
99
- --device_id DEVICE_ID
100
- Cloud IoT Core device id
101
- --private_key_file PRIVATE_KEY_FILE
102
- Path to private key file.
103
108
--algorithm {RS256,ES256}
104
109
Which encryption algorithm to use to generate the JWT.
110
+ --ca_certs CA_CERTS CA root from https://pki.google.com/roots.pem
105
111
--cloud_region CLOUD_REGION
106
112
GCP cloud region
107
- --ca_certs CA_CERTS CA root from https://pki.google.com/roots.pem
108
- --num_messages NUM_MESSAGES
109
- Number of messages to publish.
113
+ --data DATA The telemetry data sent on behalf of a device
114
+ --device_id DEVICE_ID
115
+ Cloud IoT Core device id
116
+ --gateway_id GATEWAY_ID
117
+ Gateway identifier.
118
+ --jwt_expires_minutes JWT_EXPIRES_MINUTES
119
+ Expiration time, in minutes, for JWT tokens.
120
+ --listen_dur LISTEN_DUR
121
+ Duration (seconds) to listen for configuration
122
+ messages
110
123
--message_type {event,state}
111
124
Indicates whether the message to be published is a
112
125
telemetry event or a device state message.
113
126
--mqtt_bridge_hostname MQTT_BRIDGE_HOSTNAME
114
127
MQTT bridge hostname.
115
128
--mqtt_bridge_port {8883,443}
116
129
MQTT bridge port.
117
- --jwt_expires_minutes JWT_EXPIRES_MINUTES
118
- Expiration time, in minutes, for JWT tokens.
130
+ --num_messages NUM_MESSAGES
131
+ Number of messages to publish.
132
+ --private_key_file PRIVATE_KEY_FILE
133
+ Path to private key file.
134
+ --project_id PROJECT_ID
135
+ GCP cloud project name
136
+ --registry_id REGISTRY_ID
137
+ Cloud IoT Core registry id
138
+ --service_account_json SERVICE_ACCOUNT_JSON
139
+ Path to service account json file.
119
140
120
141
142
+ MQTT Image Example
143
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
144
+
145
+ .. image :: https://gstatic.com/cloudssh/images/open-btn.png
146
+ :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_edi
57AE
tor=iot/api-client/mqtt_example/cloudiot_mqtt_image.py,iot/api-client/mqtt_example/README.rst
147
+
148
+
149
+
150
+
151
+ To run this sample:
152
+
153
+ .. code-block :: bash
154
+
155
+ $ python cloudiot_mqtt_image.py
156
+
157
+ usage: cloudiot_mqtt_image.py [-h] [--ca_certs CA_CERTS]
158
+ [--cloud_region CLOUD_REGION]
159
+ [--image_path IMAGE_PATH] --device_id DEVICE_ID
160
+ --private_key_file PRIVATE_KEY_FILE
161
+ [--project_id PROJECT_ID] --registry_id
162
+ REGISTRY_ID
163
+ [--service_account_json SERVICE_ACCOUNT_JSON]
164
+ {send} ...
165
+
166
+ Google Cloud IoT Core MQTT binary transmission demo.
167
+
168
+ positional arguments:
169
+ {send}
170
+ send Send an inage to a device registry
171
+
172
+ optional arguments:
173
+ -h, --help show this help message and exit
174
+ --ca_certs CA_CERTS CA root from https://pki.google.com/roots.pem
175
+ --cloud_region CLOUD_REGION
176
+ GCP cloud region
177
+ --image_path IMAGE_PATH
178
+ The telemetry data sent on behalf of a device
179
+ --device_id DEVICE_ID
180
+ Cloud IoT Core device id
181
+ --private_key_file PRIVATE_KEY_FILE
182
+ Path to private key file.
183
+ --project_id PROJECT_ID
184
+ GCP cloud project name
185
+ --registry_id REGISTRY_ID
186
+ Cloud IoT Core registry id
187
+ --service_account_json SERVICE_ACCOUNT_JSON
188
+ Path to service account json file.
189
+
121
190
122
191
123
192
0 commit comments