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 (*onProfileChanged)(CIProfileEventCb* cb, const CProfileChangeNotification* notification); 71 }; 72 73 enum CSyncMode : int32_t { 74 PULL, 75 PUSH, 76 PUSH_PULL, 77 }; 78 79 struct CSyncOptions { 80 CSyncMode syncMode; 81 const char *const* deviceIds; 82 size_t nDeviceIds; 83 }; 84 85 #ifdef __cplusplus 86 extern "C" { 87 #endif /* __cplusplus */ 88 89 int32_t PutDeviceProfile(const CServiceCharacteristicProfile* profile); 90 int32_t GetDeviceProfile(const char* udId, const char* serviceId, CServiceCharacteristicProfile* profile); 91 int32_t SubscribeProfileEvents(const CISubscribeInfos* subscribeInfos, 92 CIProfileEventCb* eventCb, 93 CIProfileEvents** failedEvents); 94 int32_t UnsubscribeProfileEvents(const CIProfileEvents* profileEvents, 95 CIProfileEventCb* eventCb, 96 CIProfileEvents** failedEvents); 97 98 #ifdef __cplusplus 99 } 100 #endif /* __cplusplus */ 101 #endif // FUSION_DEVICE_PROFILE_H 102