dragoon  4383
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ble.h
1 /*
2  * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form, except as embedded into a Nordic
12  * Semiconductor ASA integrated circuit in a product or a software update for
13  * such product, must reproduce the above copyright notice, this list of
14  * conditions and the following disclaimer in the documentation and/or other
15  * materials provided with the distribution.
16  *
17  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * 4. This software, with or without modification, must only be used with a
22  * Nordic Semiconductor ASA integrated circuit.
23  *
24  * 5. Any software provided in binary form under this license must not be reverse
25  * engineered, decompiled, modified and/or disassembled.
26  *
27  * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
28  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29  * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
30  * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
33  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
36  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38 
49 #ifndef BLE_H__
50 #define BLE_H__
51 
52 #include "ble_ranges.h"
53 #include "ble_types.h"
54 #include "ble_gap.h"
55 #include "ble_l2cap.h"
56 #include "ble_gatt.h"
57 #include "ble_gattc.h"
58 #include "ble_gatts.h"
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
71 {
82 };
83 
88 {
91 };
92 
98 {
104 };
105 
111 {
113 };
114 
119 {
122 };
123 
131 #define BLE_EVT_PTR_ALIGNMENT 4
132 
135 #define BLE_MAX(a, b) ((a) < (b) ? (b) : (a))
136 
141 #define BLE_EVT_LEN_MAX(ATT_MTU) (BLE_MAX( \
142  sizeof(ble_evt_t), \
143  BLE_MAX( \
144  offsetof(ble_evt_t, evt.gattc_evt.params.rel_disc_rsp.includes) + ((ATT_MTU) - 2) / 6 * sizeof(ble_gattc_include_t), \
145  offsetof(ble_evt_t, evt.gattc_evt.params.attr_info_disc_rsp.info.attr_info16) + ((ATT_MTU) - 2) / 4 * sizeof(ble_gattc_attr_info16_t) \
146  ) \
147 ))
148 
151 #define BLE_USER_MEM_TYPE_INVALID 0x00
152 #define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01
158 #define BLE_UUID_VS_COUNT_DEFAULT 10
159 #define BLE_UUID_VS_COUNT_MAX 254
165 #define BLE_CONN_CFG_TAG_DEFAULT 0
175 typedef struct
176 {
177  uint8_t *p_mem;
178  uint16_t len;
180 
182 typedef struct
183 {
184  uint8_t type;
186 
188 typedef struct
189 {
190  uint8_t type;
193 
195 typedef struct
196 {
197  uint16_t conn_handle;
198  union
199  {
202  } params;
204 
206 typedef struct
207 {
208  uint16_t evt_id;
209  uint16_t evt_len;
210 } ble_evt_hdr_t;
211 
213 typedef struct
214 {
216  union
217  {
223  } evt;
224 } ble_evt_t;
225 
226 
230 typedef struct
231 {
232  uint8_t version_number;
233  uint16_t company_id;
234  uint16_t subversion_number;
235 } ble_version_t;
236 
240 typedef struct
241 {
242  uint8_t enable :1;
243  uint8_t active_high :1;
244  uint8_t gpio_pin :6;
246 
260 typedef struct
261 {
265  uint8_t ppi_ch_id_set;
266  uint8_t ppi_ch_id_clr;
267  uint8_t gpiote_ch_id;
269 
281 typedef struct
282 {
283  uint8_t enable : 1;
285 
287 typedef union
288 {
292 
294 typedef union
295 {
298 } ble_opt_t;
299 
314 typedef struct
315 {
316  uint8_t conn_cfg_tag;
319  union {
325  } params;
327 
333 typedef struct
334 {
335  uint8_t vs_uuid_count;
339 
341 typedef union
342 {
345 
347 typedef union
348 {
353 } ble_cfg_t;
354 
392 SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(uint32_t * p_app_ram_base));
393 
428 SVCALL(SD_BLE_CFG_SET, uint32_t, sd_ble_cfg_set(uint32_t cfg_id, ble_cfg_t const * p_cfg, uint32_t app_ram_base));
429 
466 SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len));
467 
468 
495 SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type));
496 
497 
516 SVCALL(SD_BLE_UUID_DECODE, uint32_t, sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const *p_uuid_le, ble_uuid_t *p_uuid));
517 
518 
531 SVCALL(SD_BLE_UUID_ENCODE, uint32_t, sd_ble_uuid_encode(ble_uuid_t const *p_uuid, uint8_t *p_uuid_le_len, uint8_t *p_uuid_le));
532 
533 
544 SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t *p_version));
545 
546 
570 SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t const *p_block));
571 
590 SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt));
591 
592 
609 SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt));
610 
612 #ifdef __cplusplus
613 }
614 #endif
615 #endif /* BLE_H__ */
616