To get started with Seeed Tiny BLE, include detecting motion, button and battery level.

Dependencies:   BLE_API eMPL_MPU6050 mbed nRF51822

Committer:
yihui
Date:
Thu Nov 05 02:46:37 2015 +0000
Revision:
2:b61ddbb8528e
Parent:
1:fc2f9d636751
able to recover from i2c bus fault

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 1:fc2f9d636751 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
yihui 1:fc2f9d636751 2 *
yihui 1:fc2f9d636751 3 * The information contained herein is property of Nordic Semiconductor ASA.
yihui 1:fc2f9d636751 4 * Terms and conditions of usage are described in detail in NORDIC
yihui 1:fc2f9d636751 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
yihui 1:fc2f9d636751 6 *
yihui 1:fc2f9d636751 7 * Licensees are granted free, non-transferable use of the information. NO
yihui 1:fc2f9d636751 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
yihui 1:fc2f9d636751 9 * the file.
yihui 1:fc2f9d636751 10 *
yihui 1:fc2f9d636751 11 */
yihui 1:fc2f9d636751 12
yihui 1:fc2f9d636751 13 /** @file
yihui 1:fc2f9d636751 14 *
yihui 1:fc2f9d636751 15 * @defgroup ble_sdk_lib_advdata Advertising Data Encoder
yihui 1:fc2f9d636751 16 * @{
yihui 1:fc2f9d636751 17 * @ingroup ble_sdk_lib
yihui 1:fc2f9d636751 18 * @brief Function for encoding the advertising data and/or scan response data, and passing them to
yihui 1:fc2f9d636751 19 * the stack.
yihui 1:fc2f9d636751 20 */
yihui 1:fc2f9d636751 21
yihui 1:fc2f9d636751 22 #ifndef BLE_ADVDATA_H__
yihui 1:fc2f9d636751 23 #define BLE_ADVDATA_H__
yihui 1:fc2f9d636751 24
yihui 1:fc2f9d636751 25 #include <stdint.h>
yihui 1:fc2f9d636751 26 #include <stdbool.h>
yihui 1:fc2f9d636751 27 #include <string.h>
yihui 1:fc2f9d636751 28 #include "ble.h"
yihui 1:fc2f9d636751 29 #include "app_util.h"
yihui 1:fc2f9d636751 30
yihui 1:fc2f9d636751 31 /**@brief Advertising data name type. This contains the options available for the device name inside
yihui 1:fc2f9d636751 32 * the advertising data. */
yihui 1:fc2f9d636751 33 typedef enum
yihui 1:fc2f9d636751 34 {
yihui 1:fc2f9d636751 35 BLE_ADVDATA_NO_NAME, /**< Include no device name in advertising data. */
yihui 1:fc2f9d636751 36 BLE_ADVDATA_SHORT_NAME, /**< Include short device name in advertising data. */
yihui 1:fc2f9d636751 37 BLE_ADVDATA_FULL_NAME /**< Include full device name in advertising data. */
yihui 1:fc2f9d636751 38 } ble_advdata_name_type_t;
yihui 1:fc2f9d636751 39
yihui 1:fc2f9d636751 40 /**@brief UUID list type. */
yihui 1:fc2f9d636751 41 typedef struct
yihui 1:fc2f9d636751 42 {
yihui 1:fc2f9d636751 43 uint16_t uuid_cnt; /**< Number of UUID entries. */
yihui 1:fc2f9d636751 44 ble_uuid_t * p_uuids; /**< Pointer to UUID array entries. */
yihui 1:fc2f9d636751 45 } ble_advdata_uuid_list_t;
yihui 1:fc2f9d636751 46
yihui 1:fc2f9d636751 47 /**@brief Connection interval range structure. */
yihui 1:fc2f9d636751 48 typedef struct
yihui 1:fc2f9d636751 49 {
yihui 1:fc2f9d636751 50 uint16_t min_conn_interval; /**< Minimum Connection Interval, in units of 1.25ms, range 6 to 3200 (i.e. 7.5ms to 4s). */
yihui 1:fc2f9d636751 51 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. */
yihui 1:fc2f9d636751 52 } ble_advdata_conn_int_t;
yihui 1:fc2f9d636751 53
yihui 1:fc2f9d636751 54 /**@brief Manufacturer specific data structure. */
yihui 1:fc2f9d636751 55 typedef struct
yihui 1:fc2f9d636751 56 {
yihui 1:fc2f9d636751 57 uint16_t company_identifier; /**< Company Identifier Code. */
yihui 1:fc2f9d636751 58 uint8_array_t data; /**< Additional manufacturer specific data. */
yihui 1:fc2f9d636751 59 } ble_advdata_manuf_data_t;
yihui 1:fc2f9d636751 60
yihui 1:fc2f9d636751 61 /**@brief Service data structure. */
yihui 1:fc2f9d636751 62 typedef struct
yihui 1:fc2f9d636751 63 {
yihui 1:fc2f9d636751 64 uint16_t service_uuid; /**< Service UUID. */
yihui 1:fc2f9d636751 65 uint8_array_t data; /**< Additional service data. */
yihui 1:fc2f9d636751 66 } ble_advdata_service_data_t;
yihui 1:fc2f9d636751 67
yihui 1:fc2f9d636751 68 /**@brief Advertising data structure. This contains all options and data needed for encoding and
yihui 1:fc2f9d636751 69 * setting the advertising data. */
yihui 1:fc2f9d636751 70 typedef struct
yihui 1:fc2f9d636751 71 {
yihui 1:fc2f9d636751 72 ble_advdata_name_type_t name_type; /**< Type of device name. */
yihui 1:fc2f9d636751 73 uint8_t short_name_len; /**< Length of short device name (if short type is specified). */
yihui 1:fc2f9d636751 74 bool include_appearance; /**< Determines if Appearance shall be included. */
yihui 1:fc2f9d636751 75 uint8_array_t flags; /**< Advertising data Flags field. */
yihui 1:fc2f9d636751 76 int8_t * p_tx_power_level; /**< TX Power Level field. */
yihui 1:fc2f9d636751 77 ble_advdata_uuid_list_t uuids_more_available; /**< List of UUIDs in the 'More Available' list. */
yihui 1:fc2f9d636751 78 ble_advdata_uuid_list_t uuids_complete; /**< List of UUIDs in the 'Complete' list. */
yihui 1:fc2f9d636751 79 ble_advdata_uuid_list_t uuids_solicited; /**< List of solcited UUIDs. */
yihui 1:fc2f9d636751 80 ble_advdata_conn_int_t * p_slave_conn_int; /**< Slave Connection Interval Range. */
yihui 1:fc2f9d636751 81 ble_advdata_manuf_data_t * p_manuf_specific_data; /**< Manufacturer specific data. */
yihui 1:fc2f9d636751 82 ble_advdata_service_data_t * p_service_data_array; /**< Array of Service data structures. */
yihui 1:fc2f9d636751 83 uint8_t service_data_count; /**< Number of Service data structures. */
yihui 1:fc2f9d636751 84 } ble_advdata_t;
yihui 1:fc2f9d636751 85
yihui 1:fc2f9d636751 86 /**@brief Function for encoding and setting the advertising data and/or scan response data.
yihui 1:fc2f9d636751 87 *
yihui 1:fc2f9d636751 88 * @details This function encodes advertising data and/or scan response data based on the selections
yihui 1:fc2f9d636751 89 * in the supplied structures, and passes the encoded data to the stack.
yihui 1:fc2f9d636751 90 *
yihui 1:fc2f9d636751 91 * @param[in] p_advdata Structure for specifying the content of the advertising data.
yihui 1:fc2f9d636751 92 * Set to NULL if advertising data is not to be set.
yihui 1:fc2f9d636751 93 * @param[in] p_srdata Structure for specifying the content of the scan response data.
yihui 1:fc2f9d636751 94 * Set to NULL if scan response data is not to be set.
yihui 1:fc2f9d636751 95 *
yihui 1:fc2f9d636751 96 * @return NRF_SUCCESS on success, NRF_ERROR_DATA_SIZE if not all the requested data could fit
yihui 1:fc2f9d636751 97 * into the advertising packet. The maximum size of the advertisement packet is @ref
yihui 1:fc2f9d636751 98 * BLE_GAP_ADV_MAX_SIZE.
yihui 1:fc2f9d636751 99 *
yihui 1:fc2f9d636751 100 * @warning This API may override application's request to use the long name and use a short name
yihui 1:fc2f9d636751 101 * instead. This truncation will occur in case the long name does not fit advertisement data size.
yihui 1:fc2f9d636751 102 * Application is permitted to specify a preferred short name length in case truncation is required.
yihui 1:fc2f9d636751 103 * For example, if the complete device name is ABCD_HRMonitor, application can specify short name
yihui 1:fc2f9d636751 104 * length to 8 such that short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni
yihui 1:fc2f9d636751 105 * etc if available size for short name is 9 or 12 respectively to have more apporpriate short name.
yihui 1:fc2f9d636751 106 * However, it should be noted that this is just a preference that application can specify and
yihui 1:fc2f9d636751 107 * if the preference too large to fit in Advertisement Data, this can be further truncated.
yihui 1:fc2f9d636751 108 */
yihui 1:fc2f9d636751 109 uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata);
yihui 1:fc2f9d636751 110
yihui 1:fc2f9d636751 111 #endif // BLE_ADVDATA_H__
yihui 1:fc2f9d636751 112
yihui 1:fc2f9d636751 113 /** @} */