{"id":22995400,"url":"https://github.com/kingman/cloud-iot-core-protobuf-sample","last_synced_at":"2025-06-12T17:03:11.839Z","repository":{"id":35364913,"uuid":"217384453","full_name":"kingman/cloud-iot-core-protobuf-sample","owner":"kingman","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-23T22:31:00.000Z","size":10,"stargazers_count":3,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T04:51:18.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kingman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-24T19:56:35.000Z","updated_at":"2022-04-20T21:28:49.000Z","dependencies_parsed_at":"2022-07-24T18:32:10.820Z","dependency_job_id":null,"html_url":"https://github.com/kingman/cloud-iot-core-protobuf-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingman%2Fcloud-iot-core-protobuf-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingman%2Fcloud-iot-core-protobuf-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingman%2Fcloud-iot-core-protobuf-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingman%2Fcloud-iot-core-protobuf-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kingman","download_url":"https://codeload.github.com/kingman/cloud-iot-core-protobuf-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246819784,"owners_count":20839095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-15T05:29:37.810Z","updated_at":"2025-04-02T13:09:52.550Z","avatar_url":"https://github.com/kingman.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cloud-iot-core-protobuf-sample\n\nIn this guide you set up an end-to-end IoT ingestion pipeline, from a simulated client device to Cloud Functions via Cloud IoT Core.\nThe main purpose is to show-case usage to Protocol Buffers to serialize and deserialize the messages send over MQTT connection.\n\n## Generated Python protocol buffer class\nThe Python protocol buffer class is already generated for this tutorial. The class is generated based on the [proto definition file](proto/measurement.proto).\nFollow the [Python Generated Code](https://developers.google.com/protocol-buffers/docs/reference/python-generated) to understand the process of Python protocol buffer class.\n\n## Before you begin\n\n1.  [Select or create a GCP project](https://console.cloud.google.com/projectselector2/home/dashboard).\n1.  Make sure that [billing is enabled](https://cloud.google.com/billing/docs/how-to/modify-project) for your GCP project.\n1.  [Enable the Cloud IoT, Cloud Pub/Sub and Cloud Functions](https://console.cloud.google.com/flows/enableapi?apiid=cloudiot.googleapis.com,pubsub.googleapis.com,cloudfunctions.googleapis.com).\n\n## Get the tutorial source code in Cloud Shell\n\n1.  In the GCP Console, [open Cloud Shell](http://console.cloud.google.com/?cloudshell=true).\n1.  Clone the source code repository:\n\n        cd $HOME\n        git clone https://github.com/kingman/cloud-iot-core-protobuf-sample.git\n\n\n## Set environment variables\n\nTo make it easier to run commands when you create cloud resources, set environment variables in Cloud Shell to hold the names and properties of the resources:\n\n    export PROJECT_ID=$(gcloud config list --format 'value(core.project)')\n    export EVENT_TOPIC=proto-event\n    export REGISTRY_ID=proto-reg\n    export REGION=europe-west1\n    export DEVICE_ID=proto-device\n    export PRIVATE_KEY_FILE='rsa_private.pem'\n    export ALGORITHM='RS256'\n    export CA_CERTS='roots.pem'\n\n\n## Generate device key pair\n\nIn cloud shell run:\n\n    cd $HOME/cloud-iot-core-protobuf-sample/client\n    openssl req -x509 -nodes -newkey rsa:2048 -keyout rsa_private.pem -out rsa_cert.pem -subj \"/CN=unused\"\n\n## Set up cloud resources\n\n1.  Create the Cloud Pub/Sub topic:\n\n        gcloud pubsub topics create $EVENT_TOPIC\n\n1.  Create the Cloud IoT Core registry:\n\n        gcloud iot registries create $REGISTRY_ID \\\n          --region $REGION \\\n          --event-notification-config=topic=$EVENT_TOPIC\n\n1.  Create the the sensor board identity in the newly created Cloud IoT Core registry with the public key:\n\n        cd $HOME/cloud-iot-core-protobuf-sample/client\n        gcloud iot devices create $DEVICE_ID \\\n          --region=$REGION \\\n          --registry=$REGISTRY_ID \\\n          --public-key=path=rsa_cert.pem,type=rsa-x509-pem\n\n1.  Deploy Cloud Functions\n\n        cd $HOME/cloud-iot-core-protobuf-sample/cf\n        gcloud functions deploy process_proto \\\n          --trigger-topic $EVENT_TOPIC \\\n          --runtime python37 \\\n          --region $REGION\n\n## Set up client simulator\nIn cloud shell run:\n\n    cd $HOME/cloud-iot-core-protobuf-sample/client\n    virtualenv env \u0026\u0026 source env/bin/activate\n    pip install -r requirements.txt\n    wget https://pki.google.com/roots.pem\n\n## Run client simulator\nIn cloud shell run:\n\n    python run_client.py\n\n## Verify messages in cloud\nIn Cloud Functions log verify the messages are being logged as JSON\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingman%2Fcloud-iot-core-protobuf-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkingman%2Fcloud-iot-core-protobuf-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingman%2Fcloud-iot-core-protobuf-sample/lists"}