This file contains hidden or 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
def pubsub_callback(message): | |
messages.append(message.data) | |
message.ack() | |
app.logger.info(message.data) | |
@app.before_request | |
def before_first_request(): | |
subscriber = pubsub_v1.SubscriberClient() | |
subscription_path = subscriber.subscription_path(PROJECT_ID, subscription_name) | |
#subscriber.subscribe_experimental(subscription_name, pubsub_callback) |
This file contains hidden or 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
gcloud pubsub topics create robot-fun | |
gcloud pubsub subscriptions create robot-fun-sub --topic=tour-pub |
This file contains hidden or 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
gcloud iot registries create robots-fun --region=us-central1 --event-notification-config-topic=robots-fun |
This file contains hidden or 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
openssl ecparam -genkey -name prime256v1 -noout -out ec_private.pem | |
openssl ec -in ec_private.pem -pubout -out ec_public.pem |
This file contains hidden or 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
gcloud iot devices create test-dev —region=us-central1 —registry=arduino-test \ | |
—public-key path=ec_public.pem,type=es256 |
This file contains hidden or 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
openssl ec -in ec_private.pem -noout -text |
This file contains hidden or 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
virtualenv create env && source env/bin/activate | |
pip install -r requirements.txt |
This file contains hidden or 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
export FLASK_APP=server.py | |
flask run |
This file contains hidden or 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
git clone https://github.com/GoogleCloudPlatform/iot-hexspider-esp8266 |
This file contains hidden or 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
function listRegistries() { | |
Logger.log('Cloud IoT Core Apps Script sample'); | |
var projectId = 'your-project-id'; | |
var cloudRegion = 'us-central1'; | |
var parent = "projects/"+ projectId +"/locations/" + cloudRegion; | |
var response = CloudIoT.Projects.Locations.Registries.list(parent); | |
response.deviceRegistries.forEach( | |
function(result) { | |
console.log(result.id + '\n'); |