-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
3,997 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<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"/> | ||
|
||
# Google Cloud IoT Core NodeJS Samples | ||
|
||
This folder contains NodeJS samples that demonstrate an overview of the Google | ||
Cloud IoT Core platform. | ||
|
||
## Quickstart | ||
|
||
1. Install the Google Cloud SDK as described in [the device manager guide](/iot/docs/device_manager_guide#install_the_gcloud_cli). | ||
1. Create a Cloud Pub/Sub topic: | ||
|
||
gcloud beta pubsub topics create projects/my-iot-project/topics/device-events | ||
|
||
1. Add the service account `cloud-iot@system.gserviceaccount.com` to that | ||
Cloud Pub/Sub topic from the [Cloud Developer Console](https://console.cloud.google.com) | ||
or by setting the `GOOGLE_CLOUD_PROJECT` environment variable and using the | ||
helper script in the `scripts/` folder. | ||
|
||
1. Create a registry: | ||
|
||
gcloud alpha iot registries create my-registry \ | ||
--project=my-iot-project \ | ||
--region=us-central1 \ | ||
--pubsub-topic=projects/my-iot-project/topics/device-events | ||
|
||
1. Use the `generate_keys.sh` script to generate your signing keys: | ||
|
||
./scripts/generate_keys.sh | ||
|
||
1. Create a device. | ||
|
||
gcloud alpha iot devices create my-node-device \ | ||
--project=my-iot-project \ | ||
--region=us-central1 \ | ||
--registry=my-registry \ | ||
--public-key path=rsa_cert.pem,type=rs256 | ||
|
||
1. Connect a sample device using the sample app in the `mqtt_example` folder. | ||
1. Learn how to manage devices programatically with the sample app in the | ||
`manager` folder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<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"/> | ||
|
||
# Google Cloud IoT Core NodeJS Device Management example | ||
|
||
This sample app demonstrates device management for Google Cloud IoT Core. | ||
|
||
Note that before you run this sample, you must configure a Google Cloud PubSub | ||
topic for Cloud IoT as described in the parent README. | ||
|
||
# Setup | ||
|
||
Run the following command to install the library dependencies for NodeJS: | ||
|
||
npm install | ||
|
||
# Running the sample | ||
|
||
The following command summarizes the sample usage: | ||
|
||
Usage: cloudiot_device_manager_example [options] | ||
|
||
Example Google Cloud IoT device manager integration | ||
|
||
Options: | ||
|
||
-h, --help output usage information | ||
--project_id <project_id> GCP cloud project name. | ||
--pubsub_topic <pubsub_topic> Cloud Pub/Sub topic to use. | ||
--api_key <api_key> Your API key. | ||
--ec_public_key_file <ec_public_key_file> Path to EC public key. | ||
--rsa_certificate_file <rsa_certificate_file> Path to RSA certificate file. | ||
--cloud_region <cloud_region> GCP cloud region. | ||
--service_account_json <service_account_json> Path to service account JSON file. | ||
--registry_id <registry_id> Custom registry id. If not provided, a unique registry id will be generated. | ||
|
||
For example, if your project ID is `blue-jet-123`, your service account | ||
credentials are stored in your home folder in creds.json and you have generated | ||
your credentials using the shell script provided in the parent folder, you can | ||
run the sample as: | ||
|
||
node cloudiot_device_manager_example.js \ | ||
--service_account_json=$HOME/creds.json \ | ||
--api_key=YOUR_CLIENT_ID \ | ||
--project_id=blue-jet-123 \ | ||
--pubsub_topic=projects/blue-jet-123/topics/device-events \ | ||
--ec_public_key_file=../ec_public.pem \ | ||
--rsa_certificate_file=../rsa_cert.pem |
Oops, something went wrong.