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 BLE_WallbotBLE_Challenge by
ble_advdata.h
00001 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 00002 * 00003 * The information contained herein is property of Nordic Semiconductor ASA. 00004 * Terms and conditions of usage are described in detail in NORDIC 00005 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 00006 * 00007 * Licensees are granted free, non-transferable use of the information. NO 00008 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 00009 * the file. 00010 * 00011 */ 00012 00013 /** @file 00014 * 00015 * @defgroup ble_sdk_lib_advdata Advertising Data Encoder 00016 * @{ 00017 * @ingroup ble_sdk_lib 00018 * @brief Function for encoding the advertising data and/or scan response data, and passing them to 00019 * the stack. 00020 */ 00021 00022 #ifndef BLE_ADVDATA_H__ 00023 #define BLE_ADVDATA_H__ 00024 00025 #include <stdint.h> 00026 #include <stdbool.h> 00027 #include <string.h> 00028 #include "ble.h" 00029 #include "app_util.h " 00030 00031 #ifdef __cplusplus 00032 extern "C" { 00033 #endif 00034 00035 /**@brief Advertising data name type. This contains the options available for the device name inside 00036 * the advertising data. */ 00037 typedef enum 00038 { 00039 BLE_ADVDATA_NO_NAME, /**< Include no device name in advertising data. */ 00040 BLE_ADVDATA_SHORT_NAME, /**< Include short device name in advertising data. */ 00041 BLE_ADVDATA_FULL_NAME /**< Include full device name in advertising data. */ 00042 } ble_advdata_name_type_t; 00043 00044 /**@brief UUID list type. */ 00045 typedef struct 00046 { 00047 uint16_t uuid_cnt; /**< Number of UUID entries. */ 00048 ble_uuid_t * p_uuids; /**< Pointer to UUID array entries. */ 00049 } ble_advdata_uuid_list_t; 00050 00051 /**@brief Connection interval range structure. */ 00052 typedef struct 00053 { 00054 uint16_t min_conn_interval; /**< Minimum Connection Interval, in units of 1.25ms, range 6 to 3200 (i.e. 7.5ms to 4s). */ 00055 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. */ 00056 } ble_advdata_conn_int_t; 00057 00058 /**@brief Manufacturer specific data structure. */ 00059 typedef struct 00060 { 00061 uint16_t company_identifier; /**< Company Identifier Code. */ 00062 uint8_array_t data; /**< Additional manufacturer specific data. */ 00063 } ble_advdata_manuf_data_t; 00064 00065 /**@brief Service data structure. */ 00066 typedef struct 00067 { 00068 uint16_t service_uuid; /**< Service UUID. */ 00069 uint8_array_t data; /**< Additional service data. */ 00070 } ble_advdata_service_data_t; 00071 00072 /**@brief Advertising data structure. This contains all options and data needed for encoding and 00073 * setting the advertising data. */ 00074 typedef struct 00075 { 00076 ble_advdata_name_type_t name_type; /**< Type of device name. */ 00077 uint8_t short_name_len; /**< Length of short device name (if short type is specified). */ 00078 bool include_appearance; /**< Determines if Appearance shall be included. */ 00079 uint8_array_t flags; /**< Advertising data Flags field. */ 00080 int8_t * p_tx_power_level; /**< TX Power Level field. */ 00081 ble_advdata_uuid_list_t uuids_more_available; /**< List of UUIDs in the 'More Available' list. */ 00082 ble_advdata_uuid_list_t uuids_complete; /**< List of UUIDs in the 'Complete' list. */ 00083 ble_advdata_uuid_list_t uuids_solicited; /**< List of solcited UUIDs. */ 00084 ble_advdata_conn_int_t * p_slave_conn_int; /**< Slave Connection Interval Range. */ 00085 ble_advdata_manuf_data_t * p_manuf_specific_data; /**< Manufacturer specific data. */ 00086 ble_advdata_service_data_t * p_service_data_array; /**< Array of Service data structures. */ 00087 uint8_t service_data_count; /**< Number of Service data structures. */ 00088 } ble_advdata_t; 00089 00090 /**@brief Function for encoding and setting the advertising data and/or scan response data. 00091 * 00092 * @details This function encodes advertising data and/or scan response data based on the selections 00093 * in the supplied structures, and passes the encoded data to the stack. 00094 * 00095 * @param[in] p_advdata Structure for specifying the content of the advertising data. 00096 * Set to NULL if advertising data is not to be set. 00097 * @param[in] p_srdata Structure for specifying the content of the scan response data. 00098 * Set to NULL if scan response data is not to be set. 00099 * 00100 * @return NRF_SUCCESS on success, NRF_ERROR_DATA_SIZE if not all the requested data could fit 00101 * into the advertising packet. The maximum size of the advertisement packet is @ref 00102 * BLE_GAP_ADV_MAX_SIZE. 00103 * 00104 * @warning This API may override application's request to use the long name and use a short name 00105 * instead. This truncation will occur in case the long name does not fit advertisement data size. 00106 * Application is permitted to specify a preferred short name length in case truncation is required. 00107 * For example, if the complete device name is ABCD_HRMonitor, application can specify short name 00108 * length to 8 such that short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni 00109 * etc if available size for short name is 9 or 12 respectively to have more apporpriate short name. 00110 * However, it should be noted that this is just a preference that application can specify and 00111 * if the preference too large to fit in Advertisement Data, this can be further truncated. 00112 */ 00113 uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata); 00114 00115 #ifdef __cplusplus 00116 } 00117 #endif 00118 00119 #endif // BLE_ADVDATA_H__ 00120 00121 /** @} */
Generated on Tue Jul 12 2022 13:52:30 by
