1 /*
2  * Copyright (c) 2021-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 DISC_NSTACKX_ADAPTER_H
17 #define DISC_NSTACKX_ADAPTER_H
18 
19 #include <stdint.h>
20 #include "disc_manager.h"
21 
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif
26 #endif
27 
28 typedef enum {
29     INVALID_MODE = -1,
30     ACTIVE_PUBLISH = 0,
31     ACTIVE_DISCOVERY,
32 } DiscCoapMode;
33 
34 typedef struct {
35     bool isPublish;
36     union {
37         PublishOption publishOption;
38         SubscribeOption subscribeOption;
39     } option;
40 } DiscOption;
41 
42 typedef struct {
43     int32_t freq;
44     DiscCoapMode mode;
45     uint32_t capability;
46     uint32_t allCap;
47 } DiscCoapOption;
48 
49 int32_t DiscNstackxInit(void);
50 void DiscNstackxDeinit(void);
51 
52 int32_t DiscCoapRegisterCb(const DiscInnerCallback *discCoapCb);
53 int32_t DiscCoapRegisterCapability(uint32_t capabilityBitmapNum, uint32_t capabilityBitmap[]);
54 int32_t DiscCoapSetFilterCapability(uint32_t capabilityBitmapNum, uint32_t capabilityBitmap[]);
55 int32_t DiscCoapRegisterServiceData(const PublishOption *option, uint32_t allCap);
56 int32_t DiscCoapRegisterCapabilityData(const unsigned char *capabilityData, uint32_t dataLen, uint32_t capability);
57 int32_t DiscCoapStartDiscovery(DiscCoapOption *option);
58 int32_t DiscCoapStopDiscovery(void);
59 void DiscCoapUpdateLocalIp(LinkStatus status);
60 void DiscCoapUpdateDevName(void);
61 void DiscCoapUpdateAccount(void);
62 int32_t DiscCoapSendRsp(const DeviceInfo *deviceInfo, uint8_t bType);
63 
64 #ifdef __cplusplus
65 #if __cplusplus
66 }
67 #endif /* __cplusplus */
68 #endif /* __cplusplus */
69 
70 #endif // !DISC_NSTACKX_ADAPTER_H
71