Coder Social home page Coder Social logo

iot_scripts's Introduction

iot_scripts

connect your legacy systems into IOT network

this repo include scripts to connect your legacy systems like router, linux server, etc. to IOT network, so you can control them use mobile/desktop iot clients.

leverage the open-sourced mqtt client mosquitto-pub/sub, bash and awk scripts, we can put these all together to form a flow to interact with remote iot brokers.

flow design

┌───────────────────────────────────────────────────────────────────┐
│                    legacy machine                                 │
│                                                                   │
│                                                                   │
│   ┌─────────────┐pipe     ┌───────────┐pipe     ┌─────────────┐   │
│   │mosquitto_sub├────────►│awk scripts├────────►│mosquitto_pub│   │
│   └─┬───────────┘         └───────────┘         └───────┬─────┘   │
│     │                                                   │         │
└─────┼───────────────────────────────────────────────────┼─────────┘
      │                                                   │
      │                                                   │
      │           ┌─────────────────┐                     │
      │           │  mqtt server    │                     │
      └──────────►└─────────────────┘  ◄──────────────────┘
           mqtts connection

configration

the configure files located in /etc/mqtt:

mqtt.conf:

id=xxxx				#uniq mqtt client id used to connect to mqtt server. this client also subscribe to command/{id} and publish event to reply/{id}
cafile=xxx
keyfile=xx
certfile=xx			#cafile, certfile, keyfile used to auth the client,use client certification authrization methods
server=xxx.xxx.xxx.xxx                #domain name or ip this client connect to, use the standard mqtts port:8883

cmd.awk:

cmd.awk implements logic to parse mqtt message and call system commands ,then output result in json format, like this:

if (cmd=="reboot") {                                               
                line="reboot"                                              
                system (line)                                              
                res=res"\"sys\": \"rebooting\""                            
        }

following commands have been implemented:

  • reboot system
  • check uptime
  • check disk usage
  • get ipv6 address
  • turn on/off wifi
  • start other service

supported systems

linux

pre requirements

install mosquitto-clients package using os-specific package manager install gawk manually instead of traditional awk on openwrt .

run as system service

please refer to the system guide on how to registe a system service. the dirs linux and openwrt are implements to make our iot connector a system service.

mqtt server:

we can leverage public mqtt server self-hosted, by simply install mosquitto. the only should be noted is we must use client-cerfication plus ssl instead of plain user/password, for security reasons.

mqtt mobile client

there are so many mobile mqtt clients. I choose mqtt-dash, please read following link to see how to configure mqtt-dash: https://www.hackster.io/fabiosouza/use-mqtt-dash-to-control-a-lamp-over-the-internet-97fa63#:~:text=MQTT%20Dash%20is%20one%20of%20the%20best%20free,use.%20You%20can%20download%20it%20in%20Google%20Play.

use the convenient mobile mqtt clients, we can control the system remotely with just a click

iot_scripts's People

Contributors

stdanley avatar

Stargazers

 avatar

Watchers

 avatar

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.