• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 FUSION_DEVICE_PROFILE_H
17 #define FUSION_DEVICE_PROFILE_H
18 
19 #include <cstddef>
20 #include <cstdint>
21 
22 struct CServiceCharacteristicProfile {
23     const char* serviceId;
24     const char* serviceType;
25     const char* serviceProfileJson;
26     const char* characteristicProfileJson;
27 };
28 
29 struct CIProfileEvents {
30     CIProfileEvents* (*clone)(CIProfileEvents* cb);
31     void (*destruct)(CIProfileEvents* cb);
32     uint32_t* profileEvents;
33     size_t numOfProfileEvents;
34 };
35 
36 struct CSubscribeInfo {
37     uint32_t profileEvent;
38     const char* extraInfo;
39 };
40 
41 struct CISubscribeInfos {
42     const CSubscribeInfo* subscribeInfos;
43     size_t nSubscribeInfos;
44 };
45 
46 enum CProfileChangeType: int32_t {
47     UNKNOWN_CHANGE_TYPE,
48     INSERTED,
49     UPDATED,
50     DELETED,
51 };
52 
53 struct CProfileEntry {
54     const char* key;
55     const char* value;
56     CProfileChangeType changeType;
57     const CProfileEntry* next;
58 };
59 
60 struct CProfileChangeNotification {
61     const CProfileEntry* profileEntries;
62     size_t nProfileEntries;
63     const char* deviceId;
64     int32_t localFlag;
65 };
66 
67 struct CIProfileEventCb {
68     CIProfileEventCb* (*clone)(CIProfileEventCb* cb);
69     void (*destruct)(CIProfileEventCb* cb);
70     void (*onSyncCompleted)(CIProfileEventCb* cb, const char* deviceId, int32_t sync_result);
71     void (*onProfileChanged)(CIProfileEventCb* cb, const CProfileChangeNotification* notification);
72 };
73 
74 enum CSyncMode : int32_t {
75     PULL,
76     PUSH,
77     PUSH_PULL,
78 };
79 
80 struct CSyncOptions {
81     CSyncMode syncMode;
82     const char *const* deviceIds;
83     size_t nDeviceIds;
84 };
85 
86 #ifdef __cplusplus
87 extern "C" {
88 #endif /* __cplusplus */
89 
90 int32_t PutDeviceProfile(const CServiceCharacteristicProfile* profile);
91 int32_t GetDeviceProfile(const char* udId, const char* serviceId, CServiceCharacteristicProfile* profile);
92 int32_t SubscribeProfileEvents(const CISubscribeInfos* subscribeInfos,
93                                CIProfileEventCb* eventCb,
94                                CIProfileEvents** failedEvents);
95 int32_t UnsubscribeProfileEvents(const CIProfileEvents* profileEvents,
96                                  CIProfileEventCb* eventCb,
97                                  CIProfileEvents** failedEvents);
98 int32_t SyncDeviceProfile(const CSyncOptions* syncOptions,
99                           CIProfileEventCb* syncCb);
100 
101 #ifdef __cplusplus
102 }
103 #endif /* __cplusplus */
104 #endif // FUSION_DEVICE_PROFILE_H
105