-
Notifications
You must be signed in to change notification settings - Fork 596
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
1 parent
38d8148
commit 777c4fb
Showing
2 changed files
with
38 additions
and
27 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 |
---|---|---|
@@ -1,41 +1,52 @@ | ||
[//]: # "This README.md file is auto-generated, all changes to this file will be lost." | ||
[//]: # "To regenerate it, use `python -m synthtool`." | ||
<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 Internet of Things (IoT) Core: Node.js Samples](https://github.com/googleapis/nodejs-iot) | ||
|
||
This folder contains NodeJS samples that demonstrate an overview of the Google | ||
Cloud IoT Core platform. | ||
[![Open in Cloud Shell][shell_img]][shell_link] | ||
|
||
## Quickstart | ||
> Node.js idiomatic client for [Cloud IoT Core][product-docs]. | ||
1. Install the Google Cloud SDK as described in [the Cloud IoT Core documentation](https://cloud.google.com/iot/docs/how-tos/getting-started#set_up_the_google_cloud_sdk_and_gcloud). | ||
1. Create a Cloud Pub/Sub topic: | ||
[Google Cloud Internet of Things (IoT) Core](https://cloud.google.com/iot/docs) is a fully managed service for securely connecting and managing IoT devices, from a few to millions. Ingest data from connected devices and build rich applications that integrate with the other big data services of Google Cloud Platform. | ||
|
||
gcloud beta pubsub topics create projects/my-iot-project/topics/device-events | ||
## Table of Contents | ||
|
||
1. Add the service account `[email protected]` with the role `Publisher` 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. | ||
* [Before you begin](#before-you-begin) | ||
* [Samples](#samples) | ||
* [Quickstart](#quickstart) | ||
|
||
1. Create a registry: | ||
## Before you begin | ||
|
||
gcloud iot registries create "your-registry-id" \ | ||
--project=<your-project-id> \ | ||
--region=us-central1 \ | ||
--event-notification-config=topic=projects/<your-project-id>/topics/<pubsub-topic-name> | ||
Before running the samples, make sure you've followed the steps outlined in | ||
[Using the client library](https://github.com/googleapis/nodejs-iot#using-the-client-library). | ||
|
||
1. Use the `generate_keys.sh` script to generate your signing keys: | ||
`cd samples` | ||
|
||
./scripts/generate_keys.sh | ||
`npm install` | ||
|
||
1. Create a device. | ||
`cd ..` | ||
|
||
gcloud iot devices create my-node-device \ | ||
--project=my-iot-project \ | ||
--region=us-central1 \ | ||
--registry=my-registry \ | ||
--public-key path=rsa_cert.pem,type=rs256 | ||
## Samples | ||
|
||
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. | ||
|
||
|
||
### Quickstart | ||
|
||
View the [source code](https://github.com/googleapis/nodejs-iot/blob/master/samples/quickstart.js). | ||
|
||
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-iot&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | ||
|
||
__Usage:__ | ||
|
||
|
||
`node samples/quickstart.js` | ||
|
||
|
||
|
||
|
||
|
||
|
||
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png | ||
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-iot&page=editor&open_in_editor=samples/README.md | ||
[product-docs]: https://cloud.google.com/iot |
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