[feat]:Add virtual connection BLE

Signed-off-by: huxianghao <huxianghao@huawei.com>
This commit is contained in:
huxianghao 2024-05-25 08:24:45 +00:00
parent fe6a080834
commit f684b57586
8 changed files with 185 additions and 5 deletions

View File

@ -91,6 +91,7 @@ typedef enum {
SRV_TYPE_LP_BURST, // The service type is burst for lowpower.
SRV_TYPE_LP_HB, // The service type is heartbeat for lowpower.
SRV_TYPE_FAST_OFFLINE, // The service type is fast offline.
SRV_TYPE_VLINK, // The service type is virtual link discovery.
SRV_TYPE_BUTT,
} BaseServiceType;
@ -125,6 +126,7 @@ static const SrvTypeMap g_srvTypeMap[] = {
{SRV_TYPE_LP_BURST, (char *)"lp burst"},
{SRV_TYPE_LP_HB, (char *)"lp heartbeat"},
{SRV_TYPE_FAST_OFFLINE, (char *)"fast offline"},
{SRV_TYPE_VLINK, (char *)"virtual link"}
};
/**

View File

@ -38,6 +38,7 @@ typedef enum {
EVENT_STAGE_SOFTBUS_BLE_INIT = 2,
EVENT_STAGE_SHARE_BLE_INIT = 3,
EVENT_STAGE_APPROACH_BLE_INIT = 4,
EVENT_STAGE_VLINK_BLE_INIT = 5,
} DiscEventInitStage;
typedef enum {

View File

@ -29,6 +29,7 @@ ble_discovery_inc = [
"$dsoftbus_root_path/core/discovery/ble/approach_ble/include",
"$dsoftbus_root_path/core/discovery/ble/share_ble/include",
"$dsoftbus_root_path/core/discovery/ble/softbus_ble/include",
"$dsoftbus_root_path/core/discovery/ble/virtual_link_ble/include",
"$dsoftbus_root_path/core/common/include",
"$dsoftbus_root_path/core/common/dfx/hisysevent_adapter/include",
]
@ -54,13 +55,17 @@ if (disc_enhanced) {
"$dsoftbus_root_path/dsoftbus_enhance/core/discovery/ble/approach_ble/approach_ble.gni")
import(
"$dsoftbus_root_path/dsoftbus_enhance/core/discovery/ble/share_ble/share_ble.gni")
import(
"$dsoftbus_root_path/dsoftbus_enhance/core/discovery/ble/virtual_link_ble/virtual_link_ble.gni")
ble_discovery_src += share_sources + approach_sources
ble_discovery_inc += share_include_dirs + approach_include_dirs
ble_discovery_deps += share_deps + approach_deps
ble_discovery_src += share_sources + approach_sources + vlink_sources
ble_discovery_inc +=
share_include_dirs + approach_include_dirs + vlink_include_dirs
ble_discovery_deps += share_deps + approach_deps + vlink_deps
} else {
ble_discovery_src += [
"$dsoftbus_root_path/core/discovery/ble/share_ble/src/disc_share_ble_virtual.c",
"$dsoftbus_root_path/core/discovery/ble/approach_ble/src/disc_approach_ble_virtual.c",
"$dsoftbus_root_path/core/discovery/ble/virtual_link_ble/src/disc_virtual_link_ble_virtual.c",
]
}

View File

@ -20,9 +20,10 @@
#include "disc_log.h"
#include "disc_manager.h"
#include "disc_share_ble.h"
#include "disc_virtual_link_ble.h"
#include "softbus_errcode.h"
#define DISPATCHER_SIZE 3
#define DISPATCHER_SIZE 4
static DiscoveryBleDispatcherInterface *g_dispatchers[DISPATCHER_SIZE];
static uint32_t g_dispatcherSize = 0;
@ -227,6 +228,15 @@ DiscoveryFuncInterface *DiscBleInit(DiscInnerCallback *discInnerCb)
g_dispatchers[g_dispatcherSize++] = approachInterface;
DfxRecordBleInitEnd(EVENT_STAGE_APPROACH_BLE_INIT, SOFTBUS_OK);
DiscoveryBleDispatcherInterface *vlinkInterface = DiscVLinkBleInit(discInnerCb);
if (vlinkInterface == NULL) {
DfxRecordBleInitEnd(EVENT_STAGE_VLINK_BLE_INIT, SOFTBUS_DISCOVER_MANAGER_INIT_FAIL);
DISC_LOGE(DISC_INIT, "DiscVLinkBleInit err");
return NULL;
}
g_dispatchers[g_dispatcherSize++] = vlinkInterface;
DfxRecordBleInitEnd(EVENT_STAGE_VLINK_BLE_INIT, SOFTBUS_OK);
DfxRecordBleInitEnd(EVENT_STAGE_INIT, SOFTBUS_OK);
return &g_discBleFrameFuncInterface;
}

View File

@ -0,0 +1,34 @@
/*
* 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.
*/
#ifndef DISC_VIRTUAL_LINK_BLE_H
#define DISC_VIRTUAL_LINK_BLE_H
#include "disc_ble_dispatcher.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
DiscoveryBleDispatcherInterface *DiscVLinkBleInit(DiscInnerCallback *discInnerCb);
void DiscVLinkBleDeinit(void);
int32_t DiscVLinkBleEventInit(void);
void DiscVLinkBleEventDeinit(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* DISC_VIRTUAL_LINK_BLE_H */

View File

@ -0,0 +1,120 @@
/*
* 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 "disc_virtual_link_ble.h"
#include "disc_manager.h"
#include "softbus_errcode.h"
static bool IsConcern(uint32_t capability)
{
(void)capability;
return false;
}
static int32_t StartSubscribe(const SubscribeOption *option)
{
(void)option;
return SOFTBUS_NOT_IMPLEMENT;
}
static int32_t StopSubscribe(const SubscribeOption *option)
{
(void)option;
return SOFTBUS_NOT_IMPLEMENT;
}
static int32_t StartPublish(const PublishOption *option)
{
(void)option;
return SOFTBUS_NOT_IMPLEMENT;
}
static int32_t StopPublish(const PublishOption *option)
{
(void)option;
return SOFTBUS_NOT_IMPLEMENT;
}
static int32_t StartScan(const PublishOption *option)
{
(void)option;
return SOFTBUS_NOT_IMPLEMENT;
}
static int32_t StopScan(const PublishOption *option)
{
(void)option;
return SOFTBUS_NOT_IMPLEMENT;
}
static int32_t StartAdvertise(const SubscribeOption *option)
{
(void)option;
return SOFTBUS_NOT_IMPLEMENT;
}
static int32_t StopAdvertise(const SubscribeOption *option)
{
(void)option;
return SOFTBUS_NOT_IMPLEMENT;
}
static void LinkStatusChanged(LinkStatus status)
{
(void)status;
}
static void UpdateLocalDeviceInfo(InfoTypeChanged type)
{
(void)type;
}
static DiscoveryFuncInterface g_discVLinkInterface = {
.Subscribe = StartSubscribe,
.Unsubscribe = StopSubscribe,
.Publish = StartPublish,
.Unpublish = StopPublish,
.StartScan = StartScan,
.StopScan = StopScan,
.StartAdvertise = StartAdvertise,
.StopAdvertise = StopAdvertise,
.LinkStatusChanged = LinkStatusChanged,
.UpdateLocalDeviceInfo = UpdateLocalDeviceInfo
};
static DiscoveryBleDispatcherInterface g_vLinkBleInterface = {
.IsConcern = IsConcern,
.mediumInterface = &g_discVLinkInterface,
};
DiscoveryBleDispatcherInterface *DiscVLinkBleInit(DiscInnerCallback *discInnerCb)
{
(void)discInnerCb;
return &g_vLinkBleInterface;
}
void DiscVLinkBleDeinit(void)
{
}
int32_t DiscVLinkBleEventInit(void)
{
return SOFTBUS_OK;
}
void DiscVLinkBleEventDeinit(void)
{
}

View File

@ -16,6 +16,7 @@
#include "disc_approach_ble.h"
#include "disc_event_manager.h"
#include "disc_log.h"
#include "disc_virtual_link_ble.h"
#include "softbus_error_code.h"
int32_t DiscEventManagerInit(void)
@ -23,6 +24,9 @@ int32_t DiscEventManagerInit(void)
int32_t ret = DiscApproachBleEventInit();
DISC_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, DISC_INIT, "init approach ble event failed");
ret = DiscVLinkBleEventInit();
DISC_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, DISC_INIT, "init vlink ble event failed");
DISC_LOGI(DISC_INIT, "disc event manager init succ");
return SOFTBUS_OK;
}
@ -30,5 +34,6 @@ int32_t DiscEventManagerInit(void)
void DiscEventManagerDeinit(void)
{
DiscApproachBleEventDeinit();
DiscVLinkBleEventDeinit();
}

View File

@ -367,7 +367,9 @@ typedef enum {
/**Share capability */
SHARE_CAPABILITY_BITMAP,
/**Approach capability */
APPROACH_CAPABILITY_BITMAP
APPROACH_CAPABILITY_BITMAP,
/**virtual link capability */
VLINK_CAPABILITY_BITMAP
} DataBitMap;
typedef struct {
@ -401,6 +403,7 @@ static const CapabilityMap g_capabilityMap[] = {
{OSD_CAPABILITY_BITMAP, (char *)"osdCapability"},
{SHARE_CAPABILITY_BITMAP, (char *)"share"},
{APPROACH_CAPABILITY_BITMAP, (char *)"approach"},
{VLINK_CAPABILITY_BITMAP, (char *)"virtualLink"}
};
/**