JavaScript Shell HTML Ruby
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.circleci file rename Jun 8, 2018
conf docker transformer is exposed on port 7475 by default May 26, 2018
design release version bump, expiring old users after 3 months May 2, 2018
docs THX-348: MQTT API Docs moved to Wiki Jul 27, 2017
img fixed audit log to return at least something (not filtered by owner s… Jun 25, 2017
install added logrotate installation script for the transformer log rotate Apr 23, 2018
jasmine-disabled disabled statistics testing on CI Aug 15, 2017
languages `Lua` language name capitalization fix (via @marcelstoer) Oct 23, 2017
lib/thinx fixed slack reconnect issue Jun 4, 2018
platforms added missing python language descriptor Oct 31, 2017
scripts transiting from Public RSA Keys to Private Deploy Keys strategy... ke… Apr 13, 2018
spec test repo updates May 26, 2018
static added static gdpr consent document Mar 23, 2018
tools updated docker buillds May 21, 2018
webpush fixed #https://rollbar.com/thinx-dev/THiNX/items/62/ May 24, 2017
.codacy.yml safer notifier file creation, providing commit_id with dvc.info Nov 10, 2017
.coveralls.yml added test coverage using coveralls May 17, 2017
.eslintrc typo fix in gdpr consent Mar 15, 2018
.gitignore added sample aclfile Apr 13, 2018
.gitmodules testored library submodules (required for testing) Dec 6, 2017
.jshintrc jshint fixes as of to templates May 19, 2017
.nycrc added initial .nycrc file Jul 13, 2017
.snyk fix: package.json & .snyk to reduce vulnerabilities Apr 23, 2018
00-init_db_design.sh removed deprecated sources db, improvements in cleanup script Dec 7, 2017
01-analyze.sh moving from srcclr in 01-analyze to circle.yml Apr 13, 2017
02-deploy.sh updated deploy hooks Feb 16, 2018
03-test.sh 10 tests filing, replaced api keys Dec 14, 2017
04-devices.sh minor codacy fixes Sep 15, 2017
04-test-devices.json additional logging Jul 2, 2017
CHANGELOG.md updated history and changelog, version bump, close to public release Feb 15, 2018
CODE_OF_CONDUCT.md holding in-memory Slack token (should use Redis instead) Sep 5, 2017
CONTRIBUTING.md Create CONTRIBUTING.md Nov 13, 2017
Gemfile cleaning jasmine, added source deletion method Apr 28, 2017
Gemfile.lock cleaning jasmine, added source deletion method Apr 28, 2017
HISTORY.md added moment.js May 31, 2018
ISSUE_TEMPLATE.md Create ISSUE_TEMPLATE.md Nov 13, 2017
LICENSE Create LICENSE Sep 5, 2017
README.md Updated readme Jun 8, 2018
_envi.json 10 tests still failing, fixed source generator update conflict, synch… Dec 14, 2017
builder enter build dir for ls May 27, 2018
builder.thinx.dist.json variable thinx platform template Jul 17, 2017
builder.thinx.json variable thinx platform template Jul 17, 2017
couch_cleanup.sh release version bump, expiring old users after 3 months May 2, 2018
couchdb_first_run.sh more codacy fixes Sep 15, 2017
deploy-hook.sh separating deployhooks, debugging pm2 master process that is causing … Apr 23, 2018
docker-cleanup.sh integrated docker cleanup after build Jul 25, 2017
docker-update.sh added script for updating docker builders Aug 4, 2017
index.js temporarily disabled blacklisting; coffee-makers have memory issues b… Jun 5, 2018
infer adding cleanup for pre-fetched repositories May 21, 2018
karma.conf.js some fixes on apikey class thanks to tests (broken so far but still b… May 18, 2017
linter fixed linter infer paths from bash profile May 3, 2018
mosquitto.aclfile added sample aclfile Apr 13, 2018
notifier.js added `crypto` dependency to calculate MD5 using NodeJS function as w… May 25, 2018
package.json added moment.js May 31, 2018
pre-builder prebuilder exit code is 1 Oct 31, 2017
release.sh moved changelog generator to manually executed script Nov 23, 2017
sonar-project.properties sonar-based fixes Jun 27, 2017
stats_test.js correct id Jul 3, 2017
test_websocket_localhost.html correct id Jul 3, 2017
test_websocket_thinx.cloud.html correct id Jul 3, 2017

README.md

☢ thinx-device-api

Codacy Badge Twitter: @thinxcloud License

The CircleCI build is limited and therefore returns mostly bad results. Closer look may show better numbers:

Build Status Coverage Status

IoT Device Management Server running on node.js.

The Purpose

  • Update IoT device by pushing a code to a Git repository. We'll build it.
  • Swap operating system for another over-the-air.
  • Migrate multiple devices at once between WiFi networks.
  • THiNX provides complete IoT infrastructure for your device (where the data storage and visualisation can be fully up to you).
  • automatic updates for headless devices, or semi-automatic (with user consent after build and tests succeed)

As a user I have already many IoT new and/or legacy devices at home and new platforms are coming every day.

Sometimes we need to change WiFi credentials on a wireless switch mounted on a ceiling. The other day I we want to swap whole firmware for new one, but not always to rewrite working legacy Lua or Micropython code to PlatformIO.

That's why we have decided to create the über-platform: THiNX.

Supported hardware

Currently the platform supports building firmware for Arduino, PlatformIO (also with ESP-IDF), NodeMCU, Mongoose, Micropython and features JavaScript library that is intended to use on any hardware capable of running a Node.js server.

Features

  • Remote Things Management console for monitoring devices, attaching source code, pushing data, managing incoming payloads and firmware updates.

  • Continuous Integration practices to update device apps/configurations from a GitHub repository using commit hooks

  • Building secure MQTTS infrastructure as an optional side-chain transport layer.

  • Device registration endpoint while storing device data using CouchDB server and Redis session-store.

  • API is a back-end data provider (security agent) for RTM Admin Console Application.

  • Provides control to a dockerized build servers and pushes new firmware versions to client applications (FCM push) and devices (MQTT).

  • Provides HTTP-to-HTTPS proxy to secure legacy IoT devices that are not capable of TLS and/or AES-level encryption.

  • Allows transfer of device ownership (e.g. for pre-configured devices).

  • Custom firmware builder for MongooseOS, NodeMCU and Micropython (allow module selection, add THiNX as an OS-level library)

  • Transfer device to another owner along with sources/firmware.

  • Device status messages can be transformed using custom JavaScript lambda-style functions.

  • Supports OAuth login with Google and GitHub.

  • Supports InfluxDB/Grafana data storage and visualisation.

  • Supports LoRaWan server integration.

Supported IoT Platforms

  • PlatformIO and Arduino IDE (ESP8266P/ESP32)

  • Micropython

  • Lua

  • MongooseOS

  • NodeJS (Mac/Linux/Windows)

  • Tested on Wemos D1 Mini, Wemos D1 Mini Pro, RobotDyn D1, RobotDyn D1 Mini, RobotDyn MEGA WiFi and various NodeMCU (Lolin, AI-THINKER) boards with Mongoose, Arduino Core, ESP-IDF, Lua and Micropython-based core firmwares...

  • Expected: Arduino and BigClown with networking support

Base THiNXLib Platform Library in C++:

THiNXLib for ESP8266

THiNXLib for ESP32

THiNX Platform Library repositories for various IDEs and firmwares:

Platform.io

Arduino

NodeMCU/Lua

Micropython

MongooseOS

NodeJS

Custom Firmwares

With built-in THiNX Client Library:

NodeMCU/Lua

Micropython

Arduino, Plaform.io and MongooseOS are firmwares by nature.

Dockerized Firmware Builders

PlatformIO

Arduino

MongooseOS

NodeMCU/Lua

Micropython

Prerequisites for running own THiNX Server

  • Linux Server (min. 2 GB RAM, 32GB SSD, Ubuntu)
  • Docker

Port mapping

  • API runs on HTTP port 7442 (HTTPS 7443) and 7447 (web socket)
  • MQTTS runs on port 8883
  • Admin runs on HTTP/HTTPS port (80/443)
  • GitHub commit hooks are listened to on port 9000, 9001
  • Grafana (3003), InfluxDB (3004)
  • Status Transformers (localhost only, 7445)
  • Optional monitoring services (Keymetrics, TrueSight) may run on other ports as well...

Installation

Using Docker

Experimental Docker installation can be found at Docker Hub.

First of all, set a valid FQDN (THINX_HOSTNAME) for your new THiNX instance on your DNS server. Use this FQDN to parametrise the Docker image by following example:

docker pull suculent/thinx-docker

docker build --build-arg THINX_HOSTNAME=staging.thinx.cloud -t suculent/thinx-docker .

docker run -ti -e THINX_HOSTNAME='staging.thinx.cloud' -e THINX_OWNER='suculent@me.com' suculent/thinx-docker

Installing Platform Builders

Attach to the running container with bash:

docker run -ti -e THINX_HOSTNAME='staging.thinx.cloud' -e THINX_OWNER='suculent@me.com' suculent/thinx-docker /bin/bash

Fetch required builder images from Docker Hub:

bash ./install-builders.sh

Run after boot

We're currently using /etc/rc.local to kick THiNX up after a failure:


# MQTT service
mosquitto > /root/thinx-device-api/mosquitto.log &

# Redis service
redis-server > /root/thinx-device-api/redis.log &

# CouchDB service
/etc/init.d/couchdb start

# NodeJS Sandbox
docker run -d suculent/thinx-node-tranformer

# Grafana/InfluxDB
docker run -d \
  -p 3003:3003 \
  -p 3004:8083 \
  -p 8086:8086 \
  -v /root/docker-influxdb-grafana/influxdb:/var/lib/influxdb \
  -v /root/docker-influxdb-grafana/grafana:/var/lib/grafana \
  suculent/docker-influxdb-grafana:latest

# THiNX itself
cd /root/thinx-device-api/ && pm2 start index

GitHub Webhook support

You can direct your GitHub web-hooks to https://thinx.cloud:9001/ after adding a valid deploy key from GitHub to THiNX RTM.

Endpoints

See 03-test.sh. There is no point of maintaining documentation for this at current stage of development and user base zero.

Platforms State of Union

Overall

Platform libraries are now stabilised on the basic level, approaching first release version 1.0 with default HTTPS with optional fallback to HTTP for development.

PlatformIO

  • Docker builder works.
  • Deployment update can be tested now.

Arduino

  • Docker builder has been recently updated.
  • Deployment update can be tested now.

NodeMCU

  • File-based update has been pre-tested. Docker builder works fine but needs tighter integration with sources ($workdir).
  • Deployment is not verified, therefore update cannot be tested.

Micropython

  • Docker builder works fine but needs tighter integration with sources.
  • Deployment is not verified, therefore update cannot be tested now.

Roadmap

On-Horizon

  • PlatformIO: end-to-end update
  • Arduino: end-to-end update