Add OpenKNX IDF component with TPUart integration
- Created CMakeLists.txt for the OpenKNX IDF component, ensuring dependencies on OpenKNX and TPUart submodules. - Implemented Arduino compatibility header for basic functions like millis, delay, pinMode, and digitalRead. - Developed EspIdfPlatform class for network interface management and multicast communication. - Added EtsMemoryLoader for loading ETS memory snapshots and managing associations. - Introduced TpuartUartInterface for UART communication with methods for reading, writing, and managing callbacks. - Implemented arduino_compat.cpp for Arduino-like functionality on ESP-IDF. - Created source files for platform and memory loader implementations. - Updated submodules for knx, knx_dali_gw, and tpuart. Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#include "openknx_idf/ets_memory_loader.h"
|
||||
|
||||
#include "openknx_idf/esp_idf_platform.h"
|
||||
|
||||
#include "knx/bau07B0.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace gateway::openknx {
|
||||
namespace {
|
||||
|
||||
void CollectAssociation(uint16_t group_address, uint16_t group_object_number,
|
||||
void* context) {
|
||||
auto* associations = static_cast<std::vector<EtsAssociation>*>(context);
|
||||
if (associations == nullptr) {
|
||||
return;
|
||||
}
|
||||
associations->push_back(EtsAssociation{group_address, group_object_number});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
EtsMemorySnapshot LoadEtsMemorySnapshot(const std::string& nvs_namespace) {
|
||||
EspIdfPlatform platform(nullptr, nvs_namespace.c_str());
|
||||
Bau07B0 device(platform);
|
||||
device.deviceObject().manufacturerId(0xfa);
|
||||
device.deviceObject().bauNumber(platform.uniqueSerialNumber());
|
||||
device.readMemory();
|
||||
|
||||
EtsMemorySnapshot snapshot;
|
||||
snapshot.configured = device.configured();
|
||||
device.forEachEtsAssociation(CollectAssociation, &snapshot.associations);
|
||||
std::sort(snapshot.associations.begin(), snapshot.associations.end(),
|
||||
[](const EtsAssociation& lhs, const EtsAssociation& rhs) {
|
||||
if (lhs.group_address != rhs.group_address) {
|
||||
return lhs.group_address < rhs.group_address;
|
||||
}
|
||||
return lhs.group_object_number < rhs.group_object_number;
|
||||
});
|
||||
snapshot.associations.erase(
|
||||
std::unique(snapshot.associations.begin(), snapshot.associations.end(),
|
||||
[](const EtsAssociation& lhs, const EtsAssociation& rhs) {
|
||||
return lhs.group_address == rhs.group_address &&
|
||||
lhs.group_object_number == rhs.group_object_number;
|
||||
}),
|
||||
snapshot.associations.end());
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
} // namespace gateway::openknx
|
||||
Reference in New Issue
Block a user