esp_mqtt/user_basic/user_main.c

28 wiersze
838 B
C
Czysty Zwykły widok Historia

2017-06-07 20:21:26 +00:00
#include "user_interface.h"
#include "mqtt/mqtt_server.h"
2017-06-07 20:21:26 +00:00
#include "user_config.h"
2017-07-21 14:35:45 +00:00
void ICACHE_FLASH_ATTR user_init() {
2017-06-07 20:21:26 +00:00
struct station_config stationConf;
// Initialize the UART
uart_div_modify(0, UART_CLK_FREQ / 115200);
2017-08-22 19:46:45 +00:00
os_printf("\r\n\r\nMQTT Broker starting\r\n");
2017-06-07 20:21:26 +00:00
// Setup STA
wifi_set_opmode(STATIONAP_MODE);
stationConf.bssid_set = 0;
os_strcpy(&stationConf.ssid, STA_SSID);
os_strcpy(&stationConf.password, STA_PASS);
wifi_station_set_config(&stationConf);
wifi_station_set_auto_connect(1);
// Allow larger number of TCP (=MQTT) clients
espconn_tcp_set_max_con(TCP_MAX_CONNECTIONS);
os_printf("Max number of TCP clients: %d\r\n", espconn_tcp_get_max_con());
//Start MQTT broker
MQTT_server_start(MQTT_PORT, MQTT_MAX_SUBSCRIPTIONS, MQTT_MAX_RETAINED_TOPICS);
}