【001】OpenHarmony3.2 设备发现-设备管理结构体DeviceInfo分析

一、DeviceInfo介绍

foundation/communication/dsoftbus/interfaces/kits/common/softbus_common.h

/**
 * @brief Defines the device information returned by IDiscoveryCallback.
 *
 */
typedef struct {
    /** Device ID. Its maximum length is specified by {@link DISC_MAX_DEVICE_ID_LEN}. */
    char devId[DISC_MAX_DEVICE_ID_LEN];
    /** Account hash code. Its maximum length is specified by {@link MAX_ACCOUNT_HASH_LEN}. */
    char accountHash[MAX_ACCOUNT_HASH_LEN];
    /** Device type. For details, see {@link DeviceType}. */
    DeviceType devType;
    /** Device name. Its maximum length is specified by {@link DISC_MAX_DEVICE_NAME_LEN}. */
    char devName[DISC_MAX_DEVICE_NAME_LEN];
    /** Number of available connections */
    unsigned int addrNum;
    /** Connection information. For details, see {@link ConnectAddr}. */
    ConnectionAddr addr[CONNECTION_ADDR_MAX];
    /** Number of capabilities */
    unsigned int capabilityBitmapNum;
    /** Device capability bitmap.
     * The maximum number of capabilities in the bitmap is specified by {@link DISC_MAX_CAPABILITY_NUM}.
     */
    unsigned int capabilityBitmap[DISC_MAX_CAPABILITY_NUM];
    /** Custom data. Its length is specified by {@link DISC_MAX_CUST_DATA_LEN}. */
    char custData[DISC_MAX_CUST_DATA_LEN];
} DeviceInfo;
#ifdef __cplusplus
}

二、DeviceInfo字段介绍

序号 字段 类型 含义
1 devId[DISC_MAX_DEVICE_ID_LEN] char 设备的ID
2 accountHash
3 devType enum 设备类型
4 devName[DISC_MAX_DEVICE_NAME_LEN] char 设备名称
5 addrNum int 该设备可以连接地址数量
6 addr[CONNECTION_ADDR_MAX] ConnectionAddr 具体的地址内容
7 capabilityBitmapNum 此设备有多少能力
8 capabilityBitmap[DISC_MAX_CAPABILITY_NUM] 支持哪几种能力
9 custData[DISC_MAX_CUST_DATA_LEN] 用户自定义数据

三、其他

3.1 devType类别

/**
 * @brief Enumerates device types.
 *
 */
typedef enum {
    /* Smart speaker */
    SMART_SPEAKER = 0x00,
    /* PC */
    DESKTOP_PC,
    /* Laptop */
    LAPTOP,
    /* Mobile phone */
    SMART_PHONE,
    /* Tablet */
    SMART_PAD,
    /* Smart watch */
    SMART_WATCH,
    /* Smart car */
    SMART_CAR,
    /* Kids' watch */
    CHILDREN_WATCH,
    /* Smart TV */
    SMART_TV,
} DeviceType;

3.2 DataBitMap结构体

/**
 * @brief Enumerates supported capabilities published by a device.
 *
 */
typedef enum {
    /** MeeTime */会议
   HICALL_CAPABILITY_BITMAP = 0,
    /** Video reverse connection in the smart domain */智能域中的视频反向连接
   PROFILE_CAPABILITY_BITMAP = 1,
    /** Gallery in Vision */视觉陈列室
   HOMEVISIONPIC_CAPABILITY_BITMAP = 2,
    /** cast+   cast+投屏技术 */
    CASTPLUS_CAPABILITY_BITMAP,
    /** Input method in Vision */
    AA_CAPABILITY_BITMAP,
    /** Device virtualization tool package */
    DVKIT_CAPABILITY_BITMAP,
    /** Distributed middleware */
    DDMP_CAPABILITY_BITMAP,
    /** Osd capability 屏幕显示*/
    OSD_CAPABILITY_BITMAP
} DataBitMap;

你可能感兴趣的:(OpenHarmony,harmonyos)