added IP to answerback message
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "uart_buffer.h"
|
#include "uart_buffer.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
#include "wifimgr.h"
|
||||||
|
|
||||||
volatile bool enquiry_suppressed = false;
|
volatile bool enquiry_suppressed = false;
|
||||||
ETSTimer enqTimer;
|
ETSTimer enqTimer;
|
||||||
@@ -51,7 +52,15 @@ apars_handle_enq(void)
|
|||||||
wifi_get_macaddr(SOFTAP_IF, mac);
|
wifi_get_macaddr(SOFTAP_IF, mac);
|
||||||
|
|
||||||
char buf100[100];
|
char buf100[100];
|
||||||
sprintf(buf100, "\x1bXESPTerm "VERSION_STRING" #"GIT_HASH_BACKEND"+"GIT_HASH_FRONTEND" id=%02X%02X%02X\x1b\\", mac[3], mac[4], mac[5]);
|
char *buf = buf100;
|
||||||
|
buf += sprintf(buf, "\x1bX");
|
||||||
|
buf += sprintf(buf, "ESPTerm "VERSION_STRING" ");
|
||||||
|
buf += sprintf(buf, "#"GIT_HASH_BACKEND"+"GIT_HASH_FRONTEND" ");
|
||||||
|
buf += sprintf(buf, "id=%02X%02X%02X ", mac[3], mac[4], mac[5]);
|
||||||
|
int x = getStaIpAsString(buf);
|
||||||
|
if (x) buf += x;
|
||||||
|
else buf--; // remove the trailing space
|
||||||
|
buf += sprintf(buf, "\x1b\\");
|
||||||
|
|
||||||
// version encased in SOS and ST
|
// version encased in SOS and ST
|
||||||
apars_respond(buf100);
|
apars_respond(buf100);
|
||||||
|
|||||||
+1
-16
@@ -617,22 +617,7 @@ httpd_cgi_state ICACHE_FLASH_ATTR tplWlan(HttpdConnData *connData, char *token,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (streq(token, "sta_active_ip")) {
|
else if (streq(token, "sta_active_ip")) {
|
||||||
x = wifi_get_opmode();
|
getStaIpAsString(buff);
|
||||||
connectStatus = wifi_station_get_connect_status();
|
|
||||||
|
|
||||||
if (x == SOFTAP_MODE || connectStatus != STATION_GOT_IP || wificonf->opmode == SOFTAP_MODE) {
|
|
||||||
strcpy(buff, "");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
struct ip_info info;
|
|
||||||
wifi_get_ip_info(STATION_IF, &info);
|
|
||||||
sprintf(buff, IPSTR, GOOD_IP2STR(info.ip.addr));
|
|
||||||
|
|
||||||
// sprintf(buff, "ip: "IPSTR", mask: "IPSTR", gw: "IPSTR,
|
|
||||||
// GOOD_IP2STR(info.ip.addr),
|
|
||||||
// GOOD_IP2STR(info.netmask.addr),
|
|
||||||
// GOOD_IP2STR(info.gw.addr));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tplSend(connData, buff, -1);
|
tplSend(connData, buff, -1);
|
||||||
|
|||||||
@@ -8,6 +8,22 @@
|
|||||||
WiFiConfigBundle * const wificonf = &persist.current.wificonf;
|
WiFiConfigBundle * const wificonf = &persist.current.wificonf;
|
||||||
WiFiConfChangeFlags wifi_change_flags;
|
WiFiConfChangeFlags wifi_change_flags;
|
||||||
|
|
||||||
|
int ICACHE_FLASH_ATTR getStaIpAsString(char *buffer)
|
||||||
|
{
|
||||||
|
WIFI_MODE x = wifi_get_opmode();
|
||||||
|
STATION_STATUS connectStatus = wifi_station_get_connect_status();
|
||||||
|
|
||||||
|
if (x == SOFTAP_MODE || connectStatus != STATION_GOT_IP || wificonf->opmode == SOFTAP_MODE) {
|
||||||
|
strcpy(buffer, "");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
struct ip_info info;
|
||||||
|
wifi_get_ip_info(STATION_IF, &info);
|
||||||
|
return sprintf(buffer, IPSTR, GOOD_IP2STR(info.ip.addr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore defaults in the WiFi config block.
|
* Restore defaults in the WiFi config block.
|
||||||
* This is to be called if the WiFi config is corrupted on startup,
|
* This is to be called if the WiFi config is corrupted on startup,
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ void wifimgr_restore_defaults(void);
|
|||||||
|
|
||||||
void wifimgr_apply_settings(void);
|
void wifimgr_apply_settings(void);
|
||||||
|
|
||||||
|
int getStaIpAsString(char *buffer);
|
||||||
|
|
||||||
#if DEBUG_WIFI
|
#if DEBUG_WIFI
|
||||||
#define wifi_warn warn
|
#define wifi_warn warn
|
||||||
#define wifi_dbg dbg
|
#define wifi_dbg dbg
|
||||||
|
|||||||
Reference in New Issue
Block a user