Code Monkey home page Code Monkey logo

balena-gateway-poc's Introduction

Resin Gateway POC

Setup

Add a few resin app environment variables

AWS_REGION = us-east-1
LAMBDA = lambda endpoint responsible for provisioning devices

Deploying

  • Clone this repository
  • Add your resin applications endpoint
git remote add resin <username>@git.resin.io:<username>/<appName>.git
  • Push your code
git push resin master

Once your code downloads to the device it will automatically run your app. If the certificates needed to communicate with AWS aren't present it will post it's RESIN_DEVICE_UUID to LAMBDA endpoint, if the certificates do exist it will run the app.

API

Publish a message on topic

method: PUT
url: /api/publish/:topic
body: {
  value: '10',
  created_at: '1498588568783'
}

Note The post body can be in whatever shape you like, it'll simply be merged with a gateway object and proxied straight to AWS IoT. So the final payload sent to AWS looks like:

{
  value: 10,
  created_at: 1498588568783,
  gateway: {
    uuid: process.env.RESIN_DEVICE_UUID,
    name: process.env.RESIN_DEVICE_NAME_AT_INIT
  }
}

example request

curl -X POST -H "Content-Type: application/json" -d '{
	"value": "1",
	"created_at": "1498588568783"
}' "https://184021ab36fbf707583fcddef8d33961.resindevice.io/api/publish/temp"

balena-gateway-poc's People

Stargazers

 avatar

Watchers

 avatar

balena-gateway-poc's Issues

Missing documentation or code: lambda function to provision device and add variables to device

The startup script looks for environment variables

  • AWS_CERT
  • AWS_PRIVATE_KEY
  • AWS_ROOT_CA
    And if they are not found, it posts a request to the AWS endpoint defined by the variable LAMBDA which should provision the resinOS device as a AWS IoT device using the RESIN_DEVICE_UUID and RESIN_DEVICE_TYPE variables

The lambda will need to use https://docs.resin.io/reference/api/resources/device_environment_variable/
to create the device AWS_CERT, AWS_PRIVATE_KEY, AWS_ROOT_CA

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.