feat(gateway_bacnet): enhance BACnet object binding with out_of_service and reliability fields

feat(gateway_bacnet): add functions to clear BACnet objects and set their states

feat(gateway_bridge): implement discovery inventory management and scanning functionality

fix(gateway_bridge): update handleGet to support new inventory and effective model actions

refactor(gateway_bridge): improve BACnet binding handling and reliability reporting

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Tony
2026-05-02 21:16:32 +08:00
parent fa2eae87cf
commit 30a96c5125
7 changed files with 810 additions and 32 deletions
@@ -124,6 +124,8 @@ struct GatewayBacnetServer::RuntimeBinding {
uint32_t object_instance{0};
std::string model_id;
std::string property{"presentValue"};
bool out_of_service{false};
uint32_t reliability{0};
GatewayBacnetWriteCallback write_callback;
};
@@ -168,12 +170,9 @@ esp_err_t GatewayBacnetServer::registerChannel(
bindings.erase(std::remove_if(bindings.begin(), bindings.end(), [](const auto& binding) {
return !IsSupportedObjectType(binding.object_type) ||
binding.object_instance > kMaxBacnetInstance;
binding.object_instance > kMaxBacnetInstance;
}),
bindings.end());
if (bindings.empty()) {
return ESP_ERR_NOT_FOUND;
}
LockGuard guard(lock_);
if (started_ && !configCompatible(config)) {
@@ -183,6 +182,9 @@ esp_err_t GatewayBacnetServer::registerChannel(
auto channel = std::find_if(channels_.begin(), channels_.end(), [gateway_id](const auto& item) {
return item.gateway_id == gateway_id;
});
if (bindings.empty() && !started_ && channel == channels_.end()) {
return ESP_ERR_NOT_FOUND;
}
ChannelRegistration registration{gateway_id, config, std::move(bindings),
std::move(write_callback)};
if (channel == channels_.end()) {
@@ -240,6 +242,10 @@ esp_err_t GatewayBacnetServer::rebuildObjectsLocked() {
runtime_bindings_.clear();
std::set<std::pair<BridgeObjectType, uint32_t>> used_objects;
if (!gateway_bacnet_stack_clear_objects()) {
return ESP_FAIL;
}
for (const auto& channel : channels_) {
for (const auto& binding : channel.bindings) {
const auto key = std::make_pair(binding.object_type, binding.object_instance);
@@ -254,7 +260,9 @@ esp_err_t GatewayBacnetServer::rebuildObjectsLocked() {
const std::string name = ObjectName(binding);
if (!gateway_bacnet_stack_upsert_object(ToBacnetKind(binding.object_type),
binding.object_instance, name.c_str(),
binding.model_id.c_str())) {
binding.model_id.c_str(),
binding.out_of_service,
binding.reliability)) {
return ESP_FAIL;
}
runtime_bindings_.push_back(RuntimeBinding{channel.gateway_id,
@@ -263,6 +271,8 @@ esp_err_t GatewayBacnetServer::rebuildObjectsLocked() {
binding.model_id,
binding.property.empty() ? "presentValue"
: binding.property,
binding.out_of_service,
binding.reliability,
channel.write_callback});
}
}