BlueToe
an alternative GATT/BLE implementation
Loading...
Searching...
No Matches
appearance.hpp
1#ifndef BLUETOE_APPEARANCE_HPP
2#define BLUETOE_APPEARANCE_HPP
3
4#include <bluetoe/meta_types.hpp>
5
6namespace bluetoe {
7
8 namespace details {
9 struct device_appearance_meta_type {};
10 struct advertise_appearance_meta_type {};
11 }
12
16 template < std::uint16_t A >
18 {
20 struct meta_type :
21 details::device_appearance_meta_type,
22 details::valid_server_option_meta_type {};
23
24 static constexpr std::uint16_t value = A;
26 };
27
52 {
151 };
152
161 {
163 struct meta_type :
164 details::advertise_appearance_meta_type,
165 details::valid_server_option_meta_type {};
166
167 template < typename Adv >
168 static std::uint8_t* advertising_data( std::uint8_t* begin, std::uint8_t* end )
169 {
170 static constexpr std::size_t adv_data_size = 4u;
171
172 if ( std::size_t(end - begin) >= adv_data_size )
173 {
174 *begin = static_cast< std::uint8_t >( adv_data_size - 1 );
175 ++begin;
176 *begin = bits( details::gap_types::appearance );
177 ++begin;
178 begin = details::write_16bit( begin, Adv::value );
179 }
180
181 return begin;
182 }
184 };
185
187 // the default to use
188 struct no_advertise_appearance
189 {
190 struct meta_type :
191 details::advertise_appearance_meta_type,
192 details::valid_server_option_meta_type {};
193
194 template < typename >
195 static std::uint8_t* advertising_data( std::uint8_t* begin, std::uint8_t* )
196 {
197 return begin;
198 }
199 };
201}
202
203#endif // include guard
add the appearance of the device to the advertising data
Definition: appearance.hpp:161
enumeration of appearances (org.bluetooth.characteristic.gap.appearance)
Definition: appearance.hpp:52
type to keep a bluetoe::appearance value
Definition: appearance.hpp:18