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_TY51822R3/TOOLCHAIN_IAR/ble_racp.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_TY51822R3/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_11/ble/ble_racp/ble_racp.h@169:a7c7b631e539
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 143:86740a56073b | 1 | /* |
AnnaBridge | 143:86740a56073b | 2 | * Copyright (c) 2012 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 | /** @file |
AnnaBridge | 143:86740a56073b | 41 | * |
AnnaBridge | 143:86740a56073b | 42 | * @defgroup ble_sdk_lib_racp Record Access Control Point |
AnnaBridge | 143:86740a56073b | 43 | * @{ |
AnnaBridge | 143:86740a56073b | 44 | * @ingroup ble_sdk_lib |
AnnaBridge | 143:86740a56073b | 45 | * @brief Record Access Control Point library. |
AnnaBridge | 143:86740a56073b | 46 | */ |
AnnaBridge | 143:86740a56073b | 47 | |
AnnaBridge | 143:86740a56073b | 48 | #ifndef BLE_RACP_H__ |
AnnaBridge | 143:86740a56073b | 49 | #define BLE_RACP_H__ |
AnnaBridge | 143:86740a56073b | 50 | |
AnnaBridge | 143:86740a56073b | 51 | #include <stdint.h> |
AnnaBridge | 143:86740a56073b | 52 | #include <stdbool.h> |
AnnaBridge | 143:86740a56073b | 53 | #include "nrf_ble.h" |
AnnaBridge | 143:86740a56073b | 54 | #include "nrf_ble_types.h" |
AnnaBridge | 143:86740a56073b | 55 | #include "nrf_ble.h" |
AnnaBridge | 143:86740a56073b | 56 | |
AnnaBridge | 143:86740a56073b | 57 | /**@brief Record Access Control Point opcodes. */ |
AnnaBridge | 143:86740a56073b | 58 | #define RACP_OPCODE_RESERVED 0 /**< Record Access Control Point opcode - Reserved for future use. */ |
AnnaBridge | 143:86740a56073b | 59 | #define RACP_OPCODE_REPORT_RECS 1 /**< Record Access Control Point opcode - Report stored records. */ |
AnnaBridge | 143:86740a56073b | 60 | #define RACP_OPCODE_DELETE_RECS 2 /**< Record Access Control Point opcode - Delete stored records. */ |
AnnaBridge | 143:86740a56073b | 61 | #define RACP_OPCODE_ABORT_OPERATION 3 /**< Record Access Control Point opcode - Abort operation. */ |
AnnaBridge | 143:86740a56073b | 62 | #define RACP_OPCODE_REPORT_NUM_RECS 4 /**< Record Access Control Point opcode - Report number of stored records. */ |
AnnaBridge | 143:86740a56073b | 63 | #define RACP_OPCODE_NUM_RECS_RESPONSE 5 /**< Record Access Control Point opcode - Number of stored records response. */ |
AnnaBridge | 143:86740a56073b | 64 | #define RACP_OPCODE_RESPONSE_CODE 6 /**< Record Access Control Point opcode - Response code. */ |
AnnaBridge | 143:86740a56073b | 65 | |
AnnaBridge | 143:86740a56073b | 66 | /**@brief Record Access Control Point operators. */ |
AnnaBridge | 143:86740a56073b | 67 | #define RACP_OPERATOR_NULL 0 /**< Record Access Control Point operator - Null. */ |
AnnaBridge | 143:86740a56073b | 68 | #define RACP_OPERATOR_ALL 1 /**< Record Access Control Point operator - All records. */ |
AnnaBridge | 143:86740a56073b | 69 | #define RACP_OPERATOR_LESS_OR_EQUAL 2 /**< Record Access Control Point operator - Less than or equal to. */ |
AnnaBridge | 143:86740a56073b | 70 | #define RACP_OPERATOR_GREATER_OR_EQUAL 3 /**< Record Access Control Point operator - Greater than or equal to. */ |
AnnaBridge | 143:86740a56073b | 71 | #define RACP_OPERATOR_RANGE 4 /**< Record Access Control Point operator - Within range of (inclusive). */ |
AnnaBridge | 143:86740a56073b | 72 | #define RACP_OPERATOR_FIRST 5 /**< Record Access Control Point operator - First record (i.e. oldest record). */ |
AnnaBridge | 143:86740a56073b | 73 | #define RACP_OPERATOR_LAST 6 /**< Record Access Control Point operator - Last record (i.e. most recent record). */ |
AnnaBridge | 143:86740a56073b | 74 | #define RACP_OPERATOR_RFU_START 7 /**< Record Access Control Point operator - Start of Reserved for Future Use area. */ |
AnnaBridge | 143:86740a56073b | 75 | |
AnnaBridge | 143:86740a56073b | 76 | /**@brief Record Access Control Point response codes. */ |
AnnaBridge | 143:86740a56073b | 77 | #define RACP_RESPONSE_RESERVED 0 /**< Record Access Control Point response code - Reserved for future use. */ |
AnnaBridge | 143:86740a56073b | 78 | #define RACP_RESPONSE_SUCCESS 1 /**< Record Access Control Point response code - Successful operation. */ |
AnnaBridge | 143:86740a56073b | 79 | #define RACP_RESPONSE_OPCODE_UNSUPPORTED 2 /**< Record Access Control Point response code - Unsupported op code received. */ |
AnnaBridge | 143:86740a56073b | 80 | #define RACP_RESPONSE_INVALID_OPERATOR 3 /**< Record Access Control Point response code - Operator not valid for service. */ |
AnnaBridge | 143:86740a56073b | 81 | #define RACP_RESPONSE_OPERATOR_UNSUPPORTED 4 /**< Record Access Control Point response code - Unsupported operator. */ |
AnnaBridge | 143:86740a56073b | 82 | #define RACP_RESPONSE_INVALID_OPERAND 5 /**< Record Access Control Point response code - Operand not valid for service. */ |
AnnaBridge | 143:86740a56073b | 83 | #define RACP_RESPONSE_NO_RECORDS_FOUND 6 /**< Record Access Control Point response code - No matching records found. */ |
AnnaBridge | 143:86740a56073b | 84 | #define RACP_RESPONSE_ABORT_FAILED 7 /**< Record Access Control Point response code - Abort could not be completed. */ |
AnnaBridge | 143:86740a56073b | 85 | #define RACP_RESPONSE_PROCEDURE_NOT_DONE 8 /**< Record Access Control Point response code - Procedure could not be completed. */ |
AnnaBridge | 143:86740a56073b | 86 | #define RACP_RESPONSE_OPERAND_UNSUPPORTED 9 /**< Record Access Control Point response code - Unsupported operand. */ |
AnnaBridge | 143:86740a56073b | 87 | |
AnnaBridge | 143:86740a56073b | 88 | /**@brief Record Access Control Point value structure. */ |
AnnaBridge | 143:86740a56073b | 89 | typedef struct |
AnnaBridge | 143:86740a56073b | 90 | { |
AnnaBridge | 143:86740a56073b | 91 | uint8_t opcode; /**< Op Code. */ |
AnnaBridge | 143:86740a56073b | 92 | uint8_t operator; /**< Operator. */ |
AnnaBridge | 143:86740a56073b | 93 | uint8_t operand_len; /**< Length of the operand. */ |
AnnaBridge | 143:86740a56073b | 94 | uint8_t * p_operand; /**< Pointer to the operand. */ |
AnnaBridge | 143:86740a56073b | 95 | } ble_racp_value_t; |
AnnaBridge | 143:86740a56073b | 96 | |
AnnaBridge | 143:86740a56073b | 97 | /**@brief Function for decoding a Record Access Control Point write. |
AnnaBridge | 143:86740a56073b | 98 | * |
AnnaBridge | 143:86740a56073b | 99 | * @details This call decodes a write to the Record Access Control Point. |
AnnaBridge | 143:86740a56073b | 100 | * |
AnnaBridge | 143:86740a56073b | 101 | * @param[in] data_len Length of data in received write. |
AnnaBridge | 143:86740a56073b | 102 | * @param[in] p_data Pointer to received data. |
AnnaBridge | 143:86740a56073b | 103 | * @param[out] p_racp_val Pointer to decoded Record Access Control Point write. |
AnnaBridge | 143:86740a56073b | 104 | * @note This does not do a data copy. It assumes the data pointed to by |
AnnaBridge | 143:86740a56073b | 105 | * p_data is persistant until no longer needed. |
AnnaBridge | 143:86740a56073b | 106 | */ |
AnnaBridge | 143:86740a56073b | 107 | void ble_racp_decode(uint8_t data_len, uint8_t * p_data, ble_racp_value_t * p_racp_val); |
AnnaBridge | 143:86740a56073b | 108 | |
AnnaBridge | 143:86740a56073b | 109 | /**@brief Function for encoding a Record Access Control Point response. |
AnnaBridge | 143:86740a56073b | 110 | * |
AnnaBridge | 143:86740a56073b | 111 | * @details This call encodes a response from the Record Access Control Point response. |
AnnaBridge | 143:86740a56073b | 112 | * |
AnnaBridge | 143:86740a56073b | 113 | * @param[in] p_racp_val Pointer to Record Access Control Point to encode. |
AnnaBridge | 143:86740a56073b | 114 | * @param[out] p_data Pointer to where encoded data is written. |
AnnaBridge | 143:86740a56073b | 115 | * NOTE! It is calling routines respsonsibility to make sure. |
AnnaBridge | 143:86740a56073b | 116 | * |
AnnaBridge | 143:86740a56073b | 117 | * @return Length of encoded data. |
AnnaBridge | 143:86740a56073b | 118 | */ |
AnnaBridge | 143:86740a56073b | 119 | uint8_t ble_racp_encode(const ble_racp_value_t * p_racp_val, uint8_t * p_data); |
AnnaBridge | 143:86740a56073b | 120 | |
AnnaBridge | 143:86740a56073b | 121 | #endif // BLE_RACP_H__ |
AnnaBridge | 143:86740a56073b | 122 | |
AnnaBridge | 143:86740a56073b | 123 | /** @} */ |