mirror of
https://github.com/martin-ger/esp_wifi_repeater.git
synced 2026-07-28 04:06:57 +00:00
status topic in cb
This commit is contained in:
Binary file not shown.
Binary file not shown.
+2
-2
@@ -1,2 +1,2 @@
|
||||
6c355bf9c4f512baa0df1d42d4135c4248d70d54 0x00000.bin
|
||||
b9172df82b470ae3a0f6c77415efd2d6d7490f88 0x10000.bin
|
||||
2df4dab79508a655464cabda1489d8cc8bd4cfed 0x00000.bin
|
||||
d60650db4ea160f0a740d4921d20e99f251d408f 0x10000.bin
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef _USER_CONFIG_
|
||||
#define _USER_CONFIG_
|
||||
|
||||
#define ESP_REPEATER_VERSION "V1.8.10"
|
||||
#define ESP_REPEATER_VERSION "V1.8.11"
|
||||
|
||||
#define LOCAL_ACCESS 0x01
|
||||
#define REMOTE_ACCESS 0x02
|
||||
|
||||
+10
-15
@@ -167,14 +167,17 @@ uint8_t buf[32];
|
||||
|
||||
static void ICACHE_FLASH_ATTR mqttConnectedCb(uint32_t *args)
|
||||
{
|
||||
uint8_t ip_str[16];
|
||||
uint8_t buf[256];
|
||||
|
||||
MQTT_Client* client = (MQTT_Client*)args;
|
||||
os_printf("MQTT: Connected\r\n");
|
||||
mqtt_connected = true;
|
||||
|
||||
os_sprintf(ip_str, IPSTR, IP2STR(&my_ip));
|
||||
mqtt_publish_str(MQTT_TOPIC_IP, "IP", ip_str);
|
||||
os_sprintf(buf, "%s/status", config.mqtt_prefix);
|
||||
MQTT_Publish(client, buf, "online", os_strlen("online"), 0, 1);
|
||||
|
||||
os_sprintf(buf, IPSTR, IP2STR(&my_ip));
|
||||
mqtt_publish_str(MQTT_TOPIC_IP, "IP", buf);
|
||||
|
||||
if (os_strcmp(config.mqtt_command_topic, "none") != 0) {
|
||||
MQTT_Subscribe(client, config.mqtt_command_topic, 0);
|
||||
@@ -2986,17 +2989,7 @@ void wifi_handle_event_cb(System_Event_t *evt)
|
||||
}
|
||||
|
||||
#ifdef MQTT_CLIENT
|
||||
if (mqtt_enabled) {
|
||||
uint8_t buf[256];
|
||||
|
||||
// status as LWT
|
||||
os_sprintf(buf, "%s/status", config.mqtt_prefix);
|
||||
MQTT_InitLWT(&mqttClient, buf, "offline", 0, 1);
|
||||
|
||||
MQTT_Connect(&mqttClient);
|
||||
|
||||
MQTT_Publish(&mqttClient, buf, "online", sizeof("online"), 0, 1);
|
||||
}
|
||||
if (mqtt_enabled) MQTT_Connect(&mqttClient);
|
||||
#endif /* MQTT_CLIENT */
|
||||
|
||||
// Post a Server Start message as the IP has been acquired to Task with priority 0
|
||||
@@ -3520,7 +3513,9 @@ struct espconn *pCon;
|
||||
} else {
|
||||
MQTT_InitClient(&mqttClient, config.mqtt_id, config.mqtt_user, config.mqtt_password, 120, 1);
|
||||
}
|
||||
// MQTT_InitLWT(&mqttClient, "/lwt", "offline", 0, 0);
|
||||
uint8_t buf[256];
|
||||
os_sprintf(buf, "%s/status", config.mqtt_prefix);
|
||||
MQTT_InitLWT(&mqttClient, buf, "offline", 0, 1);
|
||||
MQTT_OnConnected(&mqttClient, mqttConnectedCb);
|
||||
MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
|
||||
MQTT_OnPublished(&mqttClient, mqttPublishedCb);
|
||||
|
||||
Reference in New Issue
Block a user