#include #define PORT_TX 5 #define SYMBOL 640 #define HAUT 0x2 #define STOP 0x1 #define BAS 0x4 #define PROG 0x8 #define EEPROM_ADDRESS 0 #define VERSION 1 byte frame[7]; byte checksum; struct Remote { unsigned long remoteID; unsigned int rollingCode; }; struct SomfyController { int appVersion; Remote remotes[4]; }; SomfyController somfyControllers; Remote newRemotes [4] = { {0x123456, 0}, {0x123457, 0}, {0x123458, 0}, {0x123459, 0} }; void BuildFrame(unsigned long remoteID, unsigned int rollingCode, byte *frame, byte button); void SendCommand(byte *frame, byte sync); void setup() { Serial.begin(115200); DDRD |= 1<> 8; frame[3] = rollingCode; frame[4] = remoteID >> 16; frame[5] = remoteID >> 8; frame[6] = remoteID; Serial.print("Frame : "); for (byte i = 0; i < 7; i++) { if (frame[i] >> 4 == 0) { Serial.print("0"); } Serial.print(frame[i], HEX); Serial.print(" "); } checksum = 0; for (byte i = 0; i < 7; i++) { checksum = checksum ^ frame[i] ^ (frame[i] >> 4); } checksum &= 0b1111; frame[1] |= checksum; Serial.println(""); Serial.print("Avec checksum : "); for (byte i = 0; i < 7; i++) { if (frame[i] >> 4 == 0) { Serial.print("0"); } Serial.print(frame[i], HEX); Serial.print(" "); } for (byte i = 1; i < 7; i++) { frame[i] ^= frame[i-1]; } Serial.println(""); Serial.print("Obfuscation : "); for (byte i = 0; i < 7; i++) { if (frame[i] >> 4 == 0) { Serial.print("0"); } Serial.print(frame[i], HEX); Serial.print(" "); } Serial.println(""); Serial.print("Compteur : "); Serial.println(rollingCode); } void SendCommand(byte *frame, byte sync) { if (sync == 2) { PORTD |= 1<> (7 - (i%8))) & 1) == 1) { PORTD &= !(1<