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