diff --git a/ConfigSettings.h b/ConfigSettings.h index 82533af..e7a4a89 100644 --- a/ConfigSettings.h +++ b/ConfigSettings.h @@ -3,7 +3,7 @@ #ifndef configsettings_h #define configsettings_h -#define FW_VERSION "v1.4.2" +#define FW_VERSION "v1.4.3" enum DeviceStatus { DS_OK = 0, DS_ERROR = 1, diff --git a/Somfy.cpp b/Somfy.cpp index 6778f74..e3328c8 100644 --- a/Somfy.cpp +++ b/Somfy.cpp @@ -48,6 +48,7 @@ somfy_commands translateSomfyCommand(const String& string) { else if (string.equalsIgnoreCase("Prog")) return somfy_commands::Prog; else if (string.equalsIgnoreCase("SunFlag")) return somfy_commands::SunFlag; else if (string.equalsIgnoreCase("StepUp")) return somfy_commands::StepUp; + else if (string.equalsIgnoreCase("StepDown")) return somfy_commands::StepDown; else if (string.equalsIgnoreCase("Flag")) return somfy_commands::Flag; else if (string.startsWith("mud") || string.startsWith("MUD")) return somfy_commands::MyUpDown; else if (string.startsWith("md") || string.startsWith("MD")) return somfy_commands::MyDown; @@ -115,10 +116,13 @@ void somfy_frame_t::decodeFrame(byte* frame) { this->checksum = decoded[1] & 0b1111; this->encKey = decoded[0]; // Pull in the 80-bit commands. The upper nibble will be 0 even on 80 bit packets. - this->cmd = (somfy_commands)((decoded[1] >> 4) | ((decoded[8] & 0x08) << 4)); + this->cmd = (somfy_commands)((decoded[1] >> 4)); + // Pull in the data for an 80-bit step command. + if(this->cmd == somfy_commands::StepDown) + this->cmd = (somfy_commands)((decoded[1] >> 4) | ((decoded[8] & 0x08) << 4)); this->rollingCode = decoded[3] + (decoded[2] << 8); this->remoteAddress = (decoded[6] + (decoded[5] << 8) + (decoded[4] << 16)); - this->valid = this->checksum == checksum && this->remoteAddress < 16777215; + this->valid = this->checksum == checksum && this->remoteAddress < 16777215 && this->rollingCode > 0; if (this->valid) { // Check for valid command. switch (this->cmd) { @@ -215,8 +219,8 @@ void somfy_frame_t::encodeFrame(byte *frame) { frame[9] = 29; switch(this->cmd) { case somfy_commands::StepUp: - frame[7] = 136; - frame[8] = 52; + frame[7] = 132; + frame[8] = 56; frame[9] = 22; break; case somfy_commands::StepDown: @@ -1449,6 +1453,7 @@ void SomfyRemote::sendCommand(somfy_commands cmd, uint8_t repeat) { frame.cmd = cmd; frame.repeats = repeat; frame.bitLength = this->bitLength; + frame.encKey = 0xA0 | static_cast(frame.rollingCode & 0x000F); if(frame.bitLength == 0) frame.bitLength = bit_length; this->lastRollingCode = frame.rollingCode; somfy.sendFrame(frame, repeat); @@ -1646,7 +1651,6 @@ void Transceiver::sendFrame(byte *frame, uint8_t sync, uint8_t bitLength) { REG_WRITE(GPIO_OUT_W1TC_REG, pin); delayMicroseconds(SYMBOL); // Data: bits are sent one by one, starting with the MSB. - // TODO: Handle the 80-bit send protocol for (byte i = 0; i < bitLength; i++) { if (((frame[i / 8] >> (7 - (i % 8))) & 1) == 1) { REG_WRITE(GPIO_OUT_W1TC_REG, pin); diff --git a/Somfy.h b/Somfy.h index 5a85298..ea1aa66 100644 --- a/Somfy.h +++ b/Somfy.h @@ -22,13 +22,13 @@ enum class somfy_commands : byte { Prog = 0x8, SunFlag = 0x9, Flag = 0xA, - StepUp = 0xB, + StepDown = 0xB, UnknownC = 0xC, UnknownD = 0xD, - UnknownE = 0xE, + UnknownE = 0xE, // This command byte has been witnessed in the wild but cannot tell if it is from Somfy. No rolling code is sent with this and it is 56-bits. UnknownF = 0xF, // Command extensions for 80 bit frames - StepDown = 0x8B + StepUp = 0x8B }; enum class shade_types : byte { roller = 0x00, diff --git a/SomfyController.ino.esp32.bin b/SomfyController.ino.esp32.bin index ecab614..2e2454c 100644 Binary files a/SomfyController.ino.esp32.bin and b/SomfyController.ino.esp32.bin differ diff --git a/SomfyController.littlefs.bin b/SomfyController.littlefs.bin index ea9ad6c..4bff626 100644 Binary files a/SomfyController.littlefs.bin and b/SomfyController.littlefs.bin differ diff --git a/data/appversion b/data/appversion index e21e727..3c80e4f 100644 --- a/data/appversion +++ b/data/appversion @@ -1 +1 @@ -1.4.0 \ No newline at end of file +1.4.3 \ No newline at end of file diff --git a/data/index.html b/data/index.html index 9ec8a5a..6f449aa 100644 --- a/data/index.html +++ b/data/index.html @@ -3,10 +3,10 @@ - - + + - +
diff --git a/data/index.js b/data/index.js index f2ea0c2..4e78a50 100644 --- a/data/index.js +++ b/data/index.js @@ -372,7 +372,7 @@ async function reopenSocket() { await initSockets(); } class General { - appVersion = 'v1.4.2'; + appVersion = 'v1.4.3'; reloadApp = false; async init() { this.setAppVersion();