• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #include <math.h>
17 #include <stdint.h>
18 
19 #include "comm_log.h"
20 #include "softbus_adapter_range.h"
21 #include "softbus_error_code.h"
22 
23 #define MOCK_POWER (-17)
24 #define DB_BASE (10.0)
25 #define DB_COEFFICIENT (20.0)
26 
SoftBusBleRange(SoftBusRangeParam * param,int32_t * range)27 int SoftBusBleRange(SoftBusRangeParam *param, int32_t *range)
28 {
29     if (param == NULL || range == NULL) {
30         COMM_LOGE(COMM_ADAPTER, "SoftBusBleRange param is null.");
31         return SOFTBUS_INVALID_PARAM;
32     }
33 
34     *range = (int32_t)pow(DB_BASE, param->rssi * -1 / DB_COEFFICIENT);
35     return SOFTBUS_OK;
36 }
37 
SoftBusGetBlePower(int8_t * power)38 int SoftBusGetBlePower(int8_t *power)
39 {
40     if (power == NULL) {
41         COMM_LOGE(COMM_ADAPTER, "SoftBusGetBlePower param is null.");
42         return SOFTBUS_INVALID_PARAM;
43     }
44     *power = MOCK_POWER;
45     return SOFTBUS_OK;
46 }
47 
SoftBusGetAdvPower(int8_t * power)48 int32_t SoftBusGetAdvPower(int8_t *power)
49 {
50     if (power == NULL) {
51         COMM_LOGE(COMM_ADAPTER, "SoftBusGetAdvPower param is null.");
52         return SOFTBUS_INVALID_PARAM;
53     }
54     *power = MOCK_POWER;
55     return SOFTBUS_OK;
56 }
57 
SoftBusBleRangeAsync(const SoftBusRangeParam * param)58 int32_t SoftBusBleRangeAsync(const SoftBusRangeParam *param)
59 {
60     (void)param;
61     return SOFTBUS_NOT_IMPLEMENT;
62 }
63 
SoftBusRegRangeCb(SoftBusRangeModule module,const SoftBusRangeCallback * callback)64 int32_t SoftBusRegRangeCb(SoftBusRangeModule module, const SoftBusRangeCallback *callback)
65 {
66     (void)module;
67     (void)callback;
68     return SOFTBUS_NOT_IMPLEMENT;
69 }
70 
SoftBusUnregRangeCb(SoftBusRangeModule module)71 void SoftBusUnregRangeCb(SoftBusRangeModule module)
72 {
73     (void)module;
74 }