Git Product home page Git Product logo

nrf9160-google_iot_mqtt's Introduction

Google IOT MQTT Sample

Overview

Based on the Zephyr sample, and adapted for nRF9160, leveraging modem features.

This sample application demonstrates a "full stack" application. This currently is able to:

  • Establish a TLS connection with the Google IOT Cloud servers
  • Publish data to the Google IOT Cloud
  • Send/Receive keep alive / pings from cloud server

Requirements

  • Entropy source
  • Google IOT Cloud account
  • Google IOT Cloud credentials and required information
  • Cellular connectivity

Building and Running

This application has been built and tested on the Nordic nRF9160-DK. ECDSA keys are required to authenticate to the Google IOT Cloud. The application includes a key creation script.

Run bash create_keys.sh <device-id> in the samples/net/cloud/google_iot_mqtt/src/private_info/ directory.

Clone the cred utility for programming credentials to the modem.

Program the client private key:

python3 cred.py \
  --client_private_key <device-id>-ec_private.pem \
  --sec_tag 10

Download cloud-side certs (primary and backup)

Convert cloud-side certs from binary to text

openssl x509 -inform DER -outform PEM -in gtsltsr.crt -out gtsltsr.pem
openssl x509 -inform DER -outform PEM -in GSR4.crt -out GSR4.pem

NOTE: It is not necessary to change the certs to to "C-Style\n" formatting.

Program the cloud-side certs:

python3 cred.py \
  --CA_cert gtsltsr.pem \
  --sec_tag 202
python3 cred.py \
  --CA_cert GSR4.pem \
  --sec_tag 203

Assign keys on Google Cloud IoT Core

  • Device Details -> Assign Public Key
  • Input Method: Enter Manually
  • Public key format: ES256
  • Public key value: content of <device-id>-ec_public.pem

Users will also be required to configure the following Kconfig options based on their Google Cloud IOT project. The following values come from the Google Cloud Platform itself:

  • PROJECT_ID: When you select your project at the top of the UI, it should have a "name", and there should be an ID field as well. This seems to be two words and a number, separated by hyphens.
  • REGION: The Region shows in the list of registries for your registry. And example is "us-central1".
  • REGISTRY_ID: Each registry has an id. This is a string given when creating the registry.
  • DEVICE_ID: A name given for each device. When viewing the table of devices, this will be shown.

From these values, the config values can be set using the following template:

CLOUD_CLIENT_ID="projects/PROJECT_ID/locations/REGION/registries/REGISTRY_ID/devices/DEVICE_ID"
CLOUD_AUDIENCE="PROJECT_ID"
CLOUD_SUBSCRIBE_CONFIG="/devices/DEVICE_ID/config"
CLOUD_PUBLISH_TOPIC="/devices/DEVICE_ID/state"

See Google Cloud MQTT Documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.