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
| 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
| 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
| 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
| 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 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 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
| 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
| 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
| def updateConfig(project_id, region, registry_id, device_id, data): | |
| """Push the data to the given device as configuration.""" | |
| config_data_json = json.dumps(data) | |
| body = { | |
| 'version_to_update': 0, | |
| 'binary_data': base64.b64encode( | |
| config_data_json.encode('utf-8')).decode('ascii') | |
| } | |
| device_name = ('projects/{}/locations/{}/registries/{}/' |