BlueToe
an alternative GATT/BLE implementation
Loading...
Searching...
No Matches
link_state.hpp
1#ifndef BLUETOE_LINK_STATE_HPP
2#define BLUETOE_LINK_STATE_HPP
3
4#include <bluetoe/pairing_status.hpp>
5#include <bluetoe/codes.hpp>
6
7namespace bluetoe {
8namespace details {
9
19 class link_state
20 {
21 public:
22 link_state()
23 : encrypted_( false )
24 , pairing_status_( device_pairing_status::no_key )
25 {
26 }
27
31 bool is_encrypted() const
32 {
33 return encrypted_;
34 }
35
41 bool is_encrypted( bool encrypted )
42 {
43 const bool result = encrypted_ != encrypted;
44 encrypted_ = encrypted;
45
46 return result;
47 }
48
52 device_pairing_status pairing_status() const
53 {
54 return pairing_status_;
55 }
56
60 void pairing_status( device_pairing_status status )
61 {
62 pairing_status_ = status;
63 }
64
68 connection_security_attributes security_attributes() const
69 {
70 return connection_security_attributes{ encrypted_, pairing_status_ };
71 }
72
73 private:
74 bool encrypted_;
75 device_pairing_status pairing_status_;
76 };
77
81 class link_state_no_security
82 {
83 public:
84 bool is_encrypted() const
85 {
86 return false;
87 }
88
92 device_pairing_status pairing_status() const
93 {
94 return device_pairing_status::no_key;
95 }
96
100 connection_security_attributes security_attributes() const
101 {
102 return connection_security_attributes{ false, device_pairing_status::no_key };
103 }
104 };
105
106}
107}
108
109#endif // include guard