Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ It supports both Station (STA) and Access Point (AP) modes, JSON-based configura
- 🧩 Modular: add pins, WebSockets, and more via dashboard
- 🔐 Configurable authentication (username/password)
- 🔄 Over-the-air (OTA) firmware and filesystem updates
- 🛠️ PlatformIO and Arduino IDE compatible
- 🛠️ ESP-IDF / PlatformIO (ESP-IDF) compatible

---

Expand All @@ -34,10 +34,6 @@ lib_deps =
https://github.com/vekjja/ESPWiFi.git
```

### Arduino IDE
1. Download or clone this repo
2. Move the folder into your Arduino `libraries/` directory

---

## 📂 File Structure
Expand Down Expand Up @@ -74,23 +70,28 @@ ESPWiFi/

---

## 🔧 Firmware Usage (C++/Arduino)
## 🔧 Firmware Usage (ESP-IDF)

### Quick Start (Default Configuration)

The simplest way to use ESPWiFi is with the default `start()` and `runSystem()` methods:
The simplest way to run ESPWiFi is using the default `start()` and `runSystem()` methods from your ESP-IDF entrypoint.

###### ESPWiFi will generate a default `config.json` file if not present.
```cpp
#include <ESPWiFi.h>
#include "ESPWiFi.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "nvs_flash.h"

ESPWiFi espwifi;

void setup() {
extern "C" void app_main(void) {
espwifi.start();
}

void loop() {
espwifi.runSystem();
while (1) {
espwifi.runSystem();
espwifi.feedWatchDog();
}
}
```

Expand Down Expand Up @@ -139,19 +140,19 @@ For more control, you can use `config.json` to configure the device and start se

### Example Custom Firmware Usage
```cpp
#include <ESPWiFi.h>
#include "ESPWiFi.h"

ESPWiFi espwifi;

void setup() {
extern "C" void app_main(void) {
espwifi.readConfig(); // Load config from LittleFS (Can be omitted, but will be called by other services if needed)
espwifi.startAP(); // Explicitly Start Access Point Only
espwifi.srvGPIO(); // Register Only GPIO endpoints
}

void loop() {
feedWatchDog(); // Allow other tasks to run
// Custom main loop logic here
while (1) {
espwifi.feedWatchDog(); // Allow other tasks to run
// Custom main loop logic here
}
}
```

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/FirmwareBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ jobs:
# chip: esp32
# baud: 460800
# bootloader_offset: "0x1000"
# - environment: esp32-c3
# chip: esp32c3
# baud: 921600
# bootloader_offset: "0x0"
- environment: esp32-c3
chip: esp32c3
baud: 921600
bootloader_offset: "0x0"
- environment: esp32-s3
chip: esp32s3
baud: 921600
Expand Down
50 changes: 28 additions & 22 deletions cloud/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,33 +736,39 @@ func (dc *deviceConn) closeWithReason(code int, reason string) {
}

func (s *server) publicBase(r *http.Request) string {
var base string
if strings.TrimSpace(s.publicBaseURL) != "" {
return strings.TrimRight(strings.TrimSpace(s.publicBaseURL), "/")
}

// Infer from reverse-proxy headers when available.
proto := r.Header.Get("X-Forwarded-Proto")
if proto == "" {
if r.TLS != nil {
proto = "https"
} else {
proto = "http"
base = strings.TrimRight(strings.TrimSpace(s.publicBaseURL), "/")
} else {
// Infer from reverse-proxy headers when available.
proto := r.Header.Get("X-Forwarded-Proto")
if proto == "" {
if r.TLS != nil {
proto = "https"
} else {
proto = "https" // Force HTTPS even if not detected
}
}
}
host := r.Header.Get("X-Forwarded-Host")
if host == "" {
host = r.Host
host := r.Header.Get("X-Forwarded-Host")
if host == "" {
host = r.Host
}
base = proto + "://" + host
}

// Convert http(s) -> ws(s) for convenience.
switch strings.ToLower(proto) {
case "https":
return "wss://" + host
case "http":
return "ws://" + host
default:
return "ws://" + host
// Convert https:// -> wss:// for WebSocket URLs (only support secure connections)
if strings.HasPrefix(base, "https://") {
return "wss://" + strings.TrimPrefix(base, "https://")
}

// If someone configured http://, reject it - we only support secure connections
if strings.HasPrefix(base, "http://") {
// Log a warning but still upgrade to wss for security
return "wss://" + strings.TrimPrefix(base, "http://")
}

// Already wss:// or unknown format
return base
}

func authOK(r *http.Request, token string) bool {
Expand Down
1 change: 0 additions & 1 deletion components/ESP32-A2DP
Submodule ESP32-A2DP deleted from a207fd
49 changes: 29 additions & 20 deletions dashboard/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
# Dependencies
node_modules
npm-debug.log
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Local development files - should not be in Docker images
.env.local
.env.development.local
.env.test.local
.env.production.local

# Build outputs
# Development artifacts
node_modules
build
dist

# CRA/webpack caches
.cache

# Local env files (keep these out of images)
.env*

# Allow a single optional build-time env file if you choose to use it.
# (Better practice is passing build args / CI secrets, but this enables local builds.)
!.env.prod
# IDE and editor files
.vscode
.idea
*.swp
*.swo
*~

# OS / editor noise
# OS files
.DS_Store
.idea
.vscode
Thumbs.db

# If you run dashboard builds that output to the firmware folder
../data
# Git
.git
.gitignore

# Testing
coverage
.nyc_output

# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Misc
*.log
2 changes: 1 addition & 1 deletion dashboard/.env.local
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REACT_APP_API_HOST=espwifi.local
REACT_APP_TEST_HOSTED_MODE=true
REACT_APP_TEST_HOSTED_MODE=false
REACT_APP_API_PORT=80
Loading