• 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 SOFTBUS_ADAPTER_RANGE_H
17 #define SOFTBUS_ADAPTER_RANGE_H
18 
19 #include <stdint.h>
20 
21 #include "ble_range.h"
22 #include "softbus_utils.h"
23 
24 #ifdef __cplusplus
25 #if __cplusplus
26 extern "C" {
27 #endif
28 #endif
29 
30 #define SOFTBUS_DEV_IDENTITY_LEN 96
31 // valid value of power is [-128, 10], 11 is considered to be illegal.
32 #define SOFTBUS_ILLEGAL_BLE_POWER 11
33 #define SOFTBUS_MODEL_ID_LEN (HEXIFY_LEN(3))
34 #define SOFTBUS_SUB_MODEL_ID_LEN (HEXIFY_LEN(1))
35 #define SOFTBUS_NEW_MODEL_ID_LEN (HEXIFY_LEN(4))
36 #define SOFTBUS_MODEL_NAME_LEN (HEXIFY_LEN(8))
37 #define NETWORK_ID_BUF_LEN 65
38 
39 typedef enum {
40     MODULE_BLE_DISCOVERY = 1,
41     MODULE_BLE_HEARTBEAT,
42     MODULE_BLE_APPROACH,
43     MODULE_SLE_CONNECTION,
44     MODULE_UWB,
45 } SoftBusRangeModule;
46 
47 typedef enum {
48     RANGE_SERVICE_DEFAULT = 0,
49     RANGE_SERVICE_TOUCH,
50     RANGE_SERVICE_VLINK,
51     RANGE_SERVICE_BUTT,
52 } SoftBusRangeBusinessType;
53 
54 typedef struct {
55     int8_t power;
56     bool isCycle;
57     bool isSupportNearLink;
58     char identity[SOFTBUS_DEV_IDENTITY_LEN];
59     char modelId[SOFTBUS_MODEL_ID_LEN];
60     char subModelId[SOFTBUS_SUB_MODEL_ID_LEN];
61     char newModelId[SOFTBUS_NEW_MODEL_ID_LEN];
62     char modelName[SOFTBUS_MODEL_NAME_LEN];
63     int32_t rssi;
64     SoftBusRangeBusinessType serviceType;
65 } SoftBusRangeParam;
66 
67 typedef struct {
68     SoftBusRangeModule module;
69 } SoftBusRangeHandle;
70 
71 typedef struct {
72     void (*onRangeResult)(SoftBusRangeHandle handle, const RangeResult *result);
73 } SoftBusRangeCallback;
74 
75 int SoftBusBleRange(SoftBusRangeParam *param, int32_t *range);
76 int SoftBusGetBlePower(int8_t *power);
77 int32_t SoftBusGetAdvPower(int8_t *power);
78 
79 int32_t SoftBusBleRangeAsync(const SoftBusRangeParam *param);
80 int32_t SoftBusRegRangeCb(SoftBusRangeModule module, const SoftBusRangeCallback *callback);
81 void SoftBusUnregRangeCb(SoftBusRangeModule module);
82 
83 #ifdef __cplusplus
84 #if __cplusplus
85 }
86 #endif /* __cplusplus */
87 #endif /* __cplusplus */
88 
89 #endif /* SOFTBUS_ADAPTER_RANGE_H */
90