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.

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?

UserRevisionLine numberNew contents of line
AnnaBridge 143:86740a56073b 1 /*
AnnaBridge 143:86740a56073b 2 * Copyright (c) 2015 Nordic Semiconductor ASA
AnnaBridge 143:86740a56073b 3 * All rights reserved.
AnnaBridge 143:86740a56073b 4 *
AnnaBridge 143:86740a56073b 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 143:86740a56073b 6 * are permitted provided that the following conditions are met:
AnnaBridge 143:86740a56073b 7 *
AnnaBridge 143:86740a56073b 8 * 1. Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 143:86740a56073b 9 * of conditions and the following disclaimer.
AnnaBridge 143:86740a56073b 10 *
AnnaBridge 143:86740a56073b 11 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
AnnaBridge 143:86740a56073b 12 * integrated circuit in a product or a software update for such product, must reproduce
AnnaBridge 143:86740a56073b 13 * the above copyright notice, this list of conditions and the following disclaimer in
AnnaBridge 143:86740a56073b 14 * the documentation and/or other materials provided with the distribution.
AnnaBridge 143:86740a56073b 15 *
AnnaBridge 143:86740a56073b 16 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
AnnaBridge 143:86740a56073b 17 * used to endorse or promote products derived from this software without specific prior
AnnaBridge 143:86740a56073b 18 * written permission.
AnnaBridge 143:86740a56073b 19 *
AnnaBridge 143:86740a56073b 20 * 4. This software, with or without modification, must only be used with a
AnnaBridge 143:86740a56073b 21 * Nordic Semiconductor ASA integrated circuit.
AnnaBridge 143:86740a56073b 22 *
AnnaBridge 143:86740a56073b 23 * 5. Any software provided in binary or object form under this license must not be reverse
AnnaBridge 143:86740a56073b 24 * engineered, decompiled, modified and/or disassembled.
AnnaBridge 143:86740a56073b 25 *
AnnaBridge 143:86740a56073b 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 143:86740a56073b 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 143:86740a56073b 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 143:86740a56073b 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 143:86740a56073b 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 143:86740a56073b 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 143:86740a56073b 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 143:86740a56073b 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 143:86740a56073b 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 143:86740a56073b 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 143:86740a56073b 36 *
AnnaBridge 143:86740a56073b 37 */
AnnaBridge 143:86740a56073b 38
AnnaBridge 143:86740a56073b 39
AnnaBridge 143:86740a56073b 40
AnnaBridge 143:86740a56073b 41 #ifndef GATTC_CACHE_MANAGER_H__
AnnaBridge 143:86740a56073b 42 #define GATTC_CACHE_MANAGER_H__
AnnaBridge 143:86740a56073b 43
AnnaBridge 143:86740a56073b 44 #include <stdint.h>
AnnaBridge 143:86740a56073b 45 #include "sdk_errors.h"
AnnaBridge 143:86740a56073b 46 #include "nrf_ble.h"
AnnaBridge 143:86740a56073b 47 #include "nrf_ble_gap.h"
AnnaBridge 143:86740a56073b 48 #include "peer_manager_types.h"
AnnaBridge 143:86740a56073b 49
AnnaBridge 143:86740a56073b 50
AnnaBridge 143:86740a56073b 51 /**
AnnaBridge 143:86740a56073b 52 * @cond NO_DOXYGEN
AnnaBridge 143:86740a56073b 53 * @defgroup gattc_cache_manager GATT Client Cache Manager
AnnaBridge 143:86740a56073b 54 * @ingroup peer_manager
AnnaBridge 143:86740a56073b 55 * @{
AnnaBridge 143:86740a56073b 56 * @brief An internal module of @ref peer_manager. A module for managing persistent storing of GATT
AnnaBridge 143:86740a56073b 57 * attributes pertaining to the GATT client role of the local device.
AnnaBridge 143:86740a56073b 58 */
AnnaBridge 143:86740a56073b 59
AnnaBridge 143:86740a56073b 60
AnnaBridge 143:86740a56073b 61 /**@brief Events that can come from the GATT Cache Manager module.
AnnaBridge 143:86740a56073b 62 */
AnnaBridge 143:86740a56073b 63 typedef enum
AnnaBridge 143:86740a56073b 64 {
AnnaBridge 143:86740a56073b 65 GCCM_EVT_REMOTE_DB_UPDATED, /**< Values for the specified data has been updated in persistent storage. */
AnnaBridge 143:86740a56073b 66 GCCM_EVT_REMOTE_DB_STORED, /**< New values for the specified data has been written in persistent storage. */
AnnaBridge 143:86740a56073b 67 } gccm_evt_id_t;
AnnaBridge 143:86740a56073b 68
AnnaBridge 143:86740a56073b 69
AnnaBridge 143:86740a56073b 70 typedef struct
AnnaBridge 143:86740a56073b 71 {
AnnaBridge 143:86740a56073b 72 gccm_evt_id_t evt_id;
AnnaBridge 143:86740a56073b 73 pm_peer_id_t peer_id;
AnnaBridge 143:86740a56073b 74 } gccm_evt_t;
AnnaBridge 143:86740a56073b 75
AnnaBridge 143:86740a56073b 76 /**@brief Event handler for events from the GATT Client Cache Manager module.
AnnaBridge 143:86740a56073b 77 *
AnnaBridge 143:86740a56073b 78 * @param[in] event The event that has happened.
AnnaBridge 143:86740a56073b 79 * @param[in] peer The id of the peer the event pertains to.
AnnaBridge 143:86740a56073b 80 * @param[in] flags The data the event pertains to.
AnnaBridge 143:86740a56073b 81 */
AnnaBridge 143:86740a56073b 82 typedef void (*gccm_evt_handler_t)(gccm_evt_t const * p_event);
AnnaBridge 143:86740a56073b 83
AnnaBridge 143:86740a56073b 84
AnnaBridge 143:86740a56073b 85 /**@brief Function for initializing the GATT Client Cache Manager module.
AnnaBridge 143:86740a56073b 86 *
AnnaBridge 143:86740a56073b 87 * @param[in] evt_handler Callback for events from the GATT Client Cache Manager module.
AnnaBridge 143:86740a56073b 88 *
AnnaBridge 143:86740a56073b 89 * @retval NRF_SUCCESS Initialization was successful.
AnnaBridge 143:86740a56073b 90 * @retval NRF_ERROR_NULL evt_handler was NULL.
AnnaBridge 143:86740a56073b 91 */
AnnaBridge 143:86740a56073b 92 ret_code_t gccm_init(gccm_evt_handler_t evt_handler);
AnnaBridge 143:86740a56073b 93
AnnaBridge 143:86740a56073b 94
AnnaBridge 143:86740a56073b 95 /**@brief Function for storing a discovered remote database persistently.
AnnaBridge 143:86740a56073b 96 *
AnnaBridge 143:86740a56073b 97 * @param[in] peer_id Peer to store the database for.
AnnaBridge 143:86740a56073b 98 * @param[in] p_remote_db Database values to store as an array. Can be NULL if n_services is 0.
AnnaBridge 143:86740a56073b 99 * @param[in] n_services Number of services in p_remote_db array. If 0, values are cleared.
AnnaBridge 143:86740a56073b 100 *
AnnaBridge 143:86740a56073b 101 * @retval NRF_SUCCESS Store procedure successfully started.
AnnaBridge 143:86740a56073b 102 * @retval NRF_ERROR_NOT_FOUND The peer id is invalid or unallocated.
AnnaBridge 143:86740a56073b 103 * @retval NRF_ERROR_INVALID_STATE Module is not initialized.
AnnaBridge 143:86740a56073b 104 */
AnnaBridge 143:86740a56073b 105 ret_code_t gccm_remote_db_store(pm_peer_id_t peer_id,
AnnaBridge 143:86740a56073b 106 ble_gatt_db_srv_t * p_remote_db,
AnnaBridge 143:86740a56073b 107 uint32_t n_services);
AnnaBridge 143:86740a56073b 108
AnnaBridge 143:86740a56073b 109
AnnaBridge 143:86740a56073b 110 /**@brief Function for retrieving a persistently stored remote database.
AnnaBridge 143:86740a56073b 111 *
AnnaBridge 143:86740a56073b 112 * @param[in] peer_id Peer to retrieve data for.
AnnaBridge 143:86740a56073b 113 * @param[out] p_remote_db If p_n_services was large enough: Copied database values.
AnnaBridge 143:86740a56073b 114 * @param[inout] p_n_services In: Size of provided p_remote_db array. Out: Size of data in flash.
AnnaBridge 143:86740a56073b 115 *
AnnaBridge 143:86740a56073b 116 * @note p_n_services is always updated with the size of the data to be retrieved. The data is only
AnnaBridge 143:86740a56073b 117 * copied if p_remote_db is large enough (p_n_services is large enough initially).
AnnaBridge 143:86740a56073b 118 *
AnnaBridge 143:86740a56073b 119 * @retval NRF_SUCCESS Data retrieved successfully.
AnnaBridge 143:86740a56073b 120 * @retval NRF_ERROR_NOT_FOUND The peer ID is invalid or unallocated.
AnnaBridge 143:86740a56073b 121 * @retval NRF_ERROR_INVALID_STATE Module is not initialized.
AnnaBridge 143:86740a56073b 122 */
AnnaBridge 143:86740a56073b 123 ret_code_t gccm_remote_db_retrieve(pm_peer_id_t peer_id,
AnnaBridge 143:86740a56073b 124 ble_gatt_db_srv_t * p_remote_db,
AnnaBridge 143:86740a56073b 125 uint32_t * p_n_services);
AnnaBridge 143:86740a56073b 126
AnnaBridge 143:86740a56073b 127
AnnaBridge 143:86740a56073b 128 /** @}
AnnaBridge 143:86740a56073b 129 * @endcond
AnnaBridge 143:86740a56073b 130 */
AnnaBridge 143:86740a56073b 131
AnnaBridge 143:86740a56073b 132 #endif /* GATTC_CACHE_MANAGER_H__ */