前言
在 OpenHarmony 分布式软总线当中,设备分为发现端和被发现端。发现端可以提前订阅其想要的服务,被发现端会为设备服务发现进行前期的初始化并注册设备信息,当被发现端发布服务后即可立即保存其设备信息,并开启软总线,建立总线连接。
通过阅读源码可以发现,当前 OpenHarmony 分布式软总线当中,支持蓝牙、 Wi-Fi 、USB、HiLink 等协议下的服务发布与设备发现方式。
static int32_t CallInterfaceByMedium(const DiscInfo *info, const InterfaceFuncType type)
{
switch (info->medium) {
case COAP:
return CallSpecificInterfaceFunc(&(info->option), g_discCoapInterface, info->mode, type);
case BLE:
return CallSpecificInterfaceFunc(&(info->option), g_discBleInterface, info->mode, type);
case AUTO: {
int coapRes = CallSpecificInterfaceFunc(&(info->option), g_discCoapInterface, info->mode, type);
int bleRes = CallSpecificInterfaceFunc(&(info->option), g_discBleInterface, info->mode, type);
DISC_CHECK_AND_RETURN_RET_LOG(coapRes =