Secure IoT command sending (Arduino Server). There are many ways to secure and authenticate a networking communication, but not all solutions will run on a microcontroller, where processing power and memory is a scarce resource.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.3 KiB

#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);
}