BLE FOTA APP

Dependencies:   BLE_API mbed

It doesn't work with the default FOTA bootloader. It use NVIC_SystemReset() to enter a bootloader.

Committer:
yihui
Date:
Fri Oct 10 03:36:28 2014 +0000
Revision:
1:a607cd9655d7
use NVIC_SystemReset() to run bootloader

Who changed what in which revision?

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