• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_MANAGER_H
17 #define DISC_MANAGER_H
18 
19 #include "disc_interface.h"
20 
21 #ifdef __cplusplus
22 #if __cplusplus
23 extern "C" {
24 #endif
25 #endif
26 
27 #define CAPABILITY_NUM 1
28 #define CAPABILITY_MAX_BITNUM 8
29 
30 typedef struct {
31     int32_t freq;
32     uint32_t capabilityBitmap[CAPABILITY_NUM];
33     unsigned char *capabilityData;
34     uint32_t dataLen;
35 } PublishOption;
36 
37 typedef struct {
38     int32_t freq;
39     bool isSameAccount;
40     bool isWakeRemote;
41     uint32_t capabilityBitmap[CAPABILITY_NUM];
42     unsigned char *capabilityData;
43     uint32_t dataLen;
44 } SubscribeOption;
45 
46 typedef struct {
47     int32_t (*Publish)(const PublishOption *option);
48     int32_t (*StartScan)(const PublishOption *option);
49     int32_t (*Unpublish)(const PublishOption *option);
50     int32_t (*StopScan)(const PublishOption *option);
51     int32_t (*StartAdvertise)(const SubscribeOption *option);
52     int32_t (*Subscribe)(const SubscribeOption *option);
53     int32_t (*Unsubscribe)(const SubscribeOption *option);
54     int32_t (*StopAdvertise)(const SubscribeOption *option);
55     void (*LinkStatusChanged)(LinkStatus status);
56 } DiscoveryFuncInterface;
57 
58 typedef struct {
59     int32_t (*OnServerDeviceFound)(const char *packageName, const DeviceInfo *device);
60 } IServerDiscInnerCallback;
61 
62 int32_t DiscPublishService(const char *packageName, const PublishInfo *info);
63 int32_t DiscUnPublishService(const char *packageName, int32_t publishId);
64 int32_t DiscStartDiscovery(const char *packageName, const SubscribeInfo *info, const IServerDiscInnerCallback *cb);
65 int32_t DiscStopDiscovery(const char *packageName, int32_t subscribeId);
66 
67 #ifdef __cplusplus
68 #if __cplusplus
69 }
70 #endif /* __cplusplus */
71 #endif /* __cplusplus */
72 
73 #endif /* DISC_MANAGER_H */