Replace 11 compile-time THR_* #defines with runtime float globals
(g_thr_grass_roi, g_thr_*_collision, g_thr_*_alert) defined in
stdc_post_process.c and exposed via extern in the header.
- ini/host_stream.ini: add [detect] section with integer promille values
- kp_firmware.c: read [detect] section at startup, log initial values
- event_recorder.c: add 11 BLE SET handlers (THR_GRASS_ROI,
THR_PERSON/CAR/TREE/BUNKER/POND_COL, THR_PERSON/CAR/TREE/BUNKER/POND_ALT)
each with range validation (1-1000), runtime update, and INI persistence
- app_header_init.c: rename log field mov= to moving= for clarity
- Drop write_event_json() calls from upload_thread and test_upload_thread
- tar.gz now contains JPEG snapshots only (no event.json)
- Mark write_event_json() as __attribute__((unused)) to suppress compiler warning
- Change upload URL path: golf.cgi -> golf-golface.cgi
- Add upload_dev INI key (1=dev, appends &dev=1 to URL)
- Change query params: ?filename= -> ?did={device_id}&vid={event_id}
- Add event_recorder_init params: device_id, dev_mode, speed_normal/alert/stop
- Make CAN speed limits configurable via [can] speed_normal/alert/stop in INI
(replaces hardcoded SPEED_LIMIT_* macros with runtime static vars)
- Fix build_targz: use tar -C + mkdir -p for BusyBox compat;
use open()+lseek() instead of stat() (struct stat ABI mismatch on target)
- Extend TEST_UPLOAD snapshot poll timeout: 5s -> 15s; same lseek fix
- Add BLE SET command: persist_ini_int() for runtime INI parameter update
- Fix app_header_init: elapsed_us long -> long long (overflow guard)
- Remove verbose debug printf from mcp2515 reset/send paths
- can_bus: wrap CTL log printf in #if 1 for easy toggle
MCP2515 has two RX buffers; reading only one frame per interrupt left
RX1IF set, keeping INT LOW with no new falling edge — poll() would not
wake until the 100ms timeout, causing frames to pile up and RXOVR at
high cycle rates (20ms).
Changes:
- can_rx_thread: replace single readMessage call with a drain loop that
reads all available frames before returning to poll(), then clears
ERRIF/MERRF so INT can deassert cleanly
- can_rx_thread: startup drain + clear all CANINTF flags before the
initial GPIO edge-consume, so INT is HIGH on first poll() after a
crash restart (prevents "no interrupt after restart" symptom)
- mcp2515/spi_send: add NULL checks on tx_buffer and rx_buffer malloc
to prevent segfault when memory is tight under high SPI load
- mcp2515/spi_send: replace exit(0) on ioctl failure with return NULL
so callers can handle the error gracefully (committed in previous fix)
- mcp2515/read_register, read_status: add NULL guard on spi_send return
bt_uart.c:
- Reader thread: accept plain-text (non-JSON) lines from BLE app;
routes directly to extra_cmd_cb — test commands no longer need
JSON wrapping
- bt_uart_probe_and_upgrade(): fix AT+BAUD7 sequence — reopen fd at
115200 before sending AT+NAME/AT+RESET (was sending on stale 9600 fd)
- bt_uart_send_json(): replace blocking mutex_lock with 200 ms trylock
retry to avoid deadlock if writer thread dies holding the queue mutex
- Reader select timeout 500 ms → 200 ms for faster plain-text flush
buzzer.c:
- buzzer_set_pattern(): write s_pattern directly then trylock+signal,
so callers never block on the buzzer thread's mutex
can_bus.c:
- Add debug printf in can_bus_send_control_cmd() (temporary)
event_recorder.c:
- TEST_MODE_TIMEOUT_SEC 60 → 300 (5 min, enough for full test run)
kp_firmware.c:
- Persist INI keys via sed in-place instead of iniparser_dump_ini,
preserving comments and original file structure
- setvbuf stdout/stderr to line-buffered so tee log appears immediately
Add GF_AI_Box_Test_Guide (.md/.docx/.pdf) and uclibc_compat.c
test_can_event() no longer controls buzzer; new TEST_BUZZER_ALL
thread tests all buzzer patterns independently. TEST_ALL now
runs three sequential groups: BLE, CAN-only, Buzzer-only.
Add TEST_ENTER/TEST_EXIT commands via BLE to enter/exit test mode.
In test mode, inference results are suppressed; testers can directly
trigger BLE JSON (TEST_BLE *), CAN+Buzzer actions (TEST_CAN *),
or run sequenced full-coverage tests (TEST_BLE_ALL, TEST_CAN_ALL,
TEST_ALL). Auto-exits after 60s idle. Routes unrecognised BLE
commands through new bt_uart_set_extra_cmd_cb() hook.
New buzzer.h/buzzer.c: background pthread drives gpio64 with three
patterns (GRASS 500/500ms, ALERT 300/200ms, COLLISION 100/100ms).
Integrated into fire_collision_warning(), fire_alert(), and grass
state machine in event_recorder.c; buzzer_init() called after
can_bus_init() in kp_firmware.c.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- app_header_init: detect vehicle(class=2) in print_yolo_result(),
send CAN speed=10 on detection, speed=240 on clear;
only triggers on state change, keepalive maintains cmd
- app_header_init: on speed state change, send BLE JSON
{response_type:can_status, content:{vehicle_detected, speed_cmd}}
- app_header_init: add #include can_bus.h / bt_uart.h
- event_recorder: wrap legacy MsgBroker IPC path in #if 0;
setSpeed now goes directly through can_bus_send_control_cmd()