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