• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 <string>
21 
22 #include "dm_app_image_info.h"
23 
24 #define DM_MAX_DEVICE_ID_LEN (96)
25 #define DM_MAX_DEVICE_NAME_LEN (128)
26 
27 namespace OHOS {
28 namespace DistributedHardware {
29 /**
30  * @brief Device manager event notify.
31  */
32 typedef enum DmNotifyEvent {
33     /**
34      * Device manager start event.
35      */
36     DM_NOTIFY_EVENT_START = 0,
37     /**
38      * Device manager on ready event.
39      */
40     DM_NOTIFY_EVENT_ONDEVICEREADY,
41     // Add event here
42     DM_NOTIFY_EVENT_BUTT,
43 } DmNotifyEvent;
44 
45 /**
46  * @brief Device Type definitions.
47  */
48 typedef enum DmDeviceType {
49     /**
50      * Indicates an unknown device type.
51      */
52     DEVICE_TYPE_UNKNOWN = 0x00,
53     /**
54      * Indicates a smart camera.
55      */
56     DEVICE_TYPE_WIFI_CAMERA = 0x08,
57     /**
58      * Indicates a smart speaker.
59      */
60     DEVICE_TYPE_AUDIO = 0x0A,
61     /**
62      * Indicates a smart pc.
63      */
64     DEVICE_TYPE_PC = 0x0C,
65     /**
66      * Indicates a smart phone.
67      */
68     DEVICE_TYPE_PHONE = 0x0E,
69     /**
70      * Indicates a smart pad.
71      */
72     DEVICE_TYPE_PAD = 0x11,
73     /**
74      * Indicates a smart watch.
75      */
76     DEVICE_TYPE_WATCH = 0x6D,
77     /**
78      * Indicates a car.
79      */
80     DEVICE_TYPE_CAR = 0x83,
81     /**
82      * Indicates a smart TV.
83      */
84     DEVICE_TYPE_TV = 0x9C,
85     /**
86      * Indicates smart display
87     */
88     DEVICE_TYPE_SMART_DISPLAY = 0xA02,
89 } DmDeviceType;
90 
91 /**
92  * @brief Device state change event definition.
93  */
94 typedef enum DmDeviceState {
95     /**
96      * Device status is unknown.
97      */
98     DEVICE_STATE_UNKNOWN = -1,
99     /**
100      * Device online action, which indicates the device is physically online.
101      */
102     DEVICE_STATE_ONLINE = 0,
103     /**
104      * Device ready action, which indicates the information between devices has
105      * been synchronized in the Distributed Data Service (DDS) module,
106      * and the device is ready for running distributed services.
107      */
108     DEVICE_INFO_READY = 1,
109     /**
110      * Device offline action, which Indicates the device is physically offline.
111      */
112     DEVICE_STATE_OFFLINE = 2,
113     /**
114      * Device change action, which Indicates the device is physically change.
115      */
116     DEVICE_INFO_CHANGED = 3,
117 } DmDeviceState;
118 
119 /**
120  * @brief Device authentication form.
121  */
122 typedef enum DmAuthForm {
123     /**
124      * Device Auth invalid.
125      */
126     INVALID_TYPE = -1,
127     /**
128      * Peer To Peer Device auth.
129      */
130     PEER_TO_PEER = 0,
131     /**
132      * Identical Account Device auth.
133      */
134     IDENTICAL_ACCOUNT = 1,
135     /**
136      * Across Account Device auth.
137      */
138     ACROSS_ACCOUNT = 2,
139 } DmAuthForm;
140 
141 /**
142  * @brief Device Information.
143  */
144 typedef struct DmDeviceInfo {
145     /**
146      * Device Id of the device.
147      */
148     char deviceId[DM_MAX_DEVICE_ID_LEN];
149     /**
150      * Device name of the device.
151      */
152     char deviceName[DM_MAX_DEVICE_NAME_LEN];
153     /**
154      * Device type of the device.
155      */
156     uint16_t deviceTypeId;
157     /**
158      * NetworkId of the device.
159      */
160     char networkId[DM_MAX_DEVICE_ID_LEN];
161     /**
162      * The distance of discovered device, in centimeter(cm).
163      */
164     int32_t range;
165     /**
166      * NetworkType of the device.
167      */
168     int32_t networkType;
169     /**
170      * Device authentication form.
171      */
172     DmAuthForm authForm;
173 } DmDeviceInfo;
174 
175 /**
176  * @brief Device Basic Information.
177  */
178 typedef struct
179 DmDeviceBasicInfo {
180     /**
181      * Device Id of the device.
182      */
183     char deviceId[DM_MAX_DEVICE_ID_LEN];
184     /**
185      * Device name of the device.
186      */
187     char deviceName[DM_MAX_DEVICE_NAME_LEN];
188     /**
189      * Device type of the device.
190      */
191     uint16_t deviceTypeId;
192     /**
193      * NetworkId of the device.
194      */
195     char networkId[DM_MAX_DEVICE_ID_LEN];
196 } DmDeviceBasicInfo;
197 
198 /**
199  * @brief Device Authentication param.
200  */
201 typedef struct DmAuthParam {
202     /**
203      * the token used for this authentication.
204      */
205     std::string authToken;
206     /**
207      * the package name used for this authentication.
208      */
209     std::string packageName;
210     /**
211      * the app name used for this authentication.
212      */
213     std::string appName;
214     /**
215      * the app description used for this authentication.
216      */
217     std::string appDescription;
218     /**
219      * the auth type used for this authentication.
220      */
221     int32_t authType;
222     /**
223      * the business used for this authentication.
224      */
225     int32_t business;
226     /**
227      * the pin code used for this authentication.
228      */
229     int32_t pincode;
230     /**
231      * the direction used for this authentication.
232      */
233     int32_t direction;
234     /**
235      * the pin token used for this authentication.
236      */
237     int32_t pinToken;
238     /**
239      * the app image info used for this authentication.
240      */
241     DmAppImageInfo imageinfo;
242 } DmAuthParam;
243 
244 typedef enum {
245     BIT_NETWORK_TYPE_UNKNOWN = 0,  /**< Unknown network type */
246     BIT_NETWORK_TYPE_WIFI,         /**< WIFI network type */
247     BIT_NETWORK_TYPE_BLE,          /**< BLE network type */
248     BIT_NETWORK_TYPE_BR,           /**< BR network type */
249     BIT_NETWORK_TYPE_P2P,          /**< P2P network type */
250     BIT_NETWORK_TYPE_COUNT,        /**< Invalid type */
251 } DmNetworkType;
252 
253 const std::string DEVICE_TYPE_UNKNOWN_STRING = "UNKNOWN";
254 const std::string DEVICE_TYPE_PHONE_STRING = "PHONE";
255 const std::string DEVICE_TYPE_PAD_STRING = "PAD";
256 const std::string DEVICE_TYPE_TV_STRING = "TV";
257 const std::string DEVICE_TYPE_CAR_STRING = "CAR";
258 const std::string DEVICE_TYPE_WATCH_STRING = "WATCH";
259 const std::string DEVICE_TYPE_WIFICAMERA_STRING = "WiFiCamera";
260 const std::string DEVICE_TYPE_PC_STRING = "PC";
261 const std::string DEVICE_TYPE_SMART_DISPLAY_STRING = "SMART_DISPLAY";
262 } // namespace DistributedHardware
263 } // namespace OHOS
264 #endif // OHOS_DM_DEVICE_INFO_H
265