knx/src/knx_facade.h

374 lines
8.4 KiB
C
Raw Normal View History

2018-03-20 23:56:42 +01:00
#pragma once
2018-11-07 00:32:36 +01:00
2019-08-22 22:57:35 +02:00
#include "knx/bits.h"
2020-03-12 21:34:00 +01:00
#include "knx/config.h"
2019-10-28 13:33:06 +01:00
2018-11-07 00:32:36 +01:00
#ifdef ARDUINO_ARCH_SAMD
2019-10-25 16:41:29 +02:00
#include "samd_platform.h"
#include "knx/bau07B0.h"
#include "knx/bau27B0.h"
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
#include "knx/bau2920.h"
Add support for CC1310 platform based on SimpleLink SDK (#94) * Initial commit * Clean up * Remove display code * Change cmake build * Add SimpleLink SDK for CC13xx/CC26xx as submodule * Remove commented line from build.sh * Working build * Remove SDK submodule * Squashed 'examples/knx-cc1310/coresdk_cc13xx_cc26xx/' content from commit 0d78d32 git-subtree-dir: examples/knx-cc1310/coresdk_cc13xx_cc26xx git-subtree-split: 0d78d3280357416a5c0388148cda13717c9ffaa5 * Add more comments and enable Power_idleFunc() for NoRTOS variant. Internal SDK driver functions which have to wait for something will cause Power_idleFunc to be called instead of doing busy wait. * Move CC1310 platform init around * Optimize a bit more in debug build config as the binary does not fit into 128Kb flash otherwise. * Explicitly list each source/header file in build config. Use linker group to resolve circular dependencies. * Ignore vscode settings.json * Increase stacks size * Only compile CC1310 source code if #define DeviceFamily_CC13X0 * initial commit of CC1310 RF driver with first working RX version * Better handling of buttonUp() across platforms * Start cleanup * continue cleanup * Fix bau2920 compilation * Continue cleanup * Fix compilation in other examples * Fix compilation * htons() and ntohs() only for SAMD and STM32, but not for Linux and ESP8266 and ESP32 * htons(9 and ntohs() needed for CC13x0 * Continue cleanup * Add CC1310 platform to CI * Fix CI * Use more recent toolchain from ARM * Fix travis * Use Ubuntu Focal * Fix toolchain for travis * Fix package name * Fix toolchain * Add libstdc++-dev package * Add newlib packages * Remove commented commands from CI * Fix travis * Fix compilation of knxPython * Clean up linefeeds * Fix RX callback * Move RF CRC16-DNP to bits.cpp * Fix TX * Optimization: do not calc CRC for block1 again in rf_data_link_layer * Make newline optional in printHex * Cleanup. First working version: ETS5 programming of individual address via KNX/RF coupler. * Use LEDs and Buttons to control ProgMode and Flash Erase * Remove settings.json (VScode) * Add README.md * Update README.md * Update README.md * Fix typo
2020-11-10 21:52:38 +01:00
void buttonUp();
2019-05-27 21:41:04 +02:00
#elif ARDUINO_ARCH_ESP8266
2019-10-25 16:41:29 +02:00
#include "esp_platform.h"
#include "knx/bau57B0.h"
Add support for CC1310 platform based on SimpleLink SDK (#94) * Initial commit * Clean up * Remove display code * Change cmake build * Add SimpleLink SDK for CC13xx/CC26xx as submodule * Remove commented line from build.sh * Working build * Remove SDK submodule * Squashed 'examples/knx-cc1310/coresdk_cc13xx_cc26xx/' content from commit 0d78d32 git-subtree-dir: examples/knx-cc1310/coresdk_cc13xx_cc26xx git-subtree-split: 0d78d3280357416a5c0388148cda13717c9ffaa5 * Add more comments and enable Power_idleFunc() for NoRTOS variant. Internal SDK driver functions which have to wait for something will cause Power_idleFunc to be called instead of doing busy wait. * Move CC1310 platform init around * Optimize a bit more in debug build config as the binary does not fit into 128Kb flash otherwise. * Explicitly list each source/header file in build config. Use linker group to resolve circular dependencies. * Ignore vscode settings.json * Increase stacks size * Only compile CC1310 source code if #define DeviceFamily_CC13X0 * initial commit of CC1310 RF driver with first working RX version * Better handling of buttonUp() across platforms * Start cleanup * continue cleanup * Fix bau2920 compilation * Continue cleanup * Fix compilation in other examples * Fix compilation * htons() and ntohs() only for SAMD and STM32, but not for Linux and ESP8266 and ESP32 * htons(9 and ntohs() needed for CC13x0 * Continue cleanup * Add CC1310 platform to CI * Fix CI * Use more recent toolchain from ARM * Fix travis * Use Ubuntu Focal * Fix toolchain for travis * Fix package name * Fix toolchain * Add libstdc++-dev package * Add newlib packages * Remove commented commands from CI * Fix travis * Fix compilation of knxPython * Clean up linefeeds * Fix RX callback * Move RF CRC16-DNP to bits.cpp * Fix TX * Optimization: do not calc CRC for block1 again in rf_data_link_layer * Make newline optional in printHex * Cleanup. First working version: ETS5 programming of individual address via KNX/RF coupler. * Use LEDs and Buttons to control ProgMode and Flash Erase * Remove settings.json (VScode) * Add README.md * Update README.md * Update README.md * Fix typo
2020-11-10 21:52:38 +01:00
void buttonUp();
#elif ARDUINO_ARCH_ESP32
2019-10-25 16:41:29 +02:00
#define LED_BUILTIN 13
#include "esp32_platform.h"
2020-04-07 18:24:28 +02:00
#include "knx/bau07B0.h"
2019-10-25 16:41:29 +02:00
#include "knx/bau57B0.h"
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
#include "knx/bau091A.h"
Add support for CC1310 platform based on SimpleLink SDK (#94) * Initial commit * Clean up * Remove display code * Change cmake build * Add SimpleLink SDK for CC13xx/CC26xx as submodule * Remove commented line from build.sh * Working build * Remove SDK submodule * Squashed 'examples/knx-cc1310/coresdk_cc13xx_cc26xx/' content from commit 0d78d32 git-subtree-dir: examples/knx-cc1310/coresdk_cc13xx_cc26xx git-subtree-split: 0d78d3280357416a5c0388148cda13717c9ffaa5 * Add more comments and enable Power_idleFunc() for NoRTOS variant. Internal SDK driver functions which have to wait for something will cause Power_idleFunc to be called instead of doing busy wait. * Move CC1310 platform init around * Optimize a bit more in debug build config as the binary does not fit into 128Kb flash otherwise. * Explicitly list each source/header file in build config. Use linker group to resolve circular dependencies. * Ignore vscode settings.json * Increase stacks size * Only compile CC1310 source code if #define DeviceFamily_CC13X0 * initial commit of CC1310 RF driver with first working RX version * Better handling of buttonUp() across platforms * Start cleanup * continue cleanup * Fix bau2920 compilation * Continue cleanup * Fix compilation in other examples * Fix compilation * htons() and ntohs() only for SAMD and STM32, but not for Linux and ESP8266 and ESP32 * htons(9 and ntohs() needed for CC13x0 * Continue cleanup * Add CC1310 platform to CI * Fix CI * Use more recent toolchain from ARM * Fix travis * Use Ubuntu Focal * Fix toolchain for travis * Fix package name * Fix toolchain * Add libstdc++-dev package * Add newlib packages * Remove commented commands from CI * Fix travis * Fix compilation of knxPython * Clean up linefeeds * Fix RX callback * Move RF CRC16-DNP to bits.cpp * Fix TX * Optimization: do not calc CRC for block1 again in rf_data_link_layer * Make newline optional in printHex * Cleanup. First working version: ETS5 programming of individual address via KNX/RF coupler. * Use LEDs and Buttons to control ProgMode and Flash Erase * Remove settings.json (VScode) * Add README.md * Update README.md * Update README.md * Fix typo
2020-11-10 21:52:38 +01:00
void buttonUp();
2020-04-02 18:09:53 +02:00
#elif ARDUINO_ARCH_STM32
#include "stm32_platform.h"
2020-04-02 22:10:50 +02:00
#include "knx/bau07B0.h"
Add support for CC1310 platform based on SimpleLink SDK (#94) * Initial commit * Clean up * Remove display code * Change cmake build * Add SimpleLink SDK for CC13xx/CC26xx as submodule * Remove commented line from build.sh * Working build * Remove SDK submodule * Squashed 'examples/knx-cc1310/coresdk_cc13xx_cc26xx/' content from commit 0d78d32 git-subtree-dir: examples/knx-cc1310/coresdk_cc13xx_cc26xx git-subtree-split: 0d78d3280357416a5c0388148cda13717c9ffaa5 * Add more comments and enable Power_idleFunc() for NoRTOS variant. Internal SDK driver functions which have to wait for something will cause Power_idleFunc to be called instead of doing busy wait. * Move CC1310 platform init around * Optimize a bit more in debug build config as the binary does not fit into 128Kb flash otherwise. * Explicitly list each source/header file in build config. Use linker group to resolve circular dependencies. * Ignore vscode settings.json * Increase stacks size * Only compile CC1310 source code if #define DeviceFamily_CC13X0 * initial commit of CC1310 RF driver with first working RX version * Better handling of buttonUp() across platforms * Start cleanup * continue cleanup * Fix bau2920 compilation * Continue cleanup * Fix compilation in other examples * Fix compilation * htons() and ntohs() only for SAMD and STM32, but not for Linux and ESP8266 and ESP32 * htons(9 and ntohs() needed for CC13x0 * Continue cleanup * Add CC1310 platform to CI * Fix CI * Use more recent toolchain from ARM * Fix travis * Use Ubuntu Focal * Fix toolchain for travis * Fix package name * Fix toolchain * Add libstdc++-dev package * Add newlib packages * Remove commented commands from CI * Fix travis * Fix compilation of knxPython * Clean up linefeeds * Fix RX callback * Move RF CRC16-DNP to bits.cpp * Fix TX * Optimization: do not calc CRC for block1 again in rf_data_link_layer * Make newline optional in printHex * Cleanup. First working version: ETS5 programming of individual address via KNX/RF coupler. * Use LEDs and Buttons to control ProgMode and Flash Erase * Remove settings.json (VScode) * Add README.md * Update README.md * Update README.md * Fix typo
2020-11-10 21:52:38 +01:00
void buttonUp();
#elif __linux__
2019-10-25 16:41:29 +02:00
#define LED_BUILTIN 0
#include "linux_platform.h"
#include "knx/bau57B0.h"
#include "knx/bau27B0.h"
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
#include "knx/bau07B0.h"
#include "knx/bau091A.h"
#include "knx/bau2920.h"
Add support for CC1310 platform based on SimpleLink SDK (#94) * Initial commit * Clean up * Remove display code * Change cmake build * Add SimpleLink SDK for CC13xx/CC26xx as submodule * Remove commented line from build.sh * Working build * Remove SDK submodule * Squashed 'examples/knx-cc1310/coresdk_cc13xx_cc26xx/' content from commit 0d78d32 git-subtree-dir: examples/knx-cc1310/coresdk_cc13xx_cc26xx git-subtree-split: 0d78d3280357416a5c0388148cda13717c9ffaa5 * Add more comments and enable Power_idleFunc() for NoRTOS variant. Internal SDK driver functions which have to wait for something will cause Power_idleFunc to be called instead of doing busy wait. * Move CC1310 platform init around * Optimize a bit more in debug build config as the binary does not fit into 128Kb flash otherwise. * Explicitly list each source/header file in build config. Use linker group to resolve circular dependencies. * Ignore vscode settings.json * Increase stacks size * Only compile CC1310 source code if #define DeviceFamily_CC13X0 * initial commit of CC1310 RF driver with first working RX version * Better handling of buttonUp() across platforms * Start cleanup * continue cleanup * Fix bau2920 compilation * Continue cleanup * Fix compilation in other examples * Fix compilation * htons() and ntohs() only for SAMD and STM32, but not for Linux and ESP8266 and ESP32 * htons(9 and ntohs() needed for CC13x0 * Continue cleanup * Add CC1310 platform to CI * Fix CI * Use more recent toolchain from ARM * Fix travis * Use Ubuntu Focal * Fix toolchain for travis * Fix package name * Fix toolchain * Add libstdc++-dev package * Add newlib packages * Remove commented commands from CI * Fix travis * Fix compilation of knxPython * Clean up linefeeds * Fix RX callback * Move RF CRC16-DNP to bits.cpp * Fix TX * Optimization: do not calc CRC for block1 again in rf_data_link_layer * Make newline optional in printHex * Cleanup. First working version: ETS5 programming of individual address via KNX/RF coupler. * Use LEDs and Buttons to control ProgMode and Flash Erase * Remove settings.json (VScode) * Add README.md * Update README.md * Update README.md * Fix typo
2020-11-10 21:52:38 +01:00
void buttonUp();
#else
#define LED_BUILTIN 5 // see GPIO_PinConfig gpioPinConfigs[]
#include "cc1310_platform.h"
#include "knx/bau27B0.h"
#include "knx/bau07B0.h"
#include "knx/bau2920.h"
extern void buttonUp();
2018-11-07 00:32:36 +01:00
#endif
2018-03-20 23:56:42 +01:00
typedef uint8_t* (*SaveRestoreCallback)(uint8_t* buffer);
Add support for CC1310 platform based on SimpleLink SDK (#94) * Initial commit * Clean up * Remove display code * Change cmake build * Add SimpleLink SDK for CC13xx/CC26xx as submodule * Remove commented line from build.sh * Working build * Remove SDK submodule * Squashed 'examples/knx-cc1310/coresdk_cc13xx_cc26xx/' content from commit 0d78d32 git-subtree-dir: examples/knx-cc1310/coresdk_cc13xx_cc26xx git-subtree-split: 0d78d3280357416a5c0388148cda13717c9ffaa5 * Add more comments and enable Power_idleFunc() for NoRTOS variant. Internal SDK driver functions which have to wait for something will cause Power_idleFunc to be called instead of doing busy wait. * Move CC1310 platform init around * Optimize a bit more in debug build config as the binary does not fit into 128Kb flash otherwise. * Explicitly list each source/header file in build config. Use linker group to resolve circular dependencies. * Ignore vscode settings.json * Increase stacks size * Only compile CC1310 source code if #define DeviceFamily_CC13X0 * initial commit of CC1310 RF driver with first working RX version * Better handling of buttonUp() across platforms * Start cleanup * continue cleanup * Fix bau2920 compilation * Continue cleanup * Fix compilation in other examples * Fix compilation * htons() and ntohs() only for SAMD and STM32, but not for Linux and ESP8266 and ESP32 * htons(9 and ntohs() needed for CC13x0 * Continue cleanup * Add CC1310 platform to CI * Fix CI * Use more recent toolchain from ARM * Fix travis * Use Ubuntu Focal * Fix toolchain for travis * Fix package name * Fix toolchain * Add libstdc++-dev package * Add newlib packages * Remove commented commands from CI * Fix travis * Fix compilation of knxPython * Clean up linefeeds * Fix RX callback * Move RF CRC16-DNP to bits.cpp * Fix TX * Optimization: do not calc CRC for block1 again in rf_data_link_layer * Make newline optional in printHex * Cleanup. First working version: ETS5 programming of individual address via KNX/RF coupler. * Use LEDs and Buttons to control ProgMode and Flash Erase * Remove settings.json (VScode) * Add README.md * Update README.md * Update README.md * Fix typo
2020-11-10 21:52:38 +01:00
2019-08-22 22:57:35 +02:00
template <class P, class B> class KnxFacade : private SaveRestore
2018-03-20 23:56:42 +01:00
{
2019-08-22 22:57:35 +02:00
friend void buttonUp();
public:
KnxFacade() : _platformPtr(new P()), _bauPtr(new B(*_platformPtr)), _bau(*_bauPtr)
2019-09-09 19:07:22 +02:00
{
manufacturerId(0xfa);
_bau.addSaveRestore(this);
}
2019-08-22 22:57:35 +02:00
virtual ~KnxFacade()
{
if (_bauPtr)
delete _bauPtr;
if (_platformPtr)
delete _platformPtr;
}
KnxFacade(B& bau) : _bau(bau)
{
manufacturerId(0xfa);
_bau.addSaveRestore(this);
}
P& platform()
{
return *_platformPtr;
}
B& bau()
{
return _bau;
}
bool enabled()
{
return _bau.enabled();
}
2019-08-22 22:57:35 +02:00
void enabled(bool value)
{
2019-12-28 00:29:17 +01:00
_bau.enabled(value);
2019-08-22 22:57:35 +02:00
}
2019-08-22 22:57:35 +02:00
bool progMode()
{
return _bau.deviceObject().progMode();
}
2019-08-22 22:57:35 +02:00
void progMode(bool value)
{
_bau.deviceObject().progMode(value);
}
2019-08-22 22:57:35 +02:00
bool configured()
{
return _bau.configured();
}
2019-05-27 21:41:04 +02:00
/**
* returns HIGH if led is active on HIGH, LOW otherwise
*/
2019-08-22 22:57:35 +02:00
uint32_t ledPinActiveOn()
{
return _ledPinActiveOn;
}
/**
* Sets if the programming led is active on HIGH or LOW.
*
* Set to HIGH for GPIO--RESISTOR--LED--GND or to LOW for GPIO--LED--RESISTOR--VDD
*/
2019-08-22 22:57:35 +02:00
void ledPinActiveOn(uint32_t value)
{
_ledPinActiveOn = value;
}
2019-08-22 22:57:35 +02:00
uint32_t ledPin()
{
return _ledPin;
}
2019-08-22 22:57:35 +02:00
void ledPin(uint32_t value)
{
_ledPin = value;
}
/**
* returns RISING if interrupt is created in a rising signal, FALLING otherwise
*/
uint32_t buttonPinInterruptOn()
{
return _buttonPinInterruptOn;
}
/**
* Sets if the programming button creates a RISING or a FALLING signal.
*
* Set to RISING for GPIO--BUTTON--VDD or to FALLING for GPIO--BUTTON--GND
*/
void buttonPinInterruptOn(uint32_t value)
{
_buttonPinInterruptOn = value;
}
2019-08-22 22:57:35 +02:00
uint32_t buttonPin()
{
return _buttonPin;
}
2019-08-22 22:57:35 +02:00
void buttonPin(uint32_t value)
{
_buttonPin = value;
}
2019-08-22 22:57:35 +02:00
void readMemory()
{
_bau.readMemory();
}
2019-08-22 22:57:35 +02:00
void writeMemory()
{
_bau.writeMemory();
}
uint16_t individualAddress()
2019-08-22 22:57:35 +02:00
{
return _bau.deviceObject().individualAddress();
2019-08-22 22:57:35 +02:00
}
2019-08-22 22:57:35 +02:00
void loop()
{
if (progMode() != _progLedState)
{
_progLedState = progMode();
if (_progLedState)
{
println("progmode on");
digitalWrite(ledPin(), _ledPinActiveOn);
}
else
{
println("progmode off");
digitalWrite(ledPin(), HIGH - _ledPinActiveOn);
}
}
if (_toogleProgMode)
{
progMode(!progMode());
_toogleProgMode = false;
}
_bau.loop();
}
2019-08-22 22:57:35 +02:00
void manufacturerId(uint16_t value)
{
_bau.deviceObject().manufacturerId(value);
}
2019-08-22 22:57:35 +02:00
void bauNumber(uint32_t value)
{
_bau.deviceObject().bauNumber(value);
}
void orderNumber(const uint8_t* value)
2019-08-22 22:57:35 +02:00
{
_bau.deviceObject().orderNumber(value);
}
void hardwareType(const uint8_t* value)
2019-08-22 22:57:35 +02:00
{
_bau.deviceObject().hardwareType(value);
}
2019-08-22 22:57:35 +02:00
void version(uint16_t value)
{
_bau.deviceObject().version(value);
}
2019-08-22 22:57:35 +02:00
void start()
{
pinMode(_ledPin, OUTPUT);
digitalWrite(_ledPin, HIGH - _ledPinActiveOn);
pinMode(_buttonPin, INPUT_PULLUP);
attachInterrupt(_buttonPin, buttonUp, _buttonPinInterruptOn);
2019-08-22 22:57:35 +02:00
enabled(true);
}
void setSaveCallback(SaveRestoreCallback func)
2019-08-22 22:57:35 +02:00
{
_saveCallback = func;
}
void setRestoreCallback(SaveRestoreCallback func)
2019-08-22 22:57:35 +02:00
{
_restoreCallback = func;
}
2019-08-22 22:57:35 +02:00
uint8_t* paramData(uint32_t addr)
{
if (!_bau.configured())
return nullptr;
return _bau.parameters().data(addr);
}
2019-08-22 22:57:35 +02:00
uint8_t paramByte(uint32_t addr)
{
if (!_bau.configured())
return 0;
return _bau.parameters().getByte(addr);
}
uint16_t paramWord(uint32_t addr)
{
if (!_bau.configured())
return 0;
return _bau.parameters().getWord(addr);
}
2019-08-22 22:57:35 +02:00
uint32_t paramInt(uint32_t addr)
{
if (!_bau.configured())
return 0;
return _bau.parameters().getInt(addr);
}
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
#if (MASK_VERSION == 0x07B0) || (MASK_VERSION == 0x27B0) || (MASK_VERSION == 0x57B0)
2019-08-22 22:57:35 +02:00
GroupObject& getGroupObject(uint16_t goNr)
{
return _bau.groupObjectTable().get(goNr);
}
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
#endif
2019-08-22 22:57:35 +02:00
void restart(uint16_t individualAddress)
{
_bau.restartRequest(individualAddress);
}
2019-06-24 22:22:56 +02:00
private:
2019-08-22 22:57:35 +02:00
P* _platformPtr = 0;
B* _bauPtr = 0;
B& _bau;
uint32_t _ledPinActiveOn = LOW;
2019-01-03 22:20:50 +01:00
uint32_t _ledPin = LED_BUILTIN;
uint32_t _buttonPinInterruptOn = RISING;
2018-04-09 23:58:35 +02:00
uint32_t _buttonPin = 0;
SaveRestoreCallback _saveCallback = 0;
SaveRestoreCallback _restoreCallback = 0;
2019-08-22 22:57:35 +02:00
bool _toogleProgMode = false;
bool _progLedState = false;
uint16_t _saveSize = 0;
2019-08-22 22:57:35 +02:00
uint8_t* save(uint8_t* buffer)
{
if (_saveCallback != 0)
return _saveCallback(buffer);
return buffer;
}
2019-08-22 22:57:35 +02:00
uint8_t* restore(uint8_t* buffer)
{
if (_restoreCallback != 0)
return _restoreCallback(buffer);
return buffer;
}
uint16_t saveSize()
{
return _saveSize;
}
void saveSize(uint16_t size)
{
_saveSize = size;
}
2018-03-20 23:56:42 +01:00
};
2019-08-22 22:57:35 +02:00
#ifdef ARDUINO_ARCH_SAMD
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
// predefined global instance for TP or RF or TP/RF coupler
#if MASK_VERSION == 0x07B0
extern KnxFacade<SamdPlatform, Bau07B0> knx;
#elif MASK_VERSION == 0x27B0
extern KnxFacade<SamdPlatform, Bau27B0> knx;
#elif MASK_VERSION == 0x2920
extern KnxFacade<SamdPlatform, Bau2920> knx;
2019-10-25 16:41:29 +02:00
#else
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
#error "Mask version not supported on ARDUINO_ARCH_SAMD"
2019-10-25 16:41:29 +02:00
#endif
2019-08-22 22:57:35 +02:00
#elif ARDUINO_ARCH_ESP8266
2019-10-25 16:41:29 +02:00
// predefined global instance for IP only
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
#if MASK_VERSION == 0x57B0
extern KnxFacade<EspPlatform, Bau57B0> knx;
#else
#error "Mask version not supported on ARDUINO_ARCH_ESP8266"
#endif
#elif ARDUINO_ARCH_ESP32
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
// predefined global instance for TP or IP or TP/IP coupler
#if MASK_VERSION == 0x07B0
extern KnxFacade<Esp32Platform, Bau07B0> knx;
#elif MASK_VERSION == 0x57B0
extern KnxFacade<Esp32Platform, Bau57B0> knx;
#elif MASK_VERSION == 0x091A
extern KnxFacade<Esp32Platform, Bau091A> knx;
2020-04-07 18:24:28 +02:00
#else
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
#error "Mask version not supported on ARDUINO_ARCH_ESP32"
2020-04-07 18:24:28 +02:00
#endif
2020-04-02 18:09:53 +02:00
#elif ARDUINO_ARCH_STM32
2020-04-02 18:16:15 +02:00
// predefined global instance for TP only
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
#if MASK_VERSION == 0x07B0
extern KnxFacade<Stm32Platform, Bau07B0> knx;
#else
#error Mask version not supported on ARDUINO_ARCH_STM32
#endif
Add support for CC1310 platform based on SimpleLink SDK (#94) * Initial commit * Clean up * Remove display code * Change cmake build * Add SimpleLink SDK for CC13xx/CC26xx as submodule * Remove commented line from build.sh * Working build * Remove SDK submodule * Squashed 'examples/knx-cc1310/coresdk_cc13xx_cc26xx/' content from commit 0d78d32 git-subtree-dir: examples/knx-cc1310/coresdk_cc13xx_cc26xx git-subtree-split: 0d78d3280357416a5c0388148cda13717c9ffaa5 * Add more comments and enable Power_idleFunc() for NoRTOS variant. Internal SDK driver functions which have to wait for something will cause Power_idleFunc to be called instead of doing busy wait. * Move CC1310 platform init around * Optimize a bit more in debug build config as the binary does not fit into 128Kb flash otherwise. * Explicitly list each source/header file in build config. Use linker group to resolve circular dependencies. * Ignore vscode settings.json * Increase stacks size * Only compile CC1310 source code if #define DeviceFamily_CC13X0 * initial commit of CC1310 RF driver with first working RX version * Better handling of buttonUp() across platforms * Start cleanup * continue cleanup * Fix bau2920 compilation * Continue cleanup * Fix compilation in other examples * Fix compilation * htons() and ntohs() only for SAMD and STM32, but not for Linux and ESP8266 and ESP32 * htons(9 and ntohs() needed for CC13x0 * Continue cleanup * Add CC1310 platform to CI * Fix CI * Use more recent toolchain from ARM * Fix travis * Use Ubuntu Focal * Fix toolchain for travis * Fix package name * Fix toolchain * Add libstdc++-dev package * Add newlib packages * Remove commented commands from CI * Fix travis * Fix compilation of knxPython * Clean up linefeeds * Fix RX callback * Move RF CRC16-DNP to bits.cpp * Fix TX * Optimization: do not calc CRC for block1 again in rf_data_link_layer * Make newline optional in printHex * Cleanup. First working version: ETS5 programming of individual address via KNX/RF coupler. * Use LEDs and Buttons to control ProgMode and Flash Erase * Remove settings.json (VScode) * Add README.md * Update README.md * Update README.md * Fix typo
2020-11-10 21:52:38 +01:00
#else // Non-Arduino platforms and Linux platform
2019-10-25 16:41:29 +02:00
// no predefined global instance
Add support for KNX data secure (#66) * initial comic * save work * Handle SystemBroadcast and Broadcast for TP and IP * Rework * Fix comment * save work * save work * save work * save work * save work * Restore old broadcast structure * Readd systembroadcast methods * Make sure that services from SystemBroadcast are also available from Broadcast on closed media * save work * Save work * save work * Save work * save work * save work * save work * save work * save work * Change maximum number of elements for the key tables, etc. * save work * First working seqno sync with ETS * save work * save work * save work * save work * save work * save work * Remove magic value and add comment * save work * Extend restart and masterreset for factory reset * save work * First working secure broadcast mode with IA programming * Add FunctionPropertyExt* AL services * Fix FunctionPropertyExt*. Working T_DATA_CONNECTED with FunctionPropertyExt*. * Add PropertyValueExt* AL services. Handle master reset in AL service RESTART. * Fix FunctionPropertyExtStateRead, fix restart. MILESTONE: Working physical programming of IA and toolkey with confirmed restart. Reading deviceinfos working. * Handle PDT_CONTROL in FunctionPropertyExt* * Fix FunctionPropertyExt* and FunctionProperty for PDT_CONTROL * Change comment. * save work * save work * Add group object security handling * Move map to own file * use simple_map * Include simple_map.h in CmakeFile * Move code from header to source file * Remove obsolete code * MILESTONE: working programming of secure device with IA and tables * cleanup * bugfix * flashSize must be big enough. Security IF object contains a lot more data. * Merge master into feat_datasecure * Revert "Merge master into feat_datasecure" This reverts commit 0c8358692aab13456196dc3a9ce5383bc1a2dec9. * Revert "Revert "Merge master into feat_datasecure"" This reverts commit aa5925378591eb32ea6d89dcb778ab02388a710f. * Bugfixes * cleanup * cleanup * Add printing of uint64_t * Don't compile secapplayer if data secure not enabled * pin platform for ESP8266 to specific version * SecIfObject: save/restore required for persisting STATE. Bugfix: use correct PID for group key table * Cleanup comment and debug output * Further cleanup. * Refactor master reset * Remove unused IP data link layer test code * Only reset TOOL kkey to FDSK on factory reset * Modify .gitignore and remove vscode config file * Correct comment * Handle SBC flag (systembroadcast) in SCF field. Couplers between open and closed media need this. * Remove code that slipped in.
2020-07-06 19:16:54 +02:00
#endif