Skip to content

Commit

Permalink
Merge branch 'develop' into feature/estop-config
Browse files Browse the repository at this point in the history
  • Loading branch information
hhvrc committed Oct 1, 2024
2 parents 06b98ef + 43935f2 commit b448fee
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cpp-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
cpp-linter:
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
Expand Down
134 changes: 93 additions & 41 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@
"@skeletonlabs/skeleton": "2.10.2",
"@skeletonlabs/tw-plugin": "0.4.0",
"@sveltejs/adapter-static": "^3.0.5",
"@sveltejs/kit": "2.5.28",
"@sveltejs/kit": "2.6.1",
"@sveltejs/vite-plugin-svelte": "^3.1.2",
"@tailwindcss/forms": "0.5.9",
"@tailwindcss/typography": "0.5.15",
"@types/node": "22.5.5",
"@types/node": "22.7.4",
"autoprefixer": "10.4.20",
"eslint": "^9.11.0",
"eslint": "^9.11.1",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-svelte": "2.44.0",
"eslint-plugin-svelte": "2.44.1",
"flatbuffers": "24.3.25",
"postcss": "8.4.47",
"prettier": "3.3.3",
"prettier-plugin-svelte": "3.2.6",
"prettier-plugin-svelte": "3.2.7",
"svelte": "4.2.19",
"svelte-check": "4.0.2",
"tailwindcss": "3.4.12",
"svelte-check": "4.0.4",
"tailwindcss": "3.4.13",
"tslib": "2.7.0",
"typescript": "5.6.2",
"vite": "^5.4.7",
"vite": "^5.4.8",
"vite-plugin-tailwind-purgecss": "^0.3.3",
"vitest": "2.1.1"
},
Expand Down
2 changes: 2 additions & 0 deletions include/config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ namespace OpenShock::Config {
uint8_t GetWiFiCredentialsIDbySSID(const char* ssid);
bool RemoveWiFiCredentials(uint8_t id);
bool ClearWiFiCredentials();
bool GetWiFiHostname(std::string& out);
bool SetWiFiHostname(std::string_view hostname);

bool GetOtaUpdateId(int32_t& out);
bool SetOtaUpdateId(int32_t updateId);
Expand Down
8 changes: 7 additions & 1 deletion src/CaptivePortal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ bool _startCaptive() {
return false;
}

err = mdns_hostname_set(OPENSHOCK_FW_HOSTNAME);
std::string hostname;
if (!Config::GetWiFiHostname(hostname)) {
OS_LOGE(TAG, "Failed to get WiFi hostname, reverting to default");
hostname = OPENSHOCK_FW_HOSTNAME;
}

err = mdns_hostname_set(hostname.c_str());
if (err != ESP_OK) {
OS_LOGE(TAG, "Failed to set mDNS hostname");
WiFi.softAPdisconnect(true);
Expand Down
2 changes: 1 addition & 1 deletion src/CaptivePortalInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ CaptivePortalInstance::CaptivePortalInstance()
m_webServer.serveStatic("/", m_fileSystem, "/www/", "max-age=3600").setDefaultFile("index.html").setSharedEtag(fsHash);

// Redirecting connection tests to the captive portal, triggering the "login to network" prompt
m_webServer.onNotFound([softAPURL](AsyncWebServerRequest* request) { request->redirect(softAPURL); });
m_webServer.onNotFound([&softAPURL](AsyncWebServerRequest* request) { request->redirect(softAPURL); });
} else {
OS_LOGE(TAG, "/www/index.html or hash files not found, serving error page");

Expand Down
16 changes: 16 additions & 0 deletions src/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,22 @@ bool Config::ClearWiFiCredentials() {
return _trySaveConfig();
}

bool Config::GetWiFiHostname(std::string& out) {
CONFIG_LOCK_READ(false);

out = _configData.wifi.hostname;

return true;
}

bool Config::SetWiFiHostname(std::string_view hostname) {
CONFIG_LOCK_WRITE(false);

_configData.wifi.hostname = std::string(hostname);

return _trySaveConfig();
}

bool Config::GetOtaUpdateId(int32_t& out) {
CONFIG_LOCK_READ(false);

Expand Down
Loading

0 comments on commit b448fee

Please sign in to comment.