BlueToe
an alternative GATT/BLE implementation
Loading...
Searching...
No Matches
codes.hpp
1#ifndef BLUETOE_CODES_HPP
2#define BLUETOE_CODES_HPP
3
4#include <cstdint>
5
6namespace bluetoe {
7namespace details {
8
9 static constexpr std::uint16_t default_att_mtu_size = 23;
10 static constexpr std::uint16_t default_lesc_mtu_size = 65;
11
12 enum class att_opcodes : std::uint8_t {
13 error_response = 0x01,
14 exchange_mtu_request = 0x02,
15 exchange_mtu_response = 0x03,
16 find_information_request = 0x04,
17 find_information_response = 0x05,
18 find_by_type_value_request = 0x06,
19 find_by_type_value_response = 0x07,
20 read_by_type_request = 0x08,
21 read_by_type_response = 0x09,
22 read_request = 0x0A,
23 read_response = 0x0B,
24 read_blob_request = 0x0C,
25 read_blob_response = 0x0D,
26 read_multiple_request = 0x0E,
27 read_multiple_response = 0x0F,
28 read_by_group_type_request = 0x10,
29 read_by_group_type_response = 0x11,
30 write_request = 0x12,
31 write_response = 0x13,
32 prepare_write_request = 0x16,
33 prepare_write_response = 0x17,
34 execute_write_request = 0x18,
35 execute_write_response = 0x19,
36 write_command = 0x52,
37 notification = 0x1B,
38 indication = 0x1D,
39 confirmation = 0x1E
40
41 };
42
43 constexpr std::uint8_t bits( att_opcodes c )
44 {
45 return static_cast< std::uint8_t >( c );
46 }
47
48 enum class att_error_codes : std::uint8_t {
49 invalid_handle = 0x01,
66 };
67
68 constexpr std::uint8_t bits( att_error_codes c )
69 {
70 return static_cast< std::uint8_t >( c );
71 }
72
73 enum class att_uuid_format : std::uint8_t {
74 short_16bit = 0x01,
75 long_128bit = 0x02
76 };
77
78 constexpr std::uint8_t bits( att_uuid_format c )
79 {
80 return static_cast< std::uint8_t >( c );
81 }
82
83 enum class gatt_uuids : std::uint16_t {
84 primary_service = 0x2800,
85 secondary_service = 0x2801,
86 include = 0x2802,
87 characteristic = 0x2803,
88 characteristic_user_description = 0x2901,
89 client_characteristic_configuration = 0x2902,
90
91 internal_128bit_uuid = 1
92 };
93
94 constexpr std::uint16_t bits( gatt_uuids c )
95 {
96 return static_cast< std::uint16_t >( c );
97 }
98
99 enum class gatt_characteristic_properties : std::uint8_t {
100 read = 0x02,
101 write_without_response = 0x04,
102 write = 0x08,
103 notify = 0x10,
104 indicate = 0x20
105 };
106
107 constexpr std::uint8_t bits( gatt_characteristic_properties c )
108 {
109 return static_cast< std::uint8_t >( c );
110 }
111
112 enum class gap_types : std::uint8_t {
113 flags = 0x01,
114 incomplete_service_uuids_16 = 0x02,
115 complete_service_uuids_16 = 0x03,
116 incomplete_service_uuids_128 = 0x06,
117 complete_service_uuids_128 = 0x07,
118 complete_local_name = 0x09,
119 shortened_local_name = 0x08,
120 tx_power_level = 0x0a,
121 appearance = 0x19,
122 };
123
124 constexpr std::uint8_t bits( gap_types c )
125 {
126 return static_cast< std::uint8_t >( c );
127 }
128
129 enum {
130 client_characteristic_configuration_notification_enabled = 1,
131 client_characteristic_configuration_indication_enabled = 2
132 };
133
134 inline std::uint8_t* write_opcode( std::uint8_t* out, details::att_opcodes opcode )
135 {
136 *out = bits( opcode );
137 return out + 1;
138 }
139}
140
141
145namespace error_codes {
146
150 enum error_codes : std::uint8_t {
154 success = 0x00,
155
160
165
170
175
180
185
190
195
200
205
210
215
220
226
231
236
241
246
251
257
263
270 };
271}
272}
273#endif
att_error_codes
error codes that are used by the bootloader on the ATT layer
Definition: bootloader.hpp:124
error_codes
Error codes to be returned by read and write handlers for characteristic values.
Definition: codes.hpp:150
@ insufficient_resources
Definition: codes.hpp:240
@ insufficient_authentication
Definition: codes.hpp:179
@ prepare_queue_full
Definition: codes.hpp:199
@ request_not_supported
Definition: codes.hpp:184
@ insufficient_encryption_key_size
Definition: codes.hpp:214
@ unlikely_error
Definition: codes.hpp:225
@ invalid_offset
Definition: codes.hpp:189
@ out_of_range
Definition: codes.hpp:256
@ invalid_pdu
Definition: codes.hpp:174
@ success
Definition: codes.hpp:154
@ attribute_not_found
Definition: codes.hpp:204
@ insufficient_authorization
Definition: codes.hpp:194
@ write_not_permitted
Definition: codes.hpp:169
@ attribute_not_long
Definition: codes.hpp:209
@ procedure_already_in_progress
Definition: codes.hpp:262
@ unsupported_group_type
Definition: codes.hpp:235
@ invalid_handle
Definition: codes.hpp:159
@ application_error_start
Definition: codes.hpp:245
@ invalid_attribute_value_length
Definition: codes.hpp:219
@ cccd_improperly_configured
Definition: codes.hpp:269
@ application_error_end
Definition: codes.hpp:250
@ read_not_permitted
Definition: codes.hpp:164
@ insufficient_encryption
Definition: codes.hpp:230