diff --git a/core/bus_center/bus_center_server.gni b/core/bus_center/bus_center_server.gni index e1df7664d..37fbb4c71 100644 --- a/core/bus_center/bus_center_server.gni +++ b/core/bus_center/bus_center_server.gni @@ -205,3 +205,19 @@ if (lk_enhanced) { bus_center_server_inc += [ "$dsoftbus_root_path/core/adapter/bus_center/include" ] } + +lnn_coap_dep_dir = "dsoftbus_enhance/core/bus_center/lnn/disc_mgr" +lnn_disc_enhanced = exec_script("$dsoftbus_root_path/check_sub_module.py", + [ + "$native_source_path", + "$lnn_coap_dep_dir", + ], + "value") + +if (dsoftbus_feature_lnn_net && lnn_disc_enhanced) { + disc_mgr_enhance_path = + "$dsoftbus_root_path/dsoftbus_enhance/core/bus_center/lnn/disc_mgr" + bus_center_server_src += [ "$disc_mgr_enhance_path/src/lnn_coap_adapter.c" ] +} else { + bus_center_server_src += [ "$dsoftbus_root_path/core/bus_center/lnn/disc_mgr/src/lnn_coap_adapter_virtual.c" ] +} diff --git a/core/bus_center/lnn/disc_mgr/include/lnn_coap_discovery_impl.h b/core/bus_center/lnn/disc_mgr/include/lnn_coap_discovery_impl.h index d920287b1..720c478b4 100644 --- a/core/bus_center/lnn/disc_mgr/include/lnn_coap_discovery_impl.h +++ b/core/bus_center/lnn/disc_mgr/include/lnn_coap_discovery_impl.h @@ -40,6 +40,14 @@ int32_t LnnStartCoapDiscovery(void); int32_t LnnStopCoapDiscovery(void); +void LnnDestroyCoapConnectList(void); + +void LnnCoapConnect(const char *ip); + +void LnnCoapConnectInit(void); + +void LnnCoapConnectDeinit(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/core/bus_center/lnn/disc_mgr/src/lnn_coap_adapter_virtual.c b/core/bus_center/lnn/disc_mgr/src/lnn_coap_adapter_virtual.c new file mode 100644 index 000000000..b1e7fc70a --- /dev/null +++ b/core/bus_center/lnn/disc_mgr/src/lnn_coap_adapter_virtual.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "lnn_coap_discovery_impl.h" + +void LnnDestroyCoapConnectList(void) +{ +} + +void LnnCoapConnect(const char *ip) +{ + (void)ip; +} + +void LnnCoapConnectInit(void) +{ +} + +void LnnCoapConnectDeinit(void) +{ +} \ No newline at end of file diff --git a/core/bus_center/lnn/disc_mgr/src/lnn_coap_discovery_impl.c b/core/bus_center/lnn/disc_mgr/src/lnn_coap_discovery_impl.c index c9e45ff3a..6de7a8cdc 100644 --- a/core/bus_center/lnn/disc_mgr/src/lnn_coap_discovery_impl.c +++ b/core/bus_center/lnn/disc_mgr/src/lnn_coap_discovery_impl.c @@ -63,6 +63,7 @@ static void DeviceFound(const DeviceInfo *device, const InnerDeviceInfoAddtions } if (device->addr[0].info.ip.port == 0) { DISC_LOGE(DISC_LNN, "discovery get port is 0!"); + LnnCoapConnect(device->addr[0].info.ip.ip); return; } addr.type = device->addr[0].type; @@ -123,6 +124,7 @@ int32_t LnnStartCoapDiscovery(void) InnerCallback callback = { .innerCb = g_discCb, }; + LnnDestroyCoapConnectList(); return LnnStartDiscDevice(NULL, &subscribeInfo, &callback, true); } diff --git a/core/bus_center/service/src/bus_center_manager.c b/core/bus_center/service/src/bus_center_manager.c index d60ae1889..cf26ad3e8 100644 --- a/core/bus_center/service/src/bus_center_manager.c +++ b/core/bus_center/service/src/bus_center_manager.c @@ -21,6 +21,7 @@ #include "bus_center_event.h" #include "bus_center_decision_center.h" #include "lnn_async_callback_utils.h" +#include "lnn_coap_discovery_impl.h" #include "lnn_decision_center.h" #include "lnn_discovery_manager.h" #include "lnn_event_monitor.h" @@ -141,6 +142,7 @@ static void BusCenterServerDelayInit(void *para) g_lnnLocalConfigInit.initDelayImpl[i].isInit = true; } } + LnnCoapConnectInit(); if (ret != SOFTBUS_OK) { retry++; SoftBusLooper *looper = GetLooper(LOOP_TYPE_DEFAULT); @@ -237,5 +239,6 @@ void BusCenterServerDeinit(void) LnnDeinitNetLedger(); DeinitDecisionCenter(); LnnDeinitMetaNode(); + LnnCoapConnectDeinit(); LNN_LOGI(LNN_INIT, "bus center server deinit"); } diff --git a/tests/core/bus_center/lnn/BUILD.gn b/tests/core/bus_center/lnn/BUILD.gn index 7b48209c6..9ff764554 100644 --- a/tests/core/bus_center/lnn/BUILD.gn +++ b/tests/core/bus_center/lnn/BUILD.gn @@ -1545,6 +1545,7 @@ ohos_unittest("LNNDiscoveryInterfaceTest") { "$dsoftbus_root_path/core/authentication/src/auth_deviceprofile_virtual.cpp", "$dsoftbus_root_path/core/authentication/src/auth_hichain_adapter.c", "$dsoftbus_root_path/core/authentication/src/auth_interface.c", + "$dsoftbus_root_path/core/bus_center/lnn/disc_mgr/src/lnn_coap_adapter_virtual.c", "$dsoftbus_root_path/core/bus_center/lnn/disc_mgr/src/lnn_discovery_interface.c", "$dsoftbus_root_path/core/bus_center/utils/src/lnn_file_utils.c", "$dsoftbus_root_path/tests/core/authentication/unittest/auth_common_mock.cpp",