Giter VIP home page Giter VIP logo

esp-idf-mqtt-broker's Introduction

esp-idf-mqtt-broker

MQTT Broker for esp-idf.
This project use Mongoose networking library.
I forked from here.
Your fork is welcome.


  1. In this project directory, create a components directory.

  2. In the components directory, clone Mongoose: git clone https://github.com/cesanta/mongoose.git

  3. In the new Mongoose directory, create a component.mk file containing:

COMPONENT_ADD_INCLUDEDIRS=.
  1. You have to enable MG_ENABLE_MQTT_BROKER in mongoose.h.
#ifndef MG_ENABLE_MQTT_BROKER
#define MG_ENABLE_MQTT_BROKER 1
#endif
  1. Compile this project.

git clone https://github.com/nopnop2002/esp-idf-mqtt-broker
cd esp-idf-mqtt-broker
mkdir -p components
cd components/
git clone https://github.com/cesanta/mongoose.git
cd mongoose/
echo "COMPONENT_ADD_INCLUDEDIRS=." > component.mk
vi mongoose.h
Enable MG_ENABLE_MQTT_BROKER
cd ../..
make menuconfig
make flash

Wifi Setting

You can choice Wifi setting.

config-menu

Access Point Mode

config-ap

SSID:SSID of ESP32
ESP32 have 192.168.4.1.

Station Mode

config-sta

SSID:SSID of your Wifi router
ESP32 get IP using DHCP.

Station Mode of Static Address

config-static

SSID:SSID of your Wifi router
ESP32 set your specific IP.


Monitor

Show all incoming message

show_all

Show event only

show_event


Bug Fix to mongoose.c

There is some bug in mongoose.c.
So you have to fix manually.

void mg_mqtt_suback(struct mg_connection *nc, uint8_t *qoss, size_t qoss_len,
                    uint16_t message_id) {
  size_t i;
  uint16_t netbytes;

  //Comment by nopnop2002
  //mg_send_mqtt_header(nc, MG_MQTT_CMD_SUBACK, MG_MQTT_QOS(1), 2 + qoss_len);
  //Add by nopnop2002
  mg_send_mqtt_header(nc, MG_MQTT_CMD_SUBACK, 0, 2 + qoss_len);

  netbytes = htons(message_id);
  mg_send(nc, &netbytes, 2);

  for (i = 0; i < qoss_len; i++) {
    mg_send(nc, &qoss[i], 1);
  }
}

MQTT Broker over web sockets

config-web-socket

You can test WebSocket using test-socket.py.
I forked this.

curl https://bootstrap.pypa.io/get-pip.py -o - | sudo python
sudo pip install paho-mqtt
python ./test-socket.py

esp-idf-mqtt-broker's People

Contributors

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