Skip to content

Commit d04b50a

Browse files
gguussjmdobry
authored andcommitted
Initial commit of Cloud IoT samples
1 parent 5785e8b commit d04b50a

14 files changed

+3997
-0
lines changed

iot/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
2+
3+
# Google Cloud IoT Core NodeJS Samples
4+
5+
This folder contains NodeJS samples that demonstrate an overview of the Google
6+
Cloud IoT Core platform.
7+
8+
## Quickstart
9+
10+
1. Install the Google Cloud SDK as described in [the device manager guide](/iot/docs/device_manager_guide#install_the_gcloud_cli).
11+
1. Create a Cloud Pub/Sub topic:
12+
13+
gcloud beta pubsub topics create projects/my-iot-project/topics/device-events
14+
15+
1. Add the service account `[email protected]` to that
16+
Cloud Pub/Sub topic from the [Cloud Developer Console](https://console.cloud.google.com)
17+
or by setting the `GOOGLE_CLOUD_PROJECT` environment variable and using the
18+
helper script in the `scripts/` folder.
19+
20+
1. Create a registry:
21+
22+
gcloud alpha iot registries create my-registry \
23+
--project=my-iot-project \
24+
--region=us-central1 \
25+
--pubsub-topic=projects/my-iot-project/topics/device-events
26+
27+
1. Use the `generate_keys.sh` script to generate your signing keys:
28+
29+
./scripts/generate_keys.sh
30+
31+
1. Create a device.
32+
33+
gcloud alpha iot devices create my-node-device \
34+
--project=my-iot-project \
35+
--region=us-central1 \
36+
--registry=my-registry \
37+
--public-key path=rsa_cert.pem,type=rs256
38+
39+
1. Connect a sample device using the sample app in the `mqtt_example` folder.
40+
1. Learn how to manage devices programatically with the sample app in the
41+
`manager` folder.

iot/manager/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
2+
3+
# Google Cloud IoT Core NodeJS Device Management example
4+
5+
This sample app demonstrates device management for Google Cloud IoT Core.
6+
7+
Note that before you run this sample, you must configure a Google Cloud PubSub
8+
topic for Cloud IoT as described in the parent README.
9+
10+
# Setup
11+
12+
Run the following command to install the library dependencies for NodeJS:
13+
14+
npm install
15+
16+
# Running the sample
17+
18+
The following command summarizes the sample usage:
19+
20+
Usage: cloudiot_device_manager_example [options]
21+
22+
Example Google Cloud IoT device manager integration
23+
24+
Options:
25+
26+
-h, --help output usage information
27+
--project_id <project_id> GCP cloud project name.
28+
--pubsub_topic <pubsub_topic> Cloud Pub/Sub topic to use.
29+
--api_key <api_key> Your API key.
30+
--ec_public_key_file <ec_public_key_file> Path to EC public key.
31+
--rsa_certificate_file <rsa_certificate_file> Path to RSA certificate file.
32+
--cloud_region <cloud_region> GCP cloud region.
33+
--service_account_json <service_account_json> Path to service account JSON file.
34+
--registry_id <registry_id> Custom registry id. If not provided, a unique registry id will be generated.
35+
36+
For example, if your project ID is `blue-jet-123`, your service account
37+
credentials are stored in your home folder in creds.json and you have generated
38+
your credentials using the shell script provided in the parent folder, you can
39+
run the sample as:
40+
41+
node cloudiot_device_manager_example.js \
42+
--service_account_json=$HOME/creds.json \
43+
--api_key=YOUR_CLIENT_ID \
44+
--project_id=blue-jet-123 \
45+
--pubsub_topic=projects/blue-jet-123/topics/device-events \
46+
--ec_public_key_file=../ec_public.pem \
47+
--rsa_certificate_file=../rsa_cert.pem

0 commit comments

Comments
 (0)