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
yihui 1:a607cd9655d7 13 /** @file
yihui 1:a607cd9655d7 14 *
yihui 1:a607cd9655d7 15 * @defgroup ble_sdk_lib_advdata Advertising Data Encoder
yihui 1:a607cd9655d7 16 * @{
yihui 1:a607cd9655d7 17 * @ingroup ble_sdk_lib
yihui 1:a607cd9655d7 18 * @brief Function for encoding the advertising data and/or scan response data, and passing them to
yihui 1:a607cd9655d7 19 * the stack.
yihui 1:a607cd9655d7 20 */
yihui 1:a607cd9655d7 21
yihui 1:a607cd9655d7 22 #ifndef BLE_ADVDATA_H__
yihui 1:a607cd9655d7 23 #define BLE_ADVDATA_H__
yihui 1:a607cd9655d7 24
yihui 1:a607cd9655d7 25 #include <stdint.h>
yihui 1:a607cd9655d7 26 #include <stdbool.h>
yihui 1:a607cd9655d7 27 #include <string.h>
yihui 1:a607cd9655d7 28 #include "ble.h"
yihui 1:a607cd9655d7 29 #include "app_util.h"
yihui 1:a607cd9655d7 30
yihui 1:a607cd9655d7 31 #ifdef __cplusplus
yihui 1:a607cd9655d7 32 extern "C" {
yihui 1:a607cd9655d7 33 #endif
yihui 1:a607cd9655d7 34
yihui 1:a607cd9655d7 35 /**@brief Advertising data name type. This contains the options available for the device name inside
yihui 1:a607cd9655d7 36 * the advertising data. */
yihui 1:a607cd9655d7 37 typedef enum
yihui 1:a607cd9655d7 38 {
yihui 1:a607cd9655d7 39 BLE_ADVDATA_NO_NAME, /**< Include no device name in advertising data. */
yihui 1:a607cd9655d7 40 BLE_ADVDATA_SHORT_NAME, /**< Include short device name in advertising data. */
yihui 1:a607cd9655d7 41 BLE_ADVDATA_FULL_NAME /**< Include full device name in advertising data. */
yihui 1:a607cd9655d7 42 } ble_advdata_name_type_t;
yihui 1:a607cd9655d7 43
yihui 1:a607cd9655d7 44 /**@brief UUID list type. */
yihui 1:a607cd9655d7 45 typedef struct
yihui 1:a607cd9655d7 46 {
yihui 1:a607cd9655d7 47 uint16_t uuid_cnt; /**< Number of UUID entries. */
yihui 1:a607cd9655d7 48 ble_uuid_t * p_uuids; /**< Pointer to UUID array entries. */
yihui 1:a607cd9655d7 49 } ble_advdata_uuid_list_t;
yihui 1:a607cd9655d7 50
yihui 1:a607cd9655d7 51 /**@brief Connection interval range structure. */
yihui 1:a607cd9655d7 52 typedef struct
yihui 1:a607cd9655d7 53 {
yihui 1:a607cd9655d7 54 uint16_t min_conn_interval; /**< Minimum Connection Interval, in units of 1.25ms, range 6 to 3200 (i.e. 7.5ms to 4s). */
yihui 1:a607cd9655d7 55 uint16_t max_conn_interval; /**< Maximum Connection Interval, in units of 1.25ms, range 6 to 3200 (i.e. 7.5ms to 4s). Value of 0xFFFF indicates no specific maximum. */
yihui 1:a607cd9655d7 56 } ble_advdata_conn_int_t;
yihui 1:a607cd9655d7 57
yihui 1:a607cd9655d7 58 /**@brief Manufacturer specific data structure. */
yihui 1:a607cd9655d7 59 typedef struct
yihui 1:a607cd9655d7 60 {
yihui 1:a607cd9655d7 61 uint16_t company_identifier; /**< Company Identifier Code. */
yihui 1:a607cd9655d7 62 uint8_array_t data; /**< Additional manufacturer specific data. */
yihui 1:a607cd9655d7 63 } ble_advdata_manuf_data_t;
yihui 1:a607cd9655d7 64
yihui 1:a607cd9655d7 65 /**@brief Service data structure. */
yihui 1:a607cd9655d7 66 typedef struct
yihui 1:a607cd9655d7 67 {
yihui 1:a607cd9655d7 68 uint16_t service_uuid; /**< Service UUID. */
yihui 1:a607cd9655d7 69 uint8_array_t data; /**< Additional service data. */
yihui 1:a607cd9655d7 70 } ble_advdata_service_data_t;
yihui 1:a607cd9655d7 71
yihui 1:a607cd9655d7 72 /**@brief Advertising data structure. This contains all options and data needed for encoding and
yihui 1:a607cd9655d7 73 * setting the advertising data. */
yihui 1:a607cd9655d7 74 typedef struct
yihui 1:a607cd9655d7 75 {
yihui 1:a607cd9655d7 76 ble_advdata_name_type_t name_type; /**< Type of device name. */
yihui 1:a607cd9655d7 77 uint8_t short_name_len; /**< Length of short device name (if short type is specified). */
yihui 1:a607cd9655d7 78 bool include_appearance; /**< Determines if Appearance shall be included. */
yihui 1:a607cd9655d7 79 uint8_array_t flags; /**< Advertising data Flags field. */
yihui 1:a607cd9655d7 80 int8_t * p_tx_power_level; /**< TX Power Level field. */
yihui 1:a607cd9655d7 81 ble_advdata_uuid_list_t uuids_more_available; /**< List of UUIDs in the 'More Available' list. */
yihui 1:a607cd9655d7 82 ble_advdata_uuid_list_t uuids_complete; /**< List of UUIDs in the 'Complete' list. */
yihui 1:a607cd9655d7 83 ble_advdata_uuid_list_t uuids_solicited; /**< List of solcited UUIDs. */
yihui 1:a607cd9655d7 84 ble_advdata_conn_int_t * p_slave_conn_int; /**< Slave Connection Interval Range. */
yihui 1:a607cd9655d7 85 ble_advdata_manuf_data_t * p_manuf_specific_data; /**< Manufacturer specific data. */
yihui 1:a607cd9655d7 86 ble_advdata_service_data_t * p_service_data_array; /**< Array of Service data structures. */
yihui 1:a607cd9655d7 87 uint8_t service_data_count; /**< Number of Service data structures. */
yihui 1:a607cd9655d7 88 } ble_advdata_t;
yihui 1:a607cd9655d7 89
yihui 1:a607cd9655d7 90 /**@brief Function for encoding and setting the advertising data and/or scan response data.
yihui 1:a607cd9655d7 91 *
yihui 1:a607cd9655d7 92 * @details This function encodes advertising data and/or scan response data based on the selections
yihui 1:a607cd9655d7 93 * in the supplied structures, and passes the encoded data to the stack.
yihui 1:a607cd9655d7 94 *
yihui 1:a607cd9655d7 95 * @param[in] p_advdata Structure for specifying the content of the advertising data.
yihui 1:a607cd9655d7 96 * Set to NULL if advertising data is not to be set.
yihui 1:a607cd9655d7 97 * @param[in] p_srdata Structure for specifying the content of the scan response data.
yihui 1:a607cd9655d7 98 * Set to NULL if scan response data is not to be set.
yihui 1:a607cd9655d7 99 *
yihui 1:a607cd9655d7 100 * @return NRF_SUCCESS on success, NRF_ERROR_DATA_SIZE if not all the requested data could fit
yihui 1:a607cd9655d7 101 * into the advertising packet. The maximum size of the advertisement packet is @ref
yihui 1:a607cd9655d7 102 * BLE_GAP_ADV_MAX_SIZE.
yihui 1:a607cd9655d7 103 *
yihui 1:a607cd9655d7 104 * @warning This API may override application's request to use the long name and use a short name
yihui 1:a607cd9655d7 105 * instead. This truncation will occur in case the long name does not fit advertisement data size.
yihui 1:a607cd9655d7 106 * Application is permitted to specify a preferred short name length in case truncation is required.
yihui 1:a607cd9655d7 107 * For example, if the complete device name is ABCD_HRMonitor, application can specify short name
yihui 1:a607cd9655d7 108 * length to 8 such that short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni
yihui 1:a607cd9655d7 109 * etc if available size for short name is 9 or 12 respectively to have more apporpriate short name.
yihui 1:a607cd9655d7 110 * However, it should be noted that this is just a preference that application can specify and
yihui 1:a607cd9655d7 111 * if the preference too large to fit in Advertisement Data, this can be further truncated.
yihui 1:a607cd9655d7 112 */
yihui 1:a607cd9655d7 113 uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata);
yihui 1:a607cd9655d7 114
yihui 1:a607cd9655d7 115 #ifdef __cplusplus
yihui 1:a607cd9655d7 116 }
yihui 1:a607cd9655d7 117 #endif
yihui 1:a607cd9655d7 118
yihui 1:a607cd9655d7 119 #endif // BLE_ADVDATA_H__
yihui 1:a607cd9655d7 120
yihui 1:a607cd9655d7 121 /** @} */