Commit graph

39 commits

Author SHA1 Message Date
cjkas
6923183bd0 build: give the debug build one 3 MB app slot without OTA
esp32devdbg used 98.3% of the 1.5 MB OTA slot. On esp32_huge_app.csv the
same 1,546,405-byte image uses 49.2%, so the refactors ahead have room.
The release envs keep esp32_3MB.csv and CI keeps them within limits.

NVS stays at 0x9000, but the file system shrinks from 0xE0000 to 0xD0000,
so a board moving to this table needs a backup, a USB flash with
uploadfs, and a restore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 09:15:26 +02:00
cjkas
a176017960 refactor: move the RX pulse decoder into PulseDecoder
The decoding of the time between received edges into frame bits moves out
of Transceiver::handleReceive unchanged into decodePulse(), with the RTS
timings and the receive buffer type. It stays in IRAM on the ESP32 and is
now covered by native tests that feed it the edges sendFrame() produces
for 56 and 80-bit first frames and repeats, a glitch and a broken pulse.

handleReceive keeps the noise guard, the edge timing and the RX queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 21:21:05 +02:00
cjkas
8276c1c3cd refactor: move sun and wind automation into ShadeSensors
The sun and wind timers were spread over processFrame, checkMovement and
processInternalCommand. ShadeSensors now holds them and decides when the
weather extends or retracts a shade, when turning the sun flag on moves
it, and when wind blocks a remote Down. Each caller still sets the targets
itself, so no shade moves differently yet.

The timers are now 32-bit like millis(). As 64-bit values holding a 32-bit
millis() they fired at once after the rollover every 49.7 days. The debug
logs of each timer go: they were compiled out at CORE_DEBUG_LEVEL 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 21:12:34 +02:00
cjkas
4cb676a7a7 build: limit inlining in every file of the debug build
At -Og GCC only caps inlining growth in units over large-unit-insns
(10000 instructions). Smaller files inline ArduinoJson's helpers into
every caller: moving the JSON parsing out of Somfy.cpp grew the image by
19 KB, past the 1.5 MB app partition. Treating every file as large keeps
inlining at the level the big files already had and frees 13 KB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 20:27:49 +02:00
cjkas
4135f21ee7 refactor: let one RadioScheduler own the radio job queue
The order radio jobs go out in was spread across callers, file statics and
the radio task: each remote tracked its last back job so a stop could decide
whether it may jump the queue, and the task kept a separate count of the back
jobs it had taken.  RadioScheduler now owns the waiting jobs, their tickets,
the stop-goes-first rule, delayed jobs, flush and suspend, and the outcome of
every job.  It is plain C++, with the time passed in and the caller locking,
so all of it is covered by native tests.  Transceiver keeps the FreeRTOS task,
the locks and the CC1101.

sendCommandAfter returns the job's ticket instead of leaving it in lastTxSeq.

Two stops for the same remote now go out in the order they were sent; queued
to the front they used to come out reversed, putting the rolling codes out of
order.

Adds GLOSSARY.md for the radio terms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 20:36:32 +02:00
cjkas
7e9687c023 fix: keep a repeater frame until the radio queue takes it
The frame was popped before queueTx(), so whenever the radio queue was busy
it was lost.  Peek it instead, only remove it once it is queued (or TX is
suspended), and don't try while the queue has no room.  The repeater buffer
moves to TxBuffer.h/.cpp so it can be unit tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 18:31:39 +02:00
cjkas
b6ed24f5bb fix: hook the log lock into log_printfv
The Arduino core already links with --wrap=log_printf for the ESP
Insights hook in libesp_diagnostics, so defining __wrap_log_printf
failed to link with a duplicate definition. That hook prints through
log_printfv, so wrap that instead and take the lock there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 22:23:11 +02:00
cjkas
6b19d24eb4 fix: print each log line whole
The Arduino core's log_printf() has its UART lock commented out and
writes with ets_printf(), so lines logged at the same time from
async_tcp and loop() came out interleaved character by character. It
also formats short lines into one static buffer shared by every task.

Wrap log_printf at link time and hold a mutex around the core's
log_printfv(). It never blocks before the scheduler runs, in an ISR or
in a critical section, and waits at most 50ms before printing anyway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 20:50:41 +02:00
cjkas
3a8736f4d4 refactor: share the shade travel maths in ShadeMotion.cpp
checkMovement worked out the position four times, nearly copy-pasted,
for lift down, lift up, tilt down and tilt up.  All four now call
travelPosition(), which keeps the same arithmetic, including how the
elapsed time wraps with millis().  Tilt up with no tilt time still
stops the tilt direction in the caller.

transformPosition and transformCommand keep their behaviour through
the new displayPosition() and flipCommand() helpers.  The native env
builds ShadeMotion.cpp so all of this can be unit tested on the PC.
No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 13:37:48 +02:00
cjkas
d723c1024d refactor: move JsonFormatter into JsonFormatter.cpp
JsonFormatter and BufferedJsonFormatter move verbatim out of
WResp.cpp/WResp.h, which now include JsonFormatter.h.  They don't need
the web server, so on their own they can be unit tested on the PC; the
native env builds the new file.  AsyncJsonResp and JsonSockEvent stay
in WResp.  No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 13:29:30 +02:00
cjkas
3774aba45c test: cover the frame codec and command names
Builds SomfyFrame.cpp in the native env, with a minimal String and
no-op ESP_LOGx in the stubs, and tests:

