If you are asking a question, please follow this template:
I want to make my esp8266 act as a mqtt broker, but i cant connect to it. i dont know why i cant connect it, i already change the port in mqttbox to ip that provided by my mqtt broker(esp8266).
here is my code :
#include "mongoose.h"
#if MG_ENABLE_MQTT_BROKER
#define MG_ENABLE_MQTT_BROKER 1
static const char *address = "0.0.0.0:1883";
static void ev_handler(struct mg_connection *c, int ev, void *ev_data) {
if (ev != MG_EV_POLL) printf("USER HANDLER GOT EVENT %d\n", ev);
/* Do your custom event processing here */
mg_mqtt_broker(c, ev, ev_data);
}
int main(void) {
struct mg_mgr mgr;
struct mg_connection *c;
struct mg_mqtt_broker brk;
mg_mgr_init(&mgr, NULL);
if ((c = mg_bind(&mgr, address, ev_handler)) == NULL) {
fprintf(stderr, "mg_bind(%s) failed\n", address);
exit(EXIT_FAILURE);
}
mg_mqtt_broker_init(&brk, NULL);
c->priv_2 = &brk;
mg_set_protocol_mqtt(c);
printf("MQTT broker started on %s\n", address);
/*
* TODO: Add a HTTP status page that shows current sessions
* and subscriptions
*/
for (;;) {
mg_mgr_poll(&mgr, 1000);
}
}
#endif /* MG_ENABLE_MQTT_BROKER */
oh ok, so mqtt broker is only available in https://github.com/cesanta/mongoose and if i want to use mqtt broker i need to copy mongoose.c and mongoose.h to my build trees then what?
yeah , i already try that
so is there any another way to use mqtt broker in mongoose? or its hopeless to use mqtt broker on mongoose? , i mean like if by default mongoose os does not have a mqtt broker libs , how can i even enable the mqtt broker haha.