Blob: btp.h
Blob id: a99fdf075a78f77a195c440fced1a1f5b02b9785
Size: 7.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012-2017 Intel Corporation. All rights reserved. * * */ #include <stdbool.h> #ifndef __packed #define __packed __attribute__((packed)) #endif #define BTP_INDEX_NON_CONTROLLER 0xff #define BTP_ERROR_FAIL 0x01 #define BTP_ERROR_UNKNOWN_CMD 0x02 #define BTP_ERROR_NOT_READY 0x03 #define BTP_ERROR_INVALID_INDEX 0x04 #define BTP_CORE_SERVICE 0 #define BTP_GAP_SERVICE 1 #define BTP_GATT_SERVICE 2 #define BTP_L2CAP_SERVICE 3 #define BTP_MESH_NODE_SERVICE 4 struct btp_hdr { uint8_t service; uint8_t opcode; uint8_t index; uint16_t data_len; uint8_t data[0]; } __packed; struct btp_error { uint8_t status; } __packed; #define BTP_OP_ERROR 0x00 #define BTP_OP_CORE_READ_SUPPORTED_COMMANDS 0x01 #define BTP_OP_CORE_READ_SUPPORTED_SERVICES 0x02 #define BTP_OP_CORE_REGISTER 0x03 struct btp_core_register_cp { uint8_t service_id; } __packed; #define BTP_OP_CORE_UNREGISTER 0x04 struct btp_core_unregister_cp { uint8_t service_id; } __packed; #define BTP_EV_CORE_READY 0x80 #define BTP_OP_GAP_READ_SUPPORTED_COMMANDS 0x01 #define BTP_OP_GAP_READ_CONTROLLER_INDEX_LIST 0x02 struct btp_gap_read_index_rp { uint8_t num; uint8_t indexes[0]; } __packed; #define BTP_GAP_SETTING_POWERED 0x00000001 #define BTP_GAP_SETTING_CONNECTABLE 0x00000002 #define BTP_GAP_SETTING_FAST_CONNECTABLE 0x00000004 #define BTP_GAP_SETTING_DISCOVERABLE 0x00000008 #define BTP_GAP_SETTING_BONDABLE 0x00000010 #define BTP_GAP_SETTING_LL_SECURITY 0x00000020 #define BTP_GAP_SETTING_SSP 0x00000040 #define BTP_GAP_SETTING_BREDR 0x00000080 #define BTP_GAP_SETTING_HS 0x00000100 #define BTP_GAP_SETTING_LE 0x00000200 #define BTP_GAP_SETTING_ADVERTISING 0x00000400 #define BTP_GAP_SETTING_SC 0x00000800 #define BTP_GAP_SETTING_DEBUG_KEYS 0x00001000 #define BTP_GAP_SETTING_PRIVACY 0x00002000 #define BTP_GAP_SETTING_CONTROLLER_CONF 0x00004000 #define BTP_GAP_SETTING_STATIC_ADDRESS 0x00008000 #define BTP_OP_GAP_READ_COTROLLER_INFO 0x03 struct btp_gap_read_info_rp { bdaddr_t address; uint32_t supported_settings; uint32_t current_settings; uint8_t cod[3]; uint8_t name[249]; uint8_t short_name[11]; } __packed; #define BTP_OP_GAP_RESET 0x04 struct btp_gap_reset_rp { uint32_t current_settings; } __packed; #define BTP_OP_GAP_SET_POWERED 0x05 struct btp_gap_set_powered_cp { uint8_t powered; } __packed; struct btp_gap_set_powered_rp { uint32_t current_settings; } __packed; #define BTP_OP_GAP_SET_CONNECTABLE 0x06 struct btp_gap_set_connectable_cp { uint8_t connectable; } __packed; struct btp_gap_set_connectable_rp { uint32_t current_settings; } __packed; #define BTP_OP_GAP_SET_FAST_CONNECTABLE 0x07 struct btp_gap_set_fast_connectable_cp { uint8_t fast_connectable; } __packed; struct btp_gap_set_fast_connectable_rp { uint32_t current_settings; } __packed; #define BTP_OP_GAP_SET_DISCOVERABLE 0x08 struct btp_gap_set_discoverable_cp { uint8_t discoverable; } __packed; struct btp_gap_set_discoverable_rp { uint32_t current_settings; } __packed; #define BTP_OP_GAP_SET_BONDABLE 0x09 struct btp_gap_set_bondable_cp { uint8_t bondable; } __packed; struct btp_gap_set_bondable_rp { uint32_t current_settings; } __packed; #define BTP_OP_GAP_START_ADVERTISING 0x0a struct btp_gap_start_adv_cp { uint8_t adv_data_len; uint8_t scan_rsp_len; uint8_t data[0]; } __packed; struct btp_gap_start_adv_rp { uint32_t current_settings; } __packed; #define BTP_OP_GAP_STOP_ADVERTISING 0x0b struct btp_gap_stop_adv_rp { uint32_t current_settings; } __packed; #define BTP_GAP_DISCOVERY_FLAG_LE 0x01 #define BTP_GAP_DISCOVERY_FLAG_BREDR 0x02 #define BTP_GAP_DISCOVERY_FLAG_LIMITED 0x04 #define BTP_GAP_DISCOVERY_FLAG_ACTIVE 0x08 #define BTP_GAP_DISCOVERY_FLAG_OBSERVATION 0x10 #define BTP_OP_GAP_START_DISCOVERY 0x0c struct btp_gap_start_discovery_cp { uint8_t flags; } __packed; #define BTP_OP_GAP_STOP_DISCOVERY 0x0d #define BTP_GAP_ADDR_PUBLIC 0x00 #define BTP_GAP_ADDR_RANDOM 0x01 #define BTP_OP_GAP_CONNECT 0x0e struct btp_gap_connect_cp { uint8_t address_type; bdaddr_t address; } __packed; #define BTP_OP_GAP_DISCONNECT 0x0f struct btp_gap_disconnect_cp { uint8_t address_type; bdaddr_t address; } __packed; #define BTP_GAP_IOCAPA_DISPLAY_ONLY 0x00 #define BTP_GAP_IOCAPA_DISPLAY_YESNO 0x01 #define BTP_GAP_IOCAPA_KEYBOARD_ONLY 0x02 #define BTP_GAP_IOCAPA_NO_INPUT_NO_OUTPUT 0x03 #define BTP_GAP_IOCAPA_KEYBOARD_DISPLAY 0x04 #define BTP_OP_GAP_SET_IO_CAPA 0x10 struct btp_gap_set_io_capa_cp { uint8_t capa; } __packed; #define BTP_OP_GAP_PAIR 0x11 struct btp_gap_pair_cp { uint8_t address_type; bdaddr_t address; } __packed; #define BTP_OP_GAP_UNPAIR 0x12 struct btp_gap_unpair_cp { uint8_t address_type; bdaddr_t address; } __packed; #define BTP_OP_GAP_PASSKEY_ENTRY_RSP 0x13 struct btp_gap_passkey_entry_rsp_cp { uint8_t address_type; bdaddr_t address; uint32_t passkey; } __packed; #define BTP_OP_GAP_PASSKEY_CONFIRM_RSP 0x14 struct btp_gap_passkey_confirm_rsp_cp { uint8_t address_type; bdaddr_t address; uint8_t match; } __packed; #define BTP_EV_GAP_NEW_SETTINGS 0x80 struct btp_new_settings_ev { uint32_t current_settings; } __packed; #define BTP_EV_GAP_DEVICE_FOUND_FLAG_RSSI 0x01 #define BTP_EV_GAP_DEVICE_FOUND_FLAG_AD 0x02 #define BTP_EV_GAP_DEVICE_FOUND_FLAG_SR 0x04 #define BTP_EV_GAP_DEVICE_FOUND 0x81 struct btp_device_found_ev { uint8_t address_type; bdaddr_t address; int8_t rssi; uint8_t flags; uint16_t eir_len; uint8_t eir[0]; } __packed; #define BTP_EV_GAP_DEVICE_CONNECTED 0x82 struct btp_gap_device_connected_ev { uint8_t address_type; bdaddr_t address; uint16_t connection_interval; uint16_t connection_latency; uint16_t supervision_timeout; } __packed; #define BTP_EV_GAP_DEVICE_DISCONNECTED 0x83 struct btp_gap_device_disconnected_ev { uint8_t address_type; bdaddr_t address; } __packed; #define BTP_EV_GAP_PASSKEY_DISPLAY 0x84 struct btp_gap_passkey_display_ev { uint8_t address_type; bdaddr_t address; uint32_t passkey; } __packed; #define BTP_EV_GAP_PASSKEY_REQUEST 0x85 struct btp_gap_passkey_req_ev { uint8_t address_type; bdaddr_t address; } __packed; #define BTP_EV_GAP_PASSKEY_CONFIRM 0x86 struct btp_gap_passkey_confirm_ev { uint8_t address_type; bdaddr_t address; uint32_t passkey; } __packed; #define BTP_EV_GAP_IDENTITY_RESOLVED 0x87 struct btp_gap_identity_resolved_ev { uint8_t address_type; bdaddr_t address; uint8_t identity_address_type; bdaddr_t identity_address; } __packed; struct btp; typedef void (*btp_destroy_func_t)(void *user_data); typedef void (*btp_disconnect_func_t)(struct btp *btp, void *user_data); typedef void (*btp_cmd_func_t)(uint8_t index, const void *param, uint16_t length, void *user_data); struct btp *btp_new(const char *path); void btp_cleanup(struct btp *btp); bool btp_set_disconnect_handler(struct btp *btp, btp_disconnect_func_t callback, void *user_data, btp_destroy_func_t destroy); bool btp_send_error(struct btp *btp, uint8_t service, uint8_t index, uint8_t status); bool btp_send(struct btp *btp, uint8_t service, uint8_t opcode, uint8_t index, uint16_t length, const void *param); unsigned int btp_register(struct btp *btp, uint8_t service, uint8_t opcode, btp_cmd_func_t callback, void *user_data, btp_destroy_func_t destroy); bool btp_unregister(struct btp *btp, unsigned int id); void btp_unregister_service(struct btp *btp, uint8_t service); |