1 /* 2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_DM_DEVICE_INFO_H 17 #define OHOS_DM_DEVICE_INFO_H 18 19 #include <cstdint> 20 #include <map> 21 #include <string> 22 23 #include "dm_app_image_info.h" 24 25 #define DM_MAX_DEVICE_ID_LEN (97) 26 #define DM_MAX_DEVICE_NAME_LEN (129) 27 28 namespace OHOS { 29 namespace DistributedHardware { 30 /** 31 * @brief Device manager event notify. 32 */ 33 typedef enum DmNotifyEvent { 34 /** 35 * Device manager start event. 36 */ 37 DM_NOTIFY_EVENT_START = 0, 38 /** 39 * Device manager on ready event. 40 */ 41 DM_NOTIFY_EVENT_ONDEVICEREADY, 42 /** 43 * Device manager on pin holder event. 44 */ 45 DM_NOTIFY_EVENT_ON_PINHOLDER_EVENT, 46 // Add event here 47 DM_NOTIFY_EVENT_BUTT, 48 } DmNotifyEvent; 49 50 /** 51 * @brief Device Type definitions. 52 */ 53 typedef enum DmDeviceType { 54 /** 55 * Indicates an unknown device type. 56 */ 57 DEVICE_TYPE_UNKNOWN = 0x00, 58 /** 59 * Indicates a smart camera. 60 */ 61 DEVICE_TYPE_WIFI_CAMERA = 0x08, 62 /** 63 * Indicates a smart speaker. 64 */ 65 DEVICE_TYPE_AUDIO = 0x0A, 66 /** 67 * Indicates a smart pc. 68 */ 69 DEVICE_TYPE_PC = 0x0C, 70 /** 71 * Indicates a smart phone. 72 */ 73 DEVICE_TYPE_PHONE = 0x0E, 74 /** 75 * Indicates a smart pad. 76 */ 77 DEVICE_TYPE_PAD = 0x11, 78 /** 79 * Indicates a smart watch. 80 */ 81 DEVICE_TYPE_WATCH = 0x6D, 82 /** 83 * Indicates a car. 84 */ 85 DEVICE_TYPE_CAR = 0x83, 86 /** 87 * Indicates a smart TV. 88 */ 89 DEVICE_TYPE_TV = 0x9C, 90 /** 91 * Indicates smart display 92 */ 93 DEVICE_TYPE_SMART_DISPLAY = 0xA02, 94 /** 95 * Indicates 2in1 96 */ 97 DEVICE_TYPE_2IN1 = 0xA2F, 98 THIRD_TV = 0x2E, 99 } DmDeviceType; 100 101 /** 102 * @brief Device state change event definition. 103 */ 104 typedef enum DmDeviceState { 105 /** 106 * Device status is unknown. 107 */ 108 DEVICE_STATE_UNKNOWN = -1, 109 /** 110 * Device online action, which indicates the device is physically online. 111 */ 112 DEVICE_STATE_ONLINE = 0, 113 /** 114 * Device ready action, which indicates the information between devices has 115 * been synchronized in the Distributed Data Service (DDS) module, 116 * and the device is ready for running distributed services. 117 */ 118 DEVICE_INFO_READY = 1, 119 /** 120 * Device offline action, which Indicates the device is physically offline. 121 */ 122 DEVICE_STATE_OFFLINE = 2, 123 /** 124 * Device change action, which Indicates the device is physically change. 125 */ 126 DEVICE_INFO_CHANGED = 3, 127 } DmDeviceState; 128 129 /** 130 * @brief Device authentication form. 131 */ 132 typedef enum DmAuthForm { 133 /** 134 * Device Auth invalid. 135 */ 136 INVALID_TYPE = -1, 137 /** 138 * Peer To Peer Device auth. 139 */ 140 PEER_TO_PEER = 0, 141 /** 142 * Identical Account Device auth. 143 */ 144 IDENTICAL_ACCOUNT = 1, 145 /** 146 * Across Account Device auth. 147 */ 148 ACROSS_ACCOUNT = 2, 149 } DmAuthForm; 150 151 /** 152 * @brief Device Information. 153 */ 154 typedef struct DmDeviceInfo { 155 /** 156 * Device Id of the device. 157 */ 158 char deviceId[DM_MAX_DEVICE_ID_LEN] = {0}; 159 /** 160 * Device name of the device. 161 */ 162 char deviceName[DM_MAX_DEVICE_NAME_LEN] = {0}; 163 /** 164 * Device type of the device. 165 */ 166 uint16_t deviceTypeId; 167 /** 168 * NetworkId of the device. 169 */ 170 char networkId[DM_MAX_DEVICE_ID_LEN] = {0}; 171 /** 172 * The distance of discovered device, in centimeter(cm). 173 */ 174 int32_t range; 175 /** 176 * NetworkType of the device. 177 */ 178 int32_t networkType; 179 /** 180 * Device authentication form. 181 */ 182 DmAuthForm authForm; 183 /** 184 * Extra data of the device. 185 * include json keys: "CONN_ADDR_TYPE", "BR_MAC_", "BLE_MAC", "WIFI_IP", "WIFI_PORT", "CUSTOM_DATA" 186 */ 187 std::string extraData; 188 } DmDeviceInfo; 189 190 /** 191 * @brief Device Basic Information. 192 */ 193 typedef struct 194 DmDeviceBasicInfo { 195 /** 196 * Device Id of the device. 197 */ 198 char deviceId[DM_MAX_DEVICE_ID_LEN] = {0}; 199 /** 200 * Device name of the device. 201 */ 202 char deviceName[DM_MAX_DEVICE_NAME_LEN] = {0}; 203 /** 204 * Device type of the device. 205 */ 206 uint16_t deviceTypeId; 207 /** 208 * NetworkId of the device. 209 */ 210 char networkId[DM_MAX_DEVICE_ID_LEN] = {0}; 211 } DmDeviceBasicInfo; 212 213 /** 214 * @brief Device Authentication param. 215 */ 216 typedef struct DmAuthParam { 217 /** 218 * the token used for this authentication. 219 */ 220 std::string authToken; 221 /** 222 * the package name used for this authentication. 223 */ 224 std::string packageName; 225 /** 226 * the app name used for this authentication. 227 */ 228 std::string appName; 229 /** 230 * the app description used for this authentication. 231 */ 232 std::string appDescription; 233 /** 234 * the auth type used for this authentication. 235 */ 236 int32_t authType; 237 /** 238 * the business used for this authentication. 239 */ 240 int32_t business; 241 /** 242 * the pin code used for this authentication. 243 */ 244 int32_t pincode; 245 /** 246 * the direction used for this authentication. 247 */ 248 int32_t direction; 249 /** 250 * the pin token used for this authentication. 251 */ 252 int32_t pinToken; 253 /** 254 * the app image info used for this authentication. 255 */ 256 DmAppImageInfo imageinfo; 257 } DmAuthParam; 258 259 /** 260 * @brief Peer target id Information. 261 */ 262 typedef struct PeerTargetId { 263 /** 264 * device id. 265 */ 266 std::string deviceId; 267 /** 268 * br mac address. 269 */ 270 std::string brMac; 271 /** 272 * ble mac address. 273 */ 274 std::string bleMac; 275 /** 276 * wlan ip address. 277 */ 278 std::string wifiIp; 279 /** 280 * wlan ip port. 281 */ 282 uint16_t wifiPort = 0; 283 284 bool operator==(const PeerTargetId &other) const 285 { 286 return (deviceId == other.deviceId) && (brMac == other.brMac) && 287 (bleMac == other.bleMac) && (wifiIp == other.wifiIp) && (wifiPort == other.wifiPort); 288 } 289 290 bool operator<(const PeerTargetId &other) const 291 { 292 return (deviceId < other.deviceId) || 293 (deviceId == other.deviceId && brMac < other.brMac) || 294 (deviceId == other.deviceId && brMac == other.brMac && bleMac < other.bleMac) || 295 (deviceId == other.deviceId && brMac == other.brMac && bleMac == other.bleMac && wifiIp < other.wifiIp) || 296 (deviceId == other.deviceId && brMac == other.brMac && bleMac == other.bleMac && wifiIp == other.wifiIp && 297 wifiPort < other.wifiPort); 298 } 299 } PeerTargetId; 300 301 typedef enum { 302 BIT_NETWORK_TYPE_UNKNOWN = 0, /**< Unknown network type */ 303 BIT_NETWORK_TYPE_WIFI, /**< WIFI network type */ 304 BIT_NETWORK_TYPE_BLE, /**< BLE network type */ 305 BIT_NETWORK_TYPE_BR, /**< BR network type */ 306 BIT_NETWORK_TYPE_P2P, /**< P2P network type */ 307 BIT_NETWORK_TYPE_COUNT, /**< Invalid type */ 308 } DmNetworkType; 309 310 typedef enum { 311 NUMBER_PIN_CODE = 0, 312 QR_CODE, 313 VISIBLE_LLIGHT, 314 SUPER_SONIC, 315 } DmPinType; 316 317 typedef enum { 318 CREATE = 0, 319 CREATE_RESULT, 320 DESTROY, 321 DESTROY_RESULT, 322 PIN_TYPE_CHANGE, 323 PIN_TYPE_CHANGE_RESULT, 324 } DmPinHolderEvent; 325 326 typedef enum { 327 STATUS_DM_AUTH_DEFAULT = 0, 328 STATUS_DM_AUTH_FINISH = 7, 329 STATUS_DM_SHOW_AUTHORIZE_UI = 8, 330 STATUS_DM_CLOSE_AUTHORIZE_UI = 9, 331 STATUS_DM_SHOW_PIN_DISPLAY_UI = 10, 332 STATUS_DM_CLOSE_PIN_DISPLAY_UI = 11, 333 STATUS_DM_SHOW_PIN_INPUT_UI = 12, 334 STATUS_DM_CLOSE_PIN_INPUT_UI = 13, 335 } DmAuthStatus; 336 337 const std::string DEVICE_TYPE_UNKNOWN_STRING = "UNKNOWN"; 338 const std::string DEVICE_TYPE_PHONE_STRING = "PHONE"; 339 const std::string DEVICE_TYPE_PAD_STRING = "PAD"; 340 const std::string DEVICE_TYPE_TV_STRING = "TV"; 341 const std::string DEVICE_TYPE_CAR_STRING = "CAR"; 342 const std::string DEVICE_TYPE_WATCH_STRING = "WATCH"; 343 const std::string DEVICE_TYPE_WIFICAMERA_STRING = "WiFiCamera"; 344 const std::string DEVICE_TYPE_PC_STRING = "PC"; 345 const std::string DEVICE_TYPE_SMART_DISPLAY_STRING = "SMART_DISPLAY"; 346 const std::string DEVICE_TYPE_2IN1_STRING = "2IN1"; 347 348 typedef struct DmAccessCaller { 349 std::string accountId; 350 std::string pkgName; 351 std::string networkId; 352 int32_t userId; 353 uint64_t tokenId; 354 std::string extra; 355 } DmAccessCaller; 356 357 typedef struct DmAccessCallee { 358 std::string accountId; 359 std::string networkId; 360 std::string peerId; 361 int32_t userId; 362 std::string extra; 363 } DmAccessCallee; 364 } // namespace DistributedHardware 365 } // namespace OHOS 366 #endif // OHOS_DM_DEVICE_INFO_H