mbed base bard check program for BlueTooth USB dongle module (3 switches, 6 leds, I2C LCD, A/D)
Fork of BTstack by
BTstack/hci_cmds.c@3:7b7d1273e2d5, 2016-10-17 (annotated)
- Committer:
- tamaki
- Date:
- Mon Oct 17 00:25:18 2016 +0000
- Revision:
- 3:7b7d1273e2d5
- Parent:
- 0:1ed23ab1345f
mbed base bard check program
; for BlueTooth USB dongle module
; (3 switches, 6 leds, I2C LCD, A/D)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:1ed23ab1345f | 1 | /* |
va009039 | 0:1ed23ab1345f | 2 | * Copyright (C) 2009-2012 by Matthias Ringwald |
va009039 | 0:1ed23ab1345f | 3 | * |
va009039 | 0:1ed23ab1345f | 4 | * Redistribution and use in source and binary forms, with or without |
va009039 | 0:1ed23ab1345f | 5 | * modification, are permitted provided that the following conditions |
va009039 | 0:1ed23ab1345f | 6 | * are met: |
va009039 | 0:1ed23ab1345f | 7 | * |
va009039 | 0:1ed23ab1345f | 8 | * 1. Redistributions of source code must retain the above copyright |
va009039 | 0:1ed23ab1345f | 9 | * notice, this list of conditions and the following disclaimer. |
va009039 | 0:1ed23ab1345f | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
va009039 | 0:1ed23ab1345f | 11 | * notice, this list of conditions and the following disclaimer in the |
va009039 | 0:1ed23ab1345f | 12 | * documentation and/or other materials provided with the distribution. |
va009039 | 0:1ed23ab1345f | 13 | * 3. Neither the name of the copyright holders nor the names of |
va009039 | 0:1ed23ab1345f | 14 | * contributors may be used to endorse or promote products derived |
va009039 | 0:1ed23ab1345f | 15 | * from this software without specific prior written permission. |
va009039 | 0:1ed23ab1345f | 16 | * 4. Any redistribution, use, or modification is done solely for |
va009039 | 0:1ed23ab1345f | 17 | * personal benefit and not for any commercial purpose or for |
va009039 | 0:1ed23ab1345f | 18 | * monetary gain. |
va009039 | 0:1ed23ab1345f | 19 | * |
va009039 | 0:1ed23ab1345f | 20 | * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS |
va009039 | 0:1ed23ab1345f | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
va009039 | 0:1ed23ab1345f | 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
va009039 | 0:1ed23ab1345f | 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS |
va009039 | 0:1ed23ab1345f | 24 | * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
va009039 | 0:1ed23ab1345f | 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
va009039 | 0:1ed23ab1345f | 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
va009039 | 0:1ed23ab1345f | 27 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
va009039 | 0:1ed23ab1345f | 28 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
va009039 | 0:1ed23ab1345f | 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
va009039 | 0:1ed23ab1345f | 30 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
va009039 | 0:1ed23ab1345f | 31 | * SUCH DAMAGE. |
va009039 | 0:1ed23ab1345f | 32 | * |
va009039 | 0:1ed23ab1345f | 33 | * Please inquire about commercial licensing options at btstack@ringwald.ch |
va009039 | 0:1ed23ab1345f | 34 | * |
va009039 | 0:1ed23ab1345f | 35 | */ |
va009039 | 0:1ed23ab1345f | 36 | |
va009039 | 0:1ed23ab1345f | 37 | /* |
va009039 | 0:1ed23ab1345f | 38 | * hci_cmds.c |
va009039 | 0:1ed23ab1345f | 39 | * |
va009039 | 0:1ed23ab1345f | 40 | * Created by Matthias Ringwald on 7/23/09. |
va009039 | 0:1ed23ab1345f | 41 | */ |
va009039 | 0:1ed23ab1345f | 42 | |
va009039 | 0:1ed23ab1345f | 43 | #include <btstack/hci_cmds.h> |
va009039 | 0:1ed23ab1345f | 44 | |
va009039 | 0:1ed23ab1345f | 45 | #include <string.h> |
va009039 | 0:1ed23ab1345f | 46 | |
va009039 | 0:1ed23ab1345f | 47 | #include <btstack/sdp_util.h> |
va009039 | 0:1ed23ab1345f | 48 | #include "config.h" |
va009039 | 0:1ed23ab1345f | 49 | #include "hci.h" |
va009039 | 0:1ed23ab1345f | 50 | |
va009039 | 0:1ed23ab1345f | 51 | // calculate combined ogf/ocf value |
va009039 | 0:1ed23ab1345f | 52 | #define OPCODE(ogf, ocf) (ocf | ogf << 10) |
va009039 | 0:1ed23ab1345f | 53 | |
va009039 | 0:1ed23ab1345f | 54 | /** |
va009039 | 0:1ed23ab1345f | 55 | * construct HCI Command based on template |
va009039 | 0:1ed23ab1345f | 56 | * |
va009039 | 0:1ed23ab1345f | 57 | * Format: |
va009039 | 0:1ed23ab1345f | 58 | * 1,2,3,4: one to four byte value |
va009039 | 0:1ed23ab1345f | 59 | * H: HCI connection handle |
va009039 | 0:1ed23ab1345f | 60 | * B: Bluetooth Baseband Address (BD_ADDR) |
va009039 | 0:1ed23ab1345f | 61 | * E: Extended Inquiry Result |
va009039 | 0:1ed23ab1345f | 62 | * N: Name up to 248 chars, \0 terminated |
va009039 | 0:1ed23ab1345f | 63 | * P: 16 byte Pairing code |
va009039 | 0:1ed23ab1345f | 64 | * S: Service Record (Data Element Sequence) |
va009039 | 0:1ed23ab1345f | 65 | */ |
va009039 | 0:1ed23ab1345f | 66 | uint16_t hci_create_cmd_internal(uint8_t *hci_cmd_buffer, const hci_cmd_t *cmd, va_list argptr){ |
va009039 | 0:1ed23ab1345f | 67 | |
va009039 | 0:1ed23ab1345f | 68 | hci_cmd_buffer[0] = cmd->opcode & 0xff; |
va009039 | 0:1ed23ab1345f | 69 | hci_cmd_buffer[1] = cmd->opcode >> 8; |
va009039 | 0:1ed23ab1345f | 70 | int pos = 3; |
va009039 | 0:1ed23ab1345f | 71 | |
va009039 | 0:1ed23ab1345f | 72 | const char *format = cmd->format; |
va009039 | 0:1ed23ab1345f | 73 | uint16_t word; |
va009039 | 0:1ed23ab1345f | 74 | uint32_t longword; |
va009039 | 0:1ed23ab1345f | 75 | uint8_t * ptr; |
va009039 | 0:1ed23ab1345f | 76 | while (*format) { |
va009039 | 0:1ed23ab1345f | 77 | switch(*format) { |
va009039 | 0:1ed23ab1345f | 78 | case '1': // 8 bit value |
va009039 | 0:1ed23ab1345f | 79 | case '2': // 16 bit value |
va009039 | 0:1ed23ab1345f | 80 | case 'H': // hci_handle |
va009039 | 0:1ed23ab1345f | 81 | word = va_arg(argptr, int); // minimal va_arg is int: 2 bytes on 8+16 bit CPUs |
va009039 | 0:1ed23ab1345f | 82 | hci_cmd_buffer[pos++] = word & 0xff; |
va009039 | 0:1ed23ab1345f | 83 | if (*format == '2') { |
va009039 | 0:1ed23ab1345f | 84 | hci_cmd_buffer[pos++] = word >> 8; |
va009039 | 0:1ed23ab1345f | 85 | } else if (*format == 'H') { |
va009039 | 0:1ed23ab1345f | 86 | // TODO implement opaque client connection handles |
va009039 | 0:1ed23ab1345f | 87 | // pass module handle for now |
va009039 | 0:1ed23ab1345f | 88 | hci_cmd_buffer[pos++] = word >> 8; |
va009039 | 0:1ed23ab1345f | 89 | } |
va009039 | 0:1ed23ab1345f | 90 | break; |
va009039 | 0:1ed23ab1345f | 91 | case '3': |
va009039 | 0:1ed23ab1345f | 92 | case '4': |
va009039 | 0:1ed23ab1345f | 93 | longword = va_arg(argptr, uint32_t); |
va009039 | 0:1ed23ab1345f | 94 | // longword = va_arg(argptr, int); |
va009039 | 0:1ed23ab1345f | 95 | hci_cmd_buffer[pos++] = longword; |
va009039 | 0:1ed23ab1345f | 96 | hci_cmd_buffer[pos++] = longword >> 8; |
va009039 | 0:1ed23ab1345f | 97 | hci_cmd_buffer[pos++] = longword >> 16; |
va009039 | 0:1ed23ab1345f | 98 | if (*format == '4'){ |
va009039 | 0:1ed23ab1345f | 99 | hci_cmd_buffer[pos++] = longword >> 24; |
va009039 | 0:1ed23ab1345f | 100 | } |
va009039 | 0:1ed23ab1345f | 101 | break; |
va009039 | 0:1ed23ab1345f | 102 | case 'B': // bt-addr |
va009039 | 0:1ed23ab1345f | 103 | ptr = va_arg(argptr, uint8_t *); |
va009039 | 0:1ed23ab1345f | 104 | hci_cmd_buffer[pos++] = ptr[5]; |
va009039 | 0:1ed23ab1345f | 105 | hci_cmd_buffer[pos++] = ptr[4]; |
va009039 | 0:1ed23ab1345f | 106 | hci_cmd_buffer[pos++] = ptr[3]; |
va009039 | 0:1ed23ab1345f | 107 | hci_cmd_buffer[pos++] = ptr[2]; |
va009039 | 0:1ed23ab1345f | 108 | hci_cmd_buffer[pos++] = ptr[1]; |
va009039 | 0:1ed23ab1345f | 109 | hci_cmd_buffer[pos++] = ptr[0]; |
va009039 | 0:1ed23ab1345f | 110 | break; |
va009039 | 0:1ed23ab1345f | 111 | case 'E': // Extended Inquiry Information 240 octets |
va009039 | 0:1ed23ab1345f | 112 | ptr = va_arg(argptr, uint8_t *); |
va009039 | 0:1ed23ab1345f | 113 | memcpy(&hci_cmd_buffer[pos], ptr, 240); |
va009039 | 0:1ed23ab1345f | 114 | pos += 240; |
va009039 | 0:1ed23ab1345f | 115 | break; |
va009039 | 0:1ed23ab1345f | 116 | case 'N': { // UTF-8 string, null terminated |
va009039 | 0:1ed23ab1345f | 117 | ptr = va_arg(argptr, uint8_t *); |
va009039 | 0:1ed23ab1345f | 118 | uint16_t len = strlen((const char*) ptr); |
va009039 | 0:1ed23ab1345f | 119 | if (len > 248) { |
va009039 | 0:1ed23ab1345f | 120 | len = 248; |
va009039 | 0:1ed23ab1345f | 121 | } |
va009039 | 0:1ed23ab1345f | 122 | memcpy(&hci_cmd_buffer[pos], ptr, len); |
va009039 | 0:1ed23ab1345f | 123 | if (len < 248) { |
va009039 | 0:1ed23ab1345f | 124 | // fill remaining space with zeroes |
va009039 | 0:1ed23ab1345f | 125 | memset(&hci_cmd_buffer[pos+len], 0, 248-len); |
va009039 | 0:1ed23ab1345f | 126 | } |
va009039 | 0:1ed23ab1345f | 127 | pos += 248; |
va009039 | 0:1ed23ab1345f | 128 | break; |
va009039 | 0:1ed23ab1345f | 129 | } |
va009039 | 0:1ed23ab1345f | 130 | case 'P': // 16 byte PIN code or link key |
va009039 | 0:1ed23ab1345f | 131 | ptr = va_arg(argptr, uint8_t *); |
va009039 | 0:1ed23ab1345f | 132 | memcpy(&hci_cmd_buffer[pos], ptr, 16); |
va009039 | 0:1ed23ab1345f | 133 | pos += 16; |
va009039 | 0:1ed23ab1345f | 134 | break; |
va009039 | 0:1ed23ab1345f | 135 | #ifdef HAVE_BLE |
va009039 | 0:1ed23ab1345f | 136 | case 'A': // 31 bytes advertising data |
va009039 | 0:1ed23ab1345f | 137 | ptr = va_arg(argptr, uint8_t *); |
va009039 | 0:1ed23ab1345f | 138 | memcpy(&hci_cmd_buffer[pos], ptr, 31); |
va009039 | 0:1ed23ab1345f | 139 | pos += 31; |
va009039 | 0:1ed23ab1345f | 140 | break; |
va009039 | 0:1ed23ab1345f | 141 | #endif |
va009039 | 0:1ed23ab1345f | 142 | #ifdef HAVE_SDP |
va009039 | 0:1ed23ab1345f | 143 | case 'S': { // Service Record (Data Element Sequence) |
va009039 | 0:1ed23ab1345f | 144 | ptr = va_arg(argptr, uint8_t *); |
va009039 | 0:1ed23ab1345f | 145 | uint16_t len = de_get_len(ptr); |
va009039 | 0:1ed23ab1345f | 146 | memcpy(&hci_cmd_buffer[pos], ptr, len); |
va009039 | 0:1ed23ab1345f | 147 | pos += len; |
va009039 | 0:1ed23ab1345f | 148 | break; |
va009039 | 0:1ed23ab1345f | 149 | } |
va009039 | 0:1ed23ab1345f | 150 | #endif |
va009039 | 0:1ed23ab1345f | 151 | default: |
va009039 | 0:1ed23ab1345f | 152 | break; |
va009039 | 0:1ed23ab1345f | 153 | } |
va009039 | 0:1ed23ab1345f | 154 | format++; |
va009039 | 0:1ed23ab1345f | 155 | }; |
va009039 | 0:1ed23ab1345f | 156 | hci_cmd_buffer[2] = pos - 3; |
va009039 | 0:1ed23ab1345f | 157 | return pos; |
va009039 | 0:1ed23ab1345f | 158 | } |
va009039 | 0:1ed23ab1345f | 159 | |
va009039 | 0:1ed23ab1345f | 160 | /** |
va009039 | 0:1ed23ab1345f | 161 | * construct HCI Command based on template |
va009039 | 0:1ed23ab1345f | 162 | * |
va009039 | 0:1ed23ab1345f | 163 | * mainly calls hci_create_cmd_internal |
va009039 | 0:1ed23ab1345f | 164 | */ |
va009039 | 0:1ed23ab1345f | 165 | uint16_t hci_create_cmd(uint8_t *hci_cmd_buffer, hci_cmd_t *cmd, ...){ |
va009039 | 0:1ed23ab1345f | 166 | va_list argptr; |
va009039 | 0:1ed23ab1345f | 167 | va_start(argptr, cmd); |
va009039 | 0:1ed23ab1345f | 168 | uint16_t len = hci_create_cmd_internal(hci_cmd_buffer, cmd, argptr); |
va009039 | 0:1ed23ab1345f | 169 | va_end(argptr); |
va009039 | 0:1ed23ab1345f | 170 | return len; |
va009039 | 0:1ed23ab1345f | 171 | } |
va009039 | 0:1ed23ab1345f | 172 | |
va009039 | 0:1ed23ab1345f | 173 | |
va009039 | 0:1ed23ab1345f | 174 | /** |
va009039 | 0:1ed23ab1345f | 175 | * Link Control Commands |
va009039 | 0:1ed23ab1345f | 176 | */ |
va009039 | 0:1ed23ab1345f | 177 | const hci_cmd_t hci_inquiry = { |
va009039 | 0:1ed23ab1345f | 178 | OPCODE(OGF_LINK_CONTROL, 0x01), "311" |
va009039 | 0:1ed23ab1345f | 179 | // LAP, Inquiry length, Num_responses |
va009039 | 0:1ed23ab1345f | 180 | }; |
va009039 | 0:1ed23ab1345f | 181 | const hci_cmd_t hci_inquiry_cancel = { |
va009039 | 0:1ed23ab1345f | 182 | OPCODE(OGF_LINK_CONTROL, 0x02), "" |
va009039 | 0:1ed23ab1345f | 183 | // no params |
va009039 | 0:1ed23ab1345f | 184 | }; |
va009039 | 0:1ed23ab1345f | 185 | const hci_cmd_t hci_create_connection = { |
va009039 | 0:1ed23ab1345f | 186 | OPCODE(OGF_LINK_CONTROL, 0x05), "B21121" |
va009039 | 0:1ed23ab1345f | 187 | // BD_ADDR, Packet_Type, Page_Scan_Repetition_Mode, Reserved, Clock_Offset, Allow_Role_Switch |
va009039 | 0:1ed23ab1345f | 188 | }; |
va009039 | 0:1ed23ab1345f | 189 | const hci_cmd_t hci_disconnect = { |
va009039 | 0:1ed23ab1345f | 190 | OPCODE(OGF_LINK_CONTROL, 0x06), "H1" |
va009039 | 0:1ed23ab1345f | 191 | // Handle, Reason: 0x05, 0x13-0x15, 0x1a, 0x29 |
va009039 | 0:1ed23ab1345f | 192 | // see Errors Codes in BT Spec Part D |
va009039 | 0:1ed23ab1345f | 193 | }; |
va009039 | 0:1ed23ab1345f | 194 | const hci_cmd_t hci_create_connection_cancel = { |
va009039 | 0:1ed23ab1345f | 195 | OPCODE(OGF_LINK_CONTROL, 0x08), "B" |
va009039 | 0:1ed23ab1345f | 196 | // BD_ADDR |
va009039 | 0:1ed23ab1345f | 197 | }; |
va009039 | 0:1ed23ab1345f | 198 | const hci_cmd_t hci_accept_connection_request = { |
va009039 | 0:1ed23ab1345f | 199 | OPCODE(OGF_LINK_CONTROL, 0x09), "B1" |
va009039 | 0:1ed23ab1345f | 200 | // BD_ADDR, Role: become master, stay slave |
va009039 | 0:1ed23ab1345f | 201 | }; |
va009039 | 0:1ed23ab1345f | 202 | const hci_cmd_t hci_reject_connection_request = { |
va009039 | 0:1ed23ab1345f | 203 | OPCODE(OGF_LINK_CONTROL, 0x0a), "B1" |
va009039 | 0:1ed23ab1345f | 204 | // BD_ADDR, reason e.g. CONNECTION REJECTED DUE TO LIMITED RESOURCES (0x0d) |
va009039 | 0:1ed23ab1345f | 205 | }; |
va009039 | 0:1ed23ab1345f | 206 | const hci_cmd_t hci_link_key_request_reply = { |
va009039 | 0:1ed23ab1345f | 207 | OPCODE(OGF_LINK_CONTROL, 0x0b), "BP" |
va009039 | 0:1ed23ab1345f | 208 | // BD_ADDR, LINK_KEY |
va009039 | 0:1ed23ab1345f | 209 | }; |
va009039 | 0:1ed23ab1345f | 210 | const hci_cmd_t hci_link_key_request_negative_reply = { |
va009039 | 0:1ed23ab1345f | 211 | OPCODE(OGF_LINK_CONTROL, 0x0c), "B" |
va009039 | 0:1ed23ab1345f | 212 | // BD_ADDR |
va009039 | 0:1ed23ab1345f | 213 | }; |
va009039 | 0:1ed23ab1345f | 214 | const hci_cmd_t hci_pin_code_request_reply = { |
va009039 | 0:1ed23ab1345f | 215 | OPCODE(OGF_LINK_CONTROL, 0x0d), "B1P" |
va009039 | 0:1ed23ab1345f | 216 | // BD_ADDR, pin length, PIN: c-string |
va009039 | 0:1ed23ab1345f | 217 | }; |
va009039 | 0:1ed23ab1345f | 218 | const hci_cmd_t hci_pin_code_request_negative_reply = { |
va009039 | 0:1ed23ab1345f | 219 | OPCODE(OGF_LINK_CONTROL, 0x0e), "B" |
va009039 | 0:1ed23ab1345f | 220 | // BD_ADDR |
va009039 | 0:1ed23ab1345f | 221 | }; |
va009039 | 0:1ed23ab1345f | 222 | const hci_cmd_t hci_authentication_requested = { |
va009039 | 0:1ed23ab1345f | 223 | OPCODE(OGF_LINK_CONTROL, 0x11), "H" |
va009039 | 0:1ed23ab1345f | 224 | // Handle |
va009039 | 0:1ed23ab1345f | 225 | }; |
va009039 | 0:1ed23ab1345f | 226 | const hci_cmd_t hci_set_connection_encryption = { |
va009039 | 0:1ed23ab1345f | 227 | OPCODE(OGF_LINK_CONTROL, 0x13), "H1" |
va009039 | 0:1ed23ab1345f | 228 | // Handle, Encryption_Enable |
va009039 | 0:1ed23ab1345f | 229 | }; |
va009039 | 0:1ed23ab1345f | 230 | const hci_cmd_t hci_change_connection_link_key = { |
va009039 | 0:1ed23ab1345f | 231 | OPCODE(OGF_LINK_CONTROL, 0x15), "H" |
va009039 | 0:1ed23ab1345f | 232 | // Handle |
va009039 | 0:1ed23ab1345f | 233 | }; |
va009039 | 0:1ed23ab1345f | 234 | const hci_cmd_t hci_remote_name_request = { |
va009039 | 0:1ed23ab1345f | 235 | OPCODE(OGF_LINK_CONTROL, 0x19), "B112" |
va009039 | 0:1ed23ab1345f | 236 | // BD_ADDR, Page_Scan_Repetition_Mode, Reserved, Clock_Offset |
va009039 | 0:1ed23ab1345f | 237 | }; |
va009039 | 0:1ed23ab1345f | 238 | const hci_cmd_t hci_remote_name_request_cancel = { |
va009039 | 0:1ed23ab1345f | 239 | OPCODE(OGF_LINK_CONTROL, 0x1A), "B" |
va009039 | 0:1ed23ab1345f | 240 | // BD_ADDR |
va009039 | 0:1ed23ab1345f | 241 | }; |
va009039 | 0:1ed23ab1345f | 242 | |
va009039 | 0:1ed23ab1345f | 243 | /** |
va009039 | 0:1ed23ab1345f | 244 | * Link Policy Commands |
va009039 | 0:1ed23ab1345f | 245 | */ |
va009039 | 0:1ed23ab1345f | 246 | const hci_cmd_t hci_sniff_mode = { |
va009039 | 0:1ed23ab1345f | 247 | OPCODE(OGF_LINK_POLICY, 0x03), "H2222" |
va009039 | 0:1ed23ab1345f | 248 | // handle, Sniff_Max_Interval, Sniff_Min_Interval, Sniff_Attempt, Sniff_Timeout: |
va009039 | 0:1ed23ab1345f | 249 | }; |
va009039 | 0:1ed23ab1345f | 250 | const hci_cmd_t hci_qos_setup = { |
va009039 | 0:1ed23ab1345f | 251 | OPCODE(OGF_LINK_POLICY, 0x07), "H114444" |
va009039 | 0:1ed23ab1345f | 252 | // handle, flags, service_type, token rate (bytes/s), peak bandwith (bytes/s), |
va009039 | 0:1ed23ab1345f | 253 | // latency (us), delay_variation (us) |
va009039 | 0:1ed23ab1345f | 254 | }; |
va009039 | 0:1ed23ab1345f | 255 | const hci_cmd_t hci_role_discovery = { |
va009039 | 0:1ed23ab1345f | 256 | OPCODE(OGF_LINK_POLICY, 0x09), "H" |
va009039 | 0:1ed23ab1345f | 257 | // handle |
va009039 | 0:1ed23ab1345f | 258 | }; |
va009039 | 0:1ed23ab1345f | 259 | const hci_cmd_t hci_switch_role_command= { |
va009039 | 0:1ed23ab1345f | 260 | OPCODE(OGF_LINK_POLICY, 0x0b), "B1" |
va009039 | 0:1ed23ab1345f | 261 | // BD_ADDR, role: {0=master,1=slave} |
va009039 | 0:1ed23ab1345f | 262 | }; |
va009039 | 0:1ed23ab1345f | 263 | const hci_cmd_t hci_read_link_policy_settings = { |
va009039 | 0:1ed23ab1345f | 264 | OPCODE(OGF_LINK_POLICY, 0x0c), "H" |
va009039 | 0:1ed23ab1345f | 265 | // handle |
va009039 | 0:1ed23ab1345f | 266 | }; |
va009039 | 0:1ed23ab1345f | 267 | const hci_cmd_t hci_write_link_policy_settings = { |
va009039 | 0:1ed23ab1345f | 268 | OPCODE(OGF_LINK_POLICY, 0x0d), "H2" |
va009039 | 0:1ed23ab1345f | 269 | // handle, settings |
va009039 | 0:1ed23ab1345f | 270 | }; |
va009039 | 0:1ed23ab1345f | 271 | |
va009039 | 0:1ed23ab1345f | 272 | /** |
va009039 | 0:1ed23ab1345f | 273 | * Controller & Baseband Commands |
va009039 | 0:1ed23ab1345f | 274 | */ |
va009039 | 0:1ed23ab1345f | 275 | const hci_cmd_t hci_set_event_mask = { |
va009039 | 0:1ed23ab1345f | 276 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x01), "44" |
va009039 | 0:1ed23ab1345f | 277 | // event_mask lower 4 octets, higher 4 bytes |
va009039 | 0:1ed23ab1345f | 278 | }; |
va009039 | 0:1ed23ab1345f | 279 | const hci_cmd_t hci_reset = { |
va009039 | 0:1ed23ab1345f | 280 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x03), "" |
va009039 | 0:1ed23ab1345f | 281 | // no params |
va009039 | 0:1ed23ab1345f | 282 | }; |
va009039 | 0:1ed23ab1345f | 283 | const hci_cmd_t hci_delete_stored_link_key = { |
va009039 | 0:1ed23ab1345f | 284 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x12), "B1" |
va009039 | 0:1ed23ab1345f | 285 | // BD_ADDR, Delete_All_Flag |
va009039 | 0:1ed23ab1345f | 286 | }; |
va009039 | 0:1ed23ab1345f | 287 | const hci_cmd_t hci_write_local_name = { |
va009039 | 0:1ed23ab1345f | 288 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x13), "N" |
va009039 | 0:1ed23ab1345f | 289 | // Local name (UTF-8, Null Terminated, max 248 octets) |
va009039 | 0:1ed23ab1345f | 290 | }; |
va009039 | 0:1ed23ab1345f | 291 | const hci_cmd_t hci_write_page_timeout = { |
va009039 | 0:1ed23ab1345f | 292 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x18), "2" |
va009039 | 0:1ed23ab1345f | 293 | // Page_Timeout * 0.625 ms |
va009039 | 0:1ed23ab1345f | 294 | }; |
va009039 | 0:1ed23ab1345f | 295 | const hci_cmd_t hci_write_scan_enable = { |
va009039 | 0:1ed23ab1345f | 296 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x1A), "1" |
va009039 | 0:1ed23ab1345f | 297 | // Scan_enable: no, inq, page, inq+page |
va009039 | 0:1ed23ab1345f | 298 | }; |
va009039 | 0:1ed23ab1345f | 299 | const hci_cmd_t hci_write_authentication_enable = { |
va009039 | 0:1ed23ab1345f | 300 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x20), "1" |
va009039 | 0:1ed23ab1345f | 301 | // Authentication_Enable |
va009039 | 0:1ed23ab1345f | 302 | }; |
va009039 | 0:1ed23ab1345f | 303 | const hci_cmd_t hci_write_class_of_device = { |
va009039 | 0:1ed23ab1345f | 304 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x24), "3" |
va009039 | 0:1ed23ab1345f | 305 | // Class of Device |
va009039 | 0:1ed23ab1345f | 306 | }; |
va009039 | 0:1ed23ab1345f | 307 | const hci_cmd_t hci_read_num_broadcast_retransmissions = { |
va009039 | 0:1ed23ab1345f | 308 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x29), "" |
va009039 | 0:1ed23ab1345f | 309 | }; |
va009039 | 0:1ed23ab1345f | 310 | const hci_cmd_t hci_write_num_broadcast_retransmissions = { |
va009039 | 0:1ed23ab1345f | 311 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x2a), "1" |
va009039 | 0:1ed23ab1345f | 312 | // Num broadcast retransmissions (e.g. 0 for a single broadcast) |
va009039 | 0:1ed23ab1345f | 313 | }; |
va009039 | 0:1ed23ab1345f | 314 | const hci_cmd_t hci_host_buffer_size = { |
va009039 | 0:1ed23ab1345f | 315 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x33), "2122" |
va009039 | 0:1ed23ab1345f | 316 | // Host_ACL_Data_Packet_Length:, Host_Synchronous_Data_Packet_Length:, Host_Total_Num_ACL_Data_Packets:, Host_Total_Num_Synchronous_Data_Packets: |
va009039 | 0:1ed23ab1345f | 317 | }; |
va009039 | 0:1ed23ab1345f | 318 | const hci_cmd_t hci_read_link_supervision_timeout = { |
va009039 | 0:1ed23ab1345f | 319 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x36), "H" |
va009039 | 0:1ed23ab1345f | 320 | // handle |
va009039 | 0:1ed23ab1345f | 321 | }; |
va009039 | 0:1ed23ab1345f | 322 | const hci_cmd_t hci_write_link_supervision_timeout = { |
va009039 | 0:1ed23ab1345f | 323 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x37), "H2" |
va009039 | 0:1ed23ab1345f | 324 | // handle, Range for N: 0x0001 Ð 0xFFFF Time (Range: 0.625ms Ð 40.9 sec) |
va009039 | 0:1ed23ab1345f | 325 | }; |
va009039 | 0:1ed23ab1345f | 326 | const hci_cmd_t hci_write_inquiry_mode = { |
va009039 | 0:1ed23ab1345f | 327 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x45), "1" |
va009039 | 0:1ed23ab1345f | 328 | // Inquiry mode: 0x00 = standard, 0x01 = with RSSI, 0x02 = extended |
va009039 | 0:1ed23ab1345f | 329 | }; |
va009039 | 0:1ed23ab1345f | 330 | const hci_cmd_t hci_write_extended_inquiry_response = { |
va009039 | 0:1ed23ab1345f | 331 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x52), "1E" |
va009039 | 0:1ed23ab1345f | 332 | // FEC_Required, Exstended Inquiry Response |
va009039 | 0:1ed23ab1345f | 333 | }; |
va009039 | 0:1ed23ab1345f | 334 | const hci_cmd_t hci_write_simple_pairing_mode = { |
va009039 | 0:1ed23ab1345f | 335 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x56), "1" |
va009039 | 0:1ed23ab1345f | 336 | // mode: 0 = off, 1 = on |
va009039 | 0:1ed23ab1345f | 337 | }; |
va009039 | 0:1ed23ab1345f | 338 | const hci_cmd_t hci_read_le_host_supported = { |
va009039 | 0:1ed23ab1345f | 339 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x6c), "" |
va009039 | 0:1ed23ab1345f | 340 | // params: none |
va009039 | 0:1ed23ab1345f | 341 | // return: status, le supported host, simultaneous le host |
va009039 | 0:1ed23ab1345f | 342 | }; |
va009039 | 0:1ed23ab1345f | 343 | const hci_cmd_t hci_write_le_host_supported = { |
va009039 | 0:1ed23ab1345f | 344 | OPCODE(OGF_CONTROLLER_BASEBAND, 0x6d), "11" |
va009039 | 0:1ed23ab1345f | 345 | // param: le supported host, simultaneous le host |
va009039 | 0:1ed23ab1345f | 346 | // return: status |
va009039 | 0:1ed23ab1345f | 347 | }; |
va009039 | 0:1ed23ab1345f | 348 | |
va009039 | 0:1ed23ab1345f | 349 | /** |
va009039 | 0:1ed23ab1345f | 350 | * Informational Parameters |
va009039 | 0:1ed23ab1345f | 351 | */ |
va009039 | 0:1ed23ab1345f | 352 | const hci_cmd_t hci_read_local_supported_features = { |
va009039 | 0:1ed23ab1345f | 353 | OPCODE(OGF_INFORMATIONAL_PARAMETERS, 0x03), "" |
va009039 | 0:1ed23ab1345f | 354 | // no params |
va009039 | 0:1ed23ab1345f | 355 | }; |
va009039 | 0:1ed23ab1345f | 356 | const hci_cmd_t hci_read_buffer_size = { |
va009039 | 0:1ed23ab1345f | 357 | OPCODE(OGF_INFORMATIONAL_PARAMETERS, 0x05), "" |
va009039 | 0:1ed23ab1345f | 358 | // no params |
va009039 | 0:1ed23ab1345f | 359 | }; |
va009039 | 0:1ed23ab1345f | 360 | const hci_cmd_t hci_read_bd_addr = { |
va009039 | 0:1ed23ab1345f | 361 | OPCODE(OGF_INFORMATIONAL_PARAMETERS, 0x09), "" |
va009039 | 0:1ed23ab1345f | 362 | // no params |
va009039 | 0:1ed23ab1345f | 363 | }; |
va009039 | 0:1ed23ab1345f | 364 | |
va009039 | 0:1ed23ab1345f | 365 | #ifdef HAVE_BLE |
va009039 | 0:1ed23ab1345f | 366 | /** |
va009039 | 0:1ed23ab1345f | 367 | * Low Energy Commands |
va009039 | 0:1ed23ab1345f | 368 | */ |
va009039 | 0:1ed23ab1345f | 369 | const hci_cmd_t hci_le_set_event_mask = { |
va009039 | 0:1ed23ab1345f | 370 | OPCODE(OGF_LE_CONTROLLER, 0x01), "44" |
va009039 | 0:1ed23ab1345f | 371 | // params: event_mask lower 4 octets, higher 4 bytes |
va009039 | 0:1ed23ab1345f | 372 | // return: status |
va009039 | 0:1ed23ab1345f | 373 | }; |
va009039 | 0:1ed23ab1345f | 374 | const hci_cmd_t hci_le_read_buffer_size = { |
va009039 | 0:1ed23ab1345f | 375 | OPCODE(OGF_LE_CONTROLLER, 0x02), "" |
va009039 | 0:1ed23ab1345f | 376 | // params: none |
va009039 | 0:1ed23ab1345f | 377 | // return: status, le acl data packet len (16), total num le acl data packets(8) |
va009039 | 0:1ed23ab1345f | 378 | }; |
va009039 | 0:1ed23ab1345f | 379 | const hci_cmd_t hci_le_read_supported_features = { |
va009039 | 0:1ed23ab1345f | 380 | OPCODE(OGF_LE_CONTROLLER, 0x03), "" |
va009039 | 0:1ed23ab1345f | 381 | // params: none |
va009039 | 0:1ed23ab1345f | 382 | // return: LE_Features See [Vol 6] Part B, Section 4.6 |
va009039 | 0:1ed23ab1345f | 383 | }; |
va009039 | 0:1ed23ab1345f | 384 | const hci_cmd_t hci_le_set_random_address = { |
va009039 | 0:1ed23ab1345f | 385 | OPCODE(OGF_LE_CONTROLLER, 0x05), "B" |
va009039 | 0:1ed23ab1345f | 386 | // params: random device address |
va009039 | 0:1ed23ab1345f | 387 | // return: status |
va009039 | 0:1ed23ab1345f | 388 | }; |
va009039 | 0:1ed23ab1345f | 389 | const hci_cmd_t hci_le_set_advertising_parameters = { |
va009039 | 0:1ed23ab1345f | 390 | OPCODE(OGF_LE_CONTROLLER, 0x06), "22111B11" |
va009039 | 0:1ed23ab1345f | 391 | // param: min advertising interval, [0x0020,0x4000], default: 0x0800, unit: 0.625 msec |
va009039 | 0:1ed23ab1345f | 392 | // param: max advertising interval, [0x0020,0x4000], default: 0x0800, unit: 0.625 msec |
va009039 | 0:1ed23ab1345f | 393 | // param: advertising type (enum from 0): ADV_IND, ADC_DIRECT_IND, ADV_SCAN_IND, ADV_NONCONN_IND |
va009039 | 0:1ed23ab1345f | 394 | // param: own address type (enum from 0): public device address, random device address |
va009039 | 0:1ed23ab1345f | 395 | // param: direct address type (enum from 0): public device address, random device address |
va009039 | 0:1ed23ab1345f | 396 | // param: direct address - public or random address of device to be connecteed |
va009039 | 0:1ed23ab1345f | 397 | // param: advertising channel map (flags): chan_37(1), chan_38(2), chan_39(4) |
va009039 | 0:1ed23ab1345f | 398 | // param: advertising filter policy (enum from 0): scan any conn any, scan whitelist, con any, scan any conn whitelist, scan whitelist, con whitelist |
va009039 | 0:1ed23ab1345f | 399 | // return: status |
va009039 | 0:1ed23ab1345f | 400 | }; |
va009039 | 0:1ed23ab1345f | 401 | const hci_cmd_t hci_le_read_advertising_channel_tx_power = { |
va009039 | 0:1ed23ab1345f | 402 | OPCODE(OGF_LE_CONTROLLER, 0x07), "" |
va009039 | 0:1ed23ab1345f | 403 | // params: none |
va009039 | 0:1ed23ab1345f | 404 | // return: status, level [-20,10] signed int (8), units dBm |
va009039 | 0:1ed23ab1345f | 405 | }; |
va009039 | 0:1ed23ab1345f | 406 | const hci_cmd_t hci_le_set_advertising_data= { |
va009039 | 0:1ed23ab1345f | 407 | OPCODE(OGF_LE_CONTROLLER, 0x08), "1A" |
va009039 | 0:1ed23ab1345f | 408 | // param: advertising data len |
va009039 | 0:1ed23ab1345f | 409 | // param: advertising data (31 bytes) |
va009039 | 0:1ed23ab1345f | 410 | // return: status |
va009039 | 0:1ed23ab1345f | 411 | }; |
va009039 | 0:1ed23ab1345f | 412 | const hci_cmd_t hci_le_set_scan_response_data= { |
va009039 | 0:1ed23ab1345f | 413 | OPCODE(OGF_LE_CONTROLLER, 0x09), "1A" |
va009039 | 0:1ed23ab1345f | 414 | // param: scan response data len |
va009039 | 0:1ed23ab1345f | 415 | // param: scan response data (31 bytes) |
va009039 | 0:1ed23ab1345f | 416 | // return: status |
va009039 | 0:1ed23ab1345f | 417 | }; |
va009039 | 0:1ed23ab1345f | 418 | const hci_cmd_t hci_le_set_advertise_enable = { |
va009039 | 0:1ed23ab1345f | 419 | OPCODE(OGF_LE_CONTROLLER, 0x0a), "1" |
va009039 | 0:1ed23ab1345f | 420 | // params: avertise enable: off (0), on (1) |
va009039 | 0:1ed23ab1345f | 421 | // return: status |
va009039 | 0:1ed23ab1345f | 422 | }; |
va009039 | 0:1ed23ab1345f | 423 | const hci_cmd_t hci_le_set_scan_parameters = { |
va009039 | 0:1ed23ab1345f | 424 | OPCODE(OGF_LE_CONTROLLER, 0x0b), "12211" |
va009039 | 0:1ed23ab1345f | 425 | // param: le scan type: passive (0), active (1) |
va009039 | 0:1ed23ab1345f | 426 | // param: le scan interval [0x0004,0x4000], unit: 0.625 msec |
va009039 | 0:1ed23ab1345f | 427 | // param: le scan window [0x0004,0x4000], unit: 0.625 msec |
va009039 | 0:1ed23ab1345f | 428 | // param: own address type: public (0), random (1) |
va009039 | 0:1ed23ab1345f | 429 | // param: scanning filter policy: any (0), only whitelist (1) |
va009039 | 0:1ed23ab1345f | 430 | // return: status |
va009039 | 0:1ed23ab1345f | 431 | }; |
va009039 | 0:1ed23ab1345f | 432 | const hci_cmd_t hci_le_set_scan_enable = { |
va009039 | 0:1ed23ab1345f | 433 | OPCODE(OGF_LE_CONTROLLER, 0x0c), "11" |
va009039 | 0:1ed23ab1345f | 434 | // param: le scan enable: disabled (0), enabled (1) |
va009039 | 0:1ed23ab1345f | 435 | // param: filter duplices: disabled (0), enabled (1) |
va009039 | 0:1ed23ab1345f | 436 | // return: status |
va009039 | 0:1ed23ab1345f | 437 | }; |
va009039 | 0:1ed23ab1345f | 438 | const hci_cmd_t hci_le_create_connection= { |
va009039 | 0:1ed23ab1345f | 439 | OPCODE(OGF_LE_CONTROLLER, 0x0d), "2211B1222222" |
va009039 | 0:1ed23ab1345f | 440 | // param: le scan interval, [0x0004, 0x4000], unit: 0.625 msec |
va009039 | 0:1ed23ab1345f | 441 | // param: le scan window, [0x0004, 0x4000], unit: 0.625 msec |
va009039 | 0:1ed23ab1345f | 442 | // param: initiator filter policy: peer address type + peer address (0), whitelist (1) |
va009039 | 0:1ed23ab1345f | 443 | // param: peer address type: public (0), random (1) |
va009039 | 0:1ed23ab1345f | 444 | // param: peer address |
va009039 | 0:1ed23ab1345f | 445 | // param: own address type: public (0), random (1) |
va009039 | 0:1ed23ab1345f | 446 | // param: conn interval min, [0x0006, 0x0c80], unit: 1.25 msec |
va009039 | 0:1ed23ab1345f | 447 | // param: conn interval max, [0x0006, 0x0c80], unit: 1.25 msec |
va009039 | 0:1ed23ab1345f | 448 | // param: conn latency, number of connection events [0x0000, 0x01f4] |
va009039 | 0:1ed23ab1345f | 449 | // param: supervision timeout, [0x000a, 0x0c80], unit: 10 msec |
va009039 | 0:1ed23ab1345f | 450 | // param: minimum CE length, [0x0000, 0xffff], unit: 0.625 msec |
va009039 | 0:1ed23ab1345f | 451 | // return: none -> le create connection complete event |
va009039 | 0:1ed23ab1345f | 452 | }; |
va009039 | 0:1ed23ab1345f | 453 | const hci_cmd_t hci_le_create_connection_cancel = { |
va009039 | 0:1ed23ab1345f | 454 | OPCODE(OGF_LE_CONTROLLER, 0x0e), "" |
va009039 | 0:1ed23ab1345f | 455 | // params: none |
va009039 | 0:1ed23ab1345f | 456 | // return: status |
va009039 | 0:1ed23ab1345f | 457 | }; |
va009039 | 0:1ed23ab1345f | 458 | const hci_cmd_t hci_le_read_white_list_size = { |
va009039 | 0:1ed23ab1345f | 459 | OPCODE(OGF_LE_CONTROLLER, 0x0f), "" |
va009039 | 0:1ed23ab1345f | 460 | // params: none |
va009039 | 0:1ed23ab1345f | 461 | // return: status, number of entries in controller whitelist |
va009039 | 0:1ed23ab1345f | 462 | }; |
va009039 | 0:1ed23ab1345f | 463 | const hci_cmd_t hci_le_clear_white_list = { |
va009039 | 0:1ed23ab1345f | 464 | OPCODE(OGF_LE_CONTROLLER, 0x10), "" |
va009039 | 0:1ed23ab1345f | 465 | // params: none |
va009039 | 0:1ed23ab1345f | 466 | // return: status |
va009039 | 0:1ed23ab1345f | 467 | }; |
va009039 | 0:1ed23ab1345f | 468 | const hci_cmd_t hci_le_add_device_to_whitelist = { |
va009039 | 0:1ed23ab1345f | 469 | OPCODE(OGF_LE_CONTROLLER, 0x11), "1B" |
va009039 | 0:1ed23ab1345f | 470 | // param: address type: public (0), random (1) |
va009039 | 0:1ed23ab1345f | 471 | // param: address |
va009039 | 0:1ed23ab1345f | 472 | // return: status |
va009039 | 0:1ed23ab1345f | 473 | }; |
va009039 | 0:1ed23ab1345f | 474 | const hci_cmd_t hci_le_remove_device_from_whitelist = { |
va009039 | 0:1ed23ab1345f | 475 | OPCODE(OGF_LE_CONTROLLER, 0x12), "1B" |
va009039 | 0:1ed23ab1345f | 476 | // param: address type: public (0), random (1) |
va009039 | 0:1ed23ab1345f | 477 | // param: address |
va009039 | 0:1ed23ab1345f | 478 | // return: status |
va009039 | 0:1ed23ab1345f | 479 | }; |
va009039 | 0:1ed23ab1345f | 480 | const hci_cmd_t hci_le_connection_update = { |
va009039 | 0:1ed23ab1345f | 481 | OPCODE(OGF_LE_CONTROLLER, 0x13), "H222222" |
va009039 | 0:1ed23ab1345f | 482 | // param: conn handle |
va009039 | 0:1ed23ab1345f | 483 | // param: conn interval min, [0x0006,0x0c80], unit: 1.25 msec |
va009039 | 0:1ed23ab1345f | 484 | // param: conn interval max, [0x0006,0x0c80], unit: 1.25 msec |
va009039 | 0:1ed23ab1345f | 485 | // param: conn latency, [0x0000,0x03e8], number of connection events |
va009039 | 0:1ed23ab1345f | 486 | // param: supervision timeout, [0x000a,0x0c80], unit: 10 msec |
va009039 | 0:1ed23ab1345f | 487 | // param: minimum CE length, [0x0000,0xffff], unit: 0.625 msec |
va009039 | 0:1ed23ab1345f | 488 | // param: maximum CE length, [0x0000,0xffff], unit: 0.625 msec |
va009039 | 0:1ed23ab1345f | 489 | // return: none -> le connection update complete event |
va009039 | 0:1ed23ab1345f | 490 | }; |
va009039 | 0:1ed23ab1345f | 491 | const hci_cmd_t hci_le_set_host_channel_classification = { |
va009039 | 0:1ed23ab1345f | 492 | OPCODE(OGF_LE_CONTROLLER, 0x14), "41" |
va009039 | 0:1ed23ab1345f | 493 | // param: channel map 37 bit, split into first 32 and higher 5 bits |
va009039 | 0:1ed23ab1345f | 494 | // return: status |
va009039 | 0:1ed23ab1345f | 495 | }; |
va009039 | 0:1ed23ab1345f | 496 | const hci_cmd_t hci_le_read_channel_map = { |
va009039 | 0:1ed23ab1345f | 497 | OPCODE(OGF_LE_CONTROLLER, 0x15), "H" |
va009039 | 0:1ed23ab1345f | 498 | // params: connection handle |
va009039 | 0:1ed23ab1345f | 499 | // return: status, connection handle, channel map (5 bytes, 37 used) |
va009039 | 0:1ed23ab1345f | 500 | }; |
va009039 | 0:1ed23ab1345f | 501 | const hci_cmd_t hci_le_read_remote_used_features = { |
va009039 | 0:1ed23ab1345f | 502 | OPCODE(OGF_LE_CONTROLLER, 0x16), "H" |
va009039 | 0:1ed23ab1345f | 503 | // params: connection handle |
va009039 | 0:1ed23ab1345f | 504 | // return: none -> le read remote used features complete event |
va009039 | 0:1ed23ab1345f | 505 | }; |
va009039 | 0:1ed23ab1345f | 506 | const hci_cmd_t hci_le_encrypt = { |
va009039 | 0:1ed23ab1345f | 507 | OPCODE(OGF_LE_CONTROLLER, 0x17), "PP" |
va009039 | 0:1ed23ab1345f | 508 | // param: key (128) for AES-128 |
va009039 | 0:1ed23ab1345f | 509 | // param: plain text (128) |
va009039 | 0:1ed23ab1345f | 510 | // return: status, encrypted data (128) |
va009039 | 0:1ed23ab1345f | 511 | }; |
va009039 | 0:1ed23ab1345f | 512 | const hci_cmd_t hci_le_rand = { |
va009039 | 0:1ed23ab1345f | 513 | OPCODE(OGF_LE_CONTROLLER, 0x18), "" |
va009039 | 0:1ed23ab1345f | 514 | // params: none |
va009039 | 0:1ed23ab1345f | 515 | // return: status, random number (64) |
va009039 | 0:1ed23ab1345f | 516 | }; |
va009039 | 0:1ed23ab1345f | 517 | const hci_cmd_t hci_le_start_encryption = { |
va009039 | 0:1ed23ab1345f | 518 | OPCODE(OGF_LE_CONTROLLER, 0x19), "H442P" |
va009039 | 0:1ed23ab1345f | 519 | // param: connection handle |
va009039 | 0:1ed23ab1345f | 520 | // param: 64 bit random number lower 32 bit |
va009039 | 0:1ed23ab1345f | 521 | // param: 64 bit random number higher 32 bit |
va009039 | 0:1ed23ab1345f | 522 | // param: encryption diversifier (16) |
va009039 | 0:1ed23ab1345f | 523 | // param: long term key (128) |
va009039 | 0:1ed23ab1345f | 524 | // return: none -> encryption changed or encryption key refresh complete event |
va009039 | 0:1ed23ab1345f | 525 | }; |
va009039 | 0:1ed23ab1345f | 526 | const hci_cmd_t hci_le_long_term_key_request_reply = { |
va009039 | 0:1ed23ab1345f | 527 | OPCODE(OGF_LE_CONTROLLER, 0x1a), "HP" |
va009039 | 0:1ed23ab1345f | 528 | // param: connection handle |
va009039 | 0:1ed23ab1345f | 529 | // param: long term key (128) |
va009039 | 0:1ed23ab1345f | 530 | // return: status, connection handle |
va009039 | 0:1ed23ab1345f | 531 | }; |
va009039 | 0:1ed23ab1345f | 532 | const hci_cmd_t hci_le_long_term_key_negative_reply = { |
va009039 | 0:1ed23ab1345f | 533 | OPCODE(OGF_LE_CONTROLLER, 0x1b), "H" |
va009039 | 0:1ed23ab1345f | 534 | // param: connection handle |
va009039 | 0:1ed23ab1345f | 535 | // return: status, connection handle |
va009039 | 0:1ed23ab1345f | 536 | }; |
va009039 | 0:1ed23ab1345f | 537 | const hci_cmd_t hci_le_read_supported_states = { |
va009039 | 0:1ed23ab1345f | 538 | OPCODE(OGF_LE_CONTROLLER, 0x1c), "H" |
va009039 | 0:1ed23ab1345f | 539 | // param: none |
va009039 | 0:1ed23ab1345f | 540 | // return: status, LE states (64) |
va009039 | 0:1ed23ab1345f | 541 | }; |
va009039 | 0:1ed23ab1345f | 542 | const hci_cmd_t hci_le_receiver_test = { |
va009039 | 0:1ed23ab1345f | 543 | OPCODE(OGF_LE_CONTROLLER, 0x1d), "1" |
va009039 | 0:1ed23ab1345f | 544 | // param: rx frequency, [0x00 0x27], frequency (MHz): 2420 + N*2 |
va009039 | 0:1ed23ab1345f | 545 | // return: status |
va009039 | 0:1ed23ab1345f | 546 | }; |
va009039 | 0:1ed23ab1345f | 547 | const hci_cmd_t hci_le_transmitter_test = { |
va009039 | 0:1ed23ab1345f | 548 | OPCODE(OGF_LE_CONTROLLER, 0x1e), "111" |
va009039 | 0:1ed23ab1345f | 549 | // param: tx frequency, [0x00 0x27], frequency (MHz): 2420 + N*2 |
va009039 | 0:1ed23ab1345f | 550 | // param: lengh of test payload [0x00,0x25] |
va009039 | 0:1ed23ab1345f | 551 | // param: packet payload [0,7] different patterns |
va009039 | 0:1ed23ab1345f | 552 | // return: status |
va009039 | 0:1ed23ab1345f | 553 | }; |
va009039 | 0:1ed23ab1345f | 554 | const hci_cmd_t hci_le_test_end = { |
va009039 | 0:1ed23ab1345f | 555 | OPCODE(OGF_LE_CONTROLLER, 0x1f), "1" |
va009039 | 0:1ed23ab1345f | 556 | // params: none |
va009039 | 0:1ed23ab1345f | 557 | // return: status, number of packets (8) |
va009039 | 0:1ed23ab1345f | 558 | }; |
va009039 | 0:1ed23ab1345f | 559 | #endif |
va009039 | 0:1ed23ab1345f | 560 | |
va009039 | 0:1ed23ab1345f | 561 | // BTstack commands |
va009039 | 0:1ed23ab1345f | 562 | const hci_cmd_t btstack_get_state = { |
va009039 | 0:1ed23ab1345f | 563 | OPCODE(OGF_BTSTACK, BTSTACK_GET_STATE), "" |
va009039 | 0:1ed23ab1345f | 564 | // no params -> |
va009039 | 0:1ed23ab1345f | 565 | }; |
va009039 | 0:1ed23ab1345f | 566 | |
va009039 | 0:1ed23ab1345f | 567 | const hci_cmd_t btstack_set_power_mode = { |
va009039 | 0:1ed23ab1345f | 568 | OPCODE(OGF_BTSTACK, BTSTACK_SET_POWER_MODE), "1" |
va009039 | 0:1ed23ab1345f | 569 | // mode: 0 = off, 1 = on |
va009039 | 0:1ed23ab1345f | 570 | }; |
va009039 | 0:1ed23ab1345f | 571 | |
va009039 | 0:1ed23ab1345f | 572 | const hci_cmd_t btstack_set_acl_capture_mode = { |
va009039 | 0:1ed23ab1345f | 573 | OPCODE(OGF_BTSTACK, BTSTACK_SET_ACL_CAPTURE_MODE), "1" |
va009039 | 0:1ed23ab1345f | 574 | // mode: 0 = off, 1 = on |
va009039 | 0:1ed23ab1345f | 575 | }; |
va009039 | 0:1ed23ab1345f | 576 | |
va009039 | 0:1ed23ab1345f | 577 | const hci_cmd_t btstack_get_version = { |
va009039 | 0:1ed23ab1345f | 578 | OPCODE(OGF_BTSTACK, BTSTACK_GET_VERSION), "" |
va009039 | 0:1ed23ab1345f | 579 | }; |
va009039 | 0:1ed23ab1345f | 580 | |
va009039 | 0:1ed23ab1345f | 581 | const hci_cmd_t btstack_get_system_bluetooth_enabled = { |
va009039 | 0:1ed23ab1345f | 582 | OPCODE(OGF_BTSTACK, BTSTACK_GET_SYSTEM_BLUETOOTH_ENABLED), "" |
va009039 | 0:1ed23ab1345f | 583 | }; |
va009039 | 0:1ed23ab1345f | 584 | |
va009039 | 0:1ed23ab1345f | 585 | const hci_cmd_t btstack_set_system_bluetooth_enabled = { |
va009039 | 0:1ed23ab1345f | 586 | OPCODE(OGF_BTSTACK, BTSTACK_SET_SYSTEM_BLUETOOTH_ENABLED), "1" |
va009039 | 0:1ed23ab1345f | 587 | }; |
va009039 | 0:1ed23ab1345f | 588 | |
va009039 | 0:1ed23ab1345f | 589 | const hci_cmd_t btstack_set_discoverable = { |
va009039 | 0:1ed23ab1345f | 590 | OPCODE(OGF_BTSTACK, BTSTACK_SET_DISCOVERABLE), "1" |
va009039 | 0:1ed23ab1345f | 591 | }; |
va009039 | 0:1ed23ab1345f | 592 | |
va009039 | 0:1ed23ab1345f | 593 | const hci_cmd_t btstack_set_bluetooth_enabled = { |
va009039 | 0:1ed23ab1345f | 594 | // only used by btstack config |
va009039 | 0:1ed23ab1345f | 595 | OPCODE(OGF_BTSTACK, BTSTACK_SET_BLUETOOTH_ENABLED), "1" |
va009039 | 0:1ed23ab1345f | 596 | }; |
va009039 | 0:1ed23ab1345f | 597 | |
va009039 | 0:1ed23ab1345f | 598 | const hci_cmd_t l2cap_create_channel = { |
va009039 | 0:1ed23ab1345f | 599 | OPCODE(OGF_BTSTACK, L2CAP_CREATE_CHANNEL), "B2" |
va009039 | 0:1ed23ab1345f | 600 | // @param bd_addr(48), psm (16) |
va009039 | 0:1ed23ab1345f | 601 | }; |
va009039 | 0:1ed23ab1345f | 602 | const hci_cmd_t l2cap_create_channel_mtu = { |
va009039 | 0:1ed23ab1345f | 603 | OPCODE(OGF_BTSTACK, L2CAP_CREATE_CHANNEL_MTU), "B22" |
va009039 | 0:1ed23ab1345f | 604 | // @param bd_addr(48), psm (16), mtu (16) |
va009039 | 0:1ed23ab1345f | 605 | }; |
va009039 | 0:1ed23ab1345f | 606 | const hci_cmd_t l2cap_disconnect = { |
va009039 | 0:1ed23ab1345f | 607 | OPCODE(OGF_BTSTACK, L2CAP_DISCONNECT), "21" |
va009039 | 0:1ed23ab1345f | 608 | // @param channel(16), reason(8) |
va009039 | 0:1ed23ab1345f | 609 | }; |
va009039 | 0:1ed23ab1345f | 610 | const hci_cmd_t l2cap_register_service = { |
va009039 | 0:1ed23ab1345f | 611 | OPCODE(OGF_BTSTACK, L2CAP_REGISTER_SERVICE), "22" |
va009039 | 0:1ed23ab1345f | 612 | // @param psm (16), mtu (16) |
va009039 | 0:1ed23ab1345f | 613 | }; |
va009039 | 0:1ed23ab1345f | 614 | const hci_cmd_t l2cap_unregister_service = { |
va009039 | 0:1ed23ab1345f | 615 | OPCODE(OGF_BTSTACK, L2CAP_UNREGISTER_SERVICE), "2" |
va009039 | 0:1ed23ab1345f | 616 | // @param psm (16) |
va009039 | 0:1ed23ab1345f | 617 | }; |
va009039 | 0:1ed23ab1345f | 618 | const hci_cmd_t l2cap_accept_connection = { |
va009039 | 0:1ed23ab1345f | 619 | OPCODE(OGF_BTSTACK, L2CAP_ACCEPT_CONNECTION), "2" |
va009039 | 0:1ed23ab1345f | 620 | // @param source cid (16) |
va009039 | 0:1ed23ab1345f | 621 | }; |
va009039 | 0:1ed23ab1345f | 622 | const hci_cmd_t l2cap_decline_connection = { |
va009039 | 0:1ed23ab1345f | 623 | OPCODE(OGF_BTSTACK, L2CAP_DECLINE_CONNECTION), "21" |
va009039 | 0:1ed23ab1345f | 624 | // @param source cid (16), reason(8) |
va009039 | 0:1ed23ab1345f | 625 | }; |
va009039 | 0:1ed23ab1345f | 626 | const hci_cmd_t sdp_register_service_record = { |
va009039 | 0:1ed23ab1345f | 627 | OPCODE(OGF_BTSTACK, SDP_REGISTER_SERVICE_RECORD), "S" |
va009039 | 0:1ed23ab1345f | 628 | // @param service record handle (DES) |
va009039 | 0:1ed23ab1345f | 629 | }; |
va009039 | 0:1ed23ab1345f | 630 | const hci_cmd_t sdp_unregister_service_record = { |
va009039 | 0:1ed23ab1345f | 631 | OPCODE(OGF_BTSTACK, SDP_UNREGISTER_SERVICE_RECORD), "4" |
va009039 | 0:1ed23ab1345f | 632 | // @param service record handle (32) |
va009039 | 0:1ed23ab1345f | 633 | }; |
va009039 | 0:1ed23ab1345f | 634 | |
va009039 | 0:1ed23ab1345f | 635 | // create rfcomm channel: @param bd_addr(48), channel (8) |
va009039 | 0:1ed23ab1345f | 636 | const hci_cmd_t rfcomm_create_channel = { |
va009039 | 0:1ed23ab1345f | 637 | OPCODE(OGF_BTSTACK, RFCOMM_CREATE_CHANNEL), "B1" |
va009039 | 0:1ed23ab1345f | 638 | }; |
va009039 | 0:1ed23ab1345f | 639 | // create rfcomm channel: @param bd_addr(48), channel (8), mtu (16), credits (8) |
va009039 | 0:1ed23ab1345f | 640 | const hci_cmd_t rfcomm_create_channel_with_initial_credits = { |
va009039 | 0:1ed23ab1345f | 641 | OPCODE(OGF_BTSTACK, RFCOMM_CREATE_CHANNEL_WITH_CREDITS), "B121" |
va009039 | 0:1ed23ab1345f | 642 | }; |
va009039 | 0:1ed23ab1345f | 643 | // grant credits: @param rfcomm_cid(16), credits (8) |
va009039 | 0:1ed23ab1345f | 644 | const hci_cmd_t rfcomm_grants_credits= { |
va009039 | 0:1ed23ab1345f | 645 | OPCODE(OGF_BTSTACK, RFCOMM_GRANT_CREDITS), "21" |
va009039 | 0:1ed23ab1345f | 646 | }; |
va009039 | 0:1ed23ab1345f | 647 | // disconnect rfcomm disconnect, @param rfcomm_cid(16), reason(8) |
va009039 | 0:1ed23ab1345f | 648 | const hci_cmd_t rfcomm_disconnect = { |
va009039 | 0:1ed23ab1345f | 649 | OPCODE(OGF_BTSTACK, RFCOMM_DISCONNECT), "21" |
va009039 | 0:1ed23ab1345f | 650 | }; |
va009039 | 0:1ed23ab1345f | 651 | |
va009039 | 0:1ed23ab1345f | 652 | // register rfcomm service: @param channel(8), mtu (16) |
va009039 | 0:1ed23ab1345f | 653 | const hci_cmd_t rfcomm_register_service = { |
va009039 | 0:1ed23ab1345f | 654 | OPCODE(OGF_BTSTACK, RFCOMM_REGISTER_SERVICE), "12" |
va009039 | 0:1ed23ab1345f | 655 | }; |
va009039 | 0:1ed23ab1345f | 656 | // register rfcomm service: @param channel(8), mtu (16), initial credits (8) |
va009039 | 0:1ed23ab1345f | 657 | const hci_cmd_t rfcomm_register_service_with_initial_credits = { |
va009039 | 0:1ed23ab1345f | 658 | OPCODE(OGF_BTSTACK, RFCOMM_REGISTER_SERVICE_WITH_CREDITS), "121" |
va009039 | 0:1ed23ab1345f | 659 | }; |
va009039 | 0:1ed23ab1345f | 660 | |
va009039 | 0:1ed23ab1345f | 661 | // unregister rfcomm service, @param service_channel(16) |
va009039 | 0:1ed23ab1345f | 662 | const hci_cmd_t rfcomm_unregister_service = { |
va009039 | 0:1ed23ab1345f | 663 | OPCODE(OGF_BTSTACK, RFCOMM_UNREGISTER_SERVICE), "2" |
va009039 | 0:1ed23ab1345f | 664 | }; |
va009039 | 0:1ed23ab1345f | 665 | // accept connection @param source cid (16) |
va009039 | 0:1ed23ab1345f | 666 | const hci_cmd_t rfcomm_accept_connection = { |
va009039 | 0:1ed23ab1345f | 667 | OPCODE(OGF_BTSTACK, RFCOMM_ACCEPT_CONNECTION), "2" |
va009039 | 0:1ed23ab1345f | 668 | }; |
va009039 | 0:1ed23ab1345f | 669 | // decline connection @param source cid (16) |
va009039 | 0:1ed23ab1345f | 670 | const hci_cmd_t rfcomm_decline_connection = { |
va009039 | 0:1ed23ab1345f | 671 | OPCODE(OGF_BTSTACK, RFCOMM_DECLINE_CONNECTION), "21" |
va009039 | 0:1ed23ab1345f | 672 | }; |
va009039 | 0:1ed23ab1345f | 673 | // request persisten rfcomm channel number for named service |
va009039 | 0:1ed23ab1345f | 674 | const hci_cmd_t rfcomm_persistent_channel_for_service = { |
va009039 | 0:1ed23ab1345f | 675 | OPCODE(OGF_BTSTACK, RFCOMM_PERSISTENT_CHANNEL), "N" |
va009039 | 0:1ed23ab1345f | 676 | }; |
va009039 | 0:1ed23ab1345f | 677 | |
va009039 | 0:1ed23ab1345f | 678 | // register rfcomm service: @param channel(8), mtu (16), initial credits (8) |
va009039 | 0:1ed23ab1345f | 679 | extern const hci_cmd_t rfcomm_register_service_with_initial_credits; |