Merge branch 'main' into main

This commit is contained in:
cjkas 2026-04-06 20:27:20 +02:00 committed by GitHub
commit bb3ec52e89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 27 additions and 7 deletions

View file

@ -4879,6 +4879,15 @@ bool Transceiver::begin() {
return true;
}
void Transceiver::loop() {
// Dispatch deferred frequency scan requests from the main task so that
// attachInterrupt/detachInterrupt cross-core IPCs don't race with WiFi.
if(_pendingScan >= 0) {
int8_t pending = _pendingScan;
_pendingScan = -1;
if(pending == 1) this->beginFrequencyScan();
else this->endFrequencyScan();
return;
}
somfy_rx_t rx;
if (noiseDetected && rxmode != 3 && this->config.noiseDetection) {
if (millis() - noiseStart > 100) {

View file

@ -490,6 +490,10 @@ class Transceiver {
bool _received = false;
somfy_frame_t frame;
public:
// -1 = none pending, 1 = beginFrequencyScan pending, 0 = endFrequencyScan pending.
// Set from the async_tcp task; consumed by loop() on the main task to avoid
// concurrent cross-core IPC races with the WiFi stack (EXCCAUSE_LOAD_PROHIBITED).
volatile int8_t _pendingScan = -1;
transceiver_config_t config;
bool printBuffer = false;
//bool toJSON(JsonObject& obj);

View file

@ -2406,7 +2406,7 @@ void Web::begin() {
}));
asyncServer.on("/beginFrequencyScan", HTTP_GET, [](AsyncWebServerRequest *request) {
somfy.transceiver.beginFrequencyScan();
somfy.transceiver._pendingScan = 1; // deferred to main task — see Transceiver::loop()
AsyncJsonResp resp;
resp.beginResponse(request, g_async_content, sizeof(g_async_content));
resp.beginObject();
@ -2416,7 +2416,7 @@ void Web::begin() {
});
asyncServer.on("/endFrequencyScan", HTTP_GET, [](AsyncWebServerRequest *request) {
somfy.transceiver.endFrequencyScan();
somfy.transceiver._pendingScan = 0; // deferred to main task — see Transceiver::loop()
AsyncJsonResp resp;
resp.beginResponse(request, g_async_content, sizeof(g_async_content));
resp.beginObject();