Nordic stack and drivers for the mbed BLE API

Dependents:   BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate writable_gatt ... more

Committer:
Vincent Coubard
Date:
Wed Sep 14 14:39:43 2016 +0100
Revision:
638:c90ae1400bf2
Sync with bdab10dc0f90748b6989c8b577771bb403ca6bd8 from ARMmbed/mbed-os.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Vincent Coubard 638:c90ae1400bf2 1 /*
Vincent Coubard 638:c90ae1400bf2 2 * Copyright (c) Nordic Semiconductor ASA
Vincent Coubard 638:c90ae1400bf2 3 * All rights reserved.
Vincent Coubard 638:c90ae1400bf2 4 *
Vincent Coubard 638:c90ae1400bf2 5 * Redistribution and use in source and binary forms, with or without modification,
Vincent Coubard 638:c90ae1400bf2 6 * are permitted provided that the following conditions are met:
Vincent Coubard 638:c90ae1400bf2 7 *
Vincent Coubard 638:c90ae1400bf2 8 * 1. Redistributions of source code must retain the above copyright notice, this
Vincent Coubard 638:c90ae1400bf2 9 * list of conditions and the following disclaimer.
Vincent Coubard 638:c90ae1400bf2 10 *
Vincent Coubard 638:c90ae1400bf2 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this
Vincent Coubard 638:c90ae1400bf2 12 * list of conditions and the following disclaimer in the documentation and/or
Vincent Coubard 638:c90ae1400bf2 13 * other materials provided with the distribution.
Vincent Coubard 638:c90ae1400bf2 14 *
Vincent Coubard 638:c90ae1400bf2 15 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
Vincent Coubard 638:c90ae1400bf2 16 * contributors to this software may be used to endorse or promote products
Vincent Coubard 638:c90ae1400bf2 17 * derived from this software without specific prior written permission.
Vincent Coubard 638:c90ae1400bf2 18 *
Vincent Coubard 638:c90ae1400bf2 19 *
Vincent Coubard 638:c90ae1400bf2 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Vincent Coubard 638:c90ae1400bf2 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Vincent Coubard 638:c90ae1400bf2 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Vincent Coubard 638:c90ae1400bf2 23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
Vincent Coubard 638:c90ae1400bf2 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Vincent Coubard 638:c90ae1400bf2 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Vincent Coubard 638:c90ae1400bf2 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
Vincent Coubard 638:c90ae1400bf2 27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Vincent Coubard 638:c90ae1400bf2 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Vincent Coubard 638:c90ae1400bf2 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Vincent Coubard 638:c90ae1400bf2 30 *
Vincent Coubard 638:c90ae1400bf2 31 */
Vincent Coubard 638:c90ae1400bf2 32
Vincent Coubard 638:c90ae1400bf2 33
Vincent Coubard 638:c90ae1400bf2 34 #ifndef PEER_ID_H__
Vincent Coubard 638:c90ae1400bf2 35 #define PEER_ID_H__
Vincent Coubard 638:c90ae1400bf2 36
Vincent Coubard 638:c90ae1400bf2 37
Vincent Coubard 638:c90ae1400bf2 38 #include "stdint.h"
Vincent Coubard 638:c90ae1400bf2 39 #include "sdk_errors.h"
Vincent Coubard 638:c90ae1400bf2 40 #include "ble_gap.h"
Vincent Coubard 638:c90ae1400bf2 41 #include "peer_manager_types.h"
Vincent Coubard 638:c90ae1400bf2 42
Vincent Coubard 638:c90ae1400bf2 43
Vincent Coubard 638:c90ae1400bf2 44 /**
Vincent Coubard 638:c90ae1400bf2 45 * @defgroup peer_id Peer IDs
Vincent Coubard 638:c90ae1400bf2 46 * @ingroup peer_manager
Vincent Coubard 638:c90ae1400bf2 47 * @{
Vincent Coubard 638:c90ae1400bf2 48 * @brief An internal module of @ref peer_manager. This module keeps track of which peer IDs are in
Vincent Coubard 638:c90ae1400bf2 49 * use and which are free.
Vincent Coubard 638:c90ae1400bf2 50 */
Vincent Coubard 638:c90ae1400bf2 51
Vincent Coubard 638:c90ae1400bf2 52
Vincent Coubard 638:c90ae1400bf2 53 /**@brief Function for initializing the module.
Vincent Coubard 638:c90ae1400bf2 54 */
Vincent Coubard 638:c90ae1400bf2 55 void peer_id_init(void);
Vincent Coubard 638:c90ae1400bf2 56
Vincent Coubard 638:c90ae1400bf2 57
Vincent Coubard 638:c90ae1400bf2 58 /**@brief Function for claiming an unused peer ID.
Vincent Coubard 638:c90ae1400bf2 59 *
Vincent Coubard 638:c90ae1400bf2 60 * @param peer_id The peer ID to allocate. If this is @ref PM_PEER_ID_INVALID, the first available
Vincent Coubard 638:c90ae1400bf2 61 * will be allocated.
Vincent Coubard 638:c90ae1400bf2 62 *
Vincent Coubard 638:c90ae1400bf2 63 * @return The allocated peer ID.
Vincent Coubard 638:c90ae1400bf2 64 * @retval PM_PEER_ID_INVALID If no peer ID could be allocated or module is not initialized.
Vincent Coubard 638:c90ae1400bf2 65 */
Vincent Coubard 638:c90ae1400bf2 66 pm_peer_id_t peer_id_allocate(pm_peer_id_t peer_id);
Vincent Coubard 638:c90ae1400bf2 67
Vincent Coubard 638:c90ae1400bf2 68
Vincent Coubard 638:c90ae1400bf2 69 /**@brief Function for freeing a peer ID and clearing all data associated with it in persistent
Vincent Coubard 638:c90ae1400bf2 70 * storage.
Vincent Coubard 638:c90ae1400bf2 71 *
Vincent Coubard 638:c90ae1400bf2 72 * @param[in] peer_id Peer ID to free.
Vincent Coubard 638:c90ae1400bf2 73 */
Vincent Coubard 638:c90ae1400bf2 74 void peer_id_free(pm_peer_id_t peer_id);
Vincent Coubard 638:c90ae1400bf2 75
Vincent Coubard 638:c90ae1400bf2 76
Vincent Coubard 638:c90ae1400bf2 77 /**@brief Function for finding out whether a peer ID is in use.
Vincent Coubard 638:c90ae1400bf2 78 *
Vincent Coubard 638:c90ae1400bf2 79 * @param[in] peer_id The peer ID to inquire about.
Vincent Coubard 638:c90ae1400bf2 80 *
Vincent Coubard 638:c90ae1400bf2 81 * @retval true peer_id is in use.
Vincent Coubard 638:c90ae1400bf2 82 * @retval false peer_id is free, or the module is not initialized.
Vincent Coubard 638:c90ae1400bf2 83 */
Vincent Coubard 638:c90ae1400bf2 84 bool peer_id_is_allocated(pm_peer_id_t peer_id);
Vincent Coubard 638:c90ae1400bf2 85
Vincent Coubard 638:c90ae1400bf2 86
Vincent Coubard 638:c90ae1400bf2 87 /**@brief Function for getting the next peer ID in the sequence of all used peer IDs. Can be
Vincent Coubard 638:c90ae1400bf2 88 * used to loop through all used peer IDs.
Vincent Coubard 638:c90ae1400bf2 89 *
Vincent Coubard 638:c90ae1400bf2 90 * @note @ref PM_PEER_ID_INVALID is considered to be before the first and after the last ordinary
Vincent Coubard 638:c90ae1400bf2 91 * peer ID.
Vincent Coubard 638:c90ae1400bf2 92 *
Vincent Coubard 638:c90ae1400bf2 93 * @param[in] prev_peer_id The previous peer ID.
Vincent Coubard 638:c90ae1400bf2 94 *
Vincent Coubard 638:c90ae1400bf2 95 * @return The next peer ID.
Vincent Coubard 638:c90ae1400bf2 96 * @return The first used peer ID if prev_peer_id was @ref PM_PEER_ID_INVALID.
Vincent Coubard 638:c90ae1400bf2 97 * @retval PM_PEER_ID_INVALID if prev_peer_id was the last ordinary peer ID or the module is
Vincent Coubard 638:c90ae1400bf2 98 * not initialized.
Vincent Coubard 638:c90ae1400bf2 99 */
Vincent Coubard 638:c90ae1400bf2 100 pm_peer_id_t peer_id_next_id_get(pm_peer_id_t prev_peer_id);
Vincent Coubard 638:c90ae1400bf2 101
Vincent Coubard 638:c90ae1400bf2 102
Vincent Coubard 638:c90ae1400bf2 103 /**@brief Function for querying the number of valid peer IDs available. I.E the number of peers
Vincent Coubard 638:c90ae1400bf2 104 * in persistent storage.
Vincent Coubard 638:c90ae1400bf2 105 *
Vincent Coubard 638:c90ae1400bf2 106 * @return The number of valid peer IDs, or 0 if module is not initialized.
Vincent Coubard 638:c90ae1400bf2 107 */
Vincent Coubard 638:c90ae1400bf2 108 uint32_t peer_id_n_ids(void);
Vincent Coubard 638:c90ae1400bf2 109
Vincent Coubard 638:c90ae1400bf2 110 /** @} */
Vincent Coubard 638:c90ae1400bf2 111
Vincent Coubard 638:c90ae1400bf2 112 #endif /* PEER_ID_H__ */