Somfy: add Sun status command

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
Álvaro Fernández Rojas 2023-05-29 16:02:26 +02:00
parent f632dc9c54
commit 8ed5346992
2 changed files with 14 additions and 2 deletions

View file

@ -91,6 +91,8 @@ String translateSomfyCommand(const somfy_commands cmd) {
return "Step Up";
case somfy_commands::StepDown:
return "Step Down";
case somfy_commands::Status:
return "Status";
default:
return "Unknown(" + String((uint8_t)cmd) + ")";
}
@ -173,9 +175,12 @@ void somfy_frame_t::decodeFrame(byte* frame) {
case somfy_commands::SunFlag:
case somfy_commands::Flag:
break;
case somfy_commands::Status:
this->rollingCode = 0;
this->sun = !!(decoded[3] & STATUS_SUN);
break;
case somfy_commands::UnknownC:
case somfy_commands::UnknownD:
case somfy_commands::UnknownE:
case somfy_commands::RTWProto:
this->valid = false;
break;

View file

@ -28,7 +28,7 @@ enum class somfy_commands : byte {
StepDown = 0xB,
UnknownC = 0xC,
UnknownD = 0xD,
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.
Status = 0xE,
RTWProto = 0xF, // RTW Protocol
// Command extensions for 80 bit frames
StepUp = 0x8B
@ -52,6 +52,12 @@ somfy_commands translateSomfyCommand(const String& string);
#define MAX_RX_BUFFER 3
#define MAX_TX_BUFFER 3
#if !defined(BIT)
#define BIT(x) (1 << (x))
#endif /* BIT */
#define STATUS_SUN BIT(1)
typedef enum {
waiting_synchro = 0,
receiving_data = 1,
@ -110,6 +116,7 @@ typedef struct somfy_frame_t {
uint32_t await = 0;
uint8_t bitLength = 56;
uint16_t pulseCount = 0;
bool sun = false;
void print();
void encodeFrame(byte *frame);
void decodeFrame(byte* frame);