Refactor KNX DALI Gateway Configuration and Update Device Parameters
- Introduced configuration macros for OEM manufacturer ID, application number, and application version in knxprod.h. - Updated product identity definitions to use the new configuration macros. - Modified device type enumeration to include additional device types. - Adjusted color space enumeration values for consistency. - Defined generated group object layout constants for memory offsets and block sizes. - Enhanced knx_dali_gw.cpp to utilize the new configuration macros for manufacturer ID and program version. - Updated the device initialization logic to reflect the new hardware and program version structures. - Removed obsolete knx_dali_gw subproject and updated related submodules. Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "security_storage.h"
|
||||
|
||||
#include "gateway_knx_internal.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_mac.h"
|
||||
#include "esp_timer.h"
|
||||
@@ -9,7 +11,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cinttypes>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
@@ -22,11 +26,7 @@ constexpr const char* kFactoryFdskKey = "factory_fdsk";
|
||||
constexpr size_t kFdskSize = 16;
|
||||
constexpr size_t kSerialSize = 6;
|
||||
constexpr size_t kFdskQrSize = 36;
|
||||
constexpr uint16_t kKnxManufacturerId = 0x00A4;
|
||||
constexpr const char* kProductIdentity = "REG1-Dali";
|
||||
constexpr const char* kManufacturerId = "00A4";
|
||||
constexpr const char* kApplicationNumber = "01";
|
||||
constexpr const char* kApplicationVersion = "05";
|
||||
constexpr const char* kDevelopmentStorage = "base_mac_derived_plain_nvs_development";
|
||||
constexpr char kFdskDerivationLabel[] = "DaliMaster REG1-Dali deterministic FDSK v1";
|
||||
constexpr uint8_t kCrc4Tab[16] = {
|
||||
@@ -38,6 +38,12 @@ constexpr char kHexAlphabet[] = "0123456789ABCDEF";
|
||||
|
||||
extern "C" void knx_platform_clear_cached_fdsk() __attribute__((weak));
|
||||
|
||||
std::string hexValue(uint32_t value, int width) {
|
||||
std::array<char, 9> buffer{};
|
||||
std::snprintf(buffer.data(), buffer.size(), "%0*" PRIX32, width, value);
|
||||
return buffer.data();
|
||||
}
|
||||
|
||||
bool ensureNvsReady() {
|
||||
const esp_err_t err = nvs_flash_init();
|
||||
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
@@ -123,8 +129,10 @@ bool loadKnxSerialNumber(uint8_t* serial) {
|
||||
return false;
|
||||
}
|
||||
|
||||
serial[0] = static_cast<uint8_t>((kKnxManufacturerId >> 8) & 0xff);
|
||||
serial[1] = static_cast<uint8_t>(kKnxManufacturerId & 0xff);
|
||||
serial[0] = static_cast<uint8_t>(
|
||||
(gateway::knx_internal::kReg1DaliManufacturerId >> 8) & 0xff);
|
||||
serial[1] = static_cast<uint8_t>(
|
||||
gateway::knx_internal::kReg1DaliManufacturerId & 0xff);
|
||||
std::copy(mac.begin() + 2, mac.end(), serial + 2);
|
||||
return true;
|
||||
}
|
||||
@@ -352,9 +360,11 @@ FactoryCertificatePayload BuildFactoryCertificatePayload() {
|
||||
}
|
||||
payload.available = true;
|
||||
payload.productIdentity = kProductIdentity;
|
||||
payload.manufacturerId = kManufacturerId;
|
||||
payload.applicationNumber = kApplicationNumber;
|
||||
payload.applicationVersion = kApplicationVersion;
|
||||
payload.manufacturerId = hexValue(gateway::knx_internal::kReg1DaliManufacturerId, 4);
|
||||
payload.applicationNumber = hexValue(
|
||||
gateway::knx_internal::kReg1DaliApplicationNumber, 2);
|
||||
payload.applicationVersion = hexValue(
|
||||
gateway::knx_internal::kReg1DaliApplicationVersion, 2);
|
||||
payload.serialNumber = info.serialNumber;
|
||||
payload.fdskLabel = info.label;
|
||||
payload.fdskQrCode = info.qrCode;
|
||||
|
||||
Reference in New Issue
Block a user