Junichi Katsu / Mbed 2 deprecated BLEControl

Dependencies:   FatFileSystem TB6612FNG2 mbed

Committer:
mbed_Cookbook_SE
Date:
Mon Nov 30 09:32:15 2015 +0000
Revision:
0:de03cbbcd0ff
??

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_Cookbook_SE 0:de03cbbcd0ff 1 /*
mbed_Cookbook_SE 0:de03cbbcd0ff 2 * Copyright (C) 2009 by Matthias Ringwald
mbed_Cookbook_SE 0:de03cbbcd0ff 3 *
mbed_Cookbook_SE 0:de03cbbcd0ff 4 * Redistribution and use in source and binary forms, with or without
mbed_Cookbook_SE 0:de03cbbcd0ff 5 * modification, are permitted provided that the following conditions
mbed_Cookbook_SE 0:de03cbbcd0ff 6 * are met:
mbed_Cookbook_SE 0:de03cbbcd0ff 7 *
mbed_Cookbook_SE 0:de03cbbcd0ff 8 * 1. Redistributions of source code must retain the above copyright
mbed_Cookbook_SE 0:de03cbbcd0ff 9 * notice, this list of conditions and the following disclaimer.
mbed_Cookbook_SE 0:de03cbbcd0ff 10 * 2. Redistributions in binary form must reproduce the above copyright
mbed_Cookbook_SE 0:de03cbbcd0ff 11 * notice, this list of conditions and the following disclaimer in the
mbed_Cookbook_SE 0:de03cbbcd0ff 12 * documentation and/or other materials provided with the distribution.
mbed_Cookbook_SE 0:de03cbbcd0ff 13 * 3. Neither the name of the copyright holders nor the names of
mbed_Cookbook_SE 0:de03cbbcd0ff 14 * contributors may be used to endorse or promote products derived
mbed_Cookbook_SE 0:de03cbbcd0ff 15 * from this software without specific prior written permission.
mbed_Cookbook_SE 0:de03cbbcd0ff 16 *
mbed_Cookbook_SE 0:de03cbbcd0ff 17 * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS
mbed_Cookbook_SE 0:de03cbbcd0ff 18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
mbed_Cookbook_SE 0:de03cbbcd0ff 19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
mbed_Cookbook_SE 0:de03cbbcd0ff 20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
mbed_Cookbook_SE 0:de03cbbcd0ff 21 * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
mbed_Cookbook_SE 0:de03cbbcd0ff 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
mbed_Cookbook_SE 0:de03cbbcd0ff 23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
mbed_Cookbook_SE 0:de03cbbcd0ff 24 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
mbed_Cookbook_SE 0:de03cbbcd0ff 25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_Cookbook_SE 0:de03cbbcd0ff 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
mbed_Cookbook_SE 0:de03cbbcd0ff 27 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
mbed_Cookbook_SE 0:de03cbbcd0ff 28 * SUCH DAMAGE.
mbed_Cookbook_SE 0:de03cbbcd0ff 29 *
mbed_Cookbook_SE 0:de03cbbcd0ff 30 */
mbed_Cookbook_SE 0:de03cbbcd0ff 31
mbed_Cookbook_SE 0:de03cbbcd0ff 32 /*
mbed_Cookbook_SE 0:de03cbbcd0ff 33 * hci_cmds.h
mbed_Cookbook_SE 0:de03cbbcd0ff 34 *
mbed_Cookbook_SE 0:de03cbbcd0ff 35 * Created by Matthias Ringwald on 7/23/09.
mbed_Cookbook_SE 0:de03cbbcd0ff 36 */
mbed_Cookbook_SE 0:de03cbbcd0ff 37
mbed_Cookbook_SE 0:de03cbbcd0ff 38 #pragma once
mbed_Cookbook_SE 0:de03cbbcd0ff 39
mbed_Cookbook_SE 0:de03cbbcd0ff 40 #include <stdint.h>
mbed_Cookbook_SE 0:de03cbbcd0ff 41
mbed_Cookbook_SE 0:de03cbbcd0ff 42 #if defined __cplusplus
mbed_Cookbook_SE 0:de03cbbcd0ff 43 extern "C" {
mbed_Cookbook_SE 0:de03cbbcd0ff 44 #endif
mbed_Cookbook_SE 0:de03cbbcd0ff 45
mbed_Cookbook_SE 0:de03cbbcd0ff 46 /**
mbed_Cookbook_SE 0:de03cbbcd0ff 47 * packet types - used in BTstack and over the H4 UART interface
mbed_Cookbook_SE 0:de03cbbcd0ff 48 */
mbed_Cookbook_SE 0:de03cbbcd0ff 49 #define HCI_COMMAND_DATA_PACKET 0x01
mbed_Cookbook_SE 0:de03cbbcd0ff 50 #define HCI_ACL_DATA_PACKET 0x02
mbed_Cookbook_SE 0:de03cbbcd0ff 51 #define HCI_SCO_DATA_PACKET 0x03
mbed_Cookbook_SE 0:de03cbbcd0ff 52 #define HCI_EVENT_PACKET 0x04
mbed_Cookbook_SE 0:de03cbbcd0ff 53
mbed_Cookbook_SE 0:de03cbbcd0ff 54 // extension for client/server communication
mbed_Cookbook_SE 0:de03cbbcd0ff 55 #define DAEMON_EVENT_PACKET 0x05
mbed_Cookbook_SE 0:de03cbbcd0ff 56
mbed_Cookbook_SE 0:de03cbbcd0ff 57 // L2CAP data
mbed_Cookbook_SE 0:de03cbbcd0ff 58 #define L2CAP_DATA_PACKET 0x06
mbed_Cookbook_SE 0:de03cbbcd0ff 59
mbed_Cookbook_SE 0:de03cbbcd0ff 60 // RFCOMM data
mbed_Cookbook_SE 0:de03cbbcd0ff 61 #define RFCOMM_DATA_PACKET 0x07
mbed_Cookbook_SE 0:de03cbbcd0ff 62
mbed_Cookbook_SE 0:de03cbbcd0ff 63 // Attribute protocol data
mbed_Cookbook_SE 0:de03cbbcd0ff 64 #define ATT_DATA_PACKET 0x08
mbed_Cookbook_SE 0:de03cbbcd0ff 65
mbed_Cookbook_SE 0:de03cbbcd0ff 66 // Security Manager protocol data
mbed_Cookbook_SE 0:de03cbbcd0ff 67 #define SM_DATA_PACKET 0x09
mbed_Cookbook_SE 0:de03cbbcd0ff 68
mbed_Cookbook_SE 0:de03cbbcd0ff 69 // debug log messages
mbed_Cookbook_SE 0:de03cbbcd0ff 70 #define LOG_MESSAGE_PACKET 0xfc
mbed_Cookbook_SE 0:de03cbbcd0ff 71
mbed_Cookbook_SE 0:de03cbbcd0ff 72
mbed_Cookbook_SE 0:de03cbbcd0ff 73 // Fixed PSM numbers
mbed_Cookbook_SE 0:de03cbbcd0ff 74 #define PSM_SDP 0x01
mbed_Cookbook_SE 0:de03cbbcd0ff 75 #define PSM_RFCOMM 0x03
mbed_Cookbook_SE 0:de03cbbcd0ff 76 #define PSM_HID_CONTROL 0x11
mbed_Cookbook_SE 0:de03cbbcd0ff 77 #define PSM_HID_INTERRUPT 0x13
mbed_Cookbook_SE 0:de03cbbcd0ff 78
mbed_Cookbook_SE 0:de03cbbcd0ff 79 // Events from host controller to host
mbed_Cookbook_SE 0:de03cbbcd0ff 80 #define HCI_EVENT_INQUIRY_COMPLETE 0x01
mbed_Cookbook_SE 0:de03cbbcd0ff 81 #define HCI_EVENT_INQUIRY_RESULT 0x02
mbed_Cookbook_SE 0:de03cbbcd0ff 82 #define HCI_EVENT_CONNECTION_COMPLETE 0x03
mbed_Cookbook_SE 0:de03cbbcd0ff 83 #define HCI_EVENT_CONNECTION_REQUEST 0x04
mbed_Cookbook_SE 0:de03cbbcd0ff 84 #define HCI_EVENT_DISCONNECTION_COMPLETE 0x05
mbed_Cookbook_SE 0:de03cbbcd0ff 85 #define HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT 0x06
mbed_Cookbook_SE 0:de03cbbcd0ff 86 #define HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE 0x07
mbed_Cookbook_SE 0:de03cbbcd0ff 87 #define HCI_EVENT_ENCRYPTION_CHANGE 0x08
mbed_Cookbook_SE 0:de03cbbcd0ff 88 #define HCI_EVENT_CHANGE_CONNECTION_LINK_KEY_COMPLETE 0x09
mbed_Cookbook_SE 0:de03cbbcd0ff 89 #define HCI_EVENT_MASTER_LINK_KEY_COMPLETE 0x0A
mbed_Cookbook_SE 0:de03cbbcd0ff 90 #define HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE 0x0B
mbed_Cookbook_SE 0:de03cbbcd0ff 91 #define HCI_EVENT_READ_REMOTE_VERSION_INFORMATION_COMPLETE 0x0C
mbed_Cookbook_SE 0:de03cbbcd0ff 92 #define HCI_EVENT_QOS_SETUP_COMPLETE 0x0D
mbed_Cookbook_SE 0:de03cbbcd0ff 93 #define HCI_EVENT_COMMAND_COMPLETE 0x0E
mbed_Cookbook_SE 0:de03cbbcd0ff 94 #define HCI_EVENT_COMMAND_STATUS 0x0F
mbed_Cookbook_SE 0:de03cbbcd0ff 95 #define HCI_EVENT_HARDWARE_ERROR 0x10
mbed_Cookbook_SE 0:de03cbbcd0ff 96 #define HCI_EVENT_FLUSH_OCCURED 0x11
mbed_Cookbook_SE 0:de03cbbcd0ff 97 #define HCI_EVENT_ROLE_CHANGE 0x12
mbed_Cookbook_SE 0:de03cbbcd0ff 98 #define HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS 0x13
mbed_Cookbook_SE 0:de03cbbcd0ff 99 #define HCI_EVENT_MODE_CHANGE_EVENT 0x14
mbed_Cookbook_SE 0:de03cbbcd0ff 100 #define HCI_EVENT_RETURN_LINK_KEYS 0x15
mbed_Cookbook_SE 0:de03cbbcd0ff 101 #define HCI_EVENT_PIN_CODE_REQUEST 0x16
mbed_Cookbook_SE 0:de03cbbcd0ff 102 #define HCI_EVENT_LINK_KEY_REQUEST 0x17
mbed_Cookbook_SE 0:de03cbbcd0ff 103 #define HCI_EVENT_LINK_KEY_NOTIFICATION 0x18
mbed_Cookbook_SE 0:de03cbbcd0ff 104 #define HCI_EVENT_DATA_BUFFER_OVERFLOW 0x1A
mbed_Cookbook_SE 0:de03cbbcd0ff 105 #define HCI_EVENT_MAX_SLOTS_CHANGED 0x1B
mbed_Cookbook_SE 0:de03cbbcd0ff 106 #define HCI_EVENT_READ_CLOCK_OFFSET_COMPLETE 0x1C
mbed_Cookbook_SE 0:de03cbbcd0ff 107 #define HCI_EVENT_PACKET_TYPE_CHANGED 0x1D
mbed_Cookbook_SE 0:de03cbbcd0ff 108 #define HCI_EVENT_INQUIRY_RESULT_WITH_RSSI 0x22
mbed_Cookbook_SE 0:de03cbbcd0ff 109 #define HCI_EVENT_EXTENDED_INQUIRY_RESPONSE 0x2F
mbed_Cookbook_SE 0:de03cbbcd0ff 110 #define HCI_EVENT_LE_META 0x3E
mbed_Cookbook_SE 0:de03cbbcd0ff 111 #define HCI_EVENT_VENDOR_SPECIFIC 0xFF
mbed_Cookbook_SE 0:de03cbbcd0ff 112
mbed_Cookbook_SE 0:de03cbbcd0ff 113 #define HCI_SUBEVENT_LE_CONNECTION_COMPLETE 0x01
mbed_Cookbook_SE 0:de03cbbcd0ff 114 #define HCI_SUBEVENT_LE_ADVERTISING_REPORT 0x02
mbed_Cookbook_SE 0:de03cbbcd0ff 115 #define HCI_SUBEVENT_LE_CONNECTION_UPDATE_COMPLETE 0x03
mbed_Cookbook_SE 0:de03cbbcd0ff 116 #define HCI_SUBEVENT_LE_READ_REMOTE_USED_FEATURES_COMPLETE 0x04
mbed_Cookbook_SE 0:de03cbbcd0ff 117 #define HCI_SUBEVENT_LE_LONG_TERM_KEY_REQUEST 0x05
mbed_Cookbook_SE 0:de03cbbcd0ff 118
mbed_Cookbook_SE 0:de03cbbcd0ff 119 // last used HCI_EVENT in 2.1 is 0x3d
mbed_Cookbook_SE 0:de03cbbcd0ff 120
mbed_Cookbook_SE 0:de03cbbcd0ff 121 // events 0x50-0x5f are used internally
mbed_Cookbook_SE 0:de03cbbcd0ff 122
mbed_Cookbook_SE 0:de03cbbcd0ff 123 // BTSTACK DAEMON EVENTS
mbed_Cookbook_SE 0:de03cbbcd0ff 124
mbed_Cookbook_SE 0:de03cbbcd0ff 125 // events from BTstack for application/client lib
mbed_Cookbook_SE 0:de03cbbcd0ff 126 #define BTSTACK_EVENT_STATE 0x60
mbed_Cookbook_SE 0:de03cbbcd0ff 127
mbed_Cookbook_SE 0:de03cbbcd0ff 128 // data: event(8), len(8), nr hci connections
mbed_Cookbook_SE 0:de03cbbcd0ff 129 #define BTSTACK_EVENT_NR_CONNECTIONS_CHANGED 0x61
mbed_Cookbook_SE 0:de03cbbcd0ff 130
mbed_Cookbook_SE 0:de03cbbcd0ff 131 // data: none
mbed_Cookbook_SE 0:de03cbbcd0ff 132 #define BTSTACK_EVENT_POWERON_FAILED 0x62
mbed_Cookbook_SE 0:de03cbbcd0ff 133
mbed_Cookbook_SE 0:de03cbbcd0ff 134 // data: majot (8), minor (8), revision(16)
mbed_Cookbook_SE 0:de03cbbcd0ff 135 #define BTSTACK_EVENT_VERSION 0x63
mbed_Cookbook_SE 0:de03cbbcd0ff 136
mbed_Cookbook_SE 0:de03cbbcd0ff 137 // data: system bluetooth on/off (bool)
mbed_Cookbook_SE 0:de03cbbcd0ff 138 #define BTSTACK_EVENT_SYSTEM_BLUETOOTH_ENABLED 0x64
mbed_Cookbook_SE 0:de03cbbcd0ff 139
mbed_Cookbook_SE 0:de03cbbcd0ff 140 // data: event (8), len(8), status (8) == 0, address (48), name (1984 bits = 248 bytes)
mbed_Cookbook_SE 0:de03cbbcd0ff 141 #define BTSTACK_EVENT_REMOTE_NAME_CACHED 0x65
mbed_Cookbook_SE 0:de03cbbcd0ff 142
mbed_Cookbook_SE 0:de03cbbcd0ff 143 // data: discoverable enabled (bool)
mbed_Cookbook_SE 0:de03cbbcd0ff 144 #define BTSTACK_EVENT_DISCOVERABLE_ENABLED 0x66
mbed_Cookbook_SE 0:de03cbbcd0ff 145
mbed_Cookbook_SE 0:de03cbbcd0ff 146 // L2CAP EVENTS
mbed_Cookbook_SE 0:de03cbbcd0ff 147
mbed_Cookbook_SE 0:de03cbbcd0ff 148 // data: event (8), len(8), status (8), address(48), handle (16), psm (16), local_cid(16), remote_cid (16), local_mtu(16), remote_mtu(16)
mbed_Cookbook_SE 0:de03cbbcd0ff 149 #define L2CAP_EVENT_CHANNEL_OPENED 0x70
mbed_Cookbook_SE 0:de03cbbcd0ff 150
mbed_Cookbook_SE 0:de03cbbcd0ff 151 // data: event (8), len(8), channel (16)
mbed_Cookbook_SE 0:de03cbbcd0ff 152 #define L2CAP_EVENT_CHANNEL_CLOSED 0x71
mbed_Cookbook_SE 0:de03cbbcd0ff 153
mbed_Cookbook_SE 0:de03cbbcd0ff 154 // data: event (8), len(8), address(48), handle (16), psm (16), local_cid(16), remote_cid (16)
mbed_Cookbook_SE 0:de03cbbcd0ff 155 #define L2CAP_EVENT_INCOMING_CONNECTION 0x72
mbed_Cookbook_SE 0:de03cbbcd0ff 156
mbed_Cookbook_SE 0:de03cbbcd0ff 157 // data: event(8), len(8), handle(16)
mbed_Cookbook_SE 0:de03cbbcd0ff 158 #define L2CAP_EVENT_TIMEOUT_CHECK 0x73
mbed_Cookbook_SE 0:de03cbbcd0ff 159
mbed_Cookbook_SE 0:de03cbbcd0ff 160 // data: event(8), len(8), local_cid(16), credits(8)
mbed_Cookbook_SE 0:de03cbbcd0ff 161 #define L2CAP_EVENT_CREDITS 0x74
mbed_Cookbook_SE 0:de03cbbcd0ff 162
mbed_Cookbook_SE 0:de03cbbcd0ff 163 // data: event(8), len(8), status (8), psm (16)
mbed_Cookbook_SE 0:de03cbbcd0ff 164 #define L2CAP_EVENT_SERVICE_REGISTERED 0x75
mbed_Cookbook_SE 0:de03cbbcd0ff 165
mbed_Cookbook_SE 0:de03cbbcd0ff 166
mbed_Cookbook_SE 0:de03cbbcd0ff 167 // RFCOMM EVENTS
mbed_Cookbook_SE 0:de03cbbcd0ff 168
mbed_Cookbook_SE 0:de03cbbcd0ff 169 // data: event(8), len(8), status (8), address (48), handle (16), server channel(8), rfcomm_cid(16), max frame size(16)
mbed_Cookbook_SE 0:de03cbbcd0ff 170 #define RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE 0x80
mbed_Cookbook_SE 0:de03cbbcd0ff 171
mbed_Cookbook_SE 0:de03cbbcd0ff 172 // data: event(8), len(8), rfcomm_cid(16)
mbed_Cookbook_SE 0:de03cbbcd0ff 173 #define RFCOMM_EVENT_CHANNEL_CLOSED 0x81
mbed_Cookbook_SE 0:de03cbbcd0ff 174
mbed_Cookbook_SE 0:de03cbbcd0ff 175 // data: event (8), len(8), address(48), channel (8), rfcomm_cid (16)
mbed_Cookbook_SE 0:de03cbbcd0ff 176 #define RFCOMM_EVENT_INCOMING_CONNECTION 0x82
mbed_Cookbook_SE 0:de03cbbcd0ff 177
mbed_Cookbook_SE 0:de03cbbcd0ff 178 // data: event (8), len(8), rfcommid (16), ...
mbed_Cookbook_SE 0:de03cbbcd0ff 179 #define RFCOMM_EVENT_REMOTE_LINE_STATUS 0x83
mbed_Cookbook_SE 0:de03cbbcd0ff 180
mbed_Cookbook_SE 0:de03cbbcd0ff 181 // data: event(8), len(8), rfcomm_cid(16), credits(8)
mbed_Cookbook_SE 0:de03cbbcd0ff 182 #define RFCOMM_EVENT_CREDITS 0x84
mbed_Cookbook_SE 0:de03cbbcd0ff 183
mbed_Cookbook_SE 0:de03cbbcd0ff 184 // data: event(8), len(8), status (8), rfcomm server channel id (8)
mbed_Cookbook_SE 0:de03cbbcd0ff 185 #define RFCOMM_EVENT_SERVICE_REGISTERED 0x85
mbed_Cookbook_SE 0:de03cbbcd0ff 186
mbed_Cookbook_SE 0:de03cbbcd0ff 187 // data: event(8), len(8), status (8), rfcomm server channel id (8)
mbed_Cookbook_SE 0:de03cbbcd0ff 188 #define RFCOMM_EVENT_PERSISTENT_CHANNEL 0x86
mbed_Cookbook_SE 0:de03cbbcd0ff 189
mbed_Cookbook_SE 0:de03cbbcd0ff 190
mbed_Cookbook_SE 0:de03cbbcd0ff 191 // data: event(8), len(8), status(8), service_record_handle(32)
mbed_Cookbook_SE 0:de03cbbcd0ff 192 #define SDP_SERVICE_REGISTERED 0x90
mbed_Cookbook_SE 0:de03cbbcd0ff 193
mbed_Cookbook_SE 0:de03cbbcd0ff 194
mbed_Cookbook_SE 0:de03cbbcd0ff 195 // last error code in 2.1 is 0x38 - we start with 0x50 for BTstack errors
mbed_Cookbook_SE 0:de03cbbcd0ff 196
mbed_Cookbook_SE 0:de03cbbcd0ff 197 #define BTSTACK_CONNECTION_TO_BTDAEMON_FAILED 0x50
mbed_Cookbook_SE 0:de03cbbcd0ff 198 #define BTSTACK_ACTIVATION_FAILED_SYSTEM_BLUETOOTH 0x51
mbed_Cookbook_SE 0:de03cbbcd0ff 199 #define BTSTACK_ACTIVATION_POWERON_FAILED 0x52
mbed_Cookbook_SE 0:de03cbbcd0ff 200 #define BTSTACK_ACTIVATION_FAILED_UNKNOWN 0x53
mbed_Cookbook_SE 0:de03cbbcd0ff 201 #define BTSTACK_NOT_ACTIVATED 0x54
mbed_Cookbook_SE 0:de03cbbcd0ff 202 #define BTSTACK_BUSY 0x55
mbed_Cookbook_SE 0:de03cbbcd0ff 203 #define BTSTACK_MEMORY_ALLOC_FAILED 0x56
mbed_Cookbook_SE 0:de03cbbcd0ff 204 #define BTSTACK_ACL_BUFFERS_FULL 0x57
mbed_Cookbook_SE 0:de03cbbcd0ff 205
mbed_Cookbook_SE 0:de03cbbcd0ff 206 // l2cap errors - enumeration by the command that created them
mbed_Cookbook_SE 0:de03cbbcd0ff 207 #define L2CAP_COMMAND_REJECT_REASON_COMMAND_NOT_UNDERSTOOD 0x60
mbed_Cookbook_SE 0:de03cbbcd0ff 208 #define L2CAP_COMMAND_REJECT_REASON_SIGNALING_MTU_EXCEEDED 0x61
mbed_Cookbook_SE 0:de03cbbcd0ff 209 #define L2CAP_COMMAND_REJECT_REASON_INVALID_CID_IN_REQUEST 0x62
mbed_Cookbook_SE 0:de03cbbcd0ff 210
mbed_Cookbook_SE 0:de03cbbcd0ff 211 #define L2CAP_CONNECTION_RESPONSE_RESULT_SUCCESSFUL 0x63
mbed_Cookbook_SE 0:de03cbbcd0ff 212 #define L2CAP_CONNECTION_RESPONSE_RESULT_PENDING 0x64
mbed_Cookbook_SE 0:de03cbbcd0ff 213 #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_PSM 0x65
mbed_Cookbook_SE 0:de03cbbcd0ff 214 #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_SECURITY 0x66
mbed_Cookbook_SE 0:de03cbbcd0ff 215 #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_RESOURCES 0x65
mbed_Cookbook_SE 0:de03cbbcd0ff 216
mbed_Cookbook_SE 0:de03cbbcd0ff 217 #define L2CAP_CONFIG_RESPONSE_RESULT_SUCCESSFUL 0x66
mbed_Cookbook_SE 0:de03cbbcd0ff 218 #define L2CAP_CONFIG_RESPONSE_RESULT_UNACCEPTABLE_PARAMS 0x67
mbed_Cookbook_SE 0:de03cbbcd0ff 219 #define L2CAP_CONFIG_RESPONSE_RESULT_REJECTED 0x68
mbed_Cookbook_SE 0:de03cbbcd0ff 220 #define L2CAP_CONFIG_RESPONSE_RESULT_UNKNOWN_OPTIONS 0x69
mbed_Cookbook_SE 0:de03cbbcd0ff 221 #define L2CAP_SERVICE_ALREADY_REGISTERED 0x6a
mbed_Cookbook_SE 0:de03cbbcd0ff 222
mbed_Cookbook_SE 0:de03cbbcd0ff 223 #define RFCOMM_MULTIPLEXER_STOPPED 0x70
mbed_Cookbook_SE 0:de03cbbcd0ff 224 #define RFCOMM_CHANNEL_ALREADY_REGISTERED 0x71
mbed_Cookbook_SE 0:de03cbbcd0ff 225 #define RFCOMM_NO_OUTGOING_CREDITS 0x72
mbed_Cookbook_SE 0:de03cbbcd0ff 226
mbed_Cookbook_SE 0:de03cbbcd0ff 227 #define SDP_HANDLE_ALREADY_REGISTERED 0x80
mbed_Cookbook_SE 0:de03cbbcd0ff 228
mbed_Cookbook_SE 0:de03cbbcd0ff 229 /**
mbed_Cookbook_SE 0:de03cbbcd0ff 230 * Default INQ Mode
mbed_Cookbook_SE 0:de03cbbcd0ff 231 */
mbed_Cookbook_SE 0:de03cbbcd0ff 232 #define HCI_INQUIRY_LAP 0x9E8B33L // 0x9E8B33: General/Unlimited Inquiry Access Code (GIAC)
mbed_Cookbook_SE 0:de03cbbcd0ff 233 /**
mbed_Cookbook_SE 0:de03cbbcd0ff 234 * Hardware state of Bluetooth controller
mbed_Cookbook_SE 0:de03cbbcd0ff 235 */
mbed_Cookbook_SE 0:de03cbbcd0ff 236 typedef enum {
mbed_Cookbook_SE 0:de03cbbcd0ff 237 HCI_POWER_OFF = 0,
mbed_Cookbook_SE 0:de03cbbcd0ff 238 HCI_POWER_ON,
mbed_Cookbook_SE 0:de03cbbcd0ff 239 HCI_POWER_SLEEP
mbed_Cookbook_SE 0:de03cbbcd0ff 240 } HCI_POWER_MODE;
mbed_Cookbook_SE 0:de03cbbcd0ff 241
mbed_Cookbook_SE 0:de03cbbcd0ff 242 /**
mbed_Cookbook_SE 0:de03cbbcd0ff 243 * State of BTstack
mbed_Cookbook_SE 0:de03cbbcd0ff 244 */
mbed_Cookbook_SE 0:de03cbbcd0ff 245 typedef enum {
mbed_Cookbook_SE 0:de03cbbcd0ff 246 HCI_STATE_OFF = 0,
mbed_Cookbook_SE 0:de03cbbcd0ff 247 HCI_STATE_INITIALIZING,
mbed_Cookbook_SE 0:de03cbbcd0ff 248 HCI_STATE_WORKING,
mbed_Cookbook_SE 0:de03cbbcd0ff 249 HCI_STATE_HALTING,
mbed_Cookbook_SE 0:de03cbbcd0ff 250 HCI_STATE_SLEEPING,
mbed_Cookbook_SE 0:de03cbbcd0ff 251 HCI_STATE_FALLING_ASLEEP
mbed_Cookbook_SE 0:de03cbbcd0ff 252 } HCI_STATE;
mbed_Cookbook_SE 0:de03cbbcd0ff 253
mbed_Cookbook_SE 0:de03cbbcd0ff 254 /**
mbed_Cookbook_SE 0:de03cbbcd0ff 255 * compact HCI Command packet description
mbed_Cookbook_SE 0:de03cbbcd0ff 256 */
mbed_Cookbook_SE 0:de03cbbcd0ff 257 typedef struct {
mbed_Cookbook_SE 0:de03cbbcd0ff 258 uint16_t opcode;
mbed_Cookbook_SE 0:de03cbbcd0ff 259 const char *format;
mbed_Cookbook_SE 0:de03cbbcd0ff 260 } hci_cmd_t;
mbed_Cookbook_SE 0:de03cbbcd0ff 261
mbed_Cookbook_SE 0:de03cbbcd0ff 262
mbed_Cookbook_SE 0:de03cbbcd0ff 263 // HCI Commands - see hci_cmds.c for info on parameters
mbed_Cookbook_SE 0:de03cbbcd0ff 264 extern const hci_cmd_t btstack_get_state;
mbed_Cookbook_SE 0:de03cbbcd0ff 265 extern const hci_cmd_t btstack_set_power_mode;
mbed_Cookbook_SE 0:de03cbbcd0ff 266 extern const hci_cmd_t btstack_set_acl_capture_mode;
mbed_Cookbook_SE 0:de03cbbcd0ff 267 extern const hci_cmd_t btstack_get_version;
mbed_Cookbook_SE 0:de03cbbcd0ff 268 extern const hci_cmd_t btstack_get_system_bluetooth_enabled;
mbed_Cookbook_SE 0:de03cbbcd0ff 269 extern const hci_cmd_t btstack_set_system_bluetooth_enabled;
mbed_Cookbook_SE 0:de03cbbcd0ff 270 extern const hci_cmd_t btstack_set_discoverable;
mbed_Cookbook_SE 0:de03cbbcd0ff 271 extern const hci_cmd_t btstack_set_bluetooth_enabled; // only used by btstack config
mbed_Cookbook_SE 0:de03cbbcd0ff 272
mbed_Cookbook_SE 0:de03cbbcd0ff 273 extern const hci_cmd_t hci_accept_connection_request;
mbed_Cookbook_SE 0:de03cbbcd0ff 274 extern const hci_cmd_t hci_authentication_requested;
mbed_Cookbook_SE 0:de03cbbcd0ff 275 extern const hci_cmd_t hci_change_connection_link_key;
mbed_Cookbook_SE 0:de03cbbcd0ff 276 extern const hci_cmd_t hci_create_connection;
mbed_Cookbook_SE 0:de03cbbcd0ff 277 extern const hci_cmd_t hci_create_connection_cancel;
mbed_Cookbook_SE 0:de03cbbcd0ff 278 extern const hci_cmd_t hci_delete_stored_link_key;
mbed_Cookbook_SE 0:de03cbbcd0ff 279 extern const hci_cmd_t hci_disconnect;
mbed_Cookbook_SE 0:de03cbbcd0ff 280 extern const hci_cmd_t hci_host_buffer_size;
mbed_Cookbook_SE 0:de03cbbcd0ff 281 extern const hci_cmd_t hci_inquiry;
mbed_Cookbook_SE 0:de03cbbcd0ff 282 extern const hci_cmd_t hci_inquiry_cancel;
mbed_Cookbook_SE 0:de03cbbcd0ff 283 extern const hci_cmd_t hci_link_key_request_negative_reply;
mbed_Cookbook_SE 0:de03cbbcd0ff 284 extern const hci_cmd_t hci_link_key_request_reply;
mbed_Cookbook_SE 0:de03cbbcd0ff 285 extern const hci_cmd_t hci_pin_code_request_reply;
mbed_Cookbook_SE 0:de03cbbcd0ff 286 extern const hci_cmd_t hci_pin_code_request_negative_reply;
mbed_Cookbook_SE 0:de03cbbcd0ff 287 extern const hci_cmd_t hci_qos_setup;
mbed_Cookbook_SE 0:de03cbbcd0ff 288 extern const hci_cmd_t hci_read_bd_addr;
mbed_Cookbook_SE 0:de03cbbcd0ff 289 extern const hci_cmd_t hci_read_buffer_size;
mbed_Cookbook_SE 0:de03cbbcd0ff 290 extern const hci_cmd_t hci_read_le_host_supported;
mbed_Cookbook_SE 0:de03cbbcd0ff 291 extern const hci_cmd_t hci_read_link_policy_settings;
mbed_Cookbook_SE 0:de03cbbcd0ff 292 extern const hci_cmd_t hci_read_link_supervision_timeout;
mbed_Cookbook_SE 0:de03cbbcd0ff 293 extern const hci_cmd_t hci_read_local_supported_features;
mbed_Cookbook_SE 0:de03cbbcd0ff 294 extern const hci_cmd_t hci_read_num_broadcast_retransmissions;
mbed_Cookbook_SE 0:de03cbbcd0ff 295 extern const hci_cmd_t hci_reject_connection_request;
mbed_Cookbook_SE 0:de03cbbcd0ff 296 extern const hci_cmd_t hci_remote_name_request;
mbed_Cookbook_SE 0:de03cbbcd0ff 297 extern const hci_cmd_t hci_remote_name_request_cancel;
mbed_Cookbook_SE 0:de03cbbcd0ff 298 extern const hci_cmd_t hci_reset;
mbed_Cookbook_SE 0:de03cbbcd0ff 299 extern const hci_cmd_t hci_role_discovery;
mbed_Cookbook_SE 0:de03cbbcd0ff 300 extern const hci_cmd_t hci_set_event_mask;
mbed_Cookbook_SE 0:de03cbbcd0ff 301 extern const hci_cmd_t hci_set_connection_encryption;
mbed_Cookbook_SE 0:de03cbbcd0ff 302 extern const hci_cmd_t hci_sniff_mode;
mbed_Cookbook_SE 0:de03cbbcd0ff 303 extern const hci_cmd_t hci_switch_role_command;
mbed_Cookbook_SE 0:de03cbbcd0ff 304 extern const hci_cmd_t hci_write_authentication_enable;
mbed_Cookbook_SE 0:de03cbbcd0ff 305 extern const hci_cmd_t hci_write_class_of_device;
mbed_Cookbook_SE 0:de03cbbcd0ff 306 extern const hci_cmd_t hci_write_extended_inquiry_response;
mbed_Cookbook_SE 0:de03cbbcd0ff 307 extern const hci_cmd_t hci_write_inquiry_mode;
mbed_Cookbook_SE 0:de03cbbcd0ff 308 extern const hci_cmd_t hci_write_le_host_supported;
mbed_Cookbook_SE 0:de03cbbcd0ff 309 extern const hci_cmd_t hci_write_link_policy_settings;
mbed_Cookbook_SE 0:de03cbbcd0ff 310 extern const hci_cmd_t hci_write_link_supervision_timeout;
mbed_Cookbook_SE 0:de03cbbcd0ff 311 extern const hci_cmd_t hci_write_local_name;
mbed_Cookbook_SE 0:de03cbbcd0ff 312 extern const hci_cmd_t hci_write_num_broadcast_retransmissions;
mbed_Cookbook_SE 0:de03cbbcd0ff 313 extern const hci_cmd_t hci_write_page_timeout;
mbed_Cookbook_SE 0:de03cbbcd0ff 314 extern const hci_cmd_t hci_write_scan_enable;
mbed_Cookbook_SE 0:de03cbbcd0ff 315 extern const hci_cmd_t hci_write_simple_pairing_mode;
mbed_Cookbook_SE 0:de03cbbcd0ff 316
mbed_Cookbook_SE 0:de03cbbcd0ff 317 extern const hci_cmd_t hci_le_add_device_to_whitelist;
mbed_Cookbook_SE 0:de03cbbcd0ff 318 extern const hci_cmd_t hci_le_clear_white_list;
mbed_Cookbook_SE 0:de03cbbcd0ff 319 extern const hci_cmd_t hci_le_connection_update;
mbed_Cookbook_SE 0:de03cbbcd0ff 320 extern const hci_cmd_t hci_le_create_connection;
mbed_Cookbook_SE 0:de03cbbcd0ff 321 extern const hci_cmd_t hci_le_create_connection_cancel;
mbed_Cookbook_SE 0:de03cbbcd0ff 322 extern const hci_cmd_t hci_le_encrypt;
mbed_Cookbook_SE 0:de03cbbcd0ff 323 extern const hci_cmd_t hci_le_long_term_key_negative_reply;
mbed_Cookbook_SE 0:de03cbbcd0ff 324 extern const hci_cmd_t hci_le_long_term_key_request_reply;
mbed_Cookbook_SE 0:de03cbbcd0ff 325 extern const hci_cmd_t hci_le_rand;
mbed_Cookbook_SE 0:de03cbbcd0ff 326 extern const hci_cmd_t hci_le_read_advertising_channel_tx_power;
mbed_Cookbook_SE 0:de03cbbcd0ff 327 extern const hci_cmd_t hci_le_read_buffer_size ;
mbed_Cookbook_SE 0:de03cbbcd0ff 328 extern const hci_cmd_t hci_le_read_channel_map;
mbed_Cookbook_SE 0:de03cbbcd0ff 329 extern const hci_cmd_t hci_le_read_remote_used_features;
mbed_Cookbook_SE 0:de03cbbcd0ff 330 extern const hci_cmd_t hci_le_read_supported_features;
mbed_Cookbook_SE 0:de03cbbcd0ff 331 extern const hci_cmd_t hci_le_read_supported_states;
mbed_Cookbook_SE 0:de03cbbcd0ff 332 extern const hci_cmd_t hci_le_read_white_list_size;
mbed_Cookbook_SE 0:de03cbbcd0ff 333 extern const hci_cmd_t hci_le_receiver_test;
mbed_Cookbook_SE 0:de03cbbcd0ff 334 extern const hci_cmd_t hci_le_remove_device_from_whitelist;
mbed_Cookbook_SE 0:de03cbbcd0ff 335 extern const hci_cmd_t hci_le_set_advertise_enable;
mbed_Cookbook_SE 0:de03cbbcd0ff 336 extern const hci_cmd_t hci_le_set_advertising_data;
mbed_Cookbook_SE 0:de03cbbcd0ff 337 extern const hci_cmd_t hci_le_set_advertising_parameters;
mbed_Cookbook_SE 0:de03cbbcd0ff 338 extern const hci_cmd_t hci_le_set_event_mask;
mbed_Cookbook_SE 0:de03cbbcd0ff 339 extern const hci_cmd_t hci_le_set_host_channel_classification;
mbed_Cookbook_SE 0:de03cbbcd0ff 340 extern const hci_cmd_t hci_le_set_random_address;
mbed_Cookbook_SE 0:de03cbbcd0ff 341 extern const hci_cmd_t hci_le_set_scan_enable;
mbed_Cookbook_SE 0:de03cbbcd0ff 342 extern const hci_cmd_t hci_le_set_scan_parameters;
mbed_Cookbook_SE 0:de03cbbcd0ff 343 extern const hci_cmd_t hci_le_set_scan_response_data;
mbed_Cookbook_SE 0:de03cbbcd0ff 344 extern const hci_cmd_t hci_le_start_encryption;
mbed_Cookbook_SE 0:de03cbbcd0ff 345 extern const hci_cmd_t hci_le_test_end;
mbed_Cookbook_SE 0:de03cbbcd0ff 346 extern const hci_cmd_t hci_le_transmitter_test;
mbed_Cookbook_SE 0:de03cbbcd0ff 347
mbed_Cookbook_SE 0:de03cbbcd0ff 348 extern const hci_cmd_t l2cap_accept_connection;
mbed_Cookbook_SE 0:de03cbbcd0ff 349 extern const hci_cmd_t l2cap_create_channel;
mbed_Cookbook_SE 0:de03cbbcd0ff 350 extern const hci_cmd_t l2cap_create_channel_mtu;
mbed_Cookbook_SE 0:de03cbbcd0ff 351 extern const hci_cmd_t l2cap_decline_connection;
mbed_Cookbook_SE 0:de03cbbcd0ff 352 extern const hci_cmd_t l2cap_disconnect;
mbed_Cookbook_SE 0:de03cbbcd0ff 353 extern const hci_cmd_t l2cap_register_service;
mbed_Cookbook_SE 0:de03cbbcd0ff 354 extern const hci_cmd_t l2cap_unregister_service;
mbed_Cookbook_SE 0:de03cbbcd0ff 355
mbed_Cookbook_SE 0:de03cbbcd0ff 356 extern const hci_cmd_t sdp_register_service_record;
mbed_Cookbook_SE 0:de03cbbcd0ff 357 extern const hci_cmd_t sdp_unregister_service_record;
mbed_Cookbook_SE 0:de03cbbcd0ff 358
mbed_Cookbook_SE 0:de03cbbcd0ff 359 // accept connection @param bd_addr(48), rfcomm_cid (16)
mbed_Cookbook_SE 0:de03cbbcd0ff 360 extern const hci_cmd_t rfcomm_accept_connection;
mbed_Cookbook_SE 0:de03cbbcd0ff 361 // create rfcomm channel: @param bd_addr(48), channel (8)
mbed_Cookbook_SE 0:de03cbbcd0ff 362 extern const hci_cmd_t rfcomm_create_channel;
mbed_Cookbook_SE 0:de03cbbcd0ff 363 // create rfcomm channel: @param bd_addr(48), channel (8), mtu (16), credits (8)
mbed_Cookbook_SE 0:de03cbbcd0ff 364 extern const hci_cmd_t rfcomm_create_channel_with_initial_credits;
mbed_Cookbook_SE 0:de03cbbcd0ff 365 // decline rfcomm disconnect,@param bd_addr(48), rfcomm cid (16), reason(8)
mbed_Cookbook_SE 0:de03cbbcd0ff 366 extern const hci_cmd_t rfcomm_decline_connection;
mbed_Cookbook_SE 0:de03cbbcd0ff 367 // disconnect rfcomm disconnect, @param rfcomm_cid(8), reason(8)
mbed_Cookbook_SE 0:de03cbbcd0ff 368 extern const hci_cmd_t rfcomm_disconnect;
mbed_Cookbook_SE 0:de03cbbcd0ff 369 // register rfcomm service: @param channel(8), mtu (16)
mbed_Cookbook_SE 0:de03cbbcd0ff 370 extern const hci_cmd_t rfcomm_register_service;
mbed_Cookbook_SE 0:de03cbbcd0ff 371 // register rfcomm service: @param channel(8), mtu (16), initial credits (8)
mbed_Cookbook_SE 0:de03cbbcd0ff 372 extern const hci_cmd_t rfcomm_register_service_with_initial_credits;
mbed_Cookbook_SE 0:de03cbbcd0ff 373 // unregister rfcomm service, @param service_channel(16)
mbed_Cookbook_SE 0:de03cbbcd0ff 374 extern const hci_cmd_t rfcomm_unregister_service;
mbed_Cookbook_SE 0:de03cbbcd0ff 375 // request persisten rfcomm channel for service name: serive name (char*)
mbed_Cookbook_SE 0:de03cbbcd0ff 376 extern const hci_cmd_t rfcomm_persistent_channel_for_service;
mbed_Cookbook_SE 0:de03cbbcd0ff 377
mbed_Cookbook_SE 0:de03cbbcd0ff 378 #if defined __cplusplus
mbed_Cookbook_SE 0:de03cbbcd0ff 379 }
mbed_Cookbook_SE 0:de03cbbcd0ff 380 #endif