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 
18 #include "comm_log.h"
19 #include "softbus_adapter_range.h"
20 #include "softbus_errcode.h"
21 
22 #define MOCK_POWER (-17)
23 #define DB_BASE (10.0)
24 #define DB_COEFFICIENT (20.0)
25 
SoftBusBleRange(SoftBusRangeParam * param,int32_t * range)26 int SoftBusBleRange(SoftBusRangeParam *param, int32_t *range)
27 {
28     if (param == NULL || range == NULL) {
29         COMM_LOGE(COMM_ADAPTER, "SoftBusBleRange param is null.");
30         return SOFTBUS_INVALID_PARAM;
31     }
32 
33     *range = (int32_t)pow(DB_BASE, param->rssi * -1 / DB_COEFFICIENT);
34     return SOFTBUS_OK;
35 }
36 
SoftBusGetBlePower(int8_t * power)37 int SoftBusGetBlePower(int8_t *power)
38 {
39     if (power == NULL) {
40         COMM_LOGE(COMM_ADAPTER, "SoftBusGetBlePower param is null.");
41         return SOFTBUS_INVALID_PARAM;
42     }
43     *power = MOCK_POWER;
44     return SOFTBUS_OK;
45 }