From 3e164e655314f48d61a0703f12091617d0605aba Mon Sep 17 00:00:00 2001 From: kasdimos Date: Tue, 26 Nov 2019 11:30:14 +0000 Subject: [PATCH] Add 'SecureSendSketch' --- SecureSendSketch | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 SecureSendSketch diff --git a/SecureSendSketch b/SecureSendSketch new file mode 100644 index 0000000..93c1823 --- /dev/null +++ b/SecureSendSketch @@ -0,0 +1,74 @@ +#include + +const bool enableSerial = true; + +byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED +}; +IPAddress ip(192, 168, 0, 6); +uint16_t port = 80; + +uint8_t hmacKey[]={ + 's','u','p','e','r','s','e','c','u','r','e' +}; +const int clientFirstByteCount = 1; +const int randDataLength = 100; +const int hashByteLength = 32; + +int switchGatePin = 5; +int gateClosedPin = 3; +int gateOpenPin = 1; + +int getGateState(){ + Serial.println("Get gate state"); + return 2; +} + +int switchGate(){ + Serial.println("Switch Gate"); + return 0; +} + +int switchLight(){ + Serial.println("Switch Light"); + return 1; +} + +int failFunc(){ + Serial.println("Unknown cmd"); + return -1; +} + + +void newLoop(){} + + +int (*functionArray[])(void) = { + getGateState, + switchGate, + switchLight +}; +const int functionsCount = 3; + +SecureSend secureSend(mac, ip, port, + hmacKey, sizeof(hmacKey), + functionArray, functionsCount, + failFunc, newLoop, + enableSerial, + randDataLength, + clientFirstByteCount, + hashByteLength, + analogRead(A0) + ); + +void setup() { + pinMode(switchGatePin, OUTPUT); + digitalWrite(switchGatePin, LOW); + secureSend.begin(); +} + + +void loop() { + delay(3000); +} +