Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e3038e85f | ||
|
|
de3e120c7e | ||
|
|
b65256fa45 | ||
|
|
a84abf03ca | ||
|
|
4da0679d4e |
@@ -21,6 +21,7 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
name: Build Firmware
|
name: Build Firmware
|
||||||
needs: [cppcheck, flawfinder, gitleaks]
|
needs: [cppcheck, flawfinder, gitleaks]
|
||||||
|
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||||
runs-on: anvil
|
runs-on: anvil
|
||||||
container:
|
container:
|
||||||
image: docker.io/espressif/idf:v5.3
|
image: docker.io/espressif/idf:v5.3
|
||||||
@@ -74,6 +75,31 @@ jobs:
|
|||||||
echo "::warning::Firmware using $PERCENT% of partition"
|
echo "::warning::Firmware using $PERCENT% of partition"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Security checks
|
||||||
|
run: |
|
||||||
|
BIN="get-started/csi_recv_router/build/csi_recv_router.bin"
|
||||||
|
CFG="get-started/csi_recv_router/sdkconfig"
|
||||||
|
|
||||||
|
echo "=== Checking for hardcoded secrets ==="
|
||||||
|
if strings "$BIN" | grep -iqE '(password|secret|api_key|apikey)=[^$]'; then
|
||||||
|
echo "::error::Potential hardcoded secret found in binary"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "No hardcoded secrets detected"
|
||||||
|
|
||||||
|
echo "=== Checking release configuration ==="
|
||||||
|
LOG_LEVEL=$(grep 'CONFIG_LOG_DEFAULT_LEVEL=' "$CFG" | cut -d= -f2)
|
||||||
|
if [ "$LOG_LEVEL" -gt 3 ]; then
|
||||||
|
echo "::warning::Debug/verbose logging enabled (level $LOG_LEVEL)"
|
||||||
|
else
|
||||||
|
echo "Log level OK ($LOG_LEVEL)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=== Component size breakdown ==="
|
||||||
|
. /opt/esp/idf/export.sh
|
||||||
|
cd get-started/csi_recv_router
|
||||||
|
idf.py size-components 2>/dev/null | head -30
|
||||||
|
|
||||||
- name: Upload firmware artifact
|
- name: Upload firmware artifact
|
||||||
run: |
|
run: |
|
||||||
mkdir -p /tmp/artifacts
|
mkdir -p /tmp/artifacts
|
||||||
@@ -87,15 +113,10 @@ jobs:
|
|||||||
deploy:
|
deploy:
|
||||||
name: Deploy to ESP Fleet
|
name: Deploy to ESP Fleet
|
||||||
runs-on: anvil
|
runs-on: anvil
|
||||||
needs: build
|
needs: [cppcheck, flawfinder, gitleaks]
|
||||||
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy == 'true' || startsWith(github.ref, 'refs/tags/v')
|
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy == 'true' || startsWith(github.ref, 'refs/tags/v')
|
||||||
container:
|
# Run on host for local network access to sensors
|
||||||
image: docker.io/espressif/idf:v5.3
|
|
||||||
options: --network=host
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install tools
|
|
||||||
run: apt-get update && apt-get install -y --no-install-recommends git curl jq netcat-openbsd
|
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
run: |
|
run: |
|
||||||
git clone --depth=1 --branch=${{ github.ref_name }} \
|
git clone --depth=1 --branch=${{ github.ref_name }} \
|
||||||
@@ -103,10 +124,30 @@ jobs:
|
|||||||
|
|
||||||
- name: Build firmware
|
- name: Build firmware
|
||||||
run: |
|
run: |
|
||||||
. /opt/esp/idf/export.sh
|
. $HOME/esp/esp-idf/export.sh
|
||||||
cd get-started/csi_recv_router
|
cd get-started/csi_recv_router
|
||||||
idf.py build
|
idf.py build
|
||||||
|
|
||||||
|
- name: Security checks
|
||||||
|
run: |
|
||||||
|
BIN="get-started/csi_recv_router/build/csi_recv_router.bin"
|
||||||
|
CFG="get-started/csi_recv_router/sdkconfig"
|
||||||
|
|
||||||
|
echo "=== Checking for hardcoded secrets ==="
|
||||||
|
if strings "$BIN" | grep -iqE '(password|secret|api_key|apikey)=[^$]'; then
|
||||||
|
echo "::error::Potential hardcoded secret found in binary"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "No hardcoded secrets detected"
|
||||||
|
|
||||||
|
echo "=== Checking release configuration ==="
|
||||||
|
LOG_LEVEL=$(grep 'CONFIG_LOG_DEFAULT_LEVEL=' "$CFG" | cut -d= -f2)
|
||||||
|
if [ "$LOG_LEVEL" -gt 3 ]; then
|
||||||
|
echo "::warning::Debug/verbose logging enabled (level $LOG_LEVEL)"
|
||||||
|
else
|
||||||
|
echo "Log level OK ($LOG_LEVEL)"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Validate version tag
|
- name: Validate version tag
|
||||||
run: |
|
run: |
|
||||||
TAG="${{ github.ref_name }}"
|
TAG="${{ github.ref_name }}"
|
||||||
@@ -157,14 +198,14 @@ jobs:
|
|||||||
- name: Deploy via OTA
|
- name: Deploy via OTA
|
||||||
run: |
|
run: |
|
||||||
SENSORS="muddy-storm:192.168.129.29 amber-maple:192.168.129.30 hollow-acorn:192.168.129.31"
|
SENSORS="muddy-storm:192.168.129.29 amber-maple:192.168.129.30 hollow-acorn:192.168.129.31"
|
||||||
OTA_PORT=8899
|
|
||||||
EXPECTED_VERSION="${{ github.ref_name }}"
|
EXPECTED_VERSION="${{ github.ref_name }}"
|
||||||
|
OTA_PORT=8899
|
||||||
|
|
||||||
# Get runner IP (first non-loopback interface)
|
# Get host IP on local network
|
||||||
RUNNER_IP=$(hostname -I | awk '{print $1}')
|
RUNNER_IP=$(ip route get 192.168.129.29 | grep -oP 'src \K[0-9.]+')
|
||||||
echo "Runner IP: $RUNNER_IP"
|
echo "Runner IP: $RUNNER_IP"
|
||||||
|
|
||||||
# Start HTTP server to serve firmware
|
# Start local HTTP server
|
||||||
cd get-started/csi_recv_router/build
|
cd get-started/csi_recv_router/build
|
||||||
python3 -m http.server $OTA_PORT &
|
python3 -m http.server $OTA_PORT &
|
||||||
HTTP_PID=$!
|
HTTP_PID=$!
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ static int s_send_frequency = CONFIG_SEND_FREQUENCY_DEFAULT;
|
|||||||
static int8_t s_tx_power_dbm = 10;
|
static int8_t s_tx_power_dbm = 10;
|
||||||
static esp_ping_handle_t s_ping_handle = NULL;
|
static esp_ping_handle_t s_ping_handle = NULL;
|
||||||
static volatile led_mode_t s_led_mode = LED_OFF;
|
static volatile led_mode_t s_led_mode = LED_OFF;
|
||||||
|
static bool s_led_quiet = false; /* quiet mode: off normally, solid on motion/presence */
|
||||||
static volatile int64_t s_last_csi_time = 0;
|
static volatile int64_t s_last_csi_time = 0;
|
||||||
static volatile int64_t s_identify_end_time = 0;
|
static volatile int64_t s_identify_end_time = 0;
|
||||||
static volatile bool s_ota_in_progress = false;
|
static volatile bool s_ota_in_progress = false;
|
||||||
@@ -301,11 +302,15 @@ static void config_load_nvs(void)
|
|||||||
if (nvs_get_i32(h, "chanscan_int", &chanscan_int) == ESP_OK && chanscan_int >= 60 && chanscan_int <= 3600) {
|
if (nvs_get_i32(h, "chanscan_int", &chanscan_int) == ESP_OK && chanscan_int >= 60 && chanscan_int <= 3600) {
|
||||||
s_chanscan_interval_s = (int)chanscan_int;
|
s_chanscan_interval_s = (int)chanscan_int;
|
||||||
}
|
}
|
||||||
|
int8_t led_quiet;
|
||||||
|
if (nvs_get_i8(h, "led_quiet", &led_quiet) == ESP_OK) {
|
||||||
|
s_led_quiet = (led_quiet != 0);
|
||||||
|
}
|
||||||
nvs_close(h);
|
nvs_close(h);
|
||||||
ESP_LOGI(TAG, "NVS loaded: hostname=%s rate=%d tx_power=%d adaptive=%d threshold=%.6f ble=%d target=%s:%d csi_mode=%d hybrid_n=%d powersave=%d presence=%d pr_thresh=%.4f baseline_nsub=%d",
|
ESP_LOGI(TAG, "NVS loaded: hostname=%s rate=%d tx_power=%d adaptive=%d threshold=%.6f ble=%d target=%s:%d csi_mode=%d hybrid_n=%d powersave=%d presence=%d pr_thresh=%.4f baseline_nsub=%d led_quiet=%d",
|
||||||
s_hostname, s_send_frequency, s_tx_power_dbm, s_adaptive, s_motion_threshold, s_ble_enabled,
|
s_hostname, s_send_frequency, s_tx_power_dbm, s_adaptive, s_motion_threshold, s_ble_enabled,
|
||||||
s_target_ip, s_target_port, (int)s_csi_mode, s_hybrid_interval, s_powersave,
|
s_target_ip, s_target_port, (int)s_csi_mode, s_hybrid_interval, s_powersave,
|
||||||
s_presence_enabled, s_pr_threshold, s_baseline_nsub);
|
s_presence_enabled, s_pr_threshold, s_baseline_nsub, s_led_quiet);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG, "NVS: no saved config, using defaults");
|
ESP_LOGI(TAG, "NVS: no saved config, using defaults");
|
||||||
}
|
}
|
||||||
@@ -401,10 +406,25 @@ static void led_task(void *arg)
|
|||||||
if (s_led_mode == LED_SOLID && s_identify_end_time > 0) {
|
if (s_led_mode == LED_SOLID && s_identify_end_time > 0) {
|
||||||
if (esp_timer_get_time() >= s_identify_end_time) {
|
if (esp_timer_get_time() >= s_identify_end_time) {
|
||||||
s_identify_end_time = 0;
|
s_identify_end_time = 0;
|
||||||
s_led_mode = LED_SLOW_BLINK;
|
s_led_mode = s_led_quiet ? LED_OFF : LED_SLOW_BLINK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Quiet mode: off normally, solid on motion/presence, OTA pattern during OTA */
|
||||||
|
if (s_led_quiet && s_led_mode != LED_OTA && s_identify_end_time == 0) {
|
||||||
|
bool activity = s_motion_detected ||
|
||||||
|
(s_presence_enabled && s_baseline_nsub > 0 && s_pr_last_score > s_pr_threshold);
|
||||||
|
if (activity) {
|
||||||
|
gpio_set_level(LED_GPIO, 1);
|
||||||
|
led_on = true;
|
||||||
|
} else {
|
||||||
|
gpio_set_level(LED_GPIO, 0);
|
||||||
|
led_on = false;
|
||||||
|
}
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(200));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Auto-switch between slow/fast blink based on CSI activity */
|
/* Auto-switch between slow/fast blink based on CSI activity */
|
||||||
if (s_led_mode == LED_SLOW_BLINK || s_led_mode == LED_FAST_BLINK) {
|
if (s_led_mode == LED_SLOW_BLINK || s_led_mode == LED_FAST_BLINK) {
|
||||||
int64_t now = esp_timer_get_time();
|
int64_t now = esp_timer_get_time();
|
||||||
@@ -1487,6 +1507,30 @@ static int cmd_handle(const char *cmd, char *reply, size_t reply_size)
|
|||||||
return strlen(reply);
|
return strlen(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* LED [QUIET|AUTO] */
|
||||||
|
if (strncmp(cmd, "LED", 3) == 0) {
|
||||||
|
if (cmd[3] == '\0' || cmd[3] == '\n') {
|
||||||
|
snprintf(reply, reply_size, "OK LED %s", s_led_quiet ? "quiet" : "auto");
|
||||||
|
return strlen(reply);
|
||||||
|
}
|
||||||
|
if (strncmp(cmd + 4, "QUIET", 5) == 0) {
|
||||||
|
s_led_quiet = true;
|
||||||
|
s_led_mode = LED_OFF;
|
||||||
|
config_save_i8("led_quiet", 1);
|
||||||
|
snprintf(reply, reply_size, "OK LED quiet (off, solid on motion)");
|
||||||
|
return strlen(reply);
|
||||||
|
}
|
||||||
|
if (strncmp(cmd + 4, "AUTO", 4) == 0) {
|
||||||
|
s_led_quiet = false;
|
||||||
|
s_led_mode = LED_SLOW_BLINK;
|
||||||
|
config_save_i8("led_quiet", 0);
|
||||||
|
snprintf(reply, reply_size, "OK LED auto (blink)");
|
||||||
|
return strlen(reply);
|
||||||
|
}
|
||||||
|
snprintf(reply, reply_size, "ERR LED [QUIET|AUTO]");
|
||||||
|
return strlen(reply);
|
||||||
|
}
|
||||||
|
|
||||||
/* STATUS */
|
/* STATUS */
|
||||||
if (strncmp(cmd, "STATUS", 6) == 0) {
|
if (strncmp(cmd, "STATUS", 6) == 0) {
|
||||||
int64_t up = esp_timer_get_time() / 1000000LL;
|
int64_t up = esp_timer_get_time() / 1000000LL;
|
||||||
@@ -1546,7 +1590,7 @@ static int cmd_handle(const char *cmd, char *reply, size_t reply_size)
|
|||||||
" hostname=%s version=%s adaptive=%s motion=%d ble=%s target=%s:%d"
|
" hostname=%s version=%s adaptive=%s motion=%d ble=%s target=%s:%d"
|
||||||
" temp=%.1f csi_count=%lu boots=%lu rssi_min=%d rssi_max=%d"
|
" temp=%.1f csi_count=%lu boots=%lu rssi_min=%d rssi_max=%d"
|
||||||
" csi_mode=%s hybrid_n=%d auth=%s flood_thresh=%d/%d powersave=%s"
|
" csi_mode=%s hybrid_n=%d auth=%s flood_thresh=%d/%d powersave=%s"
|
||||||
" presence=%s pr_score=%.4f chanscan=%s"
|
" presence=%s pr_score=%.4f chanscan=%s led=%s"
|
||||||
" nvs_used=%lu nvs_free=%lu nvs_total=%lu part_size=%lu"
|
" nvs_used=%lu nvs_free=%lu nvs_total=%lu part_size=%lu"
|
||||||
" built=%s_%s idf=%s chip=%sr%dc%d",
|
" built=%s_%s idf=%s chip=%sr%dc%d",
|
||||||
uptime_str, (long long)up, (unsigned long)heap, rssi, channel, (int)s_tx_power_dbm,
|
uptime_str, (long long)up, (unsigned long)heap, rssi, channel, (int)s_tx_power_dbm,
|
||||||
@@ -1561,7 +1605,7 @@ static int cmd_handle(const char *cmd, char *reply, size_t reply_size)
|
|||||||
s_flood_thresh, s_flood_window_s,
|
s_flood_thresh, s_flood_window_s,
|
||||||
s_powersave ? "on" : "off",
|
s_powersave ? "on" : "off",
|
||||||
s_presence_enabled ? "on" : "off", s_pr_last_score,
|
s_presence_enabled ? "on" : "off", s_pr_last_score,
|
||||||
s_chanscan_enabled ? "on" : "off",
|
s_chanscan_enabled ? "on" : "off", s_led_quiet ? "quiet" : "auto",
|
||||||
(unsigned long)nvs_stats.used_entries,
|
(unsigned long)nvs_stats.used_entries,
|
||||||
(unsigned long)nvs_stats.free_entries,
|
(unsigned long)nvs_stats.free_entries,
|
||||||
(unsigned long)nvs_stats.total_entries,
|
(unsigned long)nvs_stats.total_entries,
|
||||||
|
|||||||
Reference in New Issue
Block a user