- a fixed 56-bit frame, byte for byte, so what goes on air is pinned
- encode/decode round trips for 56-bit, 80-bit (repeats, Favorite,
  Stop, steps, Toggle), RTW and RTV frames
- rejection of bad checksums, addresses, rolling codes, keys and
  80-bit parity
- repeat/synonym tracking in copy()
- parsing and naming of commands

The command-name round trip fails: names the firmware reports, such as
"Step Up" and "My+Up", parse back to the wrong command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 13:20:39 +02:00
cjkas
52c67b12f8 test: add native Unity env with Utils tests
Adds an [env:native] for host-side unit tests (pio test -e native) with
a minimal Arduino.h stub, and covers the Utils helpers: _trim,
toBoolean, SETCHARPROP, sortArray and the Timestamp conversions.

The firmware envs now extend a shared [esp32] section instead of [env]
so the native env doesn't inherit the Arduino framework, the ESP32
libraries or the build scripts.

The half-hour calcTZOffset cases fail: +05:30 comes back as 2300.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 12:54:39 +02:00
cjkas
9a9afa5e86 fix: move radio TX to a dedicated task so HA WebSocket stays connected
Web command handlers ran on the async_tcp task and blocked up to 3s
waiting for loop() to bit-bang radio frames. async_tcp also services the
WebSocket on port 8080, so pongs stalled and Home Assistant
(ping_timeout=15) disconnected when several covers were commanded.

- Add a radio_tx FreeRTOS task with a job queue; sendFrame/repeatFrame
  and repeater frames enqueue instead of transmitting inline.
- Serialize CC1101 access with a recursive mutex (TX task, apply, end,
  frequency scan, RSSI read).
- Make Web::queueCommand fire-and-forget; drop the done semaphore.
- Route /setMyPosition and /unpairShade through the command queue.
- Clamp repeats to MAX_TX_REPEATS (40).
- Pin AsyncTCP to core 0 on dual-core targets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 20:13:31 +02:00
Shailen Sobhee
25f6195bbc build pass for esp32c6, added dependencies.lock 2026-04-05 21:06:48 +02:00
Shailen Sobhee
7524ce1d60 updated platformio.ini + add -D CHIP_ESP32C6 2026-04-05 20:19:23 +02:00
Shailen Sobhee
3e60dfeb21 updated platformio.ini to pass build tests 2026-04-05 20:08:53 +02:00
Shailen Sobhee
3d642509a5 updated platformio.ini to pass build tests 2026-04-05 20:02:59 +02:00
Shailen Sobhee
51109a16c5 updated gitignore file 2026-04-05 19:55:09 +02:00
Shailen Sobhee
3271327208 merge conflicts from 05.04 2026-04-05 19:08:01 +02:00
cjkas
3a3ce2ae6a Update platform to espressif32 @ 6.13.0. SSID scan interval increased to 10 minutes to offload ESP. 2026-04-04 19:58:38 +02:00
Shailen Sobhee
fe4aa83ed2 updated code logic to pic FW/App version from appversion instead of hard-coding in js/html/cpp files 2026-03-30 22:41:08 +02:00
Shailen Sobhee
bb61a1703d fixed esp32-c6 platform detection issue 2026-03-30 21:04:59 +02:00
Shailen Sobhee
ff1bb80adf huge app due to partition size issues 2026-03-30 14:52:40 +02:00
cjkas
72bfd26443 Added c6 support 2026-03-29 21:53:57 +02:00
cjkas
aa81b95bee Added OTA partition 1.5MB per app. Fixed s3 wrong partition for spiffs 2026-03-29 21:10:02 +02:00
cjkas
76bb0627af ci builds now all variants 2026-03-28 08:47:42 +01:00
cjkas
233d6abe62 Fix esp32c3 build 2026-03-27 20:21:56 +01:00
cjkas
4fd95a055f Improve release build suport for multiple esp32 chips 2026-03-27 08:49:33 +01:00
cjkas
9c17aa4642 added c3,s3 builds 2026-03-27 08:24:08 +01:00
cjkas
a220b9ecc2 replace Serial.print with logger 2026-03-24 20:28:06 +01:00
cjkas
f38dcea1f1 add archive for last 10 builds 2026-03-24 20:08:17 +01:00
cjkas
07e2e45333 update CI build scripts 2026-03-24 19:35:45 +01:00
cjkas
ed8137e686 replace sync sockets 2026-03-24 19:23:35 +01:00
cjkas
8c51e1a518 up 2026-03-24 19:23:35 +01:00
cjkas
9ccc2d4ff5 async server introduction 2026-03-24 19:22:57 +01:00
cjkas
88fdfa577a improve logging 2026-03-17 14:27:57 +01:00
cjkas
2509030c49 backup with RAM 2026-03-13 18:40:34 +01:00
cjkas
96d66c1b45 add gzip support 2026-03-12 13:59:17 +01:00
cjkas
a64b648f7a init 2026-03-10 20:23:48 +01:00