|
| 1 | +.. This file is automatically generated. Do not edit this file directly. |
| 2 | +
|
| 3 | +Google Cloud IoT Core API Python Samples |
| 4 | +=============================================================================== |
| 5 | + |
| 6 | +This directory contains samples for Google Cloud IoT Core API. `Google Cloud IoT Core`_ allows developers to easily integrate Publish and Subscribe functionality with devices and programmatically manage device authorization. |
| 7 | +Before you run the sample, you must retrieve the Google root certificate. For example, `wget https://pki.goog/roots.pem` or `curl https://pki.goog/roots.pem > roots.pem`. |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +.. _Google Cloud IoT Core API: https://cloud.google.com/iot/docs |
| 13 | + |
| 14 | +Setup |
| 15 | +------------------------------------------------------------------------------- |
| 16 | + |
| 17 | + |
| 18 | +Authentication |
| 19 | +++++++++++++++ |
| 20 | + |
| 21 | +This sample requires you to have authentication setup. Refer to the |
| 22 | +`Authentication Getting Started Guide`_ for instructions on setting up |
| 23 | +credentials for applications. |
| 24 | + |
| 25 | +.. _Authentication Getting Started Guide: |
| 26 | + https://cloud.google.com/docs/authentication/getting-started |
| 27 | + |
| 28 | +Install Dependencies |
| 29 | +++++++++++++++++++++ |
| 30 | + |
| 31 | +#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. |
| 32 | + |
| 33 | + .. _Python Development Environment Setup Guide: |
| 34 | + https://cloud.google.com/python/setup |
| 35 | + |
| 36 | +#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. |
| 37 | + |
| 38 | + .. code-block:: bash |
| 39 | +
|
| 40 | + $ virtualenv env |
| 41 | + $ source env/bin/activate |
| 42 | +
|
| 43 | +#. Install the dependencies needed to run the samples. |
| 44 | + |
| 45 | + .. code-block:: bash |
| 46 | +
|
| 47 | + $ pip install -r requirements.txt |
| 48 | +
|
| 49 | +.. _pip: https://pip.pypa.io/ |
| 50 | +.. _virtualenv: https://virtualenv.pypa.io/ |
| 51 | + |
| 52 | +Samples |
| 53 | +------------------------------------------------------------------------------- |
| 54 | + |
| 55 | +Server |
| 56 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +To run this sample: |
| 61 | + |
| 62 | +.. code-block:: bash |
| 63 | +
|
| 64 | + $ python cloudiot_pubsub_example_server.py |
| 65 | +
|
| 66 | + usage: cloudiot_pubsub_example_server.py [-h] --project_id PROJECT_ID |
| 67 | + --pubsub_subscription |
| 68 | + PUBSUB_SUBSCRIPTION |
| 69 | + [--service_account_json SERVICE_ACCOUNT_JSON] |
| 70 | +
|
| 71 | + Example of Google Cloud IoT registry and device management. |
| 72 | +
|
| 73 | + optional arguments: |
| 74 | + -h, --help show this help message and exit |
| 75 | + --project_id PROJECT_ID |
| 76 | + GCP cloud project name. |
| 77 | + --pubsub_subscription PUBSUB_SUBSCRIPTION |
| 78 | + Google Cloud Pub/Sub subscription name. |
| 79 | + --service_account_json SERVICE_ACCOUNT_JSON |
| 80 | + Path to service account json file. |
| 81 | +
|
| 82 | +
|
| 83 | +
|
| 84 | +Device |
| 85 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | +To run this sample: |
| 90 | + |
| 91 | +.. code-block:: bash |
| 92 | +
|
| 93 | + $ python cloudiot_pubsub_example_mqtt_device.py |
| 94 | +
|
| 95 | + usage: cloudiot_pubsub_example_mqtt_device.py [-h] --project_id PROJECT_ID |
| 96 | + --registry_id REGISTRY_ID |
| 97 | + --device_id DEVICE_ID |
| 98 | + --private_key_file |
| 99 | + PRIVATE_KEY_FILE --algorithm |
| 100 | + {RS256,ES256} |
| 101 | + [--cloud_region CLOUD_REGION] |
| 102 | + [--ca_certs CA_CERTS] |
| 103 | + [--num_messages NUM_MESSAGES] |
| 104 | + [--mqtt_bridge_hostname MQTT_BRIDGE_HOSTNAME] |
| 105 | + [--mqtt_bridge_port MQTT_BRIDGE_PORT] |
| 106 | +
|
| 107 | + Example Google Cloud IoT MQTT device connection code. |
| 108 | +
|
| 109 | + optional arguments: |
| 110 | + -h, --help show this help message and exit |
| 111 | + --project_id PROJECT_ID |
| 112 | + GCP cloud project name |
| 113 | + --registry_id REGISTRY_ID |
| 114 | + Cloud IoT registry id |
| 115 | + --device_id DEVICE_ID |
| 116 | + Cloud IoT device id |
| 117 | + --private_key_file PRIVATE_KEY_FILE |
| 118 | + Path to private key file. |
| 119 | + --algorithm {RS256,ES256} |
| 120 | + Which encryption algorithm to use to generate the JWT. |
| 121 | + --cloud_region CLOUD_REGION |
| 122 | + GCP cloud region |
| 123 | + --ca_certs CA_CERTS CA root certificate. Get from |
| 124 | + https://pki.google.com/roots.pem |
| 125 | + --num_messages NUM_MESSAGES |
| 126 | + Number of messages to publish. |
| 127 | + --mqtt_bridge_hostname MQTT_BRIDGE_HOSTNAME |
| 128 | + MQTT bridge hostname. |
| 129 | + --mqtt_bridge_port MQTT_BRIDGE_PORT |
| 130 | + MQTT bridge port. |
| 131 | +
|
| 132 | +
|
| 133 | +
|
| 134 | +
|
| 135 | +
|
| 136 | +.. _Google Cloud SDK: https://cloud.google.com/sdk/ |
0 commit comments