Coder Social home page Coder Social logo

mqtt-gateway's Introduction

PLEASE READ

You might not need to install this software. This software is used by the FarmBot team and advanced users who run their own FarmBot servers. We highly recommend that you use our publicly hosted server at my.farmbot.io, which elimintes the need for server setup.

How It Works

Farmbot uses MQTT for realtime events. On the device side, this is handled over a TCP connection to the MQTT broker. On the browser, this is performed over a Websocket connection.

Our MQTT Implementation

  • Log in to the broker using the same email as on the web app. A JSON Web Token from the API can be used as a password.
  • Messages are sent using JSON RPC.

Available MQTT Topics

  • bot/device_{ BOT_ID }/from_clients: Commands originated from browsers and clients.
  • bot/device_{ BOT_ID }/from_device: This is where the bot publishes messages.

Subscribing to bot/{ BOT_UUID }/* via 3rd party MQTT client (Such as MQTT FX) is useful for debugging and monitoring.

Installation

  1. git clone THIS_REPO
  2. cd THIS_REPO
  3. npm install
  4. Setup and run the Web API locally. We recommend running it on http://localhost:3000
  5. WEB_API_URL=http://localhost:3000 node app/index.js. See note below*.
  6. Websocket MQTT is now available via ws://localhost:3002 and wss://localhost:443. Raw MQTT (TCP connections) are available via mqtt://localhost:1883.

* The assumption is that you are running a Web API instance on localhost:3000. If you are using a different API server, please change WEB_API_URL accordingly.

ENV var reference

The MQTT broker uses ENV vars as the main means of configuration. These must be set properly for the app to work.

  • WEB_API_URL: URL to your FarmBot API. For instance, if you were running the API locally, you would set this value to localhost:3000.
  • SSL_DOMAIN: Optional.. Do not set if you do not plan on using Let's Encrypt. This is the domain that Let's Encrypt will verify ownership of.
  • SSL_EMAIL: Optional.. Email for correspondence related to Let's Encrypt.

Running on Local (for development)

  • Start the FarmBot API on your local machine on default port.
  • Run npm run dev

Running the Test Suite

npm test

Provisioning a Production Server

See DEPLOYMENT.md.

Want to Help?

Low Hanging Fruit

mqtt-gateway's People

Contributors

rickcarlino avatar

Watchers

 avatar  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.