modified locally to use with HRM1017
Fork of nRF51822 by
nordic/nrf-sdk/ble/ble_advdata.h@0:eff01767de02, 2014-03-26 (annotated)
- Committer:
- bogdanm
- Date:
- Wed Mar 26 14:38:17 2014 +0000
- Revision:
- 0:eff01767de02
- Child:
- 37:c29c330d942c
Initial import of the nRF51822 code
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 "nordic_global.h" |
bogdanm | 0:eff01767de02 | 29 | #include "ble.h" |
bogdanm | 0:eff01767de02 | 30 | #include "app_util.h" |
bogdanm | 0:eff01767de02 | 31 | |
bogdanm | 0:eff01767de02 | 32 | /**@brief Advertising data name type. This contains the options available for the device name inside |
bogdanm | 0:eff01767de02 | 33 | * the advertising data. */ |
bogdanm | 0:eff01767de02 | 34 | typedef enum |
bogdanm | 0:eff01767de02 | 35 | { |
bogdanm | 0:eff01767de02 | 36 | BLE_ADVDATA_NO_NAME, /**< Include no device name in advertising data. */ |
bogdanm | 0:eff01767de02 | 37 | BLE_ADVDATA_SHORT_NAME, /**< Include short device name in advertising data. */ |
bogdanm | 0:eff01767de02 | 38 | BLE_ADVDATA_FULL_NAME /**< Include full device name in advertising data. */ |
bogdanm | 0:eff01767de02 | 39 | } ble_advdata_name_type_t; |
bogdanm | 0:eff01767de02 | 40 | |
bogdanm | 0:eff01767de02 | 41 | /**@brief UUID list type. */ |
bogdanm | 0:eff01767de02 | 42 | typedef struct |
bogdanm | 0:eff01767de02 | 43 | { |
bogdanm | 0:eff01767de02 | 44 | uint16_t uuid_cnt; /**< Number of UUID entries. */ |
bogdanm | 0:eff01767de02 | 45 | ble_uuid_t * p_uuids; /**< Pointer to UUID array entries. */ |
bogdanm | 0:eff01767de02 | 46 | } ble_advdata_uuid_list_t; |
bogdanm | 0:eff01767de02 | 47 | |
bogdanm | 0:eff01767de02 | 48 | /**@brief Connection interval range structure. */ |
bogdanm | 0:eff01767de02 | 49 | typedef struct |
bogdanm | 0:eff01767de02 | 50 | { |
bogdanm | 0:eff01767de02 | 51 | 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 | 52 | 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 | 53 | } ble_advdata_conn_int_t; |
bogdanm | 0:eff01767de02 | 54 | |
bogdanm | 0:eff01767de02 | 55 | /**@brief Manufacturer specific data structure. */ |
bogdanm | 0:eff01767de02 | 56 | typedef struct |
bogdanm | 0:eff01767de02 | 57 | { |
bogdanm | 0:eff01767de02 | 58 | uint16_t company_identifier; /**< Company Identifier Code. */ |
bogdanm | 0:eff01767de02 | 59 | uint8_array_t data; /**< Additional manufacturer specific data. */ |
bogdanm | 0:eff01767de02 | 60 | } ble_advdata_manuf_data_t; |
bogdanm | 0:eff01767de02 | 61 | |
bogdanm | 0:eff01767de02 | 62 | /**@brief Service data structure. */ |
bogdanm | 0:eff01767de02 | 63 | typedef struct |
bogdanm | 0:eff01767de02 | 64 | { |
bogdanm | 0:eff01767de02 | 65 | uint16_t service_uuid; /**< Service UUID. */ |
bogdanm | 0:eff01767de02 | 66 | uint8_array_t data; /**< Additional service data. */ |
bogdanm | 0:eff01767de02 | 67 | } ble_advdata_service_data_t; |
bogdanm | 0:eff01767de02 | 68 | |
bogdanm | 0:eff01767de02 | 69 | /**@brief Advertising data structure. This contains all options and data needed for encoding and |
bogdanm | 0:eff01767de02 | 70 | * setting the advertising data. */ |
bogdanm | 0:eff01767de02 | 71 | typedef struct |
bogdanm | 0:eff01767de02 | 72 | { |
bogdanm | 0:eff01767de02 | 73 | ble_advdata_name_type_t name_type; /**< Type of device name. */ |
bogdanm | 0:eff01767de02 | 74 | uint8_t short_name_len; /**< Length of short device name (if short type is specified). */ |
bogdanm | 0:eff01767de02 | 75 | bool include_appearance; /**< Determines if Appearance shall be included. */ |
bogdanm | 0:eff01767de02 | 76 | uint8_array_t flags; /**< Advertising data Flags field. */ |
bogdanm | 0:eff01767de02 | 77 | int8_t * p_tx_power_level; /**< TX Power Level field. */ |
bogdanm | 0:eff01767de02 | 78 | ble_advdata_uuid_list_t uuids_more_available; /**< List of UUIDs in the 'More Available' list. */ |
bogdanm | 0:eff01767de02 | 79 | ble_advdata_uuid_list_t uuids_complete; /**< List of UUIDs in the 'Complete' list. */ |
bogdanm | 0:eff01767de02 | 80 | ble_advdata_uuid_list_t uuids_solicited; /**< List of solcited UUIDs. */ |
bogdanm | 0:eff01767de02 | 81 | ble_advdata_conn_int_t * p_slave_conn_int; /**< Slave Connection Interval Range. */ |
bogdanm | 0:eff01767de02 | 82 | ble_advdata_manuf_data_t * p_manuf_specific_data; /**< Manufacturer specific data. */ |
bogdanm | 0:eff01767de02 | 83 | ble_advdata_service_data_t * p_service_data_array; /**< Array of Service data structures. */ |
bogdanm | 0:eff01767de02 | 84 | uint8_t service_data_count; /**< Number of Service data structures. */ |
bogdanm | 0:eff01767de02 | 85 | } ble_advdata_t; |
bogdanm | 0:eff01767de02 | 86 | |
bogdanm | 0:eff01767de02 | 87 | /**@brief Function for encoding and setting the advertising data and/or scan response data. |
bogdanm | 0:eff01767de02 | 88 | * |
bogdanm | 0:eff01767de02 | 89 | * @details This function encodes advertising data and/or scan response data based on the selections |
bogdanm | 0:eff01767de02 | 90 | * in the supplied structures, and passes the encoded data to the stack. |
bogdanm | 0:eff01767de02 | 91 | * |
bogdanm | 0:eff01767de02 | 92 | * @param[in] p_advdata Structure for specifying the content of the advertising data. |
bogdanm | 0:eff01767de02 | 93 | * Set to NULL if advertising data is not to be set. |
bogdanm | 0:eff01767de02 | 94 | * @param[in] p_srdata Structure for specifying the content of the scan response data. |
bogdanm | 0:eff01767de02 | 95 | * Set to NULL if scan response data is not to be set. |
bogdanm | 0:eff01767de02 | 96 | * |
bogdanm | 0:eff01767de02 | 97 | * @return NRF_SUCCESS on success, NRF_ERROR_DATA_SIZE if not all the requested data could fit |
bogdanm | 0:eff01767de02 | 98 | * into the advertising packet. The maximum size of the advertisement packet is @ref |
bogdanm | 0:eff01767de02 | 99 | * BLE_GAP_ADV_MAX_SIZE. |
bogdanm | 0:eff01767de02 | 100 | * |
bogdanm | 0:eff01767de02 | 101 | * @warning This API may override application's request to use the long name and use a short name |
bogdanm | 0:eff01767de02 | 102 | * instead. This truncation will occur in case the long name does not fit advertisement data size. |
bogdanm | 0:eff01767de02 | 103 | * Application is permitted to specify a preferred short name length in case truncation is required. |
bogdanm | 0:eff01767de02 | 104 | * For example, if the complete device name is ABCD_HRMonitor, application can specify short name |
bogdanm | 0:eff01767de02 | 105 | * length to 8 such that short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni |
bogdanm | 0:eff01767de02 | 106 | * etc if available size for short name is 9 or 12 respectively to have more apporpriate short name. |
bogdanm | 0:eff01767de02 | 107 | * However, it should be noted that this is just a preference that application can specify and |
bogdanm | 0:eff01767de02 | 108 | * if the preference too large to fit in Advertisement Data, this can be further truncated. |
bogdanm | 0:eff01767de02 | 109 | */ |
bogdanm | 0:eff01767de02 | 110 | uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata); |
bogdanm | 0:eff01767de02 | 111 | |
bogdanm | 0:eff01767de02 | 112 | #endif // BLE_ADVDATA_H__ |
bogdanm | 0:eff01767de02 | 113 | |
bogdanm | 0:eff01767de02 | 114 | /** @} */ |