Compare commits

..
14 Commits
20 changed files with 247 additions and 61 deletions
+1
View File
@@ -20,3 +20,4 @@ cmake-build-debug/
.sass-cache .sass-cache
*.map *.map
.gitignore
+1
View File
@@ -170,6 +170,7 @@ add_definitions(
-DICACHE_FLASH_ATTR= -DICACHE_FLASH_ATTR=
-DICACHE_RODATA_ATTR= -DICACHE_RODATA_ATTR=
-DFLAG_GZIP=2 -DFLAG_GZIP=2
-DESP_LANG="en"
-DGIT_HASH_BACKEND="asdf" -DGIT_HASH_BACKEND="asdf"
-DGIT_HASH_FRONTEND="asdf" -DGIT_HASH_FRONTEND="asdf"
+8 -1
View File
@@ -62,6 +62,10 @@ LIBS = c gcc hal phy pp net80211 wpa main lwip crypto
#Add in esphttpd lib #Add in esphttpd lib
LIBS += esphttpd LIBS += esphttpd
ifndef ESP_LANG
ESP_LANG = en
endif
# compiler flags using during compilation of source files -ggdb # compiler flags using during compilation of source files -ggdb
CFLAGS = -Os -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \ CFLAGS = -Os -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \
-nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \ -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \
@@ -69,7 +73,7 @@ CFLAGS = -Os -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inli
CFLAGS += -DGIT_HASH_BACKEND='"$(shell git rev-parse --short HEAD)"' CFLAGS += -DGIT_HASH_BACKEND='"$(shell git rev-parse --short HEAD)"'
CFLAGS += -DGIT_HASH_FRONTEND='"$(shell cd front-end && git rev-parse --short HEAD)"' CFLAGS += -DGIT_HASH_FRONTEND='"$(shell cd front-end && git rev-parse --short HEAD)"'
CFLAGS += -D__TIMEZONE__='"$(shell date +%Z)"' CFLAGS += -D__TIMEZONE__='"$(shell date +%Z)"' -DESP_LANG='"$(ESP_LANG)"'
ifdef GLOBAL_CFLAGS ifdef GLOBAL_CFLAGS
CFLAGS += $(GLOBAL_CFLAGS) CFLAGS += $(GLOBAL_CFLAGS)
@@ -210,6 +214,9 @@ espmac:
all: checkdirs all: checkdirs
$(Q) make actual_all -j4 -B $(Q) make actual_all -j4 -B
release:
$(Q) ./release.sh
actual_all: parser $(TARGET_OUT) $(FW_BASE) actual_all: parser $(TARGET_OUT) $(FW_BASE)
libesphttpd/Makefile: libesphttpd/Makefile:
+14
View File
@@ -0,0 +1,14 @@
//
// Created by MightyPork on 2017/10/03.
//
// helper for building release packages
//
// Run with `tcc -run`
//
#include "user/version.h"
#include <stdio.h>
void main() {
printf(FW_VERSION);
}
-1
View File
@@ -1 +0,0 @@
+21
View File
@@ -0,0 +1,21 @@
This is a release archive of ESPTerm,
the VT100 terminal emulator for ESP8266.
--------------------------------------------
Version: %VERS%
Locale : %LANG%
Built : %DATETIME%
--------------------------------------------
Source repository:
https://github.com/espterm/espterm-firmware
Report any bugs to our bug-tracker at
https://github.com/espterm/espterm-firmware/issues
or send them to out mailing list
espterm-dev@googlegroups.com
On-line demo is available at
https://espterm.github.io/term.html
[EOF]
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# The parameters ESPTOOL, ESPPORT and ESPBAUD can be customized
# - export your preferred values in .bashrc
echo -e "\e[32;1mFlashing ESPTerm %VERS% (%LANG%)\e[0m"
if [ -z ${ESPTOOL} ]; then
ESPTOOL='esptool'
which ${ESPTOOL} &>/dev/null
if [ $? -ne 0 ]; then
ESPTOOL='esptool.py'
which ${ESPTOOL} &>/dev/null
if [ $? -ne 0 ]; then
echo -e '\e[31;1mesptool not found!\e[0m'
exit 1
fi
fi
fi
[ -z ESPPORT ] && ESPPORT=/dev/ttyUSB0
[ -z ESPBAUD ] && ESPBAUD=460800
set -x
${ESPTOOL} --port ${ESPPORT} --baud ${ESPBAUD} \
write_flash 0x00000 '%FILE0%' 0x40000 '%FILE4%'
+3
View File
@@ -0,0 +1,3 @@
*
!.gitignore
!flash-tpl.sh
Executable
+69
View File
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
if [ -z "$1" ]; then
vers=$(tcc -run get_version.c)
else
vers=$1
fi
git pull
echo -n -e "\e[1;36mBuilding packages for version $vers\e[0m"
cd front-end
git pull
cd ..
function buildlang() {
lang=$1
echo -e "\n\e[33;1m------ Building \"${lang}\" package ------\e[0m\n"
make clean
ESP_LANG=${lang} make web
ESP_LANG=${lang} make actual_all -B -j4
cd release
destdir="$vers-$lang"
file0=${vers}-0x00000-${lang}.bin
file4=${vers}-0x40000-${lang}.bin
[ -e ${destdir} ] && rm -r ${destdir}
mkdir ${destdir}
cp ../firmware/0x00000.bin ${destdir}/${file0}
cp ../firmware/0x40000.bin ${destdir}/${file4}
flashsh=${destdir}/flash.sh
cp ../rel-tpl/flash.sh ${flashsh}
sed -i s/%FILE0%/${file0}/ ${flashsh}
sed -i s/%FILE4%/${file4}/ ${flashsh}
sed -i s/%VERS%/${vers}/ ${flashsh}
sed -i s/%LANG%/${lang}/ ${flashsh}
chmod +x ${flashsh}
readmefil=${destdir}/README.txt
cp ../rel-tpl/README.txt ${readmefil}
sed -i s/%VERS%/${vers}/ ${readmefil}
sed -i s/%LANG%/${lang}/ ${readmefil}
dt=$(LC_TIME=en_US.UTF-8 date '+%c')
sed -i "s#%DATETIME%#${dt}#" ${readmefil}
unix2dos ${readmefil}
cd ${destdir}
sha256sum ${file0} ${file4} README.txt flash.sh > checksums.txt
cd ..
targetfile=espterm-${vers}-${lang}.zip
[[ -e ${targetfile}.zip ]] && rm ${targetfile}.zip
pwd
zip -9 ${targetfile} ${destdir}/*
cd ..
}
if [ -z "$ESP_LANG" ]; then
buildlang cs
buildlang en
buildlang de
else
buildlang ${ESP_LANG}
fi
+20 -4
View File
@@ -11,7 +11,7 @@
#include "version.h" #include "version.h"
#include "uart_buffer.h" #include "uart_buffer.h"
#include "screen.h" #include "screen.h"
#include "uart_driver.h" #include "wifimgr.h"
volatile bool enquiry_suppressed = false; volatile bool enquiry_suppressed = false;
ETSTimer enqTimer; ETSTimer enqTimer;
@@ -27,8 +27,8 @@ void ICACHE_FLASH_ATTR enqTimerCb(void *unused)
void ICACHE_FLASH_ATTR void ICACHE_FLASH_ATTR
apars_respond(const char *str) apars_respond(const char *str)
{ {
UART_WriteString(UART0, str, UART_TIMEOUT_US); // Using the Tx buffer causes issues with large data (eg. from http requests)
//UART_SendAsync(str, -1); UART_SendAsync(str, -1);
} }
/** /**
@@ -48,8 +48,24 @@ apars_handle_enq(void)
{ {
if (enquiry_suppressed) return; if (enquiry_suppressed) return;
u8 mac[6];
wifi_get_macaddr(SOFTAP_IF, mac);
char buf100[100];
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\\");
(void)buf;
// version encased in SOS and ST // version encased in SOS and ST
apars_respond("\x1bXESPTerm " FIRMWARE_VERSION "\x1b\\"); apars_respond(buf100);
// Throttle enquiry - this is a single-character-invoked response, // Throttle enquiry - this is a single-character-invoked response,
// so it tends to happen randomly when throwing garbage at the ESP. // so it tends to happen randomly when throwing garbage at the ESP.
+25 -17
View File
@@ -7,13 +7,14 @@
#include "version.h" #include "version.h"
#include "ansi_parser_callbacks.h" #include "ansi_parser_callbacks.h"
#include "api.h" #include "api.h"
#include "uart_driver.h"
#include <httpclient.h> #include <httpclient.h>
#include <esp_utils.h> #include <esp_utils.h>
#define D2D_TIMEOUT_MS 2000 #define D2D_TIMEOUT_MS 2000
#define D2D_HEADERS \ #define D2D_HEADERS \
"User-Agent: ESPTerm "FIRMWARE_VERSION" like curl wget HTTPie\r\n" \ "User-Agent: ESPTerm "VERSION_STRING" like curl wget HTTPie\r\n" \
"Content-Type: text/plain; charset=utf-8\r\n" \ "Content-Type: text/plain; charset=utf-8\r\n" \
"Accept-Encoding: identity\r\n" \ "Accept-Encoding: identity\r\n" \
"Accept-Charset: utf-8\r\n" \ "Accept-Charset: utf-8\r\n" \
@@ -29,6 +30,14 @@ struct d2d_request_opts {
volatile bool request_pending = false; volatile bool request_pending = false;
// NOTE! We bypass the async buffer here - used for user input and
// responses to queries {apars_respond()}. In rare situations this could
// lead to a race condition and mixing two different messages
static inline void ICACHE_FLASH_ATTR sendResponseToUART(const char *str)
{
UART_WriteString(UART0, str, UART_TIMEOUT_US);
}
static void ICACHE_FLASH_ATTR static void ICACHE_FLASH_ATTR
requestNoopCb(int http_status, requestNoopCb(int http_status,
char *response_headers, char *response_headers,
@@ -54,8 +63,6 @@ requestCb(int http_status,
struct d2d_request_opts *opts = userArg; struct d2d_request_opts *opts = userArg;
d2d_dbg("Rx url response, code %d, nonce \"%s\"", http_status, opts->nonce?opts->nonce:"");
// ensure positive - would be hard to parse // ensure positive - would be hard to parse
if (http_status < 0) http_status = -http_status; if (http_status < 0) http_status = -http_status;
@@ -68,6 +75,8 @@ requestCb(int http_status,
if (opts->max_result_len > 0 && len > opts->max_result_len) if (opts->max_result_len > 0 && len > opts->max_result_len)
len = (int) opts->max_result_len; len = (int) opts->max_result_len;
d2d_info("Rx HTTP response, code %d, len %d, nonce \"%s\"", http_status, len, opts->nonce?opts->nonce:"");
char *bb = buff100; char *bb = buff100;
bb += sprintf(bb, "\x1b^h;%d;", http_status); bb += sprintf(bb, "\x1b^h;%d;", http_status);
const char *comma = ""; const char *comma = "";
@@ -95,7 +104,7 @@ requestCb(int http_status,
// semicolon only if more data is to be sent // semicolon only if more data is to be sent
if (opts->want_head || opts->want_body) sprintf(bb, ";"); if (opts->want_head || opts->want_body) sprintf(bb, ";");
apars_respond(buff100); sendResponseToUART(buff100);
//d2d_dbg("Headers (part) %100s", response_headers); //d2d_dbg("Headers (part) %100s", response_headers);
//d2d_dbg("Body (part) %100s", response_body); //d2d_dbg("Body (part) %100s", response_body);
@@ -107,8 +116,8 @@ requestCb(int http_status,
response_headers[len] = 0; response_headers[len] = 0;
opts->want_body = false; // soz, it wouldn't fit opts->want_body = false; // soz, it wouldn't fit
} }
apars_respond(response_headers); sendResponseToUART(response_headers);
if(opts->want_body) apars_respond("\r\n"); if(opts->want_body) sendResponseToUART("\r\n");
} }
if(opts->want_body) { if(opts->want_body) {
@@ -117,10 +126,10 @@ requestCb(int http_status,
response_body[len - (opts->want_head*(headers_size+2))] = 0; response_body[len - (opts->want_head*(headers_size+2))] = 0;
} }
apars_respond(response_body); sendResponseToUART(response_body);
} }
apars_respond("\a"); sendResponseToUART("\a");
free(opts->nonce); free(opts->nonce);
free(opts); free(opts);
@@ -151,7 +160,7 @@ d2d_parse_command(char *msg)
FIND_NEXT(ip, ';'); FIND_NEXT(ip, ';');
const char *payload = msg; const char *payload = msg;
d2d_dbg("D2D Tx,dest=%s,msg=%s", ip, payload); d2d_info("D2D Tx,dest=%s,msg=%s", ip, payload);
sprintf(buff40, "http://%s" API_D2D_MSG, ip); sprintf(buff40, "http://%s" API_D2D_MSG, ip);
httpclient_args args; httpclient_args args;
@@ -194,9 +203,8 @@ d2d_parse_command(char *msg)
FIND_NEXT(params, ';'); FIND_NEXT(params, ';');
d2d_info("HTTP request");
d2d_dbg("Method %s", method); d2d_dbg("Method %s", method);
d2d_dbg("Params %s", params);
size_t max_buf_len = HTTPCLIENT_DEF_MAX_LEN; size_t max_buf_len = HTTPCLIENT_DEF_MAX_LEN;
size_t max_result_len = 0; // 0 = no truncate size_t max_result_len = 0; // 0 = no truncate
uint timeout = HTTPCLIENT_DEF_TIMEOUT_MS; uint timeout = HTTPCLIENT_DEF_TIMEOUT_MS;
@@ -265,7 +273,7 @@ d2d_parse_command(char *msg)
request_pending = true; request_pending = true;
http_request(&args, no_resp ? requestNoopCb : requestCb); http_request(&args, no_resp ? requestNoopCb : requestCb);
d2d_dbg("Done"); d2d_dbg("Request sent.");
return true; return true;
} }
@@ -290,16 +298,16 @@ httpd_cgi_state ICACHE_FLASH_ATTR cgiD2DMessage(HttpdConnData *connData)
u8 *ip = connData->remote_ip; u8 *ip = connData->remote_ip;
char buf[20]; char buf[20];
sprintf(buf, "\x1b^m;"IPSTR";L=%d;", ip[0], ip[1], ip[2], ip[3], (int)len); sprintf(buf, "\x1b^m;"IPSTR";L=%d;", ip[0], ip[1], ip[2], ip[3], (int)len);
apars_respond(buf); sendResponseToUART(buf);
if (connData->post && connData->post->buff) if (connData->post && connData->post->buff)
apars_respond(connData->post->buff); sendResponseToUART(connData->post->buff);
else if (connData->getArgs) else if (connData->getArgs)
apars_respond(connData->getArgs); sendResponseToUART(connData->getArgs);
apars_respond("\a"); sendResponseToUART("\a");
d2d_dbg("D2D Rx src="IPSTR",len=%d", ip[0], ip[1], ip[2], ip[3],len); d2d_info("D2D Rx src="IPSTR",len=%d", ip[0], ip[1], ip[2], ip[3],len);
// Received a msg // Received a msg
+1 -1
View File
@@ -44,7 +44,7 @@ tplAbout(HttpdConnData *connData, char *token, void **arg)
if (token == NULL) return HTTPD_CGI_DONE; if (token == NULL) return HTTPD_CGI_DONE;
if (streq(token, "vers_fw")) { if (streq(token, "vers_fw")) {
tplSend(connData, FIRMWARE_VERSION, -1); tplSend(connData, VERSION_STRING, -1);
} }
else if (streq(token, "date")) { else if (streq(token, "date")) {
tplSend(connData, __DATE__, -1); tplSend(connData, __DATE__, -1);
+1 -16
View File
@@ -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);
+1
View File
@@ -52,6 +52,7 @@ void ICACHE_FLASH_ATTR UART_Init(void)
// U0RXD // U0RXD
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD); PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD);
PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0RXD_U);
// U1TXD (GPIO2) // U1TXD (GPIO2)
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK); PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK);
+23 -15
View File
@@ -74,12 +74,12 @@ static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg)
if (diff == 0) { if (diff == 0) {
if (cnt == 5) { if (cnt == 5) {
// only every 5 secs if no change // only every 5 secs if no change
dbg("Rx: %2d%c, Tx: %2d%c, Hp: %d", rxp, '%', txp, '%', heap); dbg("Rx/Tx: %d/%d%c, Hp: %d", rxp, txp, '%', heap);
cnt = 0; cnt = 0;
} }
} else { } else {
// report change // report change
dbg("Rx: %2d%c, Tx: %2d%c, Hp: %d (%s%d)", rxp, '%', txp, '%', heap, cc, diff); dbg("Rx/Tx: %d/%d%c, Hp: %d (%s%d)", rxp, txp, '%', heap, cc, diff);
cnt = 0; cnt = 0;
} }
@@ -104,14 +104,22 @@ void ICACHE_FLASH_ATTR user_init(void)
wifi_station_set_auto_connect(false); wifi_station_set_auto_connect(false);
wifi_set_opmode(NULL_MODE); // saves to flash if changed - this might avoid the current spike on startup? wifi_set_opmode(NULL_MODE); // saves to flash if changed - this might avoid the current spike on startup?
printf("\r\n"); u8 mac[6];
banner("====== ESPTerm ======"); wifi_get_macaddr(SOFTAP_IF, mac);
banner_info("Firmware (c) Ondrej Hruska, 2017");
banner_info(TERMINAL_GITHUB_REPO); banner_gap();
banner_info(""); banner("================ ESPTerm ================");
banner_info("Version "FIRMWARE_VERSION","); banner_info();
banner_info("Project by Ondrej Hruska, 2017");
banner_info();
banner_info(TERMINAL_GITHUB_REPO_NOPROTO);
banner_info();
banner_info("Version "FW_VERSION" ("ESP_LANG"), code name "FW_CODENAME_QUOTED);
banner_info(" back-end #"GIT_HASH_BACKEND" front-end #"GIT_HASH_FRONTEND);
banner_info(" built "__DATE__" at "__TIME__" "__TIMEZONE__); banner_info(" built "__DATE__" at "__TIME__" "__TIMEZONE__);
printf("\r\n"); banner_info();
banner_info("Device ID: %02X%02X%02X", mac[3], mac[4], mac[5]);
banner_gap();
ioInit(); ioInit();
@@ -123,11 +131,6 @@ void ICACHE_FLASH_ATTR user_init(void)
espFsInit((void *) (webpages_espfs_start)); espFsInit((void *) (webpages_espfs_start));
#endif #endif
#if DEBUG_HEAP
// Heap use timer & blink
TIMER_START(&prHeapTimer, prHeapTimerCb, HEAP_TIMER_MS, 1);
#endif
// do later (some functions do not work if called from user_init) // do later (some functions do not work if called from user_init)
TIMER_START(&userStartTimer, user_start, 10, 0); TIMER_START(&userStartTimer, user_start, 10, 0);
} }
@@ -139,13 +142,18 @@ static void ICACHE_FLASH_ATTR user_start(void *unused)
captdnsInit(); captdnsInit();
httpdInit(routes, 80); httpdInit(routes, 80);
httpdSetName("ESPTerm " FIRMWARE_VERSION); httpdSetName("ESPTerm " VERSION_STRING);
ansi_parser_inhibit = false; ansi_parser_inhibit = false;
// Print the CANCEL character to indicate the module has restarted // Print the CANCEL character to indicate the module has restarted
// Critically important for client application if any kind of screen persistence / content re-use is needed // Critically important for client application if any kind of screen persistence / content re-use is needed
UART_WriteChar(UART0, CAN, UART_TIMEOUT_US); // 0x18 - 24 - CAN UART_WriteChar(UART0, CAN, UART_TIMEOUT_US); // 0x18 - 24 - CAN
#if DEBUG_HEAP
// Heap use timer & blink
TIMER_START(&prHeapTimer, prHeapTimerCb, HEAP_TIMER_MS, 1);
#endif
} }
// ---- unused funcs removed from sdk to save space --- // ---- unused funcs removed from sdk to save space ---
+12 -3
View File
@@ -5,16 +5,25 @@
#ifndef ESP_VT100_FIRMWARE_VERSION_H #ifndef ESP_VT100_FIRMWARE_VERSION_H
#define ESP_VT100_FIRMWARE_VERSION_H #define ESP_VT100_FIRMWARE_VERSION_H
#include "helpers.h" #define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
#define FW_V_MAJOR 2 #define FW_V_MAJOR 2
#define FW_V_MINOR 1 #define FW_V_MINOR 1
#define FW_V_PATCH 0 #define FW_V_PATCH 0
#define FW_V_SUFFIX ""
#define FW_CODENAME "Anthill" // 2.1.0 #define FW_CODENAME "Anthill" // 2.1.0
#define FW_CODENAME_QUOTED "\""FW_CODENAME"\""
#define FW_VERSION STR(FW_V_MAJOR) "." STR(FW_V_MINOR) "." STR(FW_V_PATCH) FW_V_SUFFIX
#define VERSION_STRING FW_VERSION " " FW_CODENAME_QUOTED
#define FIRMWARE_VERSION STR(FW_V_MAJOR) "." STR(FW_V_MINOR) "." STR(FW_V_PATCH) " \"" FW_CODENAME "\""
#define FIRMWARE_VERSION_NUM (FW_V_MAJOR*1000 + FW_V_MINOR*10 + FW_V_PATCH) // this is used in ID queries #define FIRMWARE_VERSION_NUM (FW_V_MAJOR*1000 + FW_V_MINOR*10 + FW_V_PATCH) // this is used in ID queries
#define TERMINAL_GITHUB_REPO "https://github.com/espterm/espterm-firmware"
#define TERMINAL_GITHUB_REPO_NOPROTO "github.com/espterm/espterm-firmware"
#define TERMINAL_GITHUB_REPO "https://"TERMINAL_GITHUB_REPO_NOPROTO
#define TERMINAL_GITHUB_REPO_FRONT "https://github.com/espterm/espterm-front-end" #define TERMINAL_GITHUB_REPO_FRONT "https://github.com/espterm/espterm-front-end"
#endif //ESP_VT100_FIRMWARE_VERSION_H #endif //ESP_VT100_FIRMWARE_VERSION_H
+16
View File
@@ -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,
+2
View File
@@ -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