Skip to content

Commit

Permalink
Merge pull request #15 from gjroots/dev
Browse files Browse the repository at this point in the history
v1.1.3
  • Loading branch information
gjroots authored Aug 27, 2023
2 parents badb672 + 533d5e9 commit c3e4566
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 47 deletions.
18 changes: 9 additions & 9 deletions components/utils/initialization.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ esp_err_t IRAM_ATTR parms_init()
get_config_param_str("ap_ip", &ap_ip);
get_config_param_str("auth_username", &authUsername);
// get_config_param_str("mac_ap", &macAp);
get_config_param_str("auth_username", &authPass);
get_config_param_str("auth_password", &authPass);

get_config_param_int("web_server", &webServer);
get_config_param_int("led_enable", &ledEnable);
Expand All @@ -67,7 +67,7 @@ esp_err_t IRAM_ATTR parms_init()
gateway_addr = (gateway_addr != NULL) ? gateway_addr : "";

ap_ip = (ap_ip != NULL) ? ap_ip : DEFAULT_AP_IP;
customDNSip = (customDNSip != NULL) ? customDNSip : "default";
customDNSip = (customDNSip != NULL) ? customDNSip : DEFAULT_DNS1;

authUsername = (authUsername != NULL) ? authUsername : DEFAULT_ADMIN_USERNAME;
authPass = (authPass != NULL) ? authPass : DEFAULT_ADMIN_PASSWORD;
Expand All @@ -82,13 +82,13 @@ esp_err_t IRAM_ATTR parms_init()
auth_info.username = authUsername;
auth_info.password = authPass;

if (IsCustomDnsEnable)
{
if (strcmp(customDNSip, "default") == 0)
{
customDNSip = DEFAULT_DNS1;
}
}
// if (IsCustomDnsEnable)
// {
// if (strcmp(customDNSip, "default") == 0)
// {
// customDNSip = DEFAULT_DNS1;
// }
// }

macAp = currentMAC; //(macAp != NULL) ? macAp : currentMAC;

Expand Down
6 changes: 3 additions & 3 deletions components/web_server/storage_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ esp_err_t save_settings_data_handler(httpd_req_t *req)
}
}

if (httpd_query_key_value(query_buf, "authUsername", param_buf, sizeof(param_buf)) == ESP_OK)
if (httpd_query_key_value(query_buf, "adminUsername", param_buf, sizeof(param_buf)) == ESP_OK)
{
authUsername = html_escape(strdup(param_buf));
err = nvs_set_str(handle, "auth_username", authUsername);
}
if (httpd_query_key_value(query_buf, "authPassword", param_buf, sizeof(param_buf)) == ESP_OK)
if (httpd_query_key_value(query_buf, "adminPassword", param_buf, sizeof(param_buf)) == ESP_OK)
{
authPass = html_escape(strdup(param_buf));
err = nvs_set_str(handle, "auth_username", authPass);
err = nvs_set_str(handle, "auth_password", authPass);
}

if (httpd_query_key_value(query_buf, "maxLoginAttempts", param_buf, sizeof(param_buf)) == ESP_OK)
Expand Down
4 changes: 2 additions & 2 deletions components/web_server/www/html/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ GEM
http_parser.rb (~> 0)
eventmachine (1.2.7)
execjs (2.8.1)
ffi (1.15.5-x64-mingw-ucrt)
ffi (1.15.5)
forwardable-extended (2.6.0)
google-protobuf (3.21.12-x64-mingw-ucrt)
google-protobuf (3.24.2-x64-mingw-ucrt)
htmlbeautifier (1.4.2)
htmlcompressor (0.4.0)
http_parser.rb (0.8.0)
Expand Down
2 changes: 1 addition & 1 deletion components/web_server/www/html/_i18n/english.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ info:
table:
A: "version"
B: "Update"
C: "IP / gateway"
C: "IP / DNS"
card-2:
header: "Connected Users ($$)"
table:
Expand Down
2 changes: 1 addition & 1 deletion components/web_server/www/html/js/functions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
---
var version="1.1.2",
var version="1.1.3",
sL = getE('spinner-container'),
notification = getE("notification"),
themeColor = getComputedStyle(document.body),
Expand Down
10 changes: 6 additions & 4 deletions components/web_server/www/html/js/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
---
var versionCell = getE("version"),
ipGateway = getE("ipGatewayAddress"),
ssid,
ipAddress,
gateWay,
dns,
connection = getE("connection"),
connectedUserCount = getE('clientsFound'),
connectedUsers = getE('users'),
Expand All @@ -27,8 +28,9 @@ function getData() {
return
}
// console.log(res.clients.length)
ssid = res.ssid;
ipAddress = res.ipAddress;
gateWay = res.gatewayAddress;
dns = res.dns;
ap_rss = res.rss;
wifiAuthFail = res.wifiAuthFail;
clients = res.clients;
Expand Down Expand Up @@ -130,10 +132,10 @@ function ap_connection() {

var tr = '<tr><td>Wifi status</td>';
tr += '<td><div>' + svgImg + '</div><div><span style="background:linear-gradient(135deg, ' + getColor(signalPercent) + ' ' + signalPercent + '%,rgba(0,0,0,0.15) ' + signalPercent + '%)"></span><span style="color:' + getColor(signalPercent, true) + '">' + signalPercent + '</span></div></td>';
tr += '<td class=' + (state ? "green" : "red") + '><b>' + (state ? 'Connected' : (wifiAuthFail ? "wifi Auth Fail" : 'Disconnected')) + '<b></td><tr>';
tr += '<td class=' + (state ? "green" : "red") + '><b>' + (state ? ssid : (wifiAuthFail ? "wifi Auth Fail" : 'Disconnected')) + '<b></td><tr>';
connection.innerHTML = tr;

tr = '<tr><td>{% t info.card-1.table.C %}</td><td><b>' + ipAddress + '</b></td><td>' + gateWay + '</td></tr>';
tr = '<tr><td>{% t info.card-1.table.C %}</td><td><b>' + ipAddress + '</b></td><td>' + dns + '</td></tr>';
ap_rss != 0 ? ipGateway.innerHTML = tr : "";
}
function users() {
Expand Down
4 changes: 2 additions & 2 deletions components/web_server/www/html/sysinfo.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ipAddress": "192.168.1.128",
"gatewayAddress": "192.168.1.1",
"rss": -70,
"dns": "192.168.1.1",
"rss": -70,
"wifiAuthFail" : false,
"clients": [
{
Expand Down
Binary file modified components/web_server/www/output/gzip/functions.js.gz
Binary file not shown.
Binary file modified components/web_server/www/output/gzip/info.js.gz
Binary file not shown.
1 change: 1 addition & 0 deletions components/wifi_handler/include/wifi_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extern "C"

char *wifi_scan_handler(void);
char *wifi_info_handler(void);
bool has_static_ip;

#ifdef __cplusplus
}
Expand Down
3 changes: 2 additions & 1 deletion components/wifi_handler/wifi_event_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "wifi_init.h"
#include "wifi_event_handler.h"
#include "router_handler.h"
#include "wifi_handler.h"

static const char *TAG = "wifi_event_handler";
EventGroupHandle_t wifi_event_group;
Expand Down Expand Up @@ -77,7 +78,7 @@ void set_dns_server(esp_netif_dns_info_t dnsIP)
{
dhcps_offer_t opt_val = OFFER_DNS;
esp_netif_dhcps_stop(wifiAP);
if (IsCustomDnsEnable)
if (IsCustomDnsEnable || has_static_ip)
{
dnsIP.ip.u_addr.ip4.addr = ipaddr_addr(customDNSip);
}
Expand Down
30 changes: 20 additions & 10 deletions components/wifi_handler/wifi_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,33 @@ char* IRAM_ATTR wifi_info_handler(void)
tcpip_adapter_sta_list_t adapter_sta_list;
tcpip_adapter_ip_info_t ip_info;
tcpip_adapter_dns_info_t dns_info;
char * ssid = "";
int8_t rssi = 0;
char *dns = "";
char *ip_address = "";
memset(&ap_info, 0, sizeof(ap_info));
char gateway_address[32];
char ip_address[32];
char dns[32];
if (ap_connect)
{
memset(&ap_info, 0, sizeof(ap_info));
memset(&ip_info, 0, sizeof(ip_info));
if (esp_wifi_sta_get_ap_info(&ap_info) == ESP_OK)
{
ssid = (char *)ap_info.ssid;
rssi = ap_info.rssi;
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info);
ip_address = ip4addr_ntoa(&ip_info.ip);
tcpip_adapter_get_dns_info(TCPIP_ADAPTER_IF_STA, ESP_NETIF_DNS_MAIN, &dns_info);
dns = ip4addr_ntoa((ip4_addr_t *)&dns_info.ip);
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
ESP_ERROR_CHECK(tcpip_adapter_get_dns_info(TCPIP_ADAPTER_IF_STA, ESP_NETIF_DNS_MAIN, &dns_info));

strlcpy(gateway_address, ip4addr_ntoa(&ip_info.gw), sizeof(gateway_address));
strlcpy(ip_address, ip4addr_ntoa(&ip_info.ip), sizeof(ip_address));
strlcpy(dns, ip4addr_ntoa((ip4_addr_t *)&dns_info.ip), sizeof(dns));
}
else
{
ssid = "";
rssi = 0;
dns = "";
ip_address = "";
strcpy(gateway_address, "");
strcpy(ip_address, "");
strcpy(dns, "");
}
}
memset(&wifi_sta_list, 0, sizeof(wifi_sta_list));
Expand All @@ -113,8 +121,10 @@ char* IRAM_ATTR wifi_info_handler(void)
ESP_ERROR_CHECK(tcpip_adapter_get_sta_list(&wifi_sta_list, &adapter_sta_list));

cJSON *root = cJSON_CreateObject();
cJSON_AddStringToObject(root, "ssid", ssid);
cJSON_AddStringToObject(root, "gatewayAddress", gateway_address);
cJSON_AddStringToObject(root, "ipAddress", ip_address);
cJSON_AddStringToObject(root, "gatewayAddress", dns);
cJSON_AddStringToObject(root, "dns", (has_static_ip || IsCustomDnsEnable) ? customDNSip : dns);
cJSON_AddNumberToObject(root, "rss", rssi);
cJSON_AddBoolToObject(root, "wifiAuthFail", IsWifiAuthFail);
cJSON *clients = cJSON_AddArrayToObject(root, "clients");
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


[extra_script_settings]
version = 1.1.2 ; Set the version to the project
version = 1.1.3 ; Set the version to the project
merge_to_single_bin = 1 ; (0 = disable) Enable the conversion of a multiple bins to single bin file of 0x0 format


Expand Down
18 changes: 13 additions & 5 deletions post_extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ def copy_files():
]
for src, dest in files:
shutil.copyfile(src, f'release/{dest}')
print("==========> Bin files are copied to the /release folder.")
print("==========> Bin files are copied to the /release folder.\n")


def convert_single_bin():
build_dir = env.subst("$BUILD_DIR")
binary_path = os.path.join(build_dir, "firmware.bin")
bootloader_path = os.path.join(build_dir, "bootloader.bin")
partitions_path = os.path.join(build_dir, "partitions.bin")
release_path = os.path.join(env.subst("$PROJECT_DIR"), "release")
merged_file = os.path.join(release_path, f"esp32nat_Router+_full_v{version}_0x0.bin")
esptool_dir = env.PioPlatform().get_package_dir("tool-esptoolpy")
esptool_command = f'python {str(esptool_dir)}\\esptool.py --chip esp32 merge_bin -o {merged_file} --flash_freq 40m --flash_size 4MB 0x1000 {bootloader_path} 0x8000 {partitions_path} 0x10000 {binary_path}'

os.makedirs("release", exist_ok=True)
os.system(
f'esptool.py --chip esp32 merge_bin -o release/esp32nat_Router+_full_v{version}_0x0.bin --flash_freq 40m --flash_size 4MB 0x1000 release/bootloader.bin 0x10000 release/esp32nat_Router+_v{version}.bin 0x8000 release/partitions.bin')
env.Execute(esptool_command)
zip_all_bins()


Expand All @@ -47,7 +55,7 @@ def zip_all_bins():
zipObj.write(
f'release/esp32nat_Router+_full_v{version}_0x0.bin', f'esp32nat_Router+_full_v{version}_0x0.bin')

print("==========> zip files created successfully")
print("\n==========> zip files created successfully")


def after_build_program(source, target, env):
Expand All @@ -57,4 +65,4 @@ def after_build_program(source, target, env):
convert_single_bin()


env.AddPostAction("$BUILD_DIR/firmware.bin", after_build_program)
env.AddPostAction("buildprog", after_build_program)
18 changes: 10 additions & 8 deletions pre_extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import gzip
import re
import platform

print("\033[94m╔═╗┌─┐┌─┐ ╔╗╔┌─┐┌┬┐ ╦═╗┌─┐┬ ┬┌┬┐┌─┐┬─┐ _|_\n║╣ └─┐├─┘32─║║║├─┤ │ ╠╦╝│ ││ │ │ ├┤ ├┬┘ | \n╚═╝└─┘┴ ╝╚╝┴ ┴ ┴ ╩╚═└─┘└─┘ ┴ └─┘┴└─\033[0m\n")

Expand All @@ -14,6 +15,7 @@
version = config.get("extra_script_settings", "version")

jekyll_install_status = False
system_platform = platform.system()

if os.system('jekyll -v') == 0:
# print('Jekyll is installed on your system.')
Expand All @@ -22,14 +24,14 @@
print(
'\033[91mJekyll is not installed on your system. Please install Jekyll.\033[0m')


# uncomment for linux and git bash users
# def build_site():
# env.Execute("build_web_pages.sh")

# for windows user
def build_site():
env.Execute("build_web_pages.bat")
if system_platform =="Linux":
# for linux user
def build_site():
env.Execute("build_web_pages.sh")
elif system_platform == "Windows":
# for windows user
def build_site():
env.Execute("build_web_pages.bat")


base_folder_path = './components/web_server/www/'
Expand Down

0 comments on commit c3e4566

Please sign in to comment.