テスト用です。

Dependencies:   mbed

Committer:
jksoft
Date:
Tue Oct 11 11:09:42 2016 +0000
Revision:
0:8468a4403fea
SB??ver;

Who changed what in which revision?

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