• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <bluetooth/log.h>
20 
21 #include <cstdint>
22 
23 class LeConnectionParameters {
24 public:
25   static constexpr uint16_t kAggressiveConnThreshold = 2;
26   static constexpr uint16_t kMinConnIntervalAggressive = 0x0008;  // 8, *1.25 becomes 10ms
27   static constexpr uint16_t kMaxConnIntervalAggressive = 0x0010;  // 16, *1.25 becomes 20ms
28   static constexpr uint16_t kMinConnIntervalRelaxed = 0x0018;     // 24, *1.25 becomes 30ms
29   static constexpr uint16_t kMaxConnIntervalRelaxed = 0x0028;     // 40, *1.25 becomes 50ms
30 
31   static const std::string kPropertyAggressiveConnThreshold;
32   static const std::string kPropertyMinConnIntervalAggressive;
33   static const std::string kPropertyMaxConnIntervalAggressive;
34   static const std::string kPropertyMinConnIntervalRelaxed;
35   static const std::string kPropertyMaxConnIntervalRelaxed;
36 
37   static void InitConnParamsWithSystemProperties();
38   static uint32_t GetAggressiveConnThreshold();
39   static uint32_t GetMinConnIntervalAggressive();
40   static uint32_t GetMaxConnIntervalAggressive();
41   static uint32_t GetMinConnIntervalRelaxed();
42   static uint32_t GetMaxConnIntervalRelaxed();
43 
44 private:
45   static bool initialized;
46   static uint32_t aggressive_conn_threshold;
47   static uint32_t min_conn_interval_aggressive;
48   static uint32_t max_conn_interval_aggressive;
49   static uint32_t min_conn_interval_relaxed;
50   static uint32_t max_conn_interval_relaxed;
51 };
52