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 subscriptions pull <your-subscription> --auto-ack --limit=500 |
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
google-api-python-client==1.7.8 | |
google-cloud-pubsub==0.39.1 | |
Pillow==6.2.1 |
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 receive_image(project_id, sub_name, prefix, extension, duration, binary): | |
"""Receieve images transmitted to a PubSub subscription.""" | |
import base64 | |
import binascii | |
import io | |
import time | |
from google.cloud import pubsub | |
from PIL import Image | |
subscriber = pubsub.SubscriberClient() |
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 GOOGLE_CLOUD_PROJECT=<your-cloud-project> | |
python cloudiot_mqtt_example.py --registry_id=sheetshooter --device_id=device1 --private_key_file=rsa_private.pem --algorithm=RS256 --cloud_region us-central1 --num_messages 10 --message_type state --ca_certs resources/roots.pem --listen_dur=5 device_demo | |
python cloudiot_mqtt_example.py --registry_id=sheetshooter --device_id=device2 --private_key_file=rsa_private.pem --algorithm=RS256 --cloud_region us-central1 --num_messages 10 --message_type state --ca_certs resources/roots.pem --listen_dur=5 device_demo | |
python cloudiot_mqtt_example.py --registry_id=sheetshooter --device_id=device3 --private_key_file=rsa_private.pem --algorithm=RS256 --cloud_region us-central1 --num_messages 10 --message_type state --ca_certs resources/roots.pem --listen_dur=5 device_demo | |
python cloudiot_mqtt_example.py --registry_id=sheetshooter --device_id=device4 --private_key_file=rsa_private.pem --algorithm=RS256 --cloud_region us-central1 --num_messages 10 --message_type state --ca_cert |
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 req -x509 -newkey rsa:2048 -days 3650 -keyout rsa_private.pem -nodes -out \ | |
rsa_cert.pem -subj "/CN=unused" |
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 delete --region=us-central1 --registry=sheetshooter device1 0 < 13:29:19 | |
gcloud iot devices delete --region=us-central1 --registry=sheetshooter device2 | |
gcloud iot devices delete --region=us-central1 --registry=sheetshooter device3 | |
gcloud iot devices delete --region=us-central1 --registry=sheetshooter device4 | |
gcloud iot devices delete --region=us-central1 --registry=sheetshooter device5 | |
gcloud iot devices delete --region=us-central1 --registry=sheetshooter device6 | |
gcloud iot devices delete --region=us-central1 --registry=sheetshooter device7 | |
gcloud iot devices delete --region=us-central1 --registry=sheetshooter device8 | |
gcloud iot devices delete --region=us-central1 --registry=sheetshooter device9 | |
gcloud iot devices delete --region=us-central1 --registry=sheetshooter device10 |
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 sheetshooter --region=us-central1 | |
gcloud iot devices create --region=us-central1 --registry=sheetshooter --public-key path=./rsa_cert.pem,type=rs256 device1 | |
gcloud iot devices create --region=us-central1 --registry=sheetshooter --public-key path=./rsa_cert.pem,type=rs256 device2 | |
gcloud iot devices create --region=us-central1 --registry=sheetshooter --public-key path=./rsa_cert.pem,type=rs256 device3 | |
gcloud iot devices create --region=us-central1 --registry=sheetshooter --public-key path=./rsa_cert.pem,type=rs256 device4 | |
gcloud iot devices create --region=us-central1 --registry=sheetshooter --public-key path=./rsa_cert.pem,type=rs256 device5 | |
gcloud iot devices create --region=us-central1 --registry=sheetshooter --public-key path=./rsa_cert.pem,type=rs256 device6 | |
gcloud iot devices create --region=us-central1 --registry=sheetshooter --public-key path=./rsa_cert.pem,type=rs256 device7 | |
gcloud iot devices create --region=us-central1 --registry=sheetshooter --public-key path=./rsa_cert. |
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 updateData() { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var data = sheet.getDataRange().getValues(); | |
var region = 'us-central1'; | |
var projectId = 'your-project-id'; | |
var registryName = 'your-registry-name'; | |
for (var i = 0; i < data.length; i++) { | |
if (data[i][0] == 'Cloud Region') { | |
cloudRegion = data[i][1]; |
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 listDeviceStatesForRegistry() { | |
var cloudRegion = 'us-central1'; | |
var name = 'your-registry-name'; | |
var projectId = 'your-project-id'; | |
var parent = 'projects/' + projectId + '/locations/' + cloudRegion; | |
var registryName = parent + '/registries/' + name; | |
var response = CloudIoT.Projects.Locations.Registries.Devices.list(registryName); | |
if (response.devices) { |
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'); |