1#ifndef BLUETOE_FILTER_HPP
2#define BLUETOE_FILTER_HPP
4#include <bluetoe/attribute.hpp>
5#include <bluetoe/bits.hpp>
6#include <bluetoe/uuid.hpp>
7#include <bluetoe/codes.hpp>
26 uuid_filter(
const std::uint8_t* bytes,
bool is_128bit )
28 , is_128bit_( is_128bit )
30 if ( is_128bit && representable_as_16bit_uuid( bytes ) )
38 bool operator()( std::size_t attribute_index,
const attribute& attr )
const
42 if ( attr.uuid == bits( gatt_uuids::internal_128bit_uuid ) )
44 auto compare = attribute_access_arguments::compare_128bit_uuid( bytes_ );
45 return attr.access( compare, attribute_index ) == attribute_access_result::uuid_equal;
54 return read_16bit_uuid( bytes_ ) == attr.uuid;
59 static bool representable_as_16bit_uuid(
const std::uint8_t* bytes )
61 return std::equal( std::begin( bluetooth_base_uuid::bytes ), std::end( bluetooth_base_uuid::bytes ) - 4, bytes )
62 && bytes[ 14 ] == 0 && bytes[ 15 ] == 0;
65 const std::uint8_t* bytes_;
78 template <
class UUID >
81 template < std::u
int64_t UUID,
typename Check >
82 struct uuid16_filter< uuid16< UUID, Check > >
84 constexpr bool operator()( std::size_t,
const attribute& attr )
const
86 return attr.uuid == UUID;
93 struct all_uuid_filter
95 constexpr bool operator()( std::size_t,
const details::attribute& )
const