diff --git a/gateway/include/Protocol.h b/gateway/include/Protocol.h index a00580d..e8c7376 100644 --- a/gateway/include/Protocol.h +++ b/gateway/include/Protocol.h @@ -2,19 +2,12 @@ #include #include -class ProtocolNo { -protected: - unsigned int no; - -public: - constexpr ProtocolNo(unsigned int protocol) : no(protocol) {} - constexpr operator unsigned int() const { return no; } - ProtocolNo& operator=(unsigned int p){ no = p; return *this;} +enum ProtocolNo : unsigned int { + NO_PROTOCOL = 0, + PROTOCOL_1 = 1, + PROTOCOL_2 = 2, + PROTOCOL_13 = 13 }; -constexpr ProtocolNo NO_PROTOCOL{ 0 }; -constexpr ProtocolNo PROTOCOL_1{ 1 }; -constexpr ProtocolNo PROTOCOL_2{ 2 }; -constexpr ProtocolNo PROTOCOL_13{ 13 }; class Protocol { protected: @@ -23,8 +16,8 @@ protected: public: Protocol(ProtocolNo protocol) : no(protocol) {} - Protocol& setProtocol(ProtocolNo p) { - no = p; + Protocol& setProtocol(unsigned int p) { + no = static_cast(p); return *this; } diff --git a/gateway/include/Protocol_Doorbell.h b/gateway/include/Protocol_Doorbell.h index eb3fc74..90444bf 100644 --- a/gateway/include/Protocol_Doorbell.h +++ b/gateway/include/Protocol_Doorbell.h @@ -10,7 +10,7 @@ class Protocol_Doorbell : public Protocol { public: Protocol_Doorbell() : Protocol(PROTOCOL_13) {} - static void ring(const char* value) { + void ring(const char* value) { preamble(); for (int i = 0; i < 7; i++) { delayMicroseconds(TX_DELAY); @@ -19,27 +19,27 @@ public: } private: - static void transmitBit(uint8_t value) { + void transmitBit(uint8_t value) { digitalWrite(SEND_PIN, value); delayMicroseconds(BIT_LENGTH); digitalWrite(SEND_PIN, LOW); } - static void transmitHigh() { + void transmitHigh() { digitalWrite(SEND_PIN, HIGH); delayMicroseconds(BIT_LENGTH_3); digitalWrite(SEND_PIN, LOW); delayMicroseconds(BIT_LENGTH); } - static void transmitLow() { + void transmitLow() { digitalWrite(SEND_PIN, HIGH); delayMicroseconds(BIT_LENGTH); digitalWrite(SEND_PIN, LOW); delayMicroseconds(BIT_LENGTH_3); } - static void preamble() { + void preamble() { noInterrupts(); for (int i = 0; i < 370; i++) { transmitBit(HIGH); @@ -48,7 +48,7 @@ private: interrupts(); } - static void code(const char* value) { + void code(const char* value) { noInterrupts(); for (const char* p = value; *p; p++) { *p == '1' ? transmitHigh() : transmitLow(); diff --git a/gateway/include/devices.h b/gateway/include/devices.h index e30158c..96cef8c 100644 --- a/gateway/include/devices.h +++ b/gateway/include/devices.h @@ -109,7 +109,7 @@ Command* commands[] = { }).asDevice(gatewayDevice).build(), Builder