1.0.46 • Published 6 months ago

mgmt-iot-web v1.0.46

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

mgmt-iot IoT device management platform

mgmt-iot is a module to enable a web platform to configure and interact with IoT devices. A special firmware has to be running on those IoT devices esp32-freeRTOS2. For now, only esp32 architecture is supported. It can be used with wifi or bg95 modem. A link will be published here to download firmware, as soon as it is available

This module also relies on a dedicated mqtt broker. This broker was developed to check authorizations before subscribe or publish calls. Please check this mqtt-broker-auth for more information about mqtt broker operation The purpose of this broker is to allow users to connect directly to devices in which they have permissions for that.

This module will enable the management of those permissions, as well as configure and interact with iot devices.

Furthermore, without any development a device can be configured to have it's own Autorequests, Alarms or even a dedicated JavaScript code running in real time. JavaScript code can be changed at any time. The code is limited to some internal calls and JavaScript functions.

All devices will have the most recent available firmware version. They can be configured to receive any version (nightmare) or only stable versions (stable). Firmware download can be done over http or https, it depends on how this platform was setup. This download is made automatically and is protected with SHA256 tokens.

All devices are visible only to admin accounts. However, dedicated accounts can be created and configured to have access to one or more devices.

It is not need to use this platform to interact with devices, yet only mqtt clients with the right granted permissions can have access to devices. Connecting to the mqtt broker auth service, any client can interact and acquire data in real time.

MySql

For now it depends on mysql, so it is needed to have a mysql 8 running. In mysql folder, there is a database that needs to be loaded in mysql. After that, use the struct config to init platform device management. Change values according to your setup

require("./middleware") // optional, execute it, only if you will work on a middleware
var iot = require('mgmt-iot');

let config = {
  db: {
    conn_limit : 15,
    host:'localhost',
    user:'user',
    pwd:'user_pwd',
    name:'mqtt-aedes', // db name
  },
  mqtt: {
    protocol:'MQTT',
    host:'localhost',
    port:'1883',
    user:'admin',
    pwd:'admin'
  },
  debug:{
    level: "trace" // logs level (ignore it for now)
  },
  web_port : 24000, // http port to expose
}

var iot = require('mgmt-iot');
iot.init(config);
global.iot_path = iot.path() // optional, use it to get files from module

And that's it, your program is ready to run

MQTT

mqtt-broker-auth

Note: This module must be used with a special mqtt broker. So, in order to have it working properly you need to run mqtt-broker-auth also

Adding features to this module

A middleware can be defined to customize this iot platform. For each page not served in the module, it is possible to serve it with a middleware like it.

Create a file with middleware.js

Copy the following code

var express = require('express');
const middleware = express.Router();

// Pages not served by mgmt-iot module can be served by this middleware

// check all pages requested and not served by module
middleware.use((req,res,next) => {
  var fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl;
  log.trace("route url: "+fullUrl);
  next();
});

// A special tab is implemented in iot platform, you can use it to implement a dedicated dashboard
middleware.get('/device/:device_id/dashboard',(req,res)=>{
  res.render('./server/public/views/pages/device/dashboard',{user:req.user,page:'Dashboard', path:global.iot_path});
});

// Other pages can be served as well

// In the end redirect user to the home page if no page was served before
middleware.use((req,res,next)=>{
  console.log("url not found");
  res.redirect(req.protocol + '://' + req.get('host') +'/home');
});

global.middleware = module.exports =  middleware;

How it works

Login

At any moment if no login account exists or doesn't have admin privileges, the following credentials can be used

  • user: admin
  • password : admin

They will always work and grant admin access, until a new account with admin privileges is registered

This can be done adding an user with level 5 and associate a client account to it

Dashboard

Define DB_CONTAINER_NAME to get docker stats from that container and show on dashboard

Google Auth

Google Login is also supported. Define GOOGLE_CLIENT_ID env variable to set your google account id for your project.

When a new user is registered with a google account a new a mqtt client will be created, using email prefix as the client id and the credentials set with env vars:

  • USER_TYPE
  • USER_PWD
  • USER_LVL

for mqtt user and respective permissions.

1.0.44

7 months ago

1.0.43

7 months ago

1.0.42

7 months ago

1.0.46

6 months ago

1.0.45

6 months ago

1.0.39

8 months ago

1.0.38

8 months ago

1.0.40

8 months ago

1.0.41

8 months ago

1.0.37

8 months ago

1.0.33

9 months ago

1.0.32

9 months ago

1.0.31

9 months ago

1.0.30

10 months ago

1.0.36

8 months ago

1.0.35

8 months ago

1.0.34

9 months ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.2

1 year ago