The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_SDT51822B/TOOLCHAIN_IAR/peer_id.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 20:53:29 2019 +0000
- Revision:
- 172:65be27845400
- Parent:
- 171:3a7713b1edbc
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 148:fd96258d940d | 1 | /* |
Kojto | 148:fd96258d940d | 2 | * Copyright (c) 2015 Nordic Semiconductor ASA |
Kojto | 148:fd96258d940d | 3 | * All rights reserved. |
Kojto | 148:fd96258d940d | 4 | * |
Kojto | 148:fd96258d940d | 5 | * Redistribution and use in source and binary forms, with or without modification, |
Kojto | 148:fd96258d940d | 6 | * are permitted provided that the following conditions are met: |
Kojto | 148:fd96258d940d | 7 | * |
Kojto | 148:fd96258d940d | 8 | * 1. Redistributions of source code must retain the above copyright notice, this list |
Kojto | 148:fd96258d940d | 9 | * of conditions and the following disclaimer. |
Kojto | 148:fd96258d940d | 10 | * |
Kojto | 148:fd96258d940d | 11 | * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA |
Kojto | 148:fd96258d940d | 12 | * integrated circuit in a product or a software update for such product, must reproduce |
Kojto | 148:fd96258d940d | 13 | * the above copyright notice, this list of conditions and the following disclaimer in |
Kojto | 148:fd96258d940d | 14 | * the documentation and/or other materials provided with the distribution. |
Kojto | 148:fd96258d940d | 15 | * |
Kojto | 148:fd96258d940d | 16 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be |
Kojto | 148:fd96258d940d | 17 | * used to endorse or promote products derived from this software without specific prior |
Kojto | 148:fd96258d940d | 18 | * written permission. |
Kojto | 148:fd96258d940d | 19 | * |
Kojto | 148:fd96258d940d | 20 | * 4. This software, with or without modification, must only be used with a |
Kojto | 148:fd96258d940d | 21 | * Nordic Semiconductor ASA integrated circuit. |
Kojto | 148:fd96258d940d | 22 | * |
Kojto | 148:fd96258d940d | 23 | * 5. Any software provided in binary or object form under this license must not be reverse |
Kojto | 148:fd96258d940d | 24 | * engineered, decompiled, modified and/or disassembled. |
Kojto | 148:fd96258d940d | 25 | * |
Kojto | 148:fd96258d940d | 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
Kojto | 148:fd96258d940d | 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Kojto | 148:fd96258d940d | 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Kojto | 148:fd96258d940d | 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
Kojto | 148:fd96258d940d | 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
Kojto | 148:fd96258d940d | 31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Kojto | 148:fd96258d940d | 32 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
Kojto | 148:fd96258d940d | 33 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Kojto | 148:fd96258d940d | 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Kojto | 148:fd96258d940d | 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Kojto | 148:fd96258d940d | 36 | * |
Kojto | 148:fd96258d940d | 37 | */ |
Kojto | 148:fd96258d940d | 38 | |
Kojto | 148:fd96258d940d | 39 | |
Kojto | 148:fd96258d940d | 40 | |
Kojto | 148:fd96258d940d | 41 | #ifndef PEER_ID_H__ |
Kojto | 148:fd96258d940d | 42 | #define PEER_ID_H__ |
Kojto | 148:fd96258d940d | 43 | |
Kojto | 148:fd96258d940d | 44 | |
Kojto | 148:fd96258d940d | 45 | #include <stdint.h> |
Kojto | 148:fd96258d940d | 46 | #include "sdk_errors.h" |
Kojto | 148:fd96258d940d | 47 | #include "nrf_ble_gap.h" |
Kojto | 148:fd96258d940d | 48 | #include "peer_manager_types.h" |
Kojto | 148:fd96258d940d | 49 | |
Kojto | 148:fd96258d940d | 50 | |
Kojto | 148:fd96258d940d | 51 | /** |
Kojto | 148:fd96258d940d | 52 | * @cond NO_DOXYGEN |
Kojto | 148:fd96258d940d | 53 | * @defgroup peer_id Peer IDs |
Kojto | 148:fd96258d940d | 54 | * @ingroup peer_manager |
Kojto | 148:fd96258d940d | 55 | * @{ |
Kojto | 148:fd96258d940d | 56 | * @brief An internal module of @ref peer_manager. This module keeps track of which peer IDs are in |
Kojto | 148:fd96258d940d | 57 | * use and which are free. |
Kojto | 148:fd96258d940d | 58 | */ |
Kojto | 148:fd96258d940d | 59 | |
Kojto | 148:fd96258d940d | 60 | |
Kojto | 148:fd96258d940d | 61 | /**@brief Function for initializing the module. |
Kojto | 148:fd96258d940d | 62 | */ |
Kojto | 148:fd96258d940d | 63 | void peer_id_init(void); |
Kojto | 148:fd96258d940d | 64 | |
Kojto | 148:fd96258d940d | 65 | |
Kojto | 148:fd96258d940d | 66 | /**@brief Function for claiming an unused peer ID. |
Kojto | 148:fd96258d940d | 67 | * |
Kojto | 148:fd96258d940d | 68 | * @param peer_id The peer ID to allocate. If this is @ref PM_PEER_ID_INVALID, the first available |
Kojto | 148:fd96258d940d | 69 | * will be allocated. |
Kojto | 148:fd96258d940d | 70 | * |
Kojto | 148:fd96258d940d | 71 | * @return The allocated peer ID. |
Kojto | 148:fd96258d940d | 72 | * @retval PM_PEER_ID_INVALID If no peer ID could be allocated or module is not initialized. |
Kojto | 148:fd96258d940d | 73 | */ |
Kojto | 148:fd96258d940d | 74 | pm_peer_id_t peer_id_allocate(pm_peer_id_t peer_id); |
Kojto | 148:fd96258d940d | 75 | |
Kojto | 148:fd96258d940d | 76 | |
Kojto | 148:fd96258d940d | 77 | /**@brief Function for marking a peer ID for deletion. |
Kojto | 148:fd96258d940d | 78 | * |
Kojto | 148:fd96258d940d | 79 | * @param peer_id The peer ID to delete. |
Kojto | 148:fd96258d940d | 80 | * |
Kojto | 148:fd96258d940d | 81 | * @retval true Deletion was successful. |
Kojto | 148:fd96258d940d | 82 | * @retval false Peer ID already marked for deletion, peer_id was PM_PEER_ID_INVALID, or module is |
Kojto | 148:fd96258d940d | 83 | * not initialized. |
Kojto | 148:fd96258d940d | 84 | */ |
Kojto | 148:fd96258d940d | 85 | bool peer_id_delete(pm_peer_id_t peer_id); |
Kojto | 148:fd96258d940d | 86 | |
Kojto | 148:fd96258d940d | 87 | |
Kojto | 148:fd96258d940d | 88 | /**@brief Function for freeing a peer ID and clearing all data associated with it in persistent |
Kojto | 148:fd96258d940d | 89 | * storage. |
Kojto | 148:fd96258d940d | 90 | * |
Kojto | 148:fd96258d940d | 91 | * @param[in] peer_id Peer ID to free. |
Kojto | 148:fd96258d940d | 92 | */ |
Kojto | 148:fd96258d940d | 93 | void peer_id_free(pm_peer_id_t peer_id); |
Kojto | 148:fd96258d940d | 94 | |
Kojto | 148:fd96258d940d | 95 | |
Kojto | 148:fd96258d940d | 96 | /**@brief Function for finding out whether a peer ID is marked for deletion. |
Kojto | 148:fd96258d940d | 97 | * |
Kojto | 148:fd96258d940d | 98 | * @param[in] peer_id The peer ID to inquire about. |
Kojto | 148:fd96258d940d | 99 | * |
Kojto | 148:fd96258d940d | 100 | * @retval true peer_id is in marked for deletion. |
Kojto | 148:fd96258d940d | 101 | * @retval false peer_id is not marked for deletion, or the module is not initialized. |
Kojto | 148:fd96258d940d | 102 | */ |
Kojto | 148:fd96258d940d | 103 | bool peer_id_is_deleted(pm_peer_id_t peer_id); |
Kojto | 148:fd96258d940d | 104 | |
Kojto | 148:fd96258d940d | 105 | |
Kojto | 148:fd96258d940d | 106 | /**@brief Function for finding out whether a peer ID is in use. |
Kojto | 148:fd96258d940d | 107 | * |
Kojto | 148:fd96258d940d | 108 | * @param[in] peer_id The peer ID to inquire about. |
Kojto | 148:fd96258d940d | 109 | * |
Kojto | 148:fd96258d940d | 110 | * @retval true peer_id is in use. |
Kojto | 148:fd96258d940d | 111 | * @retval false peer_id is free, or the module is not initialized. |
Kojto | 148:fd96258d940d | 112 | */ |
Kojto | 148:fd96258d940d | 113 | bool peer_id_is_allocated(pm_peer_id_t peer_id); |
Kojto | 148:fd96258d940d | 114 | |
Kojto | 148:fd96258d940d | 115 | |
Kojto | 148:fd96258d940d | 116 | /**@brief Function for getting the next peer ID in the sequence of all used peer IDs. Can be |
Kojto | 148:fd96258d940d | 117 | * used to loop through all used peer IDs. |
Kojto | 148:fd96258d940d | 118 | * |
Kojto | 148:fd96258d940d | 119 | * @note @ref PM_PEER_ID_INVALID is considered to be before the first and after the last ordinary |
Kojto | 148:fd96258d940d | 120 | * peer ID. |
Kojto | 148:fd96258d940d | 121 | * |
Kojto | 148:fd96258d940d | 122 | * @param[in] prev_peer_id The previous peer ID. |
Kojto | 148:fd96258d940d | 123 | * |
Kojto | 148:fd96258d940d | 124 | * @return The next peer ID. |
Kojto | 148:fd96258d940d | 125 | * @return The first used peer ID if prev_peer_id was @ref PM_PEER_ID_INVALID. |
Kojto | 148:fd96258d940d | 126 | * @retval PM_PEER_ID_INVALID if prev_peer_id was the last ordinary peer ID or the module is |
Kojto | 148:fd96258d940d | 127 | * not initialized. |
Kojto | 148:fd96258d940d | 128 | */ |
Kojto | 148:fd96258d940d | 129 | pm_peer_id_t peer_id_get_next_used(pm_peer_id_t prev_peer_id); |
Kojto | 148:fd96258d940d | 130 | |
Kojto | 148:fd96258d940d | 131 | |
Kojto | 148:fd96258d940d | 132 | /**@brief Function for getting the next peer ID in the sequence of all peer IDs marked for deletion. |
Kojto | 148:fd96258d940d | 133 | * Can be used to loop through all peer IDs marked for deletion. |
Kojto | 148:fd96258d940d | 134 | * |
Kojto | 148:fd96258d940d | 135 | * @note @ref PM_PEER_ID_INVALID is considered to be before the first and after the last ordinary |
Kojto | 148:fd96258d940d | 136 | * peer ID. |
Kojto | 148:fd96258d940d | 137 | * |
Kojto | 148:fd96258d940d | 138 | * @param[in] prev_peer_id The previous peer ID. |
Kojto | 148:fd96258d940d | 139 | * |
Kojto | 148:fd96258d940d | 140 | * @return The next peer ID. |
Kojto | 148:fd96258d940d | 141 | * @return The first used peer ID if prev_peer_id was @ref PM_PEER_ID_INVALID. |
Kojto | 148:fd96258d940d | 142 | * @retval PM_PEER_ID_INVALID if prev_peer_id was the last ordinary peer ID or the module is |
Kojto | 148:fd96258d940d | 143 | * not initialized. |
Kojto | 148:fd96258d940d | 144 | */ |
Kojto | 148:fd96258d940d | 145 | pm_peer_id_t peer_id_get_next_deleted(pm_peer_id_t prev_peer_id); |
Kojto | 148:fd96258d940d | 146 | |
Kojto | 148:fd96258d940d | 147 | |
Kojto | 148:fd96258d940d | 148 | /**@brief Function for querying the number of valid peer IDs available. I.E the number of peers |
Kojto | 148:fd96258d940d | 149 | * in persistent storage. |
Kojto | 148:fd96258d940d | 150 | * |
Kojto | 148:fd96258d940d | 151 | * @return The number of valid peer IDs, or 0 if module is not initialized. |
Kojto | 148:fd96258d940d | 152 | */ |
Kojto | 148:fd96258d940d | 153 | uint32_t peer_id_n_ids(void); |
Kojto | 148:fd96258d940d | 154 | |
Kojto | 148:fd96258d940d | 155 | /** @} |
Kojto | 148:fd96258d940d | 156 | * @endcond |
Kojto | 148:fd96258d940d | 157 | */ |
Kojto | 148:fd96258d940d | 158 | |
Kojto | 148:fd96258d940d | 159 | #endif /* PEER_ID_H__ */ |