Add KNX RF example

This commit is contained in:
nanosonde 2019-10-25 17:13:59 +02:00
parent b4923815fe
commit 0c8a79edbd
3 changed files with 147 additions and 0 deletions

View File

@ -0,0 +1,70 @@
#include <knx.h>
// create macros easy access to group objects
#define goTemperature knx.getGroupObject(1)
#define goHumidity knx.getGroupObject(2)
uint32_t cyclSend = 0;
uint8_t sendCounter = 0;
long lastsend = 0;
// Entry point for the example
void setup(void)
{
Serial1.begin(115200);
ArduinoPlatform::SerialDebug = &Serial1;
delay(1000);
Serial1.println("start");
// read adress table, association table, groupobject table and parameters from eeprom
knx.readMemory();
if (knx.induvidualAddress() == 0)
knx.progMode(true);
if (knx.configured())
{
cyclSend = knx.paramInt(0);
Serial1.print("Zykl. send:");
Serial1.println(cyclSend);
goTemperature.dataPointType(Dpt(9, 1));
goHumidity.dataPointType(Dpt(9, 1));
}
// start the framework.
knx.start();
}
// Function that is looped forever
void loop(void)
{
// don't delay here to much. Otherwise you might lose packages or mess up the timing with ETS
knx.loop();
// only run the application code if the device was configured with ETS
if(!knx.configured())
return;
long now = millis();
if ((now - lastsend) < 3000)
return;
lastsend = now;
float temp = 1.2345;
float humi = 60.2;
String output = String(millis());
output += ", " + String(temp);
output += ", " + String(humi);
Serial1.println(output);
if (sendCounter++ == cyclSend)
{
sendCounter = 0;
goTemperature.value(temp);
goHumidity.value(humi);
}
}

Binary file not shown.

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<KNX xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" CreatedBy="KNX MT" ToolVersion="5.1.255.16695" xmlns="http://knx.org/xml/project/11">
<ManufacturerData>
<Manufacturer RefId="M-00FA">
<Catalog>
<CatalogSection Id="M-00FA_CS-1" Name="Geräte" Number="1" DefaultLanguage="de">
<CatalogItem Id="M-00FA_H-0-0_HP-0000-0A-0000_CI-0-1" Name="KNXDEMO RFC" Number="1" ProductRefId="M-00FA_H-0-0_P-0" Hardware2ProgramRefId="M-00FA_H-0-0_HP-0000-0A-0000" DefaultLanguage="de" />
</CatalogSection>
</Catalog>
<ApplicationPrograms>
<ApplicationProgram Id="M-00FA_A-0000-0A-0000" ApplicationNumber="0" ApplicationVersion="10" ProgramType="ApplicationProgram" MaskVersion="MV-27B0" Name="RF" LoadProcedureStyle="MergedProcedure" PeiType="0" DefaultLanguage="de" DynamicTableManagement="false" Linkable="false" MinEtsVersion="4.0">
<Static>
<Code>
<RelativeSegment Id="M-00FA_A-0000-0A-0000_RS-04-00000" Name="Parameters" Offset="0" Size="4" LoadStateMachine="4" />
</Code>
<ParameterTypes>
<ParameterType Id="M-00FA_A-0000-0A-0000_PT-Int" Name="Int">
<TypeNumber SizeInBit="32" Type="signedInt" minInclusive="0" maxInclusive="1000" />
</ParameterType>
</ParameterTypes>
<Parameters>
<Parameter Id="M-00FA_A-0000-0A-0000_P-1" Name="Zyklisch Senden" ParameterType="M-00FA_A-0000-0A-0000_PT-Int" Text="Sendeinterval (*3s)" Value="20">
<Memory CodeSegment="M-00FA_A-0000-0A-0000_RS-04-00000" Offset="0" BitOffset="0" />
</Parameter>
</Parameters>
<ParameterRefs>
<ParameterRef Id="M-00FA_A-0000-0A-0000_P-1_R-1" RefId="M-00FA_A-0000-0A-0000_P-1" />
</ParameterRefs>
<ComObjectTable>
<ComObject Id="M-00FA_A-0000-0A-0000_O-1" Name="Temperatur" Text="Temperatur" Number="1" FunctionText="Temperatur lesen" ObjectSize="2 Bytes" ReadFlag="Enabled" WriteFlag="Disabled" CommunicationFlag="Enabled" TransmitFlag="Enabled" UpdateFlag="Disabled" ReadOnInitFlag="Disabled" DatapointType="" />
<ComObject Id="M-00FA_A-0000-0A-0000_O-2" Name="Luftfeuchtigkeit" Text="Luftfeuchtigkeit" Number="2" FunctionText="Luftfeuchtigkeit lesen" ObjectSize="2 Bytes" ReadFlag="Enabled" WriteFlag="Disabled" CommunicationFlag="Enabled" TransmitFlag="Enabled" UpdateFlag="Disabled" ReadOnInitFlag="Disabled" DatapointType="" />
</ComObjectTable>
<ComObjectRefs>
<ComObjectRef Id="M-00FA_A-0000-0A-0000_O-1_R-1" RefId="M-00FA_A-0000-0A-0000_O-1" />
<ComObjectRef Id="M-00FA_A-0000-0A-0000_O-2_R-2" RefId="M-00FA_A-0000-0A-0000_O-2" />
</ComObjectRefs>
<AddressTable MaxEntries="255" />
<AssociationTable MaxEntries="255" />
<LoadProcedures>
<LoadProcedure MergeId="2">
<LdCtrlRelSegment LsmIdx="4" Size="4" Mode="0" Fill="0" AppliesTo="full" />
</LoadProcedure>
<LoadProcedure MergeId="4">
<LdCtrlWriteRelMem ObjIdx="4" Offset="0" Size="4" Verify="true" />
</LoadProcedure>
</LoadProcedures>
<Options />
</Static>
<Dynamic>
<ChannelIndependentBlock>
<ParameterBlock Id="M-00FA_A-0000-0A-0000_PB-1" Name="ParameterPage" Text="Allgemeine Parameter">
<ParameterRefRef RefId="M-00FA_A-0000-0A-0000_P-1_R-1" />
<ComObjectRefRef RefId="M-00FA_A-0000-0A-0000_O-1_R-1" />
<ComObjectRefRef RefId="M-00FA_A-0000-0A-0000_O-2_R-2" />
</ParameterBlock>
</ChannelIndependentBlock>
</Dynamic>
</ApplicationProgram>
</ApplicationPrograms>
<Hardware>
<Hardware Id="M-00FA_H-0-0" Name="KNXDEMO RF" SerialNumber="0" VersionNumber="0" HasIndividualAddress="true" HasApplicationProgram="true">
<Products>
<Product Id="M-00FA_H-0-0_P-0" Text="KNXDEMO RFC" OrderNumber="0" IsRailMounted="false" DefaultLanguage="de">
<RegistrationInfo RegistrationStatus="Registered" />
</Product>
</Products>
<Hardware2Programs>
<Hardware2Program Id="M-00FA_H-0-0_HP-0000-0A-0000" MediumTypes="MT-2">
<ApplicationProgramRef RefId="M-00FA_A-0000-0A-0000" />
<RegistrationInfo RegistrationStatus="Registered" RegistrationNumber="0001/010" />
</Hardware2Program>
</Hardware2Programs>
</Hardware>
</Hardware>
</Manufacturer>
</ManufacturerData>
</KNX>