kasdimos
5 years ago
1 changed files with 74 additions and 0 deletions
@ -0,0 +1,74 @@ |
|||
#include <SecureSend.h> |
|||
|
|||
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); |
|||
} |
|||
|
Loading…
Reference in new issue