BlueToe
an alternative GATT/BLE implementation
Loading...
Searching...
No Matches
peripheral_connection_interval_range.hpp
1#ifndef BLUETOE_PERIPHERAL_CONNECTION_INTERVAL_RANGE_HPP
2#define BLUETOE_PERIPHERAL_CONNECTION_INTERVAL_RANGE_HPP
3
4namespace bluetoe {
5 static constexpr std::uint16_t no_specific_peripheral_connection_minimum_interval = 0xFFFF;
6 static constexpr std::uint16_t no_specific_peripheral_connection_maximum_interval = 0xFFFF;
7
8 namespace details {
9 struct peripheral_connection_interval_range_meta_type {};
10
11 template <
12 std::uint16_t MinInterval,
13 std::uint16_t MaxInterval >
14 struct check_peripheral_connection_interval_range_parameters
15 {
16 static_assert( ( MinInterval >= 0x0006 && MinInterval <= 0x0C80 ) || MinInterval == no_specific_peripheral_connection_minimum_interval,
17 "Invalid value for peripheral_connection_interval_range first template parameter (MinInterval) used!" );
18
19 static_assert( ( MaxInterval >= 0x0006 && MaxInterval <= 0x0C80 ) || MaxInterval == no_specific_peripheral_connection_maximum_interval,
20 "Invalid value for peripheral_connection_interval_range second template parameter (MaxInterval) used!" );
21
22 static_assert( MinInterval <= MaxInterval || MinInterval == no_specific_peripheral_connection_minimum_interval || MaxInterval == no_specific_peripheral_connection_maximum_interval,
23 "when defining the peripheral_connection_interval_range, the minimum shall not be greater than the maximum value!" );
24
25 typedef void type;
26 };
27
28 struct no_peripheral_connection_interval_range
29 {
30 typedef peripheral_connection_interval_range_meta_type meta_type;
31
32 static std::uint8_t* advertising_data( std::uint8_t* begin, std::uint8_t* )
33 {
34 return begin;
35 }
36 };
37 }
38
47 template <
48 std::uint16_t MinInterval = no_specific_peripheral_connection_minimum_interval,
49 std::uint16_t MaxInterval = no_specific_peripheral_connection_maximum_interval,
50 typename = typename details::check_peripheral_connection_interval_range_parameters< MinInterval, MaxInterval >::type
51 >
53 {
55 struct meta_type :
56 details::peripheral_connection_interval_range_meta_type,
57 details::valid_server_option_meta_type {};
58
59 static std::uint8_t* advertising_data( std::uint8_t* begin, std::uint8_t* end )
60 {
61 if ( end - begin >= 6 )
62 {
63 *begin = 0x05;
64 ++begin;
65 *begin = 0x12;
66 ++begin;
67
68 begin = details::write_16bit( begin, MinInterval );
69 begin = details::write_16bit( begin, MaxInterval );
70 }
71
72 return begin;
73 }
74
76 };
77}
78
79#endif
add peripheral connection interval range to advertising data
Definition: peripheral_connection_interval_range.hpp:53