knx/src/knx/cemi_server_object.cpp
nanosonde 77a796a39c
Add coupler support (#79)
* save work.

* save work

* save work

* save work

* save work

* Remember which interface received the cemi frame

* save work

* save work

* save work

* Use default value from PID_ROUTING_COUNT

* Add simple alternative to std::function without smart pointers or move semantics

* Remove include

* Add more comments about cleanup

* save work

* Remove forgotten code.

* Move crc16Ccitt to bits.c as it also used for PID_MCB

* save work

* move comment

* save work

* save work

* save work

* save work

* save work

* save work

* save work

* derive from TableObject instead of InterfaceObject

* save work

* save work

* Fix wrong pointer arithmetic in TableObject

* Filter table setting/clearing

* move comment

* save work

* save work

* save work

* handle SBC on closed media

* save work

* move coupler example to different dir

* Restore device example for linux

* save work

* Remove MEDIUM_TYPE and use MASK_VERSION

* save work

* save work

* save work

* save work

* save work

* save work

* save work

* save work

* save work

* save work

* save work

* save work

* save work

* save work

* Replace MEDIUM_TYPE by MASK_VERSION

* Remove adafruit/travis-ci tests

* Disable travis ci cache for platformio

* Fix missing changes

* Fix cemi server and add missing MASK_VERSION definitions

* Enable platformio caching on travis ci again

* Handle device address update for routing decision

* source address is set in network layer and not in data link layer

* Add remaining APCI types that are used with system broadcast

* Add debug print for routing

* Remove simple_functional

* Fix CMakLists.txt

* Use MASK_VERSION to conditionally compile code.

* Remove fixed version reuqirement from platform esp8266

* Add demo-coupler for MCUs

* Remove simple_functional.h from demo knx-linux

* Enable CI for coupler demos

* Correct path for knx-linux-coupler

* Fix knx_facade.h

* Refactor NetworkLayer to use getInterface() for devices and getPrimaryInterface(), getSecondaryInterface() for couplers

* Add platformio configs for other currently possible mask/platform combinations

* Add class diagrams and remove obsolete includes

* Add some minimal docs
2020-09-06 21:41:34 +02:00

59 lines
1.9 KiB
C++

#include "config.h"
#ifdef USE_CEMI_SERVER
#include <cstring>
#include "cemi_server_object.h"
#include "bits.h"
#include "data_property.h"
CemiServerObject::CemiServerObject()
{
Property* properties[] =
{
new DataProperty( PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0, (uint16_t)OT_CEMI_SERVER ),
new DataProperty( PID_MEDIUM_TYPE, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0, (uint16_t)0),
new DataProperty( PID_COMM_MODE, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0, (uint16_t)0),
new DataProperty( PID_COMM_MODES_SUPPORTED, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0, (uint16_t)0x100),
new DataProperty( PID_MEDIUM_AVAILABILITY, false, PDT_BITSET16, 1, ReadLv3 | WriteLv0, (uint16_t)0),
// cEMI additional info types supported by this cEMI server: only 0x02 (RF Control Octet and Serial Number or DoA)
new DataProperty( PID_ADD_INFO_TYPES, false, PDT_ENUM8, 1, ReadLv3 | WriteLv0, (uint8_t)0x02)
};
initializeProperties(sizeof(properties), properties);
}
void CemiServerObject::setMediumTypeAsSupported(DptMedium dptMedium)
{
uint16_t mediaTypesSupported;
property(PID_MEDIUM_TYPE)->read(mediaTypesSupported);
switch(dptMedium)
{
case DptMedium::KNX_IP:
mediaTypesSupported |= 1 << 1;
break;
case DptMedium::KNX_RF:
mediaTypesSupported |= 1 << 4;
break;
case DptMedium::KNX_TP1:
mediaTypesSupported |= 1 << 5;
break;
case DptMedium::KNX_PL110:
mediaTypesSupported |= 1 << 2;
break;
}
property(PID_MEDIUM_TYPE)->write(mediaTypesSupported);
// We also set the medium as available too
property(PID_MEDIUM_AVAILABILITY)->write(mediaTypesSupported);
}
void CemiServerObject::clearSupportedMediaTypes()
{
property(PID_MEDIUM_TYPE)->write((uint16_t) 0);
// We also set the medium as not available too
property(PID_MEDIUM_AVAILABILITY)->write((uint16_t) 0);
}
#endif