EnOcean Link  1.14.0.0
Middleware to Connect EnOcean easily to other Projects
Tutorial 2

The Source Code of the Tutorial can be found here: tutorial2.cpp

This Tutorial will help you to understand how to load configurations, use the eoProfile::GetValue Function and how to send Telegrams.

In this example Application we've a configuration which contains the Information about a Temperature Sensor sending an EEP2.1-A5-02-05 4BS Telegram.

This Application will send a 1BS "Warning" Telegram, if we reach a temperature over 30 Degree Celsius.

Here is the example Configuration File:

_EOLINK_SAVE
HEADER
{
name:_HUMAN_ARCHIVE
major:0x0
minor:0x2
}
Gateway
{
myDeviceManager
{
Counter:0x1
Device_0000
{
profile
{
rorg:0xa5
func:0x2
type:0x5
manufacturer:0x1a
}
dBm:0x0
ID:0x100867a
secIn
{
}
secIn
{
}
}
}
myFilter
{
type:0x1
Counter:0x1
ID_0000:0x100867a
}
myLearnFilter
{
}
LearnMode:FALSE
}

As you can see all number values are stored in Hex, and must of the Configuration is self explaining.

If you've a Temperature Sensor at your dispose, and want to test this application you've to change both fields containg the ID:0x100867a, to your device ID.

After including the eoLink Header File and opening the connection the eoGateway the eoStorageManager has to load the eoGateway Configuration.

eoGateway myGateway;
printf("Opening Connection to USB300 \n");
if (myGateway.Open(SER_PORT)!=OK)
{
printf("Failed to open USB300\n");
return 0;
}
//Loading the prepared Configuartion
myStore.addObject("Gateway",&myGateway);
myStore.Load(LOAD_CONFIG);
uint16_t recv;

Loading and Storing use the same Object Information.

The next Step is to prepare the warning Telegram with a certain RORG and some data. We choose 1BS and 0xFF as data.

Telegram myTel = Telegram(1);
myTel.RORG=RORG_1BS;
myTel.data[0]=0xFF;

As in the previous example we use the return flags to check if we got Information about a Profile.

When we receive a temperature over 30 degree, we use eoGateway::Send() to send our definied 1BS Telegram.

while (1)
{
recv = myGateway.Receive();
if (recv & RECV_PROFILE)
{
printf("Device %08lX\n", myGateway.device->ID);
eoProfile *profile = myGateway.device->GetProfile();
float f;
if (profile->GetValue( S_TEMP, f) ==OK)
{
printf(" %.2f \n", f);
//our value is higher then 30° send the warning message!
if(f>30.0)
myGateway.Send(myMessage);
}
}
}