1
- /*
1
+ /*
2
2
* Copyright (c) Nordic Semiconductor ASA
3
3
* All rights reserved.
4
- *
4
+ *
5
5
* Redistribution and use in source and binary forms, with or without modification,
6
6
* are permitted provided that the following conditions are met:
7
- *
7
+ *
8
8
* 1. Redistributions of source code must retain the above copyright notice, this
9
9
* list of conditions and the following disclaimer.
10
- *
10
+ *
11
11
* 2. Redistributions in binary form must reproduce the above copyright notice, this
12
12
* list of conditions and the following disclaimer in the documentation and/or
13
13
* other materials provided with the distribution.
14
- *
14
+ *
15
15
* 3. Neither the name of Nordic Semiconductor ASA nor the names of other
16
16
* contributors to this software may be used to endorse or promote products
17
17
* derived from this software without specific prior written permission.
18
- *
18
+ *
19
19
* 4. This software must only be used in a processor manufactured by Nordic
20
20
* Semiconductor ASA, or in a processor manufactured by a third party that
21
21
* is used in combination with a processor manufactured by Nordic Semiconductor.
22
- *
23
- *
22
+ *
23
+ *
24
24
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25
25
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
26
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31
31
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
32
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
33
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
- *
34
+ *
35
35
*/
36
36
37
37
/**
63
63
*/
64
64
enum BLE_COMMON_SVCS
65
65
{
66
+ #ifndef __RFduino__
66
67
SD_BLE_ENABLE = BLE_SVC_BASE , /**< Enable and initialize the BLE stack */
67
68
SD_BLE_EVT_GET , /**< Get an event from the pending events queue. */
69
+ #else
70
+ SD_BLE_EVT_GET = BLE_SVC_BASE , /**< Get an event from the pending events queue. */
71
+ #endif
68
72
SD_BLE_TX_BUFFER_COUNT_GET , /**< Get the total number of available application transmission buffers from the BLE stack. */
69
73
SD_BLE_UUID_VS_ADD , /**< Add a Vendor Specific UUID. */
70
74
SD_BLE_UUID_DECODE , /**< Decode UUID bytes. */
@@ -152,8 +156,10 @@ typedef struct
152
156
union
153
157
{
154
158
ble_evt_tx_complete_t tx_complete ; /**< Transmission Complete. */
159
+ #ifndef __RFduino__
155
160
ble_evt_user_mem_request_t user_mem_request ; /**< User Memory Request Event Parameters. */
156
161
ble_evt_user_mem_release_t user_mem_release ; /**< User Memory Release Event Parameters. */
162
+ #endif
157
163
} params ;
158
164
} ble_common_evt_t ;
159
165
@@ -238,6 +244,7 @@ typedef struct
238
244
/** @addtogroup BLE_COMMON_FUNCTIONS Functions
239
245
* @{ */
240
246
247
+ #ifndef __RFduino__
241
248
/**@brief Enable the BLE stack
242
249
*
243
250
* @param[in] p_ble_enable_params Pointer to ble_enable_params_t
@@ -252,22 +259,23 @@ typedef struct
252
259
* @return @ref NRF_ERROR_NO_MEM The Attribute Table size is too large. Decrease size in @ref ble_gatts_enable_params_t.
253
260
*/
254
261
SVCALL (SD_BLE_ENABLE , uint32_t , sd_ble_enable (ble_enable_params_t * p_ble_enable_params ));
262
+ #endif
255
263
256
264
/**@brief Get an event from the pending events queue.
257
265
*
258
266
* @param[out] p_dest Pointer to buffer to be filled in with an event, or NULL to retrieve the event length. This buffer <b>must be 4-byte aligned in memory</b>.
259
267
* @param[in, out] p_len Pointer the length of the buffer, on return it is filled with the event length.
260
268
*
261
- * @details This call allows the application to pull a BLE event from the BLE stack. The application is signalled that an event is
269
+ * @details This call allows the application to pull a BLE event from the BLE stack. The application is signalled that an event is
262
270
* available from the BLE stack by the triggering of the SD_EVT_IRQn interrupt.
263
271
* The application is free to choose whether to call this function from thread mode (main context) or directly from the Interrupt Service Routine
264
272
* that maps to SD_EVT_IRQn. In any case however, and because the BLE stack runs at a higher priority than the application, this function should be called
265
- * in a loop (until @ref NRF_ERROR_NOT_FOUND is returned) every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the BLE stack.
273
+ * in a loop (until @ref NRF_ERROR_NOT_FOUND is returned) every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the BLE stack.
266
274
* Failure to do so could potentially leave events in the internal queue without the application being aware of this fact.
267
275
* Sizing the p_dest buffer is equally important, since the application needs to provide all the memory necessary for the event to be copied into
268
276
* application memory. If the buffer provided is not large enough to fit the entire contents of the event, @ref NRF_ERROR_DATA_SIZE will be returned
269
277
* and the application can then call again with a larger buffer size.
270
- * Please note that because of the variable length nature of some events, sizeof(ble_evt_t) will not always be large enough to fit certain events,
278
+ * Please note that because of the variable length nature of some events, sizeof(ble_evt_t) will not always be large enough to fit certain events,
271
279
* and so it is the application's responsibility to provide an amount of memory large enough so that the relevant event is copied in full.
272
280
* The application may "peek" the event length by providing p_dest as a NULL pointer and inspecting the value of *p_len upon return.
273
281
*
@@ -289,7 +297,7 @@ SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len
289
297
* The application has two options to handle its own application transmission buffers:
290
298
* - Use a simple arithmetic calculation: at boot time the application should use this function
291
299
* to find out the total amount of buffers available to it and store it in a variable.
292
- * Every time a packet that consumes an application buffer is sent using any of the
300
+ * Every time a packet that consumes an application buffer is sent using any of the
293
301
* exposed functions in this BLE API, the application should decrement that variable.
294
302
* Conversely, whenever a @ref BLE_EVT_TX_COMPLETE event is received by the application
295
303
* it should retrieve the count field in such event and add that number to the same
@@ -298,11 +306,11 @@ SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len
298
306
* application packets available in the BLE stack's internal buffers, and therefore
299
307
* it can know with certainty whether it is possible to send more data or it has to
300
308
* wait for a @ref BLE_EVT_TX_COMPLETE event before it proceeds.
301
- * - Choose to simply not keep track of available buffers at all, and instead handle the
302
- * @ref BLE_ERROR_NO_TX_BUFFERS error by queueing the packet to be transmitted and
309
+ * - Choose to simply not keep track of available buffers at all, and instead handle the
310
+ * @ref BLE_ERROR_NO_TX_BUFFERS error by queueing the packet to be transmitted and
303
311
* try again as soon as a @ref BLE_EVT_TX_COMPLETE event arrives.
304
312
*
305
- * The API functions that <b>may</b> consume an application buffer depending on
313
+ * The API functions that <b>may</b> consume an application buffer depending on
306
314
* the parameters supplied to them can be found below:
307
315
*
308
316
* - @ref sd_ble_gattc_write (write without response only)
@@ -323,15 +331,15 @@ SVCALL(SD_BLE_TX_BUFFER_COUNT_GET, uint32_t, sd_ble_tx_buffer_count_get(uint8_t
323
331
* @details This call enables the application to add a vendor specific UUID to the BLE stack's table,
324
332
* for later use all other modules and APIs. This then allows the application to use the shorter,
325
333
* 24-bit @ref ble_uuid_t format when dealing with both 16-bit and 128-bit UUIDs without having to
326
- * check for lengths and having split code paths. The way that this is accomplished is by extending the
327
- * grouping mechanism that the Bluetooth SIG standard base UUID uses for all other 128-bit UUIDs. The
328
- * type field in the @ref ble_uuid_t structure is an index (relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN)
329
- * to the table populated by multiple calls to this function, and the uuid field in the same structure
330
- * contains the 2 bytes at indices 12 and 13. The number of possible 128-bit UUIDs available to the
331
- * application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536,
334
+ * check for lengths and having split code paths. The way that this is accomplished is by extending the
335
+ * grouping mechanism that the Bluetooth SIG standard base UUID uses for all other 128-bit UUIDs. The
336
+ * type field in the @ref ble_uuid_t structure is an index (relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN)
337
+ * to the table populated by multiple calls to this function, and the uuid field in the same structure
338
+ * contains the 2 bytes at indices 12 and 13. The number of possible 128-bit UUIDs available to the
339
+ * application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536,
332
340
* although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array.
333
341
*
334
- * @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by
342
+ * @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by
335
343
* the 16-bit uuid field in @ref ble_uuid_t.
336
344
*
337
345
*
@@ -348,11 +356,11 @@ SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_v
348
356
349
357
350
358
/** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure.
351
- *
352
- * @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared
353
- * to the corresponding ones in each entry of the table of vendor specific UUIDs populated with @ref sd_ble_uuid_vs_add
354
- * to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index
355
- * relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type.
359
+ *
360
+ * @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared
361
+ * to the corresponding ones in each entry of the table of vendor specific UUIDs populated with @ref sd_ble_uuid_vs_add
362
+ * to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index
363
+ * relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type.
356
364
*
357
365
* @note If the UUID length supplied is 2, then the type set by this call will always be @ref BLE_UUID_TYPE_BLE.
358
366
*
@@ -364,7 +372,7 @@ SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_v
364
372
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
365
373
* @retval ::NRF_ERROR_INVALID_LENGTH Invalid UUID length.
366
374
* @retval ::NRF_ERROR_NOT_FOUND For a 128-bit UUID, no match in the populated table of UUIDs.
367
- */
375
+ */
368
376
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 ));
369
377
370
378
0 commit comments