EnOcean Link  1.14.0.0
Middleware to Connect EnOcean easily to other Projects
Security Watcher Example

This is an example Integration for the AN513: Robust EnOcean networks

The Source Code of this Tutorial can be found here: WatcherMain.cpp

The eoWatcher class contains the function to detect possible security issues. It contains functions for a general security Detection (e.g. DOS) and device specific (e.g. REPLAY)

Using the

function one can add a specific device to check. If you set maxPerdiodTime and minPerdiodTime you assume that your device sends atleast every minPeriodTime and max maxPeriodTime.

Using the CheckSecurity you can check for securitiy issues using the information of the currently received telegram.

In the WatcherMain.cpp we use one instance of the eoWatcher Class to handle the possible Security Issue of our Gateway.

//10 telegrams allowed with less then 100ms between them(maturity time)
eoWatcher myWatcher(10,100);
myGateway.secWatcher=myWatcher;
//We add our example device, which we expect to send every 10sec and at least every 100ms.
//The device Specific RLC Window is 10, and if we receive 5 Telegrams with a wrong CMAC we get an Error.
//After each received Telegram the expted tel Period is reseted (Meaning maxPeriodTime and minPeriodTime count from
//the moment we got this Telegram
myWatcher.AddDevice(0xFEFFFEBC,1000,100,10,5,true);

The exampe Function HandleSecResult(EO_SEC_WATCH_RESULT watchRes) would handle the different threats.

//Easy Handler for the different Security Issues
void HandleSecResult(EO_SEC_WATCH_RESULT watchRes)
{
switch(watchRes)
{
case(WATCH_OK):
break;
break;
break;
break;
break;
printf("Possible DOS detected \n");
break;
break;
break;
break;
break;
printf("A possible delay Attack detected \n");
break;
default:
printf("The Security watcher returned a not valid value!\n");
break;
}
}

We add the handle function in the mainLoop of the application.

if (recv & RECV_TELEGRAM)
{
HandleSecResult((EO_SEC_WATCH_RESULT)myGateway.GetSecWatchResult());
}