-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(samples): Adds samples used in documentation (#266)
- Loading branch information
Showing
2 changed files
with
39 additions
and
40 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,52 +1,41 @@ | ||
[//]: # "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) | ||
|
||
[![Open in Cloud Shell][shell_img]][shell_link] | ||
This folder contains NodeJS samples that demonstrate an overview of the Google | ||
Cloud IoT Core platform. | ||
|
||
> Node.js idiomatic client for [Cloud IoT Core][product-docs]. | ||
## Quickstart | ||
|
||
[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. | ||
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: | ||
|
||
## Table of Contents | ||
gcloud beta pubsub topics create projects/my-iot-project/topics/device-events | ||
|
||
* [Before you begin](#before-you-begin) | ||
* [Samples](#samples) | ||
* [Quickstart](#quickstart) | ||
1. Add the service account `cloud-iot@system.gserviceaccount.com` 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 | ||
1. Create a registry: | ||
|
||
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). | ||
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> | ||
|
||
`cd samples` | ||
1. Use the `generate_keys.sh` script to generate your signing keys: | ||
|
||
`npm install` | ||
./scripts/generate_keys.sh | ||
|
||
`cd ..` | ||
1. Create a device. | ||
|
||
## Samples | ||
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 | ||
|
||
|
||
|
||
### 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 | ||
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