Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of nRF51822 by
ble_advdata.h
00001 /* 00002 * Copyright (c) Nordic Semiconductor ASA 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without modification, 00006 * are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, this 00009 * list of conditions and the following disclaimer. 00010 * 00011 * 2. Redistributions in binary form must reproduce the above copyright notice, this 00012 * list of conditions and the following disclaimer in the documentation and/or 00013 * other materials provided with the distribution. 00014 * 00015 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other 00016 * contributors to this software may be used to endorse or promote products 00017 * derived from this software without specific prior written permission. 00018 * 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00021 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00022 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00023 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 00024 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00025 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00026 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00027 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00028 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00029 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 * 00031 */ 00032 00033 /** @file 00034 * 00035 * @defgroup ble_sdk_lib_advdata Advertising Data Encoder 00036 * @{ 00037 * @ingroup ble_sdk_lib 00038 * @brief Function for encoding the advertising data and/or scan response data, and passing them to 00039 * the stack. 00040 */ 00041 00042 #ifndef BLE_ADVDATA_H__ 00043 #define BLE_ADVDATA_H__ 00044 00045 #include <stdint.h> 00046 #include <stdbool.h> 00047 #include <string.h> 00048 #include "ble.h" 00049 #include "app_util.h" 00050 00051 /**@brief Advertising data name type. This contains the options available for the device name inside 00052 * the advertising data. */ 00053 typedef enum 00054 { 00055 BLE_ADVDATA_NO_NAME, /**< Include no device name in advertising data. */ 00056 BLE_ADVDATA_SHORT_NAME, /**< Include short device name in advertising data. */ 00057 BLE_ADVDATA_FULL_NAME /**< Include full device name in advertising data. */ 00058 } ble_advdata_name_type_t; 00059 00060 /**@brief UUID list type. */ 00061 typedef struct 00062 { 00063 uint16_t uuid_cnt; /**< Number of UUID entries. */ 00064 ble_uuid_t * p_uuids; /**< Pointer to UUID array entries. */ 00065 } ble_advdata_uuid_list_t; 00066 00067 /**@brief Connection interval range structure. */ 00068 typedef struct 00069 { 00070 uint16_t min_conn_interval; /**< Minimum Connection Interval, in units of 1.25ms, range 6 to 3200 (i.e. 7.5ms to 4s). */ 00071 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. */ 00072 } ble_advdata_conn_int_t; 00073 00074 /**@brief Manufacturer specific data structure. */ 00075 typedef struct 00076 { 00077 uint16_t company_identifier; /**< Company Identifier Code. */ 00078 uint8_array_t data; /**< Additional manufacturer specific data. */ 00079 } ble_advdata_manuf_data_t; 00080 00081 /**@brief Service data structure. */ 00082 typedef struct 00083 { 00084 uint16_t service_uuid; /**< Service UUID. */ 00085 uint8_array_t data; /**< Additional service data. */ 00086 } ble_advdata_service_data_t; 00087 00088 /**@brief Advertising data structure. This contains all options and data needed for encoding and 00089 * setting the advertising data. */ 00090 typedef struct 00091 { 00092 ble_advdata_name_type_t name_type; /**< Type of device name. */ 00093 uint8_t short_name_len; /**< Length of short device name (if short type is specified). */ 00094 bool include_appearance; /**< Determines if Appearance shall be included. */ 00095 uint8_t flags; /**< Advertising data Flags field. */ 00096 int8_t * p_tx_power_level; /**< TX Power Level field. */ 00097 ble_advdata_uuid_list_t uuids_more_available; /**< List of UUIDs in the 'More Available' list. */ 00098 ble_advdata_uuid_list_t uuids_complete; /**< List of UUIDs in the 'Complete' list. */ 00099 ble_advdata_uuid_list_t uuids_solicited; /**< List of solcited UUIDs. */ 00100 ble_advdata_conn_int_t * p_slave_conn_int; /**< Slave Connection Interval Range. */ 00101 ble_advdata_manuf_data_t * p_manuf_specific_data; /**< Manufacturer specific data. */ 00102 ble_advdata_service_data_t * p_service_data_array; /**< Array of Service data structures. */ 00103 uint8_t service_data_count; /**< Number of Service data structures. */ 00104 } ble_advdata_t; 00105 00106 /**@brief Function for encoding and setting the advertising data and/or scan response data. 00107 * 00108 * @details This function encodes advertising data and/or scan response data based on the selections 00109 * in the supplied structures, and passes the encoded data to the stack. 00110 * 00111 * @param[in] p_advdata Structure for specifying the content of the advertising data. 00112 * Set to NULL if advertising data is not to be set. 00113 * @param[in] p_srdata Structure for specifying the content of the scan response data. 00114 * Set to NULL if scan response data is not to be set. 00115 * 00116 * @return NRF_SUCCESS on success, NRF_ERROR_DATA_SIZE if not all the requested data could fit 00117 * into the advertising packet. The maximum size of the advertisement packet is @ref 00118 * BLE_GAP_ADV_MAX_SIZE. 00119 * 00120 * @warning This API may override application's request to use the long name and use a short name 00121 * instead. This truncation will occur in case the long name does not fit advertisement data size. 00122 * Application is permitted to specify a preferred short name length in case truncation is required. 00123 * For example, if the complete device name is ABCD_HRMonitor, application can specify short name 00124 * length to 8 such that short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni 00125 * etc if available size for short name is 9 or 12 respectively to have more apporpriate short name. 00126 * However, it should be noted that this is just a preference that application can specify and 00127 * if the preference too large to fit in Advertisement Data, this can be further truncated. 00128 */ 00129 uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata); 00130 00131 #endif // BLE_ADVDATA_H__ 00132 00133 /** @} */
Generated on Tue Jul 12 2022 21:00:16 by
