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

This tutorials will learn in different EEP temperature profiles and creates one Generic Profile containing all temperature channels. Afterwards the received temperatures will be converted to generic profile temperatures and sent.

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

Tutorial 6 consist of 3 functions: Tries to open the gateway

bool openGateway(eoGateway &myGateway)

Lets the eoGateway run in learn mode. Only A5-02-xx temperature profiles will be learned in, and an generic profile channel will be created.

learnInMode(eoGateway &myGateway,eoGenericProfile &genericTemperatureProfiles,std::map<uint32_t,uint8_t> &devToID)

When we receive a telegram from a learned in device, the temperature will be parsed and the generic profile temperature profile channel will be set.

void operatingMode(eoGateway &myGateway,eoGenericProfile &genericTemperatureProfiles,std::map<uint32_t,uint8_t> &devToID)

and the main functions

int main(int argc, const char* argv[]) {
//First a Gateway and a storageManager will be definied
eoGateway myGateway;
//Empty Generic Profile
eoGenericProfile genericTemperatureProfiles;
std::map<uint32_t,uint8_t> devToID;
if(openGateway(myGateway))
{
eodBmFilter * learnFilter = new eodBmFilter();
myGateway.learnFilter = learnFilter;
learnFilter->maxdBm=-0;
learnFilter->mindBm=-60;
//the eoIDFilter will allow our Gateway application to filter all the unwanted Telegrams
eoIDFilter * myFilter = new eoIDFilter();
myGateway.filter=myFilter;
printf("EnOcean-Link Gateway LearnMode\n");
learnInMode(myGateway,genericTemperatureProfiles,devToID);
printf("Learn Mode off\n");
operatingMode(myGateway,genericTemperatureProfiles,devToID);
delete learnFilter;
delete myFilter;
}
return 0;
}

In the openGateway function, no generic Profile functions are used.

The learnInMode uses the eoGenericProfile::AddChannelOut(CHANNEL_TYPE type, GP_RESOLUTION resolution, int8_t engMaximum, int8_t engMinimum, GP_SCALING scaleMaximum, GP_SCALING scaleMinimum, VALUE_TYPE valueType) for adding a generic profile channel, using the eep channel information

genericTemperatureProfiles.AddChannelOut(S_TEMP,GP_RES_10BIT,(int8_t)tempChannel->max,(int8_t)tempChannel->min,GP_SCAL_1,GP_SCAL_1,VAL_CURR);

As in generic profiles the "subtype" of the same channel types are just counted, (the first temperature channel is subtype 1, the second temperature is subtype 2 and so on) we save which device has which subtype number

devToID[myGateway.device->ID]=devToID.size()-1;

Then the teach in time is over a Teach In telegram is created and sent

eoMessage teachMessage(128);
genericTemperatureProfiles.CreateTeachIN(teachMessage);
myGateway.Send(teachMessage);

In the operatingMode() function the temperatures values are updated after receing a teached in tempetature and a generic profile message is created.

eoProfile* tempProfile = myGateway.device->GetProfile();
float temperature;
if (tempProfile->GetValue( S_TEMP, temperature) ==EO_OK)
{
eoMessage gpMessage(128);
genericTemperatureProfiles.SetValue(S_TEMP,temperature,devToID[myGateway.device->ID]);
genericTemperatureProfiles.Create(gpMessage);
myGateway.Send(gpMessage);
}