project for nrf51822 qfab

Dependencies:   eddystone_URL mbed

Fork of eddystone_URL by vo dung

Committer:
tridung141196
Date:
Thu Nov 23 15:38:48 2017 +0000
Revision:
5:267bdacf5508
Parent:
0:76dfa9657d9d
ibeacon

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:76dfa9657d9d 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
jksoft 0:76dfa9657d9d 2 *
jksoft 0:76dfa9657d9d 3 * The information contained herein is property of Nordic Semiconductor ASA.
jksoft 0:76dfa9657d9d 4 * Terms and conditions of usage are described in detail in NORDIC
jksoft 0:76dfa9657d9d 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
jksoft 0:76dfa9657d9d 6 *
jksoft 0:76dfa9657d9d 7 * Licensees are granted free, non-transferable use of the information. NO
jksoft 0:76dfa9657d9d 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jksoft 0:76dfa9657d9d 9 * the file.
jksoft 0:76dfa9657d9d 10 */
jksoft 0:76dfa9657d9d 11
jksoft 0:76dfa9657d9d 12 /** @file
jksoft 0:76dfa9657d9d 13 *
jksoft 0:76dfa9657d9d 14 * @defgroup ble_sdk_lib_racp Record Access Control Point
jksoft 0:76dfa9657d9d 15 * @{
jksoft 0:76dfa9657d9d 16 * @ingroup ble_sdk_lib
jksoft 0:76dfa9657d9d 17 * @brief Record Access Control Point library.
jksoft 0:76dfa9657d9d 18 */
jksoft 0:76dfa9657d9d 19
jksoft 0:76dfa9657d9d 20 #ifndef BLE_RACP_H__
jksoft 0:76dfa9657d9d 21 #define BLE_RACP_H__
jksoft 0:76dfa9657d9d 22
jksoft 0:76dfa9657d9d 23 #include <stdint.h>
jksoft 0:76dfa9657d9d 24 #include <stdbool.h>
jksoft 0:76dfa9657d9d 25 #include "ble.h"
jksoft 0:76dfa9657d9d 26 #include "ble_types.h"
jksoft 0:76dfa9657d9d 27 #include "ble.h"
jksoft 0:76dfa9657d9d 28
jksoft 0:76dfa9657d9d 29 /**@brief Record Access Control Point opcodes. */
jksoft 0:76dfa9657d9d 30 #define RACP_OPCODE_RESERVED 0 /**< Record Access Control Point opcode - Reserved for future use. */
jksoft 0:76dfa9657d9d 31 #define RACP_OPCODE_REPORT_RECS 1 /**< Record Access Control Point opcode - Report stored records. */
jksoft 0:76dfa9657d9d 32 #define RACP_OPCODE_DELETE_RECS 2 /**< Record Access Control Point opcode - Delete stored records. */
jksoft 0:76dfa9657d9d 33 #define RACP_OPCODE_ABORT_OPERATION 3 /**< Record Access Control Point opcode - Abort operation. */
jksoft 0:76dfa9657d9d 34 #define RACP_OPCODE_REPORT_NUM_RECS 4 /**< Record Access Control Point opcode - Report number of stored records. */
jksoft 0:76dfa9657d9d 35 #define RACP_OPCODE_NUM_RECS_RESPONSE 5 /**< Record Access Control Point opcode - Number of stored records response. */
jksoft 0:76dfa9657d9d 36 #define RACP_OPCODE_RESPONSE_CODE 6 /**< Record Access Control Point opcode - Response code. */
jksoft 0:76dfa9657d9d 37
jksoft 0:76dfa9657d9d 38 /**@brief Record Access Control Point operators. */
jksoft 0:76dfa9657d9d 39 #define RACP_OPERATOR_NULL 0 /**< Record Access Control Point operator - Null. */
jksoft 0:76dfa9657d9d 40 #define RACP_OPERATOR_ALL 1 /**< Record Access Control Point operator - All records. */
jksoft 0:76dfa9657d9d 41 #define RACP_OPERATOR_LESS_OR_EQUAL 2 /**< Record Access Control Point operator - Less than or equal to. */
jksoft 0:76dfa9657d9d 42 #define RACP_OPERATOR_GREATER_OR_EQUAL 3 /**< Record Access Control Point operator - Greater than or equal to. */
jksoft 0:76dfa9657d9d 43 #define RACP_OPERATOR_RANGE 4 /**< Record Access Control Point operator - Within range of (inclusive). */
jksoft 0:76dfa9657d9d 44 #define RACP_OPERATOR_FIRST 5 /**< Record Access Control Point operator - First record (i.e. oldest record). */
jksoft 0:76dfa9657d9d 45 #define RACP_OPERATOR_LAST 6 /**< Record Access Control Point operator - Last record (i.e. most recent record). */
jksoft 0:76dfa9657d9d 46 #define RACP_OPERATOR_RFU_START 7 /**< Record Access Control Point operator - Start of Reserved for Future Use area. */
jksoft 0:76dfa9657d9d 47
jksoft 0:76dfa9657d9d 48 /**@brief Record Access Control Point response codes. */
jksoft 0:76dfa9657d9d 49 #define RACP_RESPONSE_RESERVED 0 /**< Record Access Control Point response code - Reserved for future use. */
jksoft 0:76dfa9657d9d 50 #define RACP_RESPONSE_SUCCESS 1 /**< Record Access Control Point response code - Successful operation. */
jksoft 0:76dfa9657d9d 51 #define RACP_RESPONSE_OPCODE_UNSUPPORTED 2 /**< Record Access Control Point response code - Unsupported op code received. */
jksoft 0:76dfa9657d9d 52 #define RACP_RESPONSE_INVALID_OPERATOR 3 /**< Record Access Control Point response code - Operator not valid for service. */
jksoft 0:76dfa9657d9d 53 #define RACP_RESPONSE_OPERATOR_UNSUPPORTED 4 /**< Record Access Control Point response code - Unsupported operator. */
jksoft 0:76dfa9657d9d 54 #define RACP_RESPONSE_INVALID_OPERAND 5 /**< Record Access Control Point response code - Operand not valid for service. */
jksoft 0:76dfa9657d9d 55 #define RACP_RESPONSE_NO_RECORDS_FOUND 6 /**< Record Access Control Point response code - No matching records found. */
jksoft 0:76dfa9657d9d 56 #define RACP_RESPONSE_ABORT_FAILED 7 /**< Record Access Control Point response code - Abort could not be completed. */
jksoft 0:76dfa9657d9d 57 #define RACP_RESPONSE_PROCEDURE_NOT_DONE 8 /**< Record Access Control Point response code - Procedure could not be completed. */
jksoft 0:76dfa9657d9d 58 #define RACP_RESPONSE_OPERAND_UNSUPPORTED 9 /**< Record Access Control Point response code - Unsupported operand. */
jksoft 0:76dfa9657d9d 59
jksoft 0:76dfa9657d9d 60 /**@brief Record Access Control Point value structure. */
jksoft 0:76dfa9657d9d 61 typedef struct
jksoft 0:76dfa9657d9d 62 {
jksoft 0:76dfa9657d9d 63 uint8_t opcode; /**< Op Code. */
jksoft 0:76dfa9657d9d 64 uint8_t operator; /**< Operator. */
jksoft 0:76dfa9657d9d 65 uint8_t operand_len; /**< Length of the operand. */
jksoft 0:76dfa9657d9d 66 uint8_t * p_operand; /**< Pointer to the operand. */
jksoft 0:76dfa9657d9d 67 } ble_racp_value_t;
jksoft 0:76dfa9657d9d 68
jksoft 0:76dfa9657d9d 69 /**@brief Function for decoding a Record Access Control Point write.
jksoft 0:76dfa9657d9d 70 *
jksoft 0:76dfa9657d9d 71 * @details This call decodes a write to the Record Access Control Point.
jksoft 0:76dfa9657d9d 72 *
jksoft 0:76dfa9657d9d 73 * @param[in] data_len Length of data in received write.
jksoft 0:76dfa9657d9d 74 * @param[in] p_data Pointer to received data.
jksoft 0:76dfa9657d9d 75 * @param[out] p_racp_val Pointer to decoded Record Access Control Point write.
jksoft 0:76dfa9657d9d 76 * @note This does not do a data copy. It assumes the data pointed to by
jksoft 0:76dfa9657d9d 77 * p_data is persistant until no longer needed.
jksoft 0:76dfa9657d9d 78 */
jksoft 0:76dfa9657d9d 79 void ble_racp_decode(uint8_t data_len, uint8_t * p_data, ble_racp_value_t * p_racp_val);
jksoft 0:76dfa9657d9d 80
jksoft 0:76dfa9657d9d 81 /**@brief Function for encoding a Record Access Control Point response.
jksoft 0:76dfa9657d9d 82 *
jksoft 0:76dfa9657d9d 83 * @details This call encodes a response from the Record Access Control Point response.
jksoft 0:76dfa9657d9d 84 *
jksoft 0:76dfa9657d9d 85 * @param[in] p_racp_val Pointer to Record Access Control Point to encode.
jksoft 0:76dfa9657d9d 86 * @param[out] p_data Pointer to where encoded data is written.
jksoft 0:76dfa9657d9d 87 * NOTE! It is calling routines respsonsibility to make sure.
jksoft 0:76dfa9657d9d 88 *
jksoft 0:76dfa9657d9d 89 * @return Length of encoded data.
jksoft 0:76dfa9657d9d 90 */
jksoft 0:76dfa9657d9d 91 uint8_t ble_racp_encode(const ble_racp_value_t * p_racp_val, uint8_t * p_data);
jksoft 0:76dfa9657d9d 92
jksoft 0:76dfa9657d9d 93 #endif // BLE_RACP_H__
jksoft 0:76dfa9657d9d 94
jksoft 0:76dfa9657d9d 95 /** @} */
jksoft 0:76dfa9657d9d 96
jksoft 0:76dfa9657d9d 97 /** @endcond */