ver:init

Committer:
iv123
Date:
Sun Jun 18 16:10:28 2017 +0000
Revision:
0:88b85febcb45
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
iv123 0:88b85febcb45 1 /******************** (C) COPYRIGHT 2014 STMicroelectronics ********************
iv123 0:88b85febcb45 2 * File Name : bluenrg_hci.c
iv123 0:88b85febcb45 3 * Author : AMS - HEA&RF BU
iv123 0:88b85febcb45 4 * Version : V1.0.0
iv123 0:88b85febcb45 5 * Date : 4-Oct-2013
iv123 0:88b85febcb45 6 * Description : File with HCI commands for BlueNRG FW6.0 and above.
iv123 0:88b85febcb45 7 ********************************************************************************
iv123 0:88b85febcb45 8 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
iv123 0:88b85febcb45 9 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
iv123 0:88b85febcb45 10 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
iv123 0:88b85febcb45 11 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
iv123 0:88b85febcb45 12 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
iv123 0:88b85febcb45 13 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
iv123 0:88b85febcb45 14 *******************************************************************************/
iv123 0:88b85febcb45 15
iv123 0:88b85febcb45 16 #include "ble_hal_types.h"
iv123 0:88b85febcb45 17 #include "ble_osal.h"
iv123 0:88b85febcb45 18 #include "ble_status.h"
iv123 0:88b85febcb45 19 #include "ble_hal.h"
iv123 0:88b85febcb45 20 #include "ble_osal.h"
iv123 0:88b85febcb45 21 #include "ble_hci_const.h"
iv123 0:88b85febcb45 22 #include "bluenrg_aci_const.h"
iv123 0:88b85febcb45 23 #include "bluenrg_gap_aci.h"
iv123 0:88b85febcb45 24 #include "bluenrg_gatt_server.h"
iv123 0:88b85febcb45 25 #include "bluenrg_gap.h"
iv123 0:88b85febcb45 26
iv123 0:88b85febcb45 27 #define MIN(a,b) ((a) < (b) )? (a) : (b)
iv123 0:88b85febcb45 28 #define MAX(a,b) ((a) > (b) )? (a) : (b)
iv123 0:88b85febcb45 29
iv123 0:88b85febcb45 30 tBleStatus aci_gap_init_IDB05A1(uint8_t role, uint8_t privacy_enabled, uint8_t device_name_char_len, uint16_t* service_handle, uint16_t* dev_name_char_handle, uint16_t* appearance_char_handle)
iv123 0:88b85febcb45 31 {
iv123 0:88b85febcb45 32 struct hci_request rq;
iv123 0:88b85febcb45 33 gap_init_cp_IDB05A1 cp;
iv123 0:88b85febcb45 34 gap_init_rp resp;
iv123 0:88b85febcb45 35
iv123 0:88b85febcb45 36 cp.role = role;
iv123 0:88b85febcb45 37 cp.privacy_enabled = privacy_enabled;
iv123 0:88b85febcb45 38 cp.device_name_char_len = device_name_char_len;
iv123 0:88b85febcb45 39
iv123 0:88b85febcb45 40 Osal_MemSet(&resp, 0, sizeof(resp));
iv123 0:88b85febcb45 41
iv123 0:88b85febcb45 42 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 43 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 44 rq.ocf = OCF_GAP_INIT;
iv123 0:88b85febcb45 45 rq.cparam = &cp;
iv123 0:88b85febcb45 46 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 47 rq.rparam = &resp;
iv123 0:88b85febcb45 48 rq.rlen = GAP_INIT_RP_SIZE;
iv123 0:88b85febcb45 49
iv123 0:88b85febcb45 50 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 51 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 52
iv123 0:88b85febcb45 53 if (resp.status) {
iv123 0:88b85febcb45 54 return resp.status;
iv123 0:88b85febcb45 55 }
iv123 0:88b85febcb45 56
iv123 0:88b85febcb45 57 *service_handle = btohs(resp.service_handle);
iv123 0:88b85febcb45 58 *dev_name_char_handle = btohs(resp.dev_name_char_handle);
iv123 0:88b85febcb45 59 *appearance_char_handle = btohs(resp.appearance_char_handle);
iv123 0:88b85febcb45 60
iv123 0:88b85febcb45 61 return 0;
iv123 0:88b85febcb45 62 }
iv123 0:88b85febcb45 63 tBleStatus aci_gap_init_IDB04A1(uint8_t role, uint16_t* service_handle, uint16_t* dev_name_char_handle, uint16_t* appearance_char_handle)
iv123 0:88b85febcb45 64 {
iv123 0:88b85febcb45 65 struct hci_request rq;
iv123 0:88b85febcb45 66 gap_init_cp_IDB04A1 cp;
iv123 0:88b85febcb45 67 gap_init_rp resp;
iv123 0:88b85febcb45 68
iv123 0:88b85febcb45 69 cp.role = role;
iv123 0:88b85febcb45 70
iv123 0:88b85febcb45 71 Osal_MemSet(&resp, 0, sizeof(resp));
iv123 0:88b85febcb45 72
iv123 0:88b85febcb45 73 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 74 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 75 rq.ocf = OCF_GAP_INIT;
iv123 0:88b85febcb45 76 rq.cparam = &cp;
iv123 0:88b85febcb45 77 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 78 rq.rparam = &resp;
iv123 0:88b85febcb45 79 rq.rlen = GAP_INIT_RP_SIZE;
iv123 0:88b85febcb45 80
iv123 0:88b85febcb45 81 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 82 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 83
iv123 0:88b85febcb45 84 if (resp.status) {
iv123 0:88b85febcb45 85 return resp.status;
iv123 0:88b85febcb45 86 }
iv123 0:88b85febcb45 87
iv123 0:88b85febcb45 88 *service_handle = btohs(resp.service_handle);
iv123 0:88b85febcb45 89 *dev_name_char_handle = btohs(resp.dev_name_char_handle);
iv123 0:88b85febcb45 90 *appearance_char_handle = btohs(resp.appearance_char_handle);
iv123 0:88b85febcb45 91
iv123 0:88b85febcb45 92 return 0;
iv123 0:88b85febcb45 93 }
iv123 0:88b85febcb45 94
iv123 0:88b85febcb45 95 tBleStatus aci_gap_set_non_discoverable(void)
iv123 0:88b85febcb45 96 {
iv123 0:88b85febcb45 97 struct hci_request rq;
iv123 0:88b85febcb45 98 uint8_t status;
iv123 0:88b85febcb45 99
iv123 0:88b85febcb45 100 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 101 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 102 rq.ocf = OCF_GAP_SET_NON_DISCOVERABLE;
iv123 0:88b85febcb45 103 rq.rparam = &status;
iv123 0:88b85febcb45 104 rq.rlen = 1;
iv123 0:88b85febcb45 105
iv123 0:88b85febcb45 106 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 107 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 108
iv123 0:88b85febcb45 109 return status;
iv123 0:88b85febcb45 110 }
iv123 0:88b85febcb45 111
iv123 0:88b85febcb45 112 tBleStatus aci_gap_set_limited_discoverable(uint8_t AdvType, uint16_t AdvIntervMin, uint16_t AdvIntervMax,
iv123 0:88b85febcb45 113 uint8_t OwnAddrType, uint8_t AdvFilterPolicy, uint8_t LocalNameLen,
iv123 0:88b85febcb45 114 const char *LocalName, uint8_t ServiceUUIDLen, uint8_t* ServiceUUIDList,
iv123 0:88b85febcb45 115 uint16_t SlaveConnIntervMin, uint16_t SlaveConnIntervMax)
iv123 0:88b85febcb45 116 {
iv123 0:88b85febcb45 117 struct hci_request rq;
iv123 0:88b85febcb45 118 uint8_t status;
iv123 0:88b85febcb45 119 uint8_t buffer[40];
iv123 0:88b85febcb45 120 uint8_t indx = 0;
iv123 0:88b85febcb45 121
iv123 0:88b85febcb45 122 if((unsigned int)(LocalNameLen+ServiceUUIDLen+14) > sizeof(buffer))
iv123 0:88b85febcb45 123 return BLE_STATUS_INVALID_PARAMS;
iv123 0:88b85febcb45 124
iv123 0:88b85febcb45 125 buffer[indx] = AdvType;
iv123 0:88b85febcb45 126 indx++;
iv123 0:88b85febcb45 127
iv123 0:88b85febcb45 128 AdvIntervMin = htobs(AdvIntervMin);
iv123 0:88b85febcb45 129 Osal_MemCpy(buffer + indx, &AdvIntervMin, 2);
iv123 0:88b85febcb45 130 indx += 2;
iv123 0:88b85febcb45 131
iv123 0:88b85febcb45 132 AdvIntervMax = htobs(AdvIntervMax);
iv123 0:88b85febcb45 133 Osal_MemCpy(buffer + indx, &AdvIntervMax, 2);
iv123 0:88b85febcb45 134 indx += 2;
iv123 0:88b85febcb45 135
iv123 0:88b85febcb45 136 buffer[indx] = OwnAddrType;
iv123 0:88b85febcb45 137 indx++;
iv123 0:88b85febcb45 138
iv123 0:88b85febcb45 139 buffer[indx] = AdvFilterPolicy;
iv123 0:88b85febcb45 140 indx++;
iv123 0:88b85febcb45 141
iv123 0:88b85febcb45 142 buffer[indx] = LocalNameLen;
iv123 0:88b85febcb45 143 indx++;
iv123 0:88b85febcb45 144
iv123 0:88b85febcb45 145 Osal_MemCpy(buffer + indx, LocalName, LocalNameLen);
iv123 0:88b85febcb45 146 indx += LocalNameLen;
iv123 0:88b85febcb45 147
iv123 0:88b85febcb45 148 buffer[indx] = ServiceUUIDLen;
iv123 0:88b85febcb45 149 indx++;
iv123 0:88b85febcb45 150
iv123 0:88b85febcb45 151 Osal_MemCpy(buffer + indx, ServiceUUIDList, ServiceUUIDLen);
iv123 0:88b85febcb45 152 indx += ServiceUUIDLen;
iv123 0:88b85febcb45 153
iv123 0:88b85febcb45 154 Osal_MemCpy(buffer + indx, &SlaveConnIntervMin, 2);
iv123 0:88b85febcb45 155 indx += 2;
iv123 0:88b85febcb45 156
iv123 0:88b85febcb45 157 Osal_MemCpy(buffer + indx, &SlaveConnIntervMax, 2);
iv123 0:88b85febcb45 158 indx += 2;
iv123 0:88b85febcb45 159
iv123 0:88b85febcb45 160 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 161 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 162 rq.ocf = OCF_GAP_SET_LIMITED_DISCOVERABLE;
iv123 0:88b85febcb45 163 rq.cparam = (void *)buffer;
iv123 0:88b85febcb45 164 rq.clen = indx;
iv123 0:88b85febcb45 165 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 166 rq.rparam = &status;
iv123 0:88b85febcb45 167 rq.rlen = 1;
iv123 0:88b85febcb45 168
iv123 0:88b85febcb45 169 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 170 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 171
iv123 0:88b85febcb45 172 return status;
iv123 0:88b85febcb45 173 }
iv123 0:88b85febcb45 174
iv123 0:88b85febcb45 175 tBleStatus aci_gap_set_discoverable(uint8_t AdvType, uint16_t AdvIntervMin, uint16_t AdvIntervMax,
iv123 0:88b85febcb45 176 uint8_t OwnAddrType, uint8_t AdvFilterPolicy, uint8_t LocalNameLen,
iv123 0:88b85febcb45 177 const char *LocalName, uint8_t ServiceUUIDLen, uint8_t* ServiceUUIDList,
iv123 0:88b85febcb45 178 uint16_t SlaveConnIntervMin, uint16_t SlaveConnIntervMax)
iv123 0:88b85febcb45 179 {
iv123 0:88b85febcb45 180 struct hci_request rq;
iv123 0:88b85febcb45 181 uint8_t status;
iv123 0:88b85febcb45 182 uint8_t buffer[40];
iv123 0:88b85febcb45 183 uint8_t indx = 0;
iv123 0:88b85febcb45 184
iv123 0:88b85febcb45 185 if ((unsigned int)(LocalNameLen+ServiceUUIDLen+14) > sizeof(buffer))
iv123 0:88b85febcb45 186 return BLE_STATUS_INVALID_PARAMS;
iv123 0:88b85febcb45 187
iv123 0:88b85febcb45 188 buffer[indx] = AdvType;
iv123 0:88b85febcb45 189 indx++;
iv123 0:88b85febcb45 190
iv123 0:88b85febcb45 191 AdvIntervMin = htobs(AdvIntervMin);
iv123 0:88b85febcb45 192 Osal_MemCpy(buffer + indx, &AdvIntervMin, 2);
iv123 0:88b85febcb45 193 indx += 2;
iv123 0:88b85febcb45 194
iv123 0:88b85febcb45 195 AdvIntervMax = htobs(AdvIntervMax);
iv123 0:88b85febcb45 196 Osal_MemCpy(buffer + indx, &AdvIntervMax, 2);
iv123 0:88b85febcb45 197 indx += 2;
iv123 0:88b85febcb45 198
iv123 0:88b85febcb45 199 buffer[indx] = OwnAddrType;
iv123 0:88b85febcb45 200 indx++;
iv123 0:88b85febcb45 201
iv123 0:88b85febcb45 202 buffer[indx] = AdvFilterPolicy;
iv123 0:88b85febcb45 203 indx++;
iv123 0:88b85febcb45 204
iv123 0:88b85febcb45 205 buffer[indx] = LocalNameLen;
iv123 0:88b85febcb45 206 indx++;
iv123 0:88b85febcb45 207
iv123 0:88b85febcb45 208 Osal_MemCpy(buffer + indx, LocalName, LocalNameLen);
iv123 0:88b85febcb45 209 indx += LocalNameLen;
iv123 0:88b85febcb45 210
iv123 0:88b85febcb45 211 buffer[indx] = ServiceUUIDLen;
iv123 0:88b85febcb45 212 indx++;
iv123 0:88b85febcb45 213
iv123 0:88b85febcb45 214 Osal_MemCpy(buffer + indx, ServiceUUIDList, ServiceUUIDLen);
iv123 0:88b85febcb45 215 indx += ServiceUUIDLen;
iv123 0:88b85febcb45 216
iv123 0:88b85febcb45 217 SlaveConnIntervMin = htobs(SlaveConnIntervMin);
iv123 0:88b85febcb45 218 Osal_MemCpy(buffer + indx, &SlaveConnIntervMin, 2);
iv123 0:88b85febcb45 219 indx += 2;
iv123 0:88b85febcb45 220
iv123 0:88b85febcb45 221 SlaveConnIntervMax = htobs(SlaveConnIntervMax);
iv123 0:88b85febcb45 222 Osal_MemCpy(buffer + indx, &SlaveConnIntervMax, 2);
iv123 0:88b85febcb45 223 indx += 2;
iv123 0:88b85febcb45 224
iv123 0:88b85febcb45 225 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 226 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 227 rq.ocf = OCF_GAP_SET_DISCOVERABLE;
iv123 0:88b85febcb45 228 rq.cparam = (void *)buffer;
iv123 0:88b85febcb45 229 rq.clen = indx;
iv123 0:88b85febcb45 230 rq.rparam = &status;
iv123 0:88b85febcb45 231 rq.rlen = 1;
iv123 0:88b85febcb45 232
iv123 0:88b85febcb45 233 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 234 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 235
iv123 0:88b85febcb45 236 if (status) {
iv123 0:88b85febcb45 237 return status;
iv123 0:88b85febcb45 238 }
iv123 0:88b85febcb45 239
iv123 0:88b85febcb45 240 return 0;
iv123 0:88b85febcb45 241 }
iv123 0:88b85febcb45 242
iv123 0:88b85febcb45 243 tBleStatus aci_gap_set_direct_connectable_IDB05A1(uint8_t own_addr_type, uint8_t directed_adv_type, uint8_t initiator_addr_type, const uint8_t *initiator_addr)
iv123 0:88b85febcb45 244 {
iv123 0:88b85febcb45 245 struct hci_request rq;
iv123 0:88b85febcb45 246 gap_set_direct_conectable_cp_IDB05A1 cp;
iv123 0:88b85febcb45 247 uint8_t status;
iv123 0:88b85febcb45 248
iv123 0:88b85febcb45 249 cp.own_bdaddr_type = own_addr_type;
iv123 0:88b85febcb45 250 cp.directed_adv_type = directed_adv_type;
iv123 0:88b85febcb45 251 cp.direct_bdaddr_type = initiator_addr_type;
iv123 0:88b85febcb45 252 Osal_MemCpy(cp.direct_bdaddr, initiator_addr, 6);
iv123 0:88b85febcb45 253
iv123 0:88b85febcb45 254 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 255 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 256 rq.ocf = OCF_GAP_SET_DIRECT_CONNECTABLE;
iv123 0:88b85febcb45 257 rq.cparam = &cp;
iv123 0:88b85febcb45 258 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 259 rq.rparam = &status;
iv123 0:88b85febcb45 260 rq.rlen = 1;
iv123 0:88b85febcb45 261
iv123 0:88b85febcb45 262 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 263 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 264
iv123 0:88b85febcb45 265 return status;
iv123 0:88b85febcb45 266 }
iv123 0:88b85febcb45 267
iv123 0:88b85febcb45 268 tBleStatus aci_gap_set_direct_connectable_IDB04A1(uint8_t own_addr_type, uint8_t initiator_addr_type, const uint8_t *initiator_addr)
iv123 0:88b85febcb45 269 {
iv123 0:88b85febcb45 270 struct hci_request rq;
iv123 0:88b85febcb45 271 gap_set_direct_conectable_cp_IDB04A1 cp;
iv123 0:88b85febcb45 272 uint8_t status;
iv123 0:88b85febcb45 273
iv123 0:88b85febcb45 274 cp.own_bdaddr_type = own_addr_type;
iv123 0:88b85febcb45 275 cp.direct_bdaddr_type = initiator_addr_type;
iv123 0:88b85febcb45 276 Osal_MemCpy(cp.direct_bdaddr, initiator_addr, 6);
iv123 0:88b85febcb45 277
iv123 0:88b85febcb45 278 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 279 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 280 rq.ocf = OCF_GAP_SET_DIRECT_CONNECTABLE;
iv123 0:88b85febcb45 281 rq.cparam = &cp;
iv123 0:88b85febcb45 282 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 283 rq.rparam = &status;
iv123 0:88b85febcb45 284 rq.rlen = 1;
iv123 0:88b85febcb45 285
iv123 0:88b85febcb45 286 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 287 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 288
iv123 0:88b85febcb45 289 return status;
iv123 0:88b85febcb45 290 }
iv123 0:88b85febcb45 291
iv123 0:88b85febcb45 292 tBleStatus aci_gap_set_io_capability(uint8_t io_capability)
iv123 0:88b85febcb45 293 {
iv123 0:88b85febcb45 294 struct hci_request rq;
iv123 0:88b85febcb45 295 uint8_t status;
iv123 0:88b85febcb45 296 gap_set_io_capability_cp cp;
iv123 0:88b85febcb45 297
iv123 0:88b85febcb45 298 cp.io_capability = io_capability;
iv123 0:88b85febcb45 299
iv123 0:88b85febcb45 300 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 301 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 302 rq.ocf = OCF_GAP_SET_IO_CAPABILITY;
iv123 0:88b85febcb45 303 rq.cparam = &cp;
iv123 0:88b85febcb45 304 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 305 rq.rparam = &status;
iv123 0:88b85febcb45 306 rq.rlen = 1;
iv123 0:88b85febcb45 307
iv123 0:88b85febcb45 308 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 309 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 310
iv123 0:88b85febcb45 311 return status;
iv123 0:88b85febcb45 312 }
iv123 0:88b85febcb45 313
iv123 0:88b85febcb45 314 tBleStatus aci_gap_set_auth_requirement(uint8_t mitm_mode,
iv123 0:88b85febcb45 315 uint8_t oob_enable,
iv123 0:88b85febcb45 316 uint8_t oob_data[16],
iv123 0:88b85febcb45 317 uint8_t min_encryption_key_size,
iv123 0:88b85febcb45 318 uint8_t max_encryption_key_size,
iv123 0:88b85febcb45 319 uint8_t use_fixed_pin,
iv123 0:88b85febcb45 320 uint32_t fixed_pin,
iv123 0:88b85febcb45 321 uint8_t bonding_mode)
iv123 0:88b85febcb45 322 {
iv123 0:88b85febcb45 323 struct hci_request rq;
iv123 0:88b85febcb45 324 gap_set_auth_requirement_cp cp;
iv123 0:88b85febcb45 325 uint8_t status;
iv123 0:88b85febcb45 326
iv123 0:88b85febcb45 327 cp.mitm_mode = mitm_mode;
iv123 0:88b85febcb45 328 cp.oob_enable = oob_enable;
iv123 0:88b85febcb45 329 Osal_MemCpy(cp.oob_data, oob_data, 16);
iv123 0:88b85febcb45 330 cp.min_encryption_key_size = min_encryption_key_size;
iv123 0:88b85febcb45 331 cp.max_encryption_key_size = max_encryption_key_size;
iv123 0:88b85febcb45 332 cp.use_fixed_pin = use_fixed_pin;
iv123 0:88b85febcb45 333 cp.fixed_pin = htobl(fixed_pin);
iv123 0:88b85febcb45 334 cp.bonding_mode = bonding_mode;
iv123 0:88b85febcb45 335
iv123 0:88b85febcb45 336 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 337 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 338 rq.ocf = OCF_GAP_SET_AUTH_REQUIREMENT;
iv123 0:88b85febcb45 339 rq.cparam = &cp;
iv123 0:88b85febcb45 340 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 341 rq.rparam = &status;
iv123 0:88b85febcb45 342 rq.rlen = 1;
iv123 0:88b85febcb45 343
iv123 0:88b85febcb45 344 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 345 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 346
iv123 0:88b85febcb45 347 if (status) {
iv123 0:88b85febcb45 348 return status;
iv123 0:88b85febcb45 349 }
iv123 0:88b85febcb45 350
iv123 0:88b85febcb45 351 return 0;
iv123 0:88b85febcb45 352 }
iv123 0:88b85febcb45 353
iv123 0:88b85febcb45 354 tBleStatus aci_gap_set_author_requirement(uint16_t conn_handle, uint8_t authorization_enable)
iv123 0:88b85febcb45 355 {
iv123 0:88b85febcb45 356 struct hci_request rq;
iv123 0:88b85febcb45 357 gap_set_author_requirement_cp cp;
iv123 0:88b85febcb45 358 uint8_t status;
iv123 0:88b85febcb45 359
iv123 0:88b85febcb45 360 cp.conn_handle = htobs(conn_handle);
iv123 0:88b85febcb45 361 cp.authorization_enable = authorization_enable;
iv123 0:88b85febcb45 362
iv123 0:88b85febcb45 363 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 364 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 365 rq.ocf = OCF_GAP_SET_AUTHOR_REQUIREMENT;
iv123 0:88b85febcb45 366 rq.cparam = &cp;
iv123 0:88b85febcb45 367 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 368 rq.rparam = &status;
iv123 0:88b85febcb45 369 rq.rlen = 1;
iv123 0:88b85febcb45 370
iv123 0:88b85febcb45 371 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 372 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 373
iv123 0:88b85febcb45 374 return status;
iv123 0:88b85febcb45 375 }
iv123 0:88b85febcb45 376
iv123 0:88b85febcb45 377 tBleStatus aci_gap_pass_key_response(uint16_t conn_handle, uint32_t passkey)
iv123 0:88b85febcb45 378 {
iv123 0:88b85febcb45 379 struct hci_request rq;
iv123 0:88b85febcb45 380 gap_passkey_response_cp cp;
iv123 0:88b85febcb45 381 uint8_t status;
iv123 0:88b85febcb45 382
iv123 0:88b85febcb45 383 cp.conn_handle = htobs(conn_handle);
iv123 0:88b85febcb45 384 cp.passkey = htobl(passkey);
iv123 0:88b85febcb45 385
iv123 0:88b85febcb45 386 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 387 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 388 rq.ocf = OCF_GAP_PASSKEY_RESPONSE;
iv123 0:88b85febcb45 389 rq.cparam = &cp;
iv123 0:88b85febcb45 390 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 391 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 392 rq.rparam = &status;
iv123 0:88b85febcb45 393 rq.rlen = 1;
iv123 0:88b85febcb45 394
iv123 0:88b85febcb45 395 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 396 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 397
iv123 0:88b85febcb45 398 return status;
iv123 0:88b85febcb45 399 }
iv123 0:88b85febcb45 400
iv123 0:88b85febcb45 401 tBleStatus aci_gap_authorization_response(uint16_t conn_handle, uint8_t authorize)
iv123 0:88b85febcb45 402 {
iv123 0:88b85febcb45 403 struct hci_request rq;
iv123 0:88b85febcb45 404 gap_authorization_response_cp cp;
iv123 0:88b85febcb45 405 uint8_t status;
iv123 0:88b85febcb45 406
iv123 0:88b85febcb45 407 cp.conn_handle = htobs(conn_handle);
iv123 0:88b85febcb45 408 cp.authorize = authorize;
iv123 0:88b85febcb45 409
iv123 0:88b85febcb45 410 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 411 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 412 rq.ocf = OCF_GAP_AUTHORIZATION_RESPONSE;
iv123 0:88b85febcb45 413 rq.cparam = &cp;
iv123 0:88b85febcb45 414 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 415 rq.rparam = &status;
iv123 0:88b85febcb45 416 rq.rlen = 1;
iv123 0:88b85febcb45 417
iv123 0:88b85febcb45 418 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 419 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 420
iv123 0:88b85febcb45 421 return status;
iv123 0:88b85febcb45 422 }
iv123 0:88b85febcb45 423
iv123 0:88b85febcb45 424 tBleStatus aci_gap_set_non_connectable_IDB05A1(uint8_t adv_type, uint8_t own_address_type)
iv123 0:88b85febcb45 425 {
iv123 0:88b85febcb45 426 struct hci_request rq;
iv123 0:88b85febcb45 427 gap_set_non_connectable_cp_IDB05A1 cp;
iv123 0:88b85febcb45 428 uint8_t status;
iv123 0:88b85febcb45 429
iv123 0:88b85febcb45 430 cp.advertising_event_type = adv_type;
iv123 0:88b85febcb45 431 cp.own_address_type = own_address_type;
iv123 0:88b85febcb45 432 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 433 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 434 rq.ocf = OCF_GAP_SET_NON_CONNECTABLE;
iv123 0:88b85febcb45 435 rq.cparam = &cp;
iv123 0:88b85febcb45 436 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 437 rq.rparam = &status;
iv123 0:88b85febcb45 438 rq.rlen = 1;
iv123 0:88b85febcb45 439
iv123 0:88b85febcb45 440 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 441 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 442
iv123 0:88b85febcb45 443 return status;
iv123 0:88b85febcb45 444 }
iv123 0:88b85febcb45 445
iv123 0:88b85febcb45 446 tBleStatus aci_gap_set_non_connectable_IDB04A1(uint8_t adv_type)
iv123 0:88b85febcb45 447 {
iv123 0:88b85febcb45 448 struct hci_request rq;
iv123 0:88b85febcb45 449 gap_set_non_connectable_cp_IDB04A1 cp;
iv123 0:88b85febcb45 450 uint8_t status;
iv123 0:88b85febcb45 451
iv123 0:88b85febcb45 452 cp.advertising_event_type = adv_type;
iv123 0:88b85febcb45 453
iv123 0:88b85febcb45 454 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 455 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 456 rq.ocf = OCF_GAP_SET_NON_CONNECTABLE;
iv123 0:88b85febcb45 457 rq.cparam = &cp;
iv123 0:88b85febcb45 458 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 459 rq.rparam = &status;
iv123 0:88b85febcb45 460 rq.rlen = 1;
iv123 0:88b85febcb45 461
iv123 0:88b85febcb45 462 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 463 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 464
iv123 0:88b85febcb45 465 return status;
iv123 0:88b85febcb45 466 }
iv123 0:88b85febcb45 467
iv123 0:88b85febcb45 468 tBleStatus aci_gap_set_undirected_connectable(uint8_t own_addr_type, uint8_t adv_filter_policy)
iv123 0:88b85febcb45 469 {
iv123 0:88b85febcb45 470 struct hci_request rq;
iv123 0:88b85febcb45 471 gap_set_undirected_connectable_cp cp;
iv123 0:88b85febcb45 472 uint8_t status;
iv123 0:88b85febcb45 473
iv123 0:88b85febcb45 474 cp.own_addr_type = own_addr_type;
iv123 0:88b85febcb45 475 cp.adv_filter_policy = adv_filter_policy;
iv123 0:88b85febcb45 476
iv123 0:88b85febcb45 477 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 478 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 479 rq.ocf = OCF_GAP_SET_UNDIRECTED_CONNECTABLE;
iv123 0:88b85febcb45 480 rq.cparam = &cp;
iv123 0:88b85febcb45 481 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 482 rq.rparam = &status;
iv123 0:88b85febcb45 483 rq.rlen = 1;
iv123 0:88b85febcb45 484
iv123 0:88b85febcb45 485 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 486 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 487
iv123 0:88b85febcb45 488 return status;
iv123 0:88b85febcb45 489 }
iv123 0:88b85febcb45 490
iv123 0:88b85febcb45 491 tBleStatus aci_gap_slave_security_request(uint16_t conn_handle, uint8_t bonding, uint8_t mitm_protection)
iv123 0:88b85febcb45 492 {
iv123 0:88b85febcb45 493 struct hci_request rq;
iv123 0:88b85febcb45 494 gap_slave_security_request_cp cp;
iv123 0:88b85febcb45 495 uint8_t status;
iv123 0:88b85febcb45 496
iv123 0:88b85febcb45 497 cp.conn_handle = htobs(conn_handle);
iv123 0:88b85febcb45 498 cp.bonding = bonding;
iv123 0:88b85febcb45 499 cp.mitm_protection = mitm_protection;
iv123 0:88b85febcb45 500
iv123 0:88b85febcb45 501 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 502 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 503 rq.ocf = OCF_GAP_SLAVE_SECURITY_REQUEST;
iv123 0:88b85febcb45 504 rq.cparam = &cp;
iv123 0:88b85febcb45 505 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 506 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 507 rq.rparam = &status;
iv123 0:88b85febcb45 508 rq.rlen = 1;
iv123 0:88b85febcb45 509
iv123 0:88b85febcb45 510 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 511 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 512
iv123 0:88b85febcb45 513 return status;
iv123 0:88b85febcb45 514
iv123 0:88b85febcb45 515 }
iv123 0:88b85febcb45 516
iv123 0:88b85febcb45 517 tBleStatus aci_gap_update_adv_data(uint8_t AdvLen, const uint8_t *AdvData)
iv123 0:88b85febcb45 518 {
iv123 0:88b85febcb45 519 struct hci_request rq;
iv123 0:88b85febcb45 520 uint8_t status;
iv123 0:88b85febcb45 521 uint8_t buffer[32];
iv123 0:88b85febcb45 522 uint8_t indx = 0;
iv123 0:88b85febcb45 523
iv123 0:88b85febcb45 524 if (AdvLen > (sizeof(buffer)-1))
iv123 0:88b85febcb45 525 return BLE_STATUS_INVALID_PARAMS;
iv123 0:88b85febcb45 526
iv123 0:88b85febcb45 527 buffer[indx] = AdvLen;
iv123 0:88b85febcb45 528 indx++;
iv123 0:88b85febcb45 529
iv123 0:88b85febcb45 530 Osal_MemCpy(buffer + indx, AdvData, AdvLen);
iv123 0:88b85febcb45 531 indx += AdvLen;
iv123 0:88b85febcb45 532
iv123 0:88b85febcb45 533 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 534 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 535 rq.ocf = OCF_GAP_UPDATE_ADV_DATA;
iv123 0:88b85febcb45 536 rq.cparam = (void *)buffer;
iv123 0:88b85febcb45 537 rq.clen = indx;
iv123 0:88b85febcb45 538 rq.rparam = &status;
iv123 0:88b85febcb45 539 rq.rlen = 1;
iv123 0:88b85febcb45 540
iv123 0:88b85febcb45 541 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 542 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 543
iv123 0:88b85febcb45 544 return status;
iv123 0:88b85febcb45 545 }
iv123 0:88b85febcb45 546
iv123 0:88b85febcb45 547 tBleStatus aci_gap_delete_ad_type(uint8_t ad_type)
iv123 0:88b85febcb45 548 {
iv123 0:88b85febcb45 549 struct hci_request rq;
iv123 0:88b85febcb45 550 gap_delete_ad_type_cp cp;
iv123 0:88b85febcb45 551 uint8_t status;
iv123 0:88b85febcb45 552
iv123 0:88b85febcb45 553 cp.ad_type = ad_type;
iv123 0:88b85febcb45 554
iv123 0:88b85febcb45 555 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 556 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 557 rq.ocf = OCF_GAP_DELETE_AD_TYPE;
iv123 0:88b85febcb45 558 rq.cparam = &cp;
iv123 0:88b85febcb45 559 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 560 rq.rparam = &status;
iv123 0:88b85febcb45 561 rq.rlen = 1;
iv123 0:88b85febcb45 562
iv123 0:88b85febcb45 563 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 564 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 565
iv123 0:88b85febcb45 566 return status;
iv123 0:88b85febcb45 567 }
iv123 0:88b85febcb45 568
iv123 0:88b85febcb45 569 tBleStatus aci_gap_get_security_level(uint8_t* mitm_protection, uint8_t* bonding,
iv123 0:88b85febcb45 570 uint8_t* oob_data, uint8_t* passkey_required)
iv123 0:88b85febcb45 571 {
iv123 0:88b85febcb45 572 struct hci_request rq;
iv123 0:88b85febcb45 573 gap_get_security_level_rp resp;
iv123 0:88b85febcb45 574
iv123 0:88b85febcb45 575 Osal_MemSet(&resp, 0, sizeof(resp));
iv123 0:88b85febcb45 576
iv123 0:88b85febcb45 577 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 578 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 579 rq.ocf = OCF_GAP_GET_SECURITY_LEVEL;
iv123 0:88b85febcb45 580 rq.rparam = &resp;
iv123 0:88b85febcb45 581 rq.rlen = GAP_GET_SECURITY_LEVEL_RP_SIZE;
iv123 0:88b85febcb45 582
iv123 0:88b85febcb45 583 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 584 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 585
iv123 0:88b85febcb45 586 if (resp.status) {
iv123 0:88b85febcb45 587 return resp.status;
iv123 0:88b85febcb45 588 }
iv123 0:88b85febcb45 589
iv123 0:88b85febcb45 590 *mitm_protection = resp.mitm_protection;
iv123 0:88b85febcb45 591 *bonding = resp.bonding;
iv123 0:88b85febcb45 592 *oob_data = resp.oob_data;
iv123 0:88b85febcb45 593 *passkey_required = resp.passkey_required;
iv123 0:88b85febcb45 594
iv123 0:88b85febcb45 595 return resp.status;
iv123 0:88b85febcb45 596 }
iv123 0:88b85febcb45 597
iv123 0:88b85febcb45 598 tBleStatus aci_gap_configure_whitelist(void)
iv123 0:88b85febcb45 599 {
iv123 0:88b85febcb45 600 struct hci_request rq;
iv123 0:88b85febcb45 601 uint8_t status;
iv123 0:88b85febcb45 602
iv123 0:88b85febcb45 603 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 604 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 605 rq.ocf = OCF_GAP_CONFIGURE_WHITELIST;
iv123 0:88b85febcb45 606 rq.rparam = &status;
iv123 0:88b85febcb45 607 rq.rlen = 1;
iv123 0:88b85febcb45 608
iv123 0:88b85febcb45 609 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 610 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 611
iv123 0:88b85febcb45 612 return status;
iv123 0:88b85febcb45 613 }
iv123 0:88b85febcb45 614
iv123 0:88b85febcb45 615 tBleStatus aci_gap_terminate(uint16_t conn_handle, uint8_t reason)
iv123 0:88b85febcb45 616 {
iv123 0:88b85febcb45 617 struct hci_request rq;
iv123 0:88b85febcb45 618 gap_terminate_cp cp;
iv123 0:88b85febcb45 619 uint8_t status;
iv123 0:88b85febcb45 620
iv123 0:88b85febcb45 621 cp.handle = htobs(conn_handle);
iv123 0:88b85febcb45 622 cp.reason = reason;
iv123 0:88b85febcb45 623
iv123 0:88b85febcb45 624 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 625 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 626 rq.ocf = OCF_GAP_TERMINATE;
iv123 0:88b85febcb45 627 rq.cparam = &cp;
iv123 0:88b85febcb45 628 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 629 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 630 rq.rparam = &status;
iv123 0:88b85febcb45 631 rq.rlen = 1;
iv123 0:88b85febcb45 632
iv123 0:88b85febcb45 633 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 634 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 635
iv123 0:88b85febcb45 636 return status;
iv123 0:88b85febcb45 637 }
iv123 0:88b85febcb45 638
iv123 0:88b85febcb45 639 tBleStatus aci_gap_clear_security_database(void)
iv123 0:88b85febcb45 640 {
iv123 0:88b85febcb45 641 struct hci_request rq;
iv123 0:88b85febcb45 642 uint8_t status;
iv123 0:88b85febcb45 643
iv123 0:88b85febcb45 644 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 645 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 646 rq.ocf = OCF_GAP_CLEAR_SECURITY_DB;
iv123 0:88b85febcb45 647 rq.rparam = &status;
iv123 0:88b85febcb45 648 rq.rlen = 1;
iv123 0:88b85febcb45 649
iv123 0:88b85febcb45 650 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 651 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 652
iv123 0:88b85febcb45 653 return status;
iv123 0:88b85febcb45 654 }
iv123 0:88b85febcb45 655
iv123 0:88b85febcb45 656 tBleStatus aci_gap_allow_rebond_IDB05A1(uint16_t conn_handle)
iv123 0:88b85febcb45 657 {
iv123 0:88b85febcb45 658 struct hci_request rq;
iv123 0:88b85febcb45 659 gap_allow_rebond_cp_IDB05A1 cp;
iv123 0:88b85febcb45 660 uint8_t status;
iv123 0:88b85febcb45 661
iv123 0:88b85febcb45 662 cp.conn_handle = conn_handle;
iv123 0:88b85febcb45 663
iv123 0:88b85febcb45 664 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 665 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 666 rq.ocf = OCF_GAP_ALLOW_REBOND_DB;
iv123 0:88b85febcb45 667 rq.cparam = &cp;
iv123 0:88b85febcb45 668 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 669 rq.rparam = &status;
iv123 0:88b85febcb45 670 rq.rlen = 1;
iv123 0:88b85febcb45 671
iv123 0:88b85febcb45 672 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 673 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 674
iv123 0:88b85febcb45 675 return status;
iv123 0:88b85febcb45 676 }
iv123 0:88b85febcb45 677 tBleStatus aci_gap_allow_rebond_IDB04A1(void)
iv123 0:88b85febcb45 678 {
iv123 0:88b85febcb45 679 struct hci_request rq;
iv123 0:88b85febcb45 680 uint8_t status;
iv123 0:88b85febcb45 681
iv123 0:88b85febcb45 682 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 683 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 684 rq.ocf = OCF_GAP_ALLOW_REBOND_DB;
iv123 0:88b85febcb45 685 rq.rparam = &status;
iv123 0:88b85febcb45 686 rq.rlen = 1;
iv123 0:88b85febcb45 687
iv123 0:88b85febcb45 688 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 689 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 690
iv123 0:88b85febcb45 691 return status;
iv123 0:88b85febcb45 692 }
iv123 0:88b85febcb45 693
iv123 0:88b85febcb45 694 tBleStatus aci_gap_start_limited_discovery_proc(uint16_t scanInterval, uint16_t scanWindow,
iv123 0:88b85febcb45 695 uint8_t own_address_type, uint8_t filterDuplicates)
iv123 0:88b85febcb45 696 {
iv123 0:88b85febcb45 697 struct hci_request rq;
iv123 0:88b85febcb45 698 gap_start_limited_discovery_proc_cp cp;
iv123 0:88b85febcb45 699 uint8_t status;
iv123 0:88b85febcb45 700
iv123 0:88b85febcb45 701 cp.scanInterval = htobs(scanInterval);
iv123 0:88b85febcb45 702 cp.scanWindow = htobs(scanWindow);
iv123 0:88b85febcb45 703 cp.own_address_type = own_address_type;
iv123 0:88b85febcb45 704 cp.filterDuplicates = filterDuplicates;
iv123 0:88b85febcb45 705
iv123 0:88b85febcb45 706 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 707 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 708 rq.ocf = OCF_GAP_START_LIMITED_DISCOVERY_PROC;
iv123 0:88b85febcb45 709 rq.cparam = &cp;
iv123 0:88b85febcb45 710 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 711 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 712 rq.rparam = &status;
iv123 0:88b85febcb45 713 rq.rlen = 1;
iv123 0:88b85febcb45 714
iv123 0:88b85febcb45 715 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 716 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 717
iv123 0:88b85febcb45 718 return status;
iv123 0:88b85febcb45 719 }
iv123 0:88b85febcb45 720
iv123 0:88b85febcb45 721 tBleStatus aci_gap_start_general_discovery_proc(uint16_t scanInterval, uint16_t scanWindow,
iv123 0:88b85febcb45 722 uint8_t own_address_type, uint8_t filterDuplicates)
iv123 0:88b85febcb45 723 {
iv123 0:88b85febcb45 724 struct hci_request rq;
iv123 0:88b85febcb45 725 gap_start_general_discovery_proc_cp cp;
iv123 0:88b85febcb45 726 uint8_t status;
iv123 0:88b85febcb45 727
iv123 0:88b85febcb45 728 cp.scanInterval = htobs(scanInterval);
iv123 0:88b85febcb45 729 cp.scanWindow = htobs(scanWindow);
iv123 0:88b85febcb45 730 cp.own_address_type = own_address_type;
iv123 0:88b85febcb45 731 cp.filterDuplicates = filterDuplicates;
iv123 0:88b85febcb45 732
iv123 0:88b85febcb45 733 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 734 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 735 rq.ocf = OCF_GAP_START_GENERAL_DISCOVERY_PROC;
iv123 0:88b85febcb45 736 rq.cparam = &cp;
iv123 0:88b85febcb45 737 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 738 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 739 rq.rparam = &status;
iv123 0:88b85febcb45 740 rq.rlen = 1;
iv123 0:88b85febcb45 741
iv123 0:88b85febcb45 742 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 743 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 744
iv123 0:88b85febcb45 745 return status;
iv123 0:88b85febcb45 746 }
iv123 0:88b85febcb45 747
iv123 0:88b85febcb45 748
iv123 0:88b85febcb45 749 tBleStatus aci_gap_start_name_discovery_proc(uint16_t scanInterval, uint16_t scanWindow,
iv123 0:88b85febcb45 750 uint8_t peer_bdaddr_type, tBDAddr peer_bdaddr,
iv123 0:88b85febcb45 751 uint8_t own_bdaddr_type, uint16_t conn_min_interval,
iv123 0:88b85febcb45 752 uint16_t conn_max_interval, uint16_t conn_latency,
iv123 0:88b85febcb45 753 uint16_t supervision_timeout, uint16_t min_conn_length,
iv123 0:88b85febcb45 754 uint16_t max_conn_length)
iv123 0:88b85febcb45 755 {
iv123 0:88b85febcb45 756 struct hci_request rq;
iv123 0:88b85febcb45 757 gap_start_name_discovery_proc_cp cp;
iv123 0:88b85febcb45 758 uint8_t status;
iv123 0:88b85febcb45 759
iv123 0:88b85febcb45 760 cp.scanInterval = htobs(scanInterval);
iv123 0:88b85febcb45 761 cp.scanWindow = htobs(scanWindow);
iv123 0:88b85febcb45 762 cp.peer_bdaddr_type = peer_bdaddr_type;
iv123 0:88b85febcb45 763 Osal_MemCpy(cp.peer_bdaddr, peer_bdaddr, 6);
iv123 0:88b85febcb45 764 cp.own_bdaddr_type = own_bdaddr_type;
iv123 0:88b85febcb45 765 cp.conn_min_interval = htobs(conn_min_interval);
iv123 0:88b85febcb45 766 cp.conn_max_interval = htobs(conn_max_interval);
iv123 0:88b85febcb45 767 cp.conn_latency = htobs(conn_latency);
iv123 0:88b85febcb45 768 cp.supervision_timeout = htobs(supervision_timeout);
iv123 0:88b85febcb45 769 cp.min_conn_length = htobs(min_conn_length);
iv123 0:88b85febcb45 770 cp.max_conn_length = htobs(max_conn_length);
iv123 0:88b85febcb45 771
iv123 0:88b85febcb45 772 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 773 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 774 rq.ocf = OCF_GAP_START_NAME_DISCOVERY_PROC;
iv123 0:88b85febcb45 775 rq.cparam = &cp;
iv123 0:88b85febcb45 776 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 777 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 778 rq.rparam = &status;
iv123 0:88b85febcb45 779 rq.rlen = 1;
iv123 0:88b85febcb45 780
iv123 0:88b85febcb45 781 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 782 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 783
iv123 0:88b85febcb45 784 return status;
iv123 0:88b85febcb45 785 }
iv123 0:88b85febcb45 786
iv123 0:88b85febcb45 787 tBleStatus aci_gap_start_auto_conn_establish_proc_IDB05A1(uint16_t scanInterval, uint16_t scanWindow,
iv123 0:88b85febcb45 788 uint8_t own_bdaddr_type, uint16_t conn_min_interval,
iv123 0:88b85febcb45 789 uint16_t conn_max_interval, uint16_t conn_latency,
iv123 0:88b85febcb45 790 uint16_t supervision_timeout, uint16_t min_conn_length,
iv123 0:88b85febcb45 791 uint16_t max_conn_length,
iv123 0:88b85febcb45 792 uint8_t num_whitelist_entries,
iv123 0:88b85febcb45 793 const uint8_t *addr_array)
iv123 0:88b85febcb45 794 {
iv123 0:88b85febcb45 795 struct hci_request rq;
iv123 0:88b85febcb45 796 uint8_t status;
iv123 0:88b85febcb45 797 uint8_t buffer[HCI_MAX_PAYLOAD_SIZE];
iv123 0:88b85febcb45 798 uint8_t indx = 0;
iv123 0:88b85febcb45 799
iv123 0:88b85febcb45 800 if (((num_whitelist_entries*7)+25) > HCI_MAX_PAYLOAD_SIZE)
iv123 0:88b85febcb45 801 return BLE_STATUS_INVALID_PARAMS;
iv123 0:88b85febcb45 802
iv123 0:88b85febcb45 803 scanInterval = htobs(scanInterval);
iv123 0:88b85febcb45 804 Osal_MemCpy(buffer + indx, &scanInterval, 2);
iv123 0:88b85febcb45 805 indx += 2;
iv123 0:88b85febcb45 806
iv123 0:88b85febcb45 807 scanWindow = htobs(scanWindow);
iv123 0:88b85febcb45 808 Osal_MemCpy(buffer + indx, &scanWindow, 2);
iv123 0:88b85febcb45 809 indx += 2;
iv123 0:88b85febcb45 810
iv123 0:88b85febcb45 811 buffer[indx] = own_bdaddr_type;
iv123 0:88b85febcb45 812 indx++;
iv123 0:88b85febcb45 813
iv123 0:88b85febcb45 814 conn_min_interval = htobs(conn_min_interval);
iv123 0:88b85febcb45 815 Osal_MemCpy(buffer + indx, &conn_min_interval, 2);
iv123 0:88b85febcb45 816 indx += 2;
iv123 0:88b85febcb45 817
iv123 0:88b85febcb45 818 conn_max_interval = htobs(conn_max_interval);
iv123 0:88b85febcb45 819 Osal_MemCpy(buffer + indx, &conn_max_interval, 2);
iv123 0:88b85febcb45 820 indx += 2;
iv123 0:88b85febcb45 821
iv123 0:88b85febcb45 822 conn_latency = htobs(conn_latency);
iv123 0:88b85febcb45 823 Osal_MemCpy(buffer + indx, &conn_latency, 2);
iv123 0:88b85febcb45 824 indx += 2;
iv123 0:88b85febcb45 825
iv123 0:88b85febcb45 826 supervision_timeout = htobs(supervision_timeout);
iv123 0:88b85febcb45 827 Osal_MemCpy(buffer + indx, &supervision_timeout, 2);
iv123 0:88b85febcb45 828 indx += 2;
iv123 0:88b85febcb45 829
iv123 0:88b85febcb45 830 min_conn_length = htobs(min_conn_length);
iv123 0:88b85febcb45 831 Osal_MemCpy(buffer + indx, &min_conn_length, 2);
iv123 0:88b85febcb45 832 indx += 2;
iv123 0:88b85febcb45 833
iv123 0:88b85febcb45 834 max_conn_length = htobs(max_conn_length);
iv123 0:88b85febcb45 835 Osal_MemCpy(buffer + indx, &max_conn_length, 2);
iv123 0:88b85febcb45 836 indx += 2;
iv123 0:88b85febcb45 837
iv123 0:88b85febcb45 838 buffer[indx] = num_whitelist_entries;
iv123 0:88b85febcb45 839 indx++;
iv123 0:88b85febcb45 840
iv123 0:88b85febcb45 841 Osal_MemCpy(buffer + indx, addr_array, (num_whitelist_entries*7));
iv123 0:88b85febcb45 842 indx += num_whitelist_entries * 7;
iv123 0:88b85febcb45 843
iv123 0:88b85febcb45 844 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 845 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 846 rq.ocf = OCF_GAP_START_AUTO_CONN_ESTABLISH_PROC;
iv123 0:88b85febcb45 847 rq.cparam = (void *)buffer;
iv123 0:88b85febcb45 848 rq.clen = indx;
iv123 0:88b85febcb45 849 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 850 rq.rparam = &status;
iv123 0:88b85febcb45 851 rq.rlen = 1;
iv123 0:88b85febcb45 852
iv123 0:88b85febcb45 853 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 854 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 855
iv123 0:88b85febcb45 856 return status;
iv123 0:88b85febcb45 857 }
iv123 0:88b85febcb45 858
iv123 0:88b85febcb45 859 tBleStatus aci_gap_start_auto_conn_establish_proc_IDB04A1(uint16_t scanInterval, uint16_t scanWindow,
iv123 0:88b85febcb45 860 uint8_t own_bdaddr_type, uint16_t conn_min_interval,
iv123 0:88b85febcb45 861 uint16_t conn_max_interval, uint16_t conn_latency,
iv123 0:88b85febcb45 862 uint16_t supervision_timeout, uint16_t min_conn_length,
iv123 0:88b85febcb45 863 uint16_t max_conn_length,
iv123 0:88b85febcb45 864 uint8_t use_reconn_addr,
iv123 0:88b85febcb45 865 const tBDAddr reconn_addr,
iv123 0:88b85febcb45 866 uint8_t num_whitelist_entries,
iv123 0:88b85febcb45 867 const uint8_t *addr_array)
iv123 0:88b85febcb45 868 {
iv123 0:88b85febcb45 869 struct hci_request rq;
iv123 0:88b85febcb45 870 uint8_t status;
iv123 0:88b85febcb45 871 uint8_t buffer[HCI_MAX_PAYLOAD_SIZE];
iv123 0:88b85febcb45 872 uint8_t indx = 0;
iv123 0:88b85febcb45 873
iv123 0:88b85febcb45 874 if (((num_whitelist_entries*7)+25) > HCI_MAX_PAYLOAD_SIZE)
iv123 0:88b85febcb45 875 return BLE_STATUS_INVALID_PARAMS;
iv123 0:88b85febcb45 876
iv123 0:88b85febcb45 877 scanInterval = htobs(scanInterval);
iv123 0:88b85febcb45 878 Osal_MemCpy(buffer + indx, &scanInterval, 2);
iv123 0:88b85febcb45 879 indx += 2;
iv123 0:88b85febcb45 880
iv123 0:88b85febcb45 881 scanWindow = htobs(scanWindow);
iv123 0:88b85febcb45 882 Osal_MemCpy(buffer + indx, &scanWindow, 2);
iv123 0:88b85febcb45 883 indx += 2;
iv123 0:88b85febcb45 884
iv123 0:88b85febcb45 885 buffer[indx] = own_bdaddr_type;
iv123 0:88b85febcb45 886 indx++;
iv123 0:88b85febcb45 887
iv123 0:88b85febcb45 888 conn_min_interval = htobs(conn_min_interval);
iv123 0:88b85febcb45 889 Osal_MemCpy(buffer + indx, &conn_min_interval, 2);
iv123 0:88b85febcb45 890 indx += 2;
iv123 0:88b85febcb45 891
iv123 0:88b85febcb45 892 conn_max_interval = htobs(conn_max_interval);
iv123 0:88b85febcb45 893 Osal_MemCpy(buffer + indx, &conn_max_interval, 2);
iv123 0:88b85febcb45 894 indx += 2;
iv123 0:88b85febcb45 895
iv123 0:88b85febcb45 896 conn_latency = htobs(conn_latency);
iv123 0:88b85febcb45 897 Osal_MemCpy(buffer + indx, &conn_latency, 2);
iv123 0:88b85febcb45 898 indx += 2;
iv123 0:88b85febcb45 899
iv123 0:88b85febcb45 900 supervision_timeout = htobs(supervision_timeout);
iv123 0:88b85febcb45 901 Osal_MemCpy(buffer + indx, &supervision_timeout, 2);
iv123 0:88b85febcb45 902 indx += 2;
iv123 0:88b85febcb45 903
iv123 0:88b85febcb45 904 min_conn_length = htobs(min_conn_length);
iv123 0:88b85febcb45 905 Osal_MemCpy(buffer + indx, &min_conn_length, 2);
iv123 0:88b85febcb45 906 indx += 2;
iv123 0:88b85febcb45 907
iv123 0:88b85febcb45 908 max_conn_length = htobs(max_conn_length);
iv123 0:88b85febcb45 909 Osal_MemCpy(buffer + indx, &max_conn_length, 2);
iv123 0:88b85febcb45 910 indx += 2;
iv123 0:88b85febcb45 911
iv123 0:88b85febcb45 912 buffer[indx] = use_reconn_addr;
iv123 0:88b85febcb45 913 indx++;
iv123 0:88b85febcb45 914
iv123 0:88b85febcb45 915 Osal_MemCpy(buffer + indx, reconn_addr, 6);
iv123 0:88b85febcb45 916 indx += 6;
iv123 0:88b85febcb45 917
iv123 0:88b85febcb45 918 buffer[indx] = num_whitelist_entries;
iv123 0:88b85febcb45 919 indx++;
iv123 0:88b85febcb45 920
iv123 0:88b85febcb45 921 Osal_MemCpy(buffer + indx, addr_array, (num_whitelist_entries*7));
iv123 0:88b85febcb45 922 indx += num_whitelist_entries * 7;
iv123 0:88b85febcb45 923
iv123 0:88b85febcb45 924 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 925 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 926 rq.ocf = OCF_GAP_START_AUTO_CONN_ESTABLISH_PROC;
iv123 0:88b85febcb45 927 rq.cparam = (void *)buffer;
iv123 0:88b85febcb45 928 rq.clen = indx;
iv123 0:88b85febcb45 929 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 930 rq.rparam = &status;
iv123 0:88b85febcb45 931 rq.rlen = 1;
iv123 0:88b85febcb45 932
iv123 0:88b85febcb45 933 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 934 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 935
iv123 0:88b85febcb45 936 return status;
iv123 0:88b85febcb45 937 }
iv123 0:88b85febcb45 938
iv123 0:88b85febcb45 939 tBleStatus aci_gap_start_general_conn_establish_proc_IDB05A1(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window,
iv123 0:88b85febcb45 940 uint8_t own_address_type, uint8_t filter_duplicates)
iv123 0:88b85febcb45 941 {
iv123 0:88b85febcb45 942 struct hci_request rq;
iv123 0:88b85febcb45 943 gap_start_general_conn_establish_proc_cp_IDB05A1 cp;
iv123 0:88b85febcb45 944 uint8_t status;
iv123 0:88b85febcb45 945
iv123 0:88b85febcb45 946 cp.scan_type = scan_type;
iv123 0:88b85febcb45 947 cp.scan_interval = htobs(scan_interval);
iv123 0:88b85febcb45 948 cp.scan_window = htobs(scan_window);
iv123 0:88b85febcb45 949 cp.own_address_type = own_address_type;
iv123 0:88b85febcb45 950 cp.filter_duplicates = filter_duplicates;
iv123 0:88b85febcb45 951
iv123 0:88b85febcb45 952 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 953 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 954 rq.ocf = OCF_GAP_START_GENERAL_CONN_ESTABLISH_PROC;
iv123 0:88b85febcb45 955 rq.cparam = &cp;
iv123 0:88b85febcb45 956 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 957 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 958 rq.rparam = &status;
iv123 0:88b85febcb45 959 rq.rlen = 1;
iv123 0:88b85febcb45 960
iv123 0:88b85febcb45 961 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 962 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 963
iv123 0:88b85febcb45 964 return status;
iv123 0:88b85febcb45 965 }
iv123 0:88b85febcb45 966 tBleStatus aci_gap_start_general_conn_establish_proc_IDB04A1(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window,
iv123 0:88b85febcb45 967 uint8_t own_address_type, uint8_t filter_duplicates, uint8_t use_reconn_addr, const tBDAddr reconn_addr)
iv123 0:88b85febcb45 968 {
iv123 0:88b85febcb45 969 struct hci_request rq;
iv123 0:88b85febcb45 970 gap_start_general_conn_establish_proc_cp_IDB04A1 cp;
iv123 0:88b85febcb45 971 uint8_t status;
iv123 0:88b85febcb45 972
iv123 0:88b85febcb45 973 cp.scan_type = scan_type;
iv123 0:88b85febcb45 974 cp.scan_interval = htobs(scan_interval);
iv123 0:88b85febcb45 975 cp.scan_window = htobs(scan_window);
iv123 0:88b85febcb45 976 cp.own_address_type = own_address_type;
iv123 0:88b85febcb45 977 cp.filter_duplicates = filter_duplicates;
iv123 0:88b85febcb45 978 cp.use_reconn_addr = use_reconn_addr;
iv123 0:88b85febcb45 979 Osal_MemCpy(cp.reconn_addr, reconn_addr, 6);
iv123 0:88b85febcb45 980
iv123 0:88b85febcb45 981 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 982 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 983 rq.ocf = OCF_GAP_START_GENERAL_CONN_ESTABLISH_PROC;
iv123 0:88b85febcb45 984 rq.cparam = &cp;
iv123 0:88b85febcb45 985 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 986 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 987 rq.rparam = &status;
iv123 0:88b85febcb45 988 rq.rlen = 1;
iv123 0:88b85febcb45 989
iv123 0:88b85febcb45 990 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 991 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 992
iv123 0:88b85febcb45 993 return status;
iv123 0:88b85febcb45 994 }
iv123 0:88b85febcb45 995
iv123 0:88b85febcb45 996 tBleStatus aci_gap_start_selective_conn_establish_proc(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window,
iv123 0:88b85febcb45 997 uint8_t own_address_type, uint8_t filter_duplicates, uint8_t num_whitelist_entries,
iv123 0:88b85febcb45 998 const uint8_t *addr_array)
iv123 0:88b85febcb45 999 {
iv123 0:88b85febcb45 1000 struct hci_request rq;
iv123 0:88b85febcb45 1001 gap_start_selective_conn_establish_proc_cp cp;
iv123 0:88b85febcb45 1002 uint8_t status;
iv123 0:88b85febcb45 1003
iv123 0:88b85febcb45 1004 if (((num_whitelist_entries*7)+GAP_START_SELECTIVE_CONN_ESTABLISH_PROC_CP_SIZE) > HCI_MAX_PAYLOAD_SIZE)
iv123 0:88b85febcb45 1005 return BLE_STATUS_INVALID_PARAMS;
iv123 0:88b85febcb45 1006
iv123 0:88b85febcb45 1007 cp.scan_type = scan_type;
iv123 0:88b85febcb45 1008 cp.scan_interval = htobs(scan_interval);
iv123 0:88b85febcb45 1009 cp.scan_window = htobs(scan_window);
iv123 0:88b85febcb45 1010 cp.own_address_type = own_address_type;
iv123 0:88b85febcb45 1011 cp.filter_duplicates = filter_duplicates;
iv123 0:88b85febcb45 1012 cp.num_whitelist_entries = num_whitelist_entries;
iv123 0:88b85febcb45 1013
iv123 0:88b85febcb45 1014 Osal_MemCpy(cp.addr_array, addr_array, (num_whitelist_entries*7));
iv123 0:88b85febcb45 1015
iv123 0:88b85febcb45 1016 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 1017 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 1018 rq.ocf = OCF_GAP_START_SELECTIVE_CONN_ESTABLISH_PROC;
iv123 0:88b85febcb45 1019 rq.cparam = &cp;
iv123 0:88b85febcb45 1020 rq.clen = GAP_START_SELECTIVE_CONN_ESTABLISH_PROC_CP_SIZE + (num_whitelist_entries*7);
iv123 0:88b85febcb45 1021 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 1022 rq.rparam = &status;
iv123 0:88b85febcb45 1023 rq.rlen = 1;
iv123 0:88b85febcb45 1024
iv123 0:88b85febcb45 1025 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 1026 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 1027
iv123 0:88b85febcb45 1028 return status;
iv123 0:88b85febcb45 1029 }
iv123 0:88b85febcb45 1030
iv123 0:88b85febcb45 1031 tBleStatus aci_gap_create_connection(uint16_t scanInterval, uint16_t scanWindow,
iv123 0:88b85febcb45 1032 uint8_t peer_bdaddr_type, tBDAddr peer_bdaddr,
iv123 0:88b85febcb45 1033 uint8_t own_bdaddr_type, uint16_t conn_min_interval,
iv123 0:88b85febcb45 1034 uint16_t conn_max_interval, uint16_t conn_latency,
iv123 0:88b85febcb45 1035 uint16_t supervision_timeout, uint16_t min_conn_length,
iv123 0:88b85febcb45 1036 uint16_t max_conn_length)
iv123 0:88b85febcb45 1037 {
iv123 0:88b85febcb45 1038 struct hci_request rq;
iv123 0:88b85febcb45 1039 gap_create_connection_cp cp;
iv123 0:88b85febcb45 1040 uint8_t status;
iv123 0:88b85febcb45 1041
iv123 0:88b85febcb45 1042 cp.scanInterval = htobs(scanInterval);
iv123 0:88b85febcb45 1043 cp.scanWindow = htobs(scanWindow);
iv123 0:88b85febcb45 1044 cp.peer_bdaddr_type = peer_bdaddr_type;
iv123 0:88b85febcb45 1045 Osal_MemCpy(cp.peer_bdaddr, peer_bdaddr, 6);
iv123 0:88b85febcb45 1046 cp.own_bdaddr_type = own_bdaddr_type;
iv123 0:88b85febcb45 1047 cp.conn_min_interval = htobs(conn_min_interval);
iv123 0:88b85febcb45 1048 cp.conn_max_interval = htobs(conn_max_interval);
iv123 0:88b85febcb45 1049 cp.conn_latency = htobs(conn_latency);
iv123 0:88b85febcb45 1050 cp.supervision_timeout = htobs(supervision_timeout);
iv123 0:88b85febcb45 1051 cp.min_conn_length = htobs(min_conn_length);
iv123 0:88b85febcb45 1052 cp.max_conn_length = htobs(max_conn_length);
iv123 0:88b85febcb45 1053
iv123 0:88b85febcb45 1054 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 1055 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 1056 rq.ocf = OCF_GAP_CREATE_CONNECTION;
iv123 0:88b85febcb45 1057 rq.cparam = &cp;
iv123 0:88b85febcb45 1058 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 1059 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 1060 rq.rparam = &status;
iv123 0:88b85febcb45 1061 rq.rlen = 1;
iv123 0:88b85febcb45 1062
iv123 0:88b85febcb45 1063 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 1064 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 1065
iv123 0:88b85febcb45 1066 return status;
iv123 0:88b85febcb45 1067 }
iv123 0:88b85febcb45 1068
iv123 0:88b85febcb45 1069 tBleStatus aci_gap_terminate_gap_procedure(uint8_t procedure_code)
iv123 0:88b85febcb45 1070 {
iv123 0:88b85febcb45 1071 struct hci_request rq;
iv123 0:88b85febcb45 1072 uint8_t status;
iv123 0:88b85febcb45 1073
iv123 0:88b85febcb45 1074 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 1075 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 1076 rq.ocf = OCF_GAP_TERMINATE_GAP_PROCEDURE;
iv123 0:88b85febcb45 1077 rq.cparam = &procedure_code;
iv123 0:88b85febcb45 1078 rq.clen = 1;
iv123 0:88b85febcb45 1079 rq.rparam = &status;
iv123 0:88b85febcb45 1080 rq.rlen = 1;
iv123 0:88b85febcb45 1081
iv123 0:88b85febcb45 1082 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 1083 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 1084
iv123 0:88b85febcb45 1085 return status;
iv123 0:88b85febcb45 1086
iv123 0:88b85febcb45 1087 }
iv123 0:88b85febcb45 1088
iv123 0:88b85febcb45 1089 tBleStatus aci_gap_start_connection_update(uint16_t conn_handle, uint16_t conn_min_interval,
iv123 0:88b85febcb45 1090 uint16_t conn_max_interval, uint16_t conn_latency,
iv123 0:88b85febcb45 1091 uint16_t supervision_timeout, uint16_t min_conn_length,
iv123 0:88b85febcb45 1092 uint16_t max_conn_length)
iv123 0:88b85febcb45 1093 {
iv123 0:88b85febcb45 1094 struct hci_request rq;
iv123 0:88b85febcb45 1095 gap_start_connection_update_cp cp;
iv123 0:88b85febcb45 1096 uint8_t status;
iv123 0:88b85febcb45 1097
iv123 0:88b85febcb45 1098 cp.conn_handle = htobs(conn_handle);
iv123 0:88b85febcb45 1099 cp.conn_min_interval = htobs(conn_min_interval);
iv123 0:88b85febcb45 1100 cp.conn_max_interval = htobs(conn_max_interval);
iv123 0:88b85febcb45 1101 cp.conn_latency = htobs(conn_latency);
iv123 0:88b85febcb45 1102 cp.supervision_timeout = htobs(supervision_timeout);
iv123 0:88b85febcb45 1103 cp.min_conn_length = htobs(min_conn_length);
iv123 0:88b85febcb45 1104 cp.max_conn_length = htobs(max_conn_length);
iv123 0:88b85febcb45 1105
iv123 0:88b85febcb45 1106 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 1107 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 1108 rq.ocf = OCF_GAP_START_CONNECTION_UPDATE;
iv123 0:88b85febcb45 1109 rq.cparam = &cp;
iv123 0:88b85febcb45 1110 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 1111 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 1112 rq.rparam = &status;
iv123 0:88b85febcb45 1113 rq.rlen = 1;
iv123 0:88b85febcb45 1114
iv123 0:88b85febcb45 1115 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 1116 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 1117
iv123 0:88b85febcb45 1118 return status;
iv123 0:88b85febcb45 1119 }
iv123 0:88b85febcb45 1120
iv123 0:88b85febcb45 1121 tBleStatus aci_gap_send_pairing_request(uint16_t conn_handle, uint8_t force_rebond)
iv123 0:88b85febcb45 1122 {
iv123 0:88b85febcb45 1123 struct hci_request rq;
iv123 0:88b85febcb45 1124 gap_send_pairing_request_cp cp;
iv123 0:88b85febcb45 1125 uint8_t status;
iv123 0:88b85febcb45 1126
iv123 0:88b85febcb45 1127 cp.conn_handle = htobs(conn_handle);
iv123 0:88b85febcb45 1128 cp.force_rebond = force_rebond;
iv123 0:88b85febcb45 1129
iv123 0:88b85febcb45 1130 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 1131 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 1132 rq.ocf = OCF_GAP_SEND_PAIRING_REQUEST;
iv123 0:88b85febcb45 1133 rq.cparam = &cp;
iv123 0:88b85febcb45 1134 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 1135 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 1136 rq.rparam = &status;
iv123 0:88b85febcb45 1137 rq.rlen = 1;
iv123 0:88b85febcb45 1138
iv123 0:88b85febcb45 1139 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 1140 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 1141
iv123 0:88b85febcb45 1142 return status;
iv123 0:88b85febcb45 1143 }
iv123 0:88b85febcb45 1144
iv123 0:88b85febcb45 1145 tBleStatus aci_gap_resolve_private_address_IDB05A1(const tBDAddr private_address, tBDAddr actual_address)
iv123 0:88b85febcb45 1146 {
iv123 0:88b85febcb45 1147 struct hci_request rq;
iv123 0:88b85febcb45 1148 gap_resolve_private_address_cp cp;
iv123 0:88b85febcb45 1149 gap_resolve_private_address_rp rp;
iv123 0:88b85febcb45 1150
iv123 0:88b85febcb45 1151 Osal_MemCpy(cp.address, private_address, 6);
iv123 0:88b85febcb45 1152
iv123 0:88b85febcb45 1153 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 1154 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 1155 rq.ocf = OCF_GAP_RESOLVE_PRIVATE_ADDRESS;
iv123 0:88b85febcb45 1156 rq.cparam = &cp;
iv123 0:88b85febcb45 1157 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 1158 rq.rparam = &rp;
iv123 0:88b85febcb45 1159 rq.rlen = sizeof(rp);
iv123 0:88b85febcb45 1160
iv123 0:88b85febcb45 1161 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 1162 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 1163
iv123 0:88b85febcb45 1164 if(rp.status)
iv123 0:88b85febcb45 1165 return rp.status;
iv123 0:88b85febcb45 1166
iv123 0:88b85febcb45 1167 Osal_MemCpy(actual_address, rp.address, 6);
iv123 0:88b85febcb45 1168
iv123 0:88b85febcb45 1169 return 0;
iv123 0:88b85febcb45 1170 }
iv123 0:88b85febcb45 1171 tBleStatus aci_gap_resolve_private_address_IDB04A1(const tBDAddr address)
iv123 0:88b85febcb45 1172 {
iv123 0:88b85febcb45 1173 struct hci_request rq;
iv123 0:88b85febcb45 1174 gap_resolve_private_address_cp cp;
iv123 0:88b85febcb45 1175 uint8_t status;
iv123 0:88b85febcb45 1176
iv123 0:88b85febcb45 1177 Osal_MemCpy(cp.address, address, 6);
iv123 0:88b85febcb45 1178
iv123 0:88b85febcb45 1179 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 1180 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 1181 rq.ocf = OCF_GAP_RESOLVE_PRIVATE_ADDRESS;
iv123 0:88b85febcb45 1182 rq.cparam = &cp;
iv123 0:88b85febcb45 1183 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 1184 rq.rparam = &status;
iv123 0:88b85febcb45 1185 rq.rlen = 1;
iv123 0:88b85febcb45 1186
iv123 0:88b85febcb45 1187 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 1188 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 1189
iv123 0:88b85febcb45 1190 return status;
iv123 0:88b85febcb45 1191 }
iv123 0:88b85febcb45 1192
iv123 0:88b85febcb45 1193 tBleStatus aci_gap_set_broadcast_mode(uint16_t adv_interv_min, uint16_t adv_interv_max, uint8_t adv_type,
iv123 0:88b85febcb45 1194 uint8_t own_addr_type, uint8_t adv_data_length, const uint8_t *adv_data, uint8_t num_whitelist_entries,
iv123 0:88b85febcb45 1195 const uint8_t *addr_array)
iv123 0:88b85febcb45 1196 {
iv123 0:88b85febcb45 1197 struct hci_request rq;
iv123 0:88b85febcb45 1198 gap_set_broadcast_mode_cp cp;
iv123 0:88b85febcb45 1199 uint8_t status;
iv123 0:88b85febcb45 1200 uint8_t indx = 0;
iv123 0:88b85febcb45 1201 uint8_t variable_size = 1 + adv_data_length + 1 + num_whitelist_entries*7;
iv123 0:88b85febcb45 1202
iv123 0:88b85febcb45 1203 if (variable_size > sizeof(cp.var_len_data) )
iv123 0:88b85febcb45 1204 return BLE_STATUS_INVALID_PARAMS;
iv123 0:88b85febcb45 1205
iv123 0:88b85febcb45 1206 cp.adv_interv_min = htobs(adv_interv_min);
iv123 0:88b85febcb45 1207 cp.adv_interv_max = htobs(adv_interv_max);
iv123 0:88b85febcb45 1208 cp.adv_type = adv_type;
iv123 0:88b85febcb45 1209 cp.own_addr_type = own_addr_type;
iv123 0:88b85febcb45 1210
iv123 0:88b85febcb45 1211 cp.var_len_data[indx] = adv_data_length;
iv123 0:88b85febcb45 1212 indx++;
iv123 0:88b85febcb45 1213 Osal_MemCpy(cp.var_len_data + indx, adv_data, adv_data_length);
iv123 0:88b85febcb45 1214 indx += adv_data_length;
iv123 0:88b85febcb45 1215 cp.var_len_data[indx] = num_whitelist_entries;
iv123 0:88b85febcb45 1216 indx ++;
iv123 0:88b85febcb45 1217 Osal_MemCpy(cp.var_len_data + indx, addr_array, num_whitelist_entries*7);
iv123 0:88b85febcb45 1218
iv123 0:88b85febcb45 1219 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 1220 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 1221 rq.ocf = OCF_GAP_SET_BROADCAST_MODE;
iv123 0:88b85febcb45 1222 rq.cparam = &cp;
iv123 0:88b85febcb45 1223 rq.clen = GAP_SET_BROADCAST_MODE_CP_SIZE + variable_size;
iv123 0:88b85febcb45 1224 rq.rparam = &status;
iv123 0:88b85febcb45 1225 rq.rlen = 1;
iv123 0:88b85febcb45 1226
iv123 0:88b85febcb45 1227 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 1228 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 1229
iv123 0:88b85febcb45 1230 return status;
iv123 0:88b85febcb45 1231 }
iv123 0:88b85febcb45 1232
iv123 0:88b85febcb45 1233 tBleStatus aci_gap_start_observation_procedure(uint16_t scan_interval, uint16_t scan_window, uint8_t scan_type,
iv123 0:88b85febcb45 1234 uint8_t own_address_type, uint8_t filter_duplicates)
iv123 0:88b85febcb45 1235 {
iv123 0:88b85febcb45 1236 struct hci_request rq;
iv123 0:88b85febcb45 1237 gap_start_observation_proc_cp cp;
iv123 0:88b85febcb45 1238 uint8_t status;
iv123 0:88b85febcb45 1239
iv123 0:88b85febcb45 1240 cp.scan_interval = scan_interval;
iv123 0:88b85febcb45 1241 cp.scan_window = scan_window;
iv123 0:88b85febcb45 1242 cp.scan_type = scan_type;
iv123 0:88b85febcb45 1243 cp.own_address_type = own_address_type;
iv123 0:88b85febcb45 1244 cp.filter_duplicates = filter_duplicates;
iv123 0:88b85febcb45 1245
iv123 0:88b85febcb45 1246 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 1247 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 1248 rq.ocf = OCF_GAP_START_OBSERVATION_PROC;
iv123 0:88b85febcb45 1249 rq.cparam = &cp;
iv123 0:88b85febcb45 1250 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 1251 rq.event = EVT_CMD_STATUS;
iv123 0:88b85febcb45 1252 rq.rparam = &status;
iv123 0:88b85febcb45 1253 rq.rlen = 1;
iv123 0:88b85febcb45 1254
iv123 0:88b85febcb45 1255 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 1256 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 1257
iv123 0:88b85febcb45 1258 return status;
iv123 0:88b85febcb45 1259 }
iv123 0:88b85febcb45 1260
iv123 0:88b85febcb45 1261 tBleStatus aci_gap_is_device_bonded(uint8_t peer_address_type, const tBDAddr peer_address)
iv123 0:88b85febcb45 1262 {
iv123 0:88b85febcb45 1263 struct hci_request rq;
iv123 0:88b85febcb45 1264 gap_is_device_bonded_cp cp;
iv123 0:88b85febcb45 1265 uint8_t status;
iv123 0:88b85febcb45 1266
iv123 0:88b85febcb45 1267 cp.peer_address_type = peer_address_type;
iv123 0:88b85febcb45 1268 Osal_MemCpy(cp.peer_address, peer_address, sizeof(cp.peer_address));
iv123 0:88b85febcb45 1269
iv123 0:88b85febcb45 1270 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 1271 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 1272 rq.ocf = OCF_GAP_IS_DEVICE_BONDED;
iv123 0:88b85febcb45 1273 rq.cparam = &cp;
iv123 0:88b85febcb45 1274 rq.clen = sizeof(cp);
iv123 0:88b85febcb45 1275 rq.rparam = &status;
iv123 0:88b85febcb45 1276 rq.rlen = 1;
iv123 0:88b85febcb45 1277
iv123 0:88b85febcb45 1278 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 1279 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 1280
iv123 0:88b85febcb45 1281 return status;
iv123 0:88b85febcb45 1282 }
iv123 0:88b85febcb45 1283
iv123 0:88b85febcb45 1284 tBleStatus aci_gap_get_bonded_devices(uint8_t *num_devices, uint8_t *device_list, uint8_t device_list_size)
iv123 0:88b85febcb45 1285 {
iv123 0:88b85febcb45 1286 struct hci_request rq;
iv123 0:88b85febcb45 1287 gap_get_bonded_devices_rp rp;
iv123 0:88b85febcb45 1288
iv123 0:88b85febcb45 1289 Osal_MemSet(&rq, 0, sizeof(rq));
iv123 0:88b85febcb45 1290 rq.ogf = OGF_VENDOR_CMD;
iv123 0:88b85febcb45 1291 rq.ocf = OCF_GAP_GET_BONDED_DEVICES;
iv123 0:88b85febcb45 1292 rq.rparam = &rp;
iv123 0:88b85febcb45 1293 rq.rlen = sizeof(rp);
iv123 0:88b85febcb45 1294
iv123 0:88b85febcb45 1295 if (hci_send_req(&rq, FALSE) < 0)
iv123 0:88b85febcb45 1296 return BLE_STATUS_TIMEOUT;
iv123 0:88b85febcb45 1297
iv123 0:88b85febcb45 1298 if (rp.status) {
iv123 0:88b85febcb45 1299 return rp.status;
iv123 0:88b85febcb45 1300 }
iv123 0:88b85febcb45 1301
iv123 0:88b85febcb45 1302 *num_devices = rp.num_addr;
iv123 0:88b85febcb45 1303 if(device_list != NULL)
iv123 0:88b85febcb45 1304 Osal_MemCpy(device_list, rp.dev_list, MIN(device_list_size,rp.num_addr*7));
iv123 0:88b85febcb45 1305
iv123 0:88b85febcb45 1306 return 0;
iv123 0:88b85febcb45 1307 }