mbed HRM11017を使ってkonashi.jsでナイトライダー

Dependencies:   BLE_API_Native_IRC mbed

Fork of BLE_RCBController by Junichi Katsu

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