Closed steveasm closed 1 year ago
// sets up a soft Access Point (no internet connection) // and runs the MQTT broker on that access point
using namespace mqttBrokerName;
const char soft_ap_ssid = "MyNetwork"; const char soft_ap_password = "MyPassword";
/*** mqtt broker ****/ uint16_t mqttPort = 1883; MqttBroker broker(mqttPort);
void setup(){
/**
More info: @link https://github.com/alexCajas/EmbeddedMqttBroker @endlink */
Serial.begin(115200); // Connect to WiFi network WiFi.mode(WIFI_AP_STA);
Serial.println("\n[*] Creating ESP32 AP"); WiFi.softAP(soft_ap_ssid, soft_ap_password); Serial.print("[+] AP Created with IP Gateway "); Serial.println(WiFi.softAPIP());
// Start the mqtt broker broker.setMaxNumClients(9); // set according to your system. broker.startBroker(); Serial.println("broker started");
// Print the IP address Serial.print("Use this ip: "); Serial.println(WiFi.softAPIP()); Serial.print("and this port: "); Serial.println(mqttPort); Serial.println("To connect to mqtt broker");
}
void loop(){
}
Would it be possible to show an example of this running on an ESP32 which is also running a soft access point? Thinking an ultraportable AP and MQTT broker for IoT demos.