knx/src/knx_facade.h

486 lines
13 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"
2020-11-18 18:39:35 +01:00
#include "knx/bau07B0.h"
#include "knx/bau091A.h"
#include "knx/bau27B0.h"
#include "knx/bau2920.h"
#include "knx/bau57B0.h"
2019-10-28 13:33:06 +01:00
#ifndef USERDATA_SAVE_SIZE
#define USERDATA_SAVE_SIZE 0
#endif
2018-11-07 00:32:36 +01:00
#ifdef ARDUINO_ARCH_SAMD
2019-10-25 16:41:29 +02:00
#include "samd_platform.h"
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
#ifndef KNX_NO_AUTOMATIC_GLOBAL_INSTANCE
void buttonUp();
#endif
#elif defined(ARDUINO_ARCH_RP2040)
#include "rp2040_arduino_platform.h"
#ifndef KNX_NO_AUTOMATIC_GLOBAL_INSTANCE
void buttonUp();
#endif
#elif defined(ARDUINO_ARCH_ESP8266)
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
#include "esp_platform.h"
#ifndef KNX_NO_AUTOMATIC_GLOBAL_INSTANCE
void buttonUp();
#endif
#elif defined(ARDUINO_ARCH_ESP32)
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
#define LED_BUILTIN 13
#include "esp32_platform.h"
#ifndef KNX_NO_AUTOMATIC_GLOBAL_INSTANCE
void buttonUp();
#endif
#elif defined(ARDUINO_ARCH_STM32)
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
#include "stm32_platform.h"
#ifndef KNX_NO_AUTOMATIC_GLOBAL_INSTANCE
void buttonUp();
#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
#elif __linux__
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
#define LED_BUILTIN 0
#include "linux_platform.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
#else
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
#define LED_BUILTIN 5 // see GPIO_PinConfig gpioPinConfigs[]
#include "cc1310_platform.h"
#ifndef KNX_NO_AUTOMATIC_GLOBAL_INSTANCE
extern void buttonUp();
#endif
2018-11-07 00:32:36 +01:00
#endif
2018-03-20 23:56:42 +01:00
typedef const uint8_t* (*RestoreCallback)(const uint8_t* buffer);
typedef uint8_t* (*SaveCallback)(uint8_t* buffer);
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
typedef void (*IsrFunctionPtr)();
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
public:
KnxFacade() : _platformPtr(new P()), _bauPtr(new B(*_platformPtr)), _bau(*_bauPtr)
2019-09-09 19:07:22 +02:00
{
manufacturerId(0xfa);
bauNumber(platform().uniqueSerialNumber());
2019-09-09 19:07:22 +02:00
_bau.addSaveRestore(this);
}
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
KnxFacade(B& bau) : _bau(bau)
{
manufacturerId(0xfa);
bauNumber(platform().uniqueSerialNumber());
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
_bau.addSaveRestore(this);
}
KnxFacade(IsrFunctionPtr buttonISRFunction) : _platformPtr(new P()), _bauPtr(new B(*_platformPtr)), _bau(*_bauPtr)
{
manufacturerId(0xfa);
bauNumber(platform().uniqueSerialNumber());
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
_bau.addSaveRestore(this);
setButtonISRFunction(buttonISRFunction);
}
2019-08-22 22:57:35 +02:00
virtual ~KnxFacade()
{
if (_bauPtr)
delete _bauPtr;
if (_platformPtr)
delete _platformPtr;
}
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);
}
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
/**
* To be called by ISR handling on button press.
*/
void toggleProgMode()
{
_toggleProgMode = true;
}
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);
}
}
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
if (_toggleProgMode)
2019-08-22 22:57:35 +02:00
{
progMode(!progMode());
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
_toggleProgMode = false;
2019-08-22 22:57:35 +02:00
}
_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()
{
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
pinMode(ledPin(), OUTPUT);
2019-08-22 22:57:35 +02:00
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
digitalWrite(ledPin(), HIGH - _ledPinActiveOn);
2019-08-22 22:57:35 +02:00
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
pinMode(buttonPin(), INPUT_PULLUP);
if (_progButtonISRFuncPtr)
{
// Workaround for https://github.com/arduino/ArduinoCore-samd/issues/587
#if (ARDUINO_API_VERSION >= 10200)
attachInterrupt(_buttonPin, _progButtonISRFuncPtr, (PinStatus)_buttonPinInterruptOn);
#else
attachInterrupt(_buttonPin, _progButtonISRFuncPtr, _buttonPinInterruptOn);
#endif
}
2019-08-22 22:57:35 +02:00
enabled(true);
}
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
void setButtonISRFunction(IsrFunctionPtr progButtonISRFuncPtr)
{
_progButtonISRFuncPtr = progButtonISRFuncPtr;
}
void setSaveCallback(SaveCallback func)
2019-08-22 22:57:35 +02:00
{
_saveCallback = func;
}
void setRestoreCallback(RestoreCallback 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);
}
// paramBit(address, shift)
// get state of a parameter as a boolean like "enable/disable", ...
// Declaration in XML file:
// ...
// <ParameterType Id="M-00FA_A-0066-EA-0001_PT-toggle" Name="toggle">
// <TypeRestriction Base="Value" SizeInBit="1">
// <Enumeration Text="Désactivé" Value="0" Id="M-00FA_A-0066-EA-0001_PT-toggle_EN-0"/>
// <Enumeration Text="Activé" Value="1" Id="M-00FA_A-0066-EA-0001_PT-toggle_EN-1"/>
// </TypeRestriction>
// </ParameterType>
// ...
// <Parameter Id="M-00FA_A-0066-EA-0001_P-2" Name="Input 1" ParameterType="M-00FA_A-0066-EA-0001_PT-toggle" Text="Input 1" Value="1">
// <Memory CodeSegment="M-00FA_A-0066-EA-0001_RS-04-00000" Offset="1" BitOffset="0"/>
// </Parameter>
// <Parameter Id="M-00FA_A-0066-EA-0001_P-3" Name="Input 2" ParameterType="M-00FA_A-0066-EA-0001_PT-toggle" Text="Input 2" Value="1">
// <Memory CodeSegment="M-00FA_A-0066-EA-0001_RS-04-00000" Offset="1" BitOffset="1"/>
// </Parameter>
// <Parameter Id="M-00FA_A-0066-EA-0001_P-4" Name="Inout 3" ParameterType="M-00FA_A-0066-EA-0001_PT-toggle" Text="Input 3" Value="1">
// <Memory CodeSegment="M-00FA_A-0066-EA-0001_RS-04-00000" Offset="1" BitOffset="2"/>
// </Parameter>
// ...
// Usage in code :
// if ( knx.paramBit(1,1))
// {
// //do somthings ....
// }
bool paramBit(uint32_t addr, uint8_t shift)
{
if (!_bau.configured())
return 0;
return (bool) ((_bau.parameters().getByte(addr) >> (7-shift)) & 0x01);
}
2019-08-22 22:57:35 +02:00
uint8_t paramByte(uint32_t addr)
{
if (!_bau.configured())
return 0;
return _bau.parameters().getByte(addr);
}
// Same usage than paramByte(addresse) for signed parameters
// Declaration in XML file
// <ParameterType Id="M-00FA_A-0066-EA-0001_PT-delta" Name="delta">
// <TypeNumber SizeInBit="8" Type="signedInt" minInclusive="-10" maxInclusive="10"/>
// </ParameterType>
int8_t paramSignedByte(uint32_t addr)
{
if (!_bau.configured())
return 0;
2019-08-22 22:57:35 +02:00
return (int8_t) _bau.parameters().getByte(addr);
}
2019-08-22 22:57:35 +02:00
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);
}
double paramFloat(uint32_t addr, ParameterFloatEncodings enc)
{
if (!_bau.configured())
return 0;
return _bau.parameters().getFloat(addr, enc);
}
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;
SaveCallback _saveCallback = 0;
RestoreCallback _restoreCallback = 0;
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
volatile bool _toggleProgMode = false;
2019-08-22 22:57:35 +02:00
bool _progLedState = false;
uint16_t _saveSize = USERDATA_SAVE_SIZE;
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
IsrFunctionPtr _progButtonISRFuncPtr = 0;
2019-08-22 22:57:35 +02:00
uint8_t* save(uint8_t* buffer)
{
if (_saveCallback != 0)
return _saveCallback(buffer);
return buffer;
}
const uint8_t* restore(const uint8_t* buffer)
2019-08-22 22:57:35 +02:00
{
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
};
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
#ifndef KNX_NO_AUTOMATIC_GLOBAL_INSTANCE
#ifdef ARDUINO_ARCH_SAMD
// 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;
#else
#error "Mask version not supported on ARDUINO_ARCH_SAMD"
#endif
#elif defined(ARDUINO_ARCH_RP2040)
// predefined global instance for TP or RF or TP/RF coupler
#if MASK_VERSION == 0x07B0
extern KnxFacade<RP2040ArduinoPlatform, Bau07B0> knx;
#elif MASK_VERSION == 0x27B0
extern KnxFacade<RP2040ArduinoPlatform, Bau27B0> knx;
#elif MASK_VERSION == 0x2920
extern KnxFacade<RP2040ArduinoPlatform, Bau2920> knx;
#else
#error "Mask version not supported on ARDUINO_ARCH_RP2040"
#endif
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
#elif defined(ARDUINO_ARCH_ESP8266)
// predefined global instance for TP or IP or TP/IP coupler
#if MASK_VERSION == 0x07B0
extern KnxFacade<EspPlatform, Bau07B0> knx;
#elif MASK_VERSION == 0x57B0
extern KnxFacade<EspPlatform, Bau57B0> knx;
#elif MASK_VERSION == 0x091A
extern KnxFacade<EspPlatform, Bau091A> knx;
#else
#error "Mask version not supported on ARDUINO_ARCH_ESP8266"
#endif
#elif defined(ARDUINO_ARCH_ESP32)
// 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;
#else
#error "Mask version not supported on ARDUINO_ARCH_ESP32"
#endif
#elif defined(ARDUINO_ARCH_STM32)
// predefined global instance for TP only
#if MASK_VERSION == 0x07B0
extern KnxFacade<Stm32Platform, Bau07B0> knx;
#else
#error "Mask version not supported on ARDUINO_ARCH_STM32"
#endif
#else // Non-Arduino platforms and Linux platform
// no predefined global instance
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
opt-out global KNX, ability to DIY construct knx object, minor cleanups (#121) * Refactored the knx_facade a bit to make the auto-building of the global knx object and the buttonUp() ISR function opt-in. Also added the ability to quite easily attach another serial (in this case tested with Serial2 of an ESP32). * Added visual studio code temp files to .gitignore * Fix for missing build flag for WifiManager in ESP32_ip demo * Added example in which we DIY build the KNX object and use ESP32's second UART to connect so that you can debug with the first one that's connected to USB. * Minor platform cleanups to remove compilation warnings. * ESP32 can't handle the defaulted 8192 byte EPROM. Next to that I needed to begin() the eprom lib in my setup() to get it to work and that requires knowing how much memory KNX will use. This fix makes the default more conservative and moves it's definition to the .h file so that other files can always use it as well. * After comments from thelsing, inverted the logic. The default global knx object is now opt-out by defining KNX_NO_AUTOMATIC_GLOBAL_INSTANCE. See the knx-demo-diy project for an example. Minor syntactic cleanups. * Removed hardwareserial from facade (detail which was not needed) Placed facade constructors together Minor syntactic cleanup * Fixed knx-cc1310 where own button routine was calling now private internal knx facade variable. Renamed files in knx-demo-diy Minor syntactic stuff * Added gitattributes for binary knxprod files
2021-02-05 15:57:45 +01:00
#endif // KNX_NO_AUTOMATIC_GLOBAL_INSTANCE