#define SER_PORT "/dev/ttyUSB0"
#include "./eoLink.h"
#include <stdio.h>
const uint8_t pskVector[16] ={0x54,0x6F,0x62,0x69,0x20,0x52,0x6F,0x63,0x6B,0x74,0x20,0x50,0x53,0x4B,0x21,0x00};
const uint8_t keyVector[16] ={0x45,0x6E,0x4F,0x63,0x65,0x61,0x6E,0x20,0x47,0x6D,0x62,0x48,0x2E,0x31,0x33,0x00};
void securedPTM()
{
const uint32_t destID=0xFFFFFFFF;
printf("Opening Connection to USB300 \n");
{
printf("Failed to open USB300\n");
return ;
}
else
{
printf("EnOcean-Link Gateway\n");
}
{
printf("%s %i.%i.%i.%i, ID:0x%08X on %s\n",
SER_PORT);
}
else
{
printf("Failed to retrieve USB300 version\n");
return ;
}
memcpy(devOut.
key,keyVector,
sizeof(keyVector));
{
printf("Sending TeachIn Message \n");
myGateway.
Send(TeachInMessage);
}
else
{
}
unsecureMsg.destinationID=destID;
securePTM->
Create(unsecureMsg);
{
printf("Sending Encrypted Message\n");
myGateway.
Send(secureMsg);
}
else
{
}
securePTM->
Create(unsecureMsg);
{
printf("Sending Encrypted Message\n");
myGateway.
Send(secureMsg);
}
else
{
}
delete securePTM;
return;
}
void securedSTM()
{
const uint32_t destID=0xFFFFFFFF;
printf("Opening Connection to USB300 \n");
{
printf("Failed to open USB300\n");
return ;
}
else
{
printf("EnOcean-Link Gateway\n");
}
{
printf("%s %i.%i.%i.%i, ID:0x%08X on %s\n",
SER_PORT);
}
else
{
printf("Failed to retrieve USB300 version\n");
return ;
}
memcpy(devOut.
key,keyVector,
sizeof(keyVector));
memcpy(devOut.
psk,pskVector,
sizeof(pskVector));
{
printf("Sending TeachIn Message \n");
myGateway.
Send(TeachInMessage);
}
else
{
}
unsecureMsg.destinationID=destID;
{
printf("Sending Encrypted Message\n");
myGateway.
Send(secureMsg);
}
else
{
}
for(int temp=-10;temp<30;temp+=5)
{
secureSTM->
Create(unsecureMsg);
unsecureMsg.destinationID = destID;
{
printf("Sending Encrypted Message\n");
myGateway.
Send(secureMsg);
}
else
{
}
}
delete secureSTM;
return;
}