Committer:
jinu
Date:
Thu Feb 09 06:08:17 2017 +0000
Revision:
0:6ba9b94b8997
NRF51 serialization libraries for mDot

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jinu 0:6ba9b94b8997 1 /* Copyright (c) Nordic Semiconductor ASA
jinu 0:6ba9b94b8997 2 * All rights reserved.
jinu 0:6ba9b94b8997 3 *
jinu 0:6ba9b94b8997 4 * Redistribution and use in source and binary forms, with or without modification,
jinu 0:6ba9b94b8997 5 * are permitted provided that the following conditions are met:
jinu 0:6ba9b94b8997 6 *
jinu 0:6ba9b94b8997 7 * 1. Redistributions of source code must retain the above copyright notice, this
jinu 0:6ba9b94b8997 8 * list of conditions and the following disclaimer.
jinu 0:6ba9b94b8997 9 *
jinu 0:6ba9b94b8997 10 * 2. Redistributions in binary form must reproduce the above copyright notice, this
jinu 0:6ba9b94b8997 11 * list of conditions and the following disclaimer in the documentation and/or
jinu 0:6ba9b94b8997 12 * other materials provided with the distribution.
jinu 0:6ba9b94b8997 13 *
jinu 0:6ba9b94b8997 14 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
jinu 0:6ba9b94b8997 15 * contributors to this software may be used to endorse or promote products
jinu 0:6ba9b94b8997 16 * derived from this software without specific prior written permission.
jinu 0:6ba9b94b8997 17 *
jinu 0:6ba9b94b8997 18 * 4. This software must only be used in a processor manufactured by Nordic
jinu 0:6ba9b94b8997 19 * Semiconductor ASA, or in a processor manufactured by a third party that
jinu 0:6ba9b94b8997 20 * is used in combination with a processor manufactured by Nordic Semiconductor.
jinu 0:6ba9b94b8997 21 *
jinu 0:6ba9b94b8997 22 *
jinu 0:6ba9b94b8997 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
jinu 0:6ba9b94b8997 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
jinu 0:6ba9b94b8997 25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
jinu 0:6ba9b94b8997 26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
jinu 0:6ba9b94b8997 27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
jinu 0:6ba9b94b8997 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
jinu 0:6ba9b94b8997 29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
jinu 0:6ba9b94b8997 30 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
jinu 0:6ba9b94b8997 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
jinu 0:6ba9b94b8997 32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
jinu 0:6ba9b94b8997 33 */
jinu 0:6ba9b94b8997 34
jinu 0:6ba9b94b8997 35 /**@file
jinu 0:6ba9b94b8997 36 *
jinu 0:6ba9b94b8997 37 * @defgroup XXX
jinu 0:6ba9b94b8997 38 * @{
jinu 0:6ba9b94b8997 39 * @ingroup XXX
jinu 0:6ba9b94b8997 40 *
jinu 0:6ba9b94b8997 41 * @brief XXX
jinu 0:6ba9b94b8997 42 */
jinu 0:6ba9b94b8997 43
jinu 0:6ba9b94b8997 44 #ifndef BLE_ENCODE_ACCESS_H__
jinu 0:6ba9b94b8997 45 #define BLE_ENCODE_ACCESS_H__
jinu 0:6ba9b94b8997 46
jinu 0:6ba9b94b8997 47 #include <stdint.h>
jinu 0:6ba9b94b8997 48 #include "ble.h"
jinu 0:6ba9b94b8997 49
jinu 0:6ba9b94b8997 50 /**@brief Command result callback function type.
jinu 0:6ba9b94b8997 51 *
jinu 0:6ba9b94b8997 52 * @param[in] result_code Command result code.
jinu 0:6ba9b94b8997 53 */
jinu 0:6ba9b94b8997 54 typedef void (*ble_encode_cmd_resp_handler_t)(uint32_t result_code);
jinu 0:6ba9b94b8997 55
jinu 0:6ba9b94b8997 56 /**@brief Generic event callback function events. */
jinu 0:6ba9b94b8997 57 typedef enum
jinu 0:6ba9b94b8997 58 {
jinu 0:6ba9b94b8997 59 BLE_ENCODE_EVT_RDY /**< An event indicating that SoftDevice event is available for read. */
jinu 0:6ba9b94b8997 60 } ble_encode_evt_type_t;
jinu 0:6ba9b94b8997 61
jinu 0:6ba9b94b8997 62 /**@brief Event callback function type.
jinu 0:6ba9b94b8997 63 *
jinu 0:6ba9b94b8997 64 * @param[in] event The event occurred.
jinu 0:6ba9b94b8997 65 */
jinu 0:6ba9b94b8997 66 typedef void (*ble_encode_event_handler_t)(ble_encode_evt_type_t event);
jinu 0:6ba9b94b8997 67
jinu 0:6ba9b94b8997 68 /**@brief Function for opening the module.
jinu 0:6ba9b94b8997 69 *
jinu 0:6ba9b94b8997 70 * @warning Must not be called for a module which has been allready opened.
jinu 0:6ba9b94b8997 71 *
jinu 0:6ba9b94b8997 72 * @retval NRF_SUCCESS Operation success.
jinu 0:6ba9b94b8997 73 * @retval NRF_ERROR_INTERNAL Operation failure. Internal error ocurred.
jinu 0:6ba9b94b8997 74 */
jinu 0:6ba9b94b8997 75 uint32_t ble_encode_open(void);
jinu 0:6ba9b94b8997 76
jinu 0:6ba9b94b8997 77 /**@brief Function for closing the module and resetting its internal state.
jinu 0:6ba9b94b8997 78 *
jinu 0:6ba9b94b8997 79 * @note Can be called multiple times and also for not opened module.
jinu 0:6ba9b94b8997 80 *
jinu 0:6ba9b94b8997 81 * @retval NRF_SUCCESS Operation success.
jinu 0:6ba9b94b8997 82 */
jinu 0:6ba9b94b8997 83 uint32_t ble_encode_close(void);
jinu 0:6ba9b94b8997 84
jinu 0:6ba9b94b8997 85 /**@brief Function for registering a BLE command response callback handler.
jinu 0:6ba9b94b8997 86 *
jinu 0:6ba9b94b8997 87 * @param[in] command_resp_handler BLE command response handler.
jinu 0:6ba9b94b8997 88 *
jinu 0:6ba9b94b8997 89 * @retval NRF_SUCCESS Operation success.
jinu 0:6ba9b94b8997 90 * @retval NRF_ERROR_BUSY Operation failure. Command allready in progress.
jinu 0:6ba9b94b8997 91 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied.
jinu 0:6ba9b94b8997 92 */
jinu 0:6ba9b94b8997 93 uint32_t ble_encode_cmd_resp_handler_reg(ble_encode_cmd_resp_handler_t command_resp_handler);
jinu 0:6ba9b94b8997 94
jinu 0:6ba9b94b8997 95 /**@brief Function for registering a generic event handler.
jinu 0:6ba9b94b8997 96 *
jinu 0:6ba9b94b8997 97 * @note Multiple registration requests will overwrite any possible existing registration.
jinu 0:6ba9b94b8997 98 *
jinu 0:6ba9b94b8997 99 * @param[in] event_handler The function to be called upon an event.
jinu 0:6ba9b94b8997 100 *
jinu 0:6ba9b94b8997 101 * @retval NRF_SUCCESS Operation success.
jinu 0:6ba9b94b8997 102 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied.
jinu 0:6ba9b94b8997 103 */
jinu 0:6ba9b94b8997 104 uint32_t ble_encode_evt_handler_register(ble_encode_event_handler_t event_handler);
jinu 0:6ba9b94b8997 105
jinu 0:6ba9b94b8997 106 /**@brief Function for extracting an received BLE event.
jinu 0:6ba9b94b8997 107 *
jinu 0:6ba9b94b8997 108 * If @ref p_event is NULL, the required length of @ref p_event is returned in @ref p_event_len.
jinu 0:6ba9b94b8997 109 *
jinu 0:6ba9b94b8997 110 * @param[out] p_event Pointer to memory where event specific data is copied. If
jinu 0:6ba9b94b8997 111 * NULL, required length will be returned in @ref p_event_len.
jinu 0:6ba9b94b8997 112 * @param[in,out] p_event_len in: Size (in bytes) of @ref p_event buffer.
jinu 0:6ba9b94b8997 113 * out: Length of decoded contents of @ref p_event.
jinu 0:6ba9b94b8997 114 *
jinu 0:6ba9b94b8997 115 * @retval NRF_SUCCESS Operation success. Event was copied to @ref p_event or in case @ref
jinu 0:6ba9b94b8997 116 * p_event is NULL @ref p_event_len is updated.
jinu 0:6ba9b94b8997 117 * @retval NRF_ERROR_NO_MEM Operation failure. No event available to extract.
jinu 0:6ba9b94b8997 118 * @retval NRF_ERROR_DATA_SIZE Operation failure. Length of @ref p_event is too small to hold
jinu 0:6ba9b94b8997 119 * decoded event.
jinu 0:6ba9b94b8997 120 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied.
jinu 0:6ba9b94b8997 121 */
jinu 0:6ba9b94b8997 122 uint32_t ble_encode_event_pop(ble_evt_t * p_event, uint32_t * p_event_len);
jinu 0:6ba9b94b8997 123
jinu 0:6ba9b94b8997 124 #endif // BLE_ENCODE_ACCESS_H__
jinu 0:6ba9b94b8997 125
jinu 0:6ba9b94b8997 126 /** @} */
jinu 0:6ba9b94b8997 127