-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloud iot core #946
Cloud iot core #946
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Cloud IoT Core Python Samples | ||
This folder contains Python samples that demonstrate an overview of the | ||
Google Cloud IoT Core platform. | ||
|
||
## Quickstart | ||
1. Install the gCloud CLI as described in [the device manager guide](https://cloud.google.com/iot/docs/device_manager_guide). | ||
2. Create a PubSub topic: | ||
|
||
gcloud beta pubsub topics create projects/my-iot-project/topics/device-events | ||
|
||
3. Add the service account `cloud-iot@system.gserviceaccount.com` to that | ||
PubSub topic from the [Cloud Developer Console](https://console.cloud.google.com) | ||
or by using the helper script in the /scripts folder. | ||
|
||
4. 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 | ||
|
||
5. Use the `generate_keys.sh` script to generate your signing keys: | ||
|
||
./generate_keys.sh | ||
|
||
6. Register a device: | ||
|
||
gcloud alpha iot devices create my-python-device \ | ||
--project=my-iot-project \ | ||
--region=us-central1 \ | ||
--registry=my-registry \ | ||
--public-key path=rsa_cert.pem,type=rs256 | ||
|
||
7. Connect a sample device using the sample app in the `mqtt_example` folder. | ||
8. Learn how to manage devices programatically with the sample app in the | ||
`manager` folder. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For portability (windows) I'm wondering if it's easy to do this in Windows? No action needed, but just curious. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Works from Cygwin / Bash for Windows AFAIK. For a native solution, I have used PuTTyGen in the past. |
||
|
||
# Copyright 2017 Google Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
openssl req -x509 -newkey rsa:2048 -keyout rsa_private.pem -nodes -out \ | ||
rsa_cert.pem -subj "/CN=unused" | ||
openssl ecparam -genkey -name prime256v1 -noout -out ec_private.pem | ||
openssl ec -in ec_private.pem -pubout -out ec_public.pem |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Cloud IoT Core Device Manager Python Sample | ||
|
||
This sample application shows you how to manage devices programmatically using | ||
Python. | ||
|
||
|
||
# Setup | ||
|
||
1. Use virtualenv to create a local Python environment. | ||
|
||
virtualenv env && source env/bin/activate | ||
|
||
2. Install the dependencies | ||
|
||
pip install -r requirements.txt | ||
|
||
|
||
# Running the sample | ||
|
||
The following snippet summarizes usage for the device manager sample: | ||
|
||
usage: cloudiot_device_manager_example.py [-h] \ | ||
--project_id PROJECT_ID \ | ||
--pubsub_topic PUBSUB_TOPIC \ | ||
--api_key API_KEY \ | ||
[--ec_public_key_file EC_PUBLIC_KEY_FILE] \ | ||
[--rsa_certificate_file RSA_CERTIFICATE_FILE] \ | ||
[--cloud_region CLOUD_REGION] \ | ||
[--service_account_json SERVICE_ACCOUNT_JSON] \ | ||
[--registry_id REGISTRY_ID] | ||
|
||
|
||
For example, if your project-id is `blue-jet-123` and your service account | ||
credentials are stored in `creds.json` in your home folder, the following | ||
command would run the sample: | ||
|
||
python cloudiot_device_manager_example.py \ | ||
--project_id blue-jet-123 \ | ||
--pubsub_topic projects/blue-jet-123/topics/device-events \ | ||
--ec_public_key ../ec_public.pem \ | ||
--rsa_certificate_file ../rsa_cert.pem \ | ||
--api_key YOUR_API_KEY \ | ||
--service_account_json $HOME/creds.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use autogenned readmes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am reusing the parent README in Node / Java / Python because there's some tricky steps that are unrelated to the language-specific steps.