Patched version of nrf51822 FOTA compatible driver, with GPTIO disabled, as it clashed with the mbed definitions...

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ble_advdata.h Source File

ble_advdata.h

Go to the documentation of this file.
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 /**@brief Advertising data name type. This contains the options available for the device name inside
00032  *        the advertising data. */
00033 typedef enum
00034 {
00035     BLE_ADVDATA_NO_NAME,                                              /**< Include no device name in advertising data. */
00036     BLE_ADVDATA_SHORT_NAME,                                           /**< Include short device name in advertising data. */
00037     BLE_ADVDATA_FULL_NAME                                             /**< Include full device name in advertising data. */
00038 } ble_advdata_name_type_t;
00039 
00040 /**@brief UUID list type. */
00041 typedef struct
00042 {
00043     uint16_t                     uuid_cnt;                            /**< Number of UUID entries. */
00044     ble_uuid_t *                 p_uuids;                             /**< Pointer to UUID array entries. */
00045 } ble_advdata_uuid_list_t;
00046 
00047 /**@brief Connection interval range structure. */
00048 typedef struct
00049 {
00050     uint16_t                     min_conn_interval;                   /**< Minimum Connection Interval, in units of 1.25ms, range 6 to 3200 (i.e. 7.5ms to 4s). */
00051     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. */
00052 } ble_advdata_conn_int_t;
00053 
00054 /**@brief Manufacturer specific data structure. */
00055 typedef struct
00056 {
00057     uint16_t                     company_identifier;                  /**< Company Identifier Code. */
00058     uint8_array_t                data;                                /**< Additional manufacturer specific data. */
00059 } ble_advdata_manuf_data_t;
00060 
00061 /**@brief Service data structure. */
00062 typedef struct
00063 {
00064     uint16_t                     service_uuid;                        /**< Service UUID. */
00065     uint8_array_t                data;                                /**< Additional service data. */
00066 } ble_advdata_service_data_t;
00067 
00068 /**@brief Advertising data structure. This contains all options and data needed for encoding and
00069  *        setting the advertising data. */
00070 typedef struct
00071 {
00072     ble_advdata_name_type_t      name_type;                           /**< Type of device name. */
00073     uint8_t                      short_name_len;                      /**< Length of short device name (if short type is specified). */
00074     bool                         include_appearance;                  /**< Determines if Appearance shall be included. */
00075     uint8_array_t                flags;                               /**< Advertising data Flags field. */
00076     int8_t *                     p_tx_power_level;                    /**< TX Power Level field. */
00077     ble_advdata_uuid_list_t      uuids_more_available;                /**< List of UUIDs in the 'More Available' list. */
00078     ble_advdata_uuid_list_t      uuids_complete;                      /**< List of UUIDs in the 'Complete' list. */
00079     ble_advdata_uuid_list_t      uuids_solicited;                     /**< List of solcited UUIDs. */
00080     ble_advdata_conn_int_t *     p_slave_conn_int;                    /**< Slave Connection Interval Range. */
00081     ble_advdata_manuf_data_t *   p_manuf_specific_data;               /**< Manufacturer specific data. */
00082     ble_advdata_service_data_t * p_service_data_array;                /**< Array of Service data structures. */
00083     uint8_t                      service_data_count;                  /**< Number of Service data structures. */
00084 } ble_advdata_t;
00085 
00086 /**@brief Function for encoding and setting the advertising data and/or scan response data.
00087  *
00088  * @details This function encodes advertising data and/or scan response data based on the selections
00089  *          in the supplied structures, and passes the encoded data to the stack.
00090  *
00091  * @param[in]   p_advdata   Structure for specifying the content of the advertising data.
00092  *                          Set to NULL if advertising data is not to be set.
00093  * @param[in]   p_srdata    Structure for specifying the content of the scan response data.
00094  *                          Set to NULL if scan response data is not to be set.
00095  *
00096  * @return      NRF_SUCCESS on success, NRF_ERROR_DATA_SIZE if not all the requested data could fit
00097  *              into the advertising packet. The maximum size of the advertisement packet is @ref
00098  *              BLE_GAP_ADV_MAX_SIZE.
00099  *
00100  * @warning This API may override application's request to use the long name and use a short name
00101  * instead. This truncation will occur in case the long name does not fit advertisement data size.
00102  * Application is permitted to specify a preferred short name length in case truncation is required.
00103  * For example, if the complete device name is ABCD_HRMonitor, application can specify short name 
00104  * length to 8 such that short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni
00105  * etc if available size for short name is 9 or 12 respectively to have more apporpriate short name.
00106  * However, it should be noted that this is just a preference that application can specify and
00107  * if the preference too large to fit in Advertisement Data, this can be further truncated. 
00108  */
00109 uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata);
00110 
00111 #endif // BLE_ADVDATA_H__
00112 
00113 /** @} */