テスト用です。

Dependencies:   mbed

Committer:
jksoft
Date:
Tue Oct 11 11:09:42 2016 +0000
Revision:
0:8468a4403fea
SB??ver;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:8468a4403fea 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
jksoft 0:8468a4403fea 2 *
jksoft 0:8468a4403fea 3 * The information contained herein is property of Nordic Semiconductor ASA.
jksoft 0:8468a4403fea 4 * Terms and conditions of usage are described in detail in NORDIC
jksoft 0:8468a4403fea 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
jksoft 0:8468a4403fea 6 *
jksoft 0:8468a4403fea 7 * Licensees are granted free, non-transferable use of the information. NO
jksoft 0:8468a4403fea 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jksoft 0:8468a4403fea 9 * the file.
jksoft 0:8468a4403fea 10 *
jksoft 0:8468a4403fea 11 */
jksoft 0:8468a4403fea 12
jksoft 0:8468a4403fea 13 /** @file
jksoft 0:8468a4403fea 14 *
jksoft 0:8468a4403fea 15 * @defgroup ble_sdk_srv_ias_c Immediate Alert Service Client
jksoft 0:8468a4403fea 16 * @{
jksoft 0:8468a4403fea 17 * @ingroup ble_sdk_srv
jksoft 0:8468a4403fea 18 * @brief Immediate Alert Service Client module
jksoft 0:8468a4403fea 19 *
jksoft 0:8468a4403fea 20 * @details This module implements the Immediate Alert Service client - locator role of the Find Me
jksoft 0:8468a4403fea 21 * profile. On @ref BLE_GAP_EVT_CONNECTED event, this module starts discovery of the
jksoft 0:8468a4403fea 22 * Immediate Alert Service with Alert Level characteristic at the peer. This module will
jksoft 0:8468a4403fea 23 * indicate the application about a successful service & characteristic discovery using
jksoft 0:8468a4403fea 24 * @ref BLE_IAS_C_EVT_CHAR_DISCOVERED event. The application can use @ref
jksoft 0:8468a4403fea 25 * ble_ias_c_send_alert_level function to signal alerts to the peer.
jksoft 0:8468a4403fea 26 *
jksoft 0:8468a4403fea 27 * @note The application must propagate BLE stack events to this module by calling
jksoft 0:8468a4403fea 28 * ble_ias_c_on_ble_evt() from the from the @ref ble_stack_handler callback function.
jksoft 0:8468a4403fea 29 */
jksoft 0:8468a4403fea 30
jksoft 0:8468a4403fea 31 #ifndef BLE_IAS_C_H__
jksoft 0:8468a4403fea 32 #define BLE_IAS_C_H__
jksoft 0:8468a4403fea 33
jksoft 0:8468a4403fea 34 #include "ble_srv_common.h"
jksoft 0:8468a4403fea 35 #include "ble_gattc.h"
jksoft 0:8468a4403fea 36 #include "ble.h"
jksoft 0:8468a4403fea 37 #include <stdint.h>
jksoft 0:8468a4403fea 38
jksoft 0:8468a4403fea 39 // Forward declaration of the ble_ias_c_t type.
jksoft 0:8468a4403fea 40 typedef struct ble_ias_c_s ble_ias_c_t;
jksoft 0:8468a4403fea 41
jksoft 0:8468a4403fea 42 /**@brief Immediate Alert Service client event type. */
jksoft 0:8468a4403fea 43 typedef enum
jksoft 0:8468a4403fea 44 {
jksoft 0:8468a4403fea 45 BLE_IAS_C_EVT_SRV_DISCOVERED, /**< Event indicating that the Immediate Alert Service is found at the peer. */
jksoft 0:8468a4403fea 46 BLE_IAS_C_EVT_SRV_NOT_FOUND, /**< Event indicating that the Immediate Alert Service is not found at the peer. */
jksoft 0:8468a4403fea 47 BLE_IAS_C_EVT_DISCONN_COMPLETE /**< Event indicating that the Immediate Alert Service client module has completed the processing of BLE_GAP_EVT_DISCONNECTED event. This event is raised only if a valid instance of IAS was found at the peer during the discovery phase. This event can be used the application to do clean up related to the IAS Client.*/
jksoft 0:8468a4403fea 48 } ble_ias_c_evt_type_t;
jksoft 0:8468a4403fea 49
jksoft 0:8468a4403fea 50 /**@brief Immediate Alert Service client event. */
jksoft 0:8468a4403fea 51 typedef struct
jksoft 0:8468a4403fea 52 {
jksoft 0:8468a4403fea 53 ble_ias_c_evt_type_t evt_type; /**< Type of event. */
jksoft 0:8468a4403fea 54 } ble_ias_c_evt_t;
jksoft 0:8468a4403fea 55
jksoft 0:8468a4403fea 56 /**@brief Immediate Alert Service client event handler type. */
jksoft 0:8468a4403fea 57 typedef void (*ble_ias_c_evt_handler_t) (ble_ias_c_t * p_ias_c, ble_ias_c_evt_t * p_evt);
jksoft 0:8468a4403fea 58
jksoft 0:8468a4403fea 59 /**@brief IAS Client structure. This contains various status information for the client. */
jksoft 0:8468a4403fea 60 typedef struct ble_ias_c_s
jksoft 0:8468a4403fea 61 {
jksoft 0:8468a4403fea 62 ble_ias_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Immediate Alert Service client. */
jksoft 0:8468a4403fea 63 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */
jksoft 0:8468a4403fea 64 uint16_t alert_level_handle; /**< Handle of Alert Level characteristic at peer (as provided by the BLE stack). */
jksoft 0:8468a4403fea 65 uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
jksoft 0:8468a4403fea 66 } ble_ias_c_t;
jksoft 0:8468a4403fea 67
jksoft 0:8468a4403fea 68 /**@brief IAS Client init structure. This contains all options and data needed for initialization of
jksoft 0:8468a4403fea 69 * the client.*/
jksoft 0:8468a4403fea 70 typedef struct
jksoft 0:8468a4403fea 71 {
jksoft 0:8468a4403fea 72 ble_ias_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events from the Immediate Alert Service client. */
jksoft 0:8468a4403fea 73 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */
jksoft 0:8468a4403fea 74 } ble_ias_c_init_t;
jksoft 0:8468a4403fea 75
jksoft 0:8468a4403fea 76 /**@brief Function for initializing the Immediate Alert Service client.
jksoft 0:8468a4403fea 77 *
jksoft 0:8468a4403fea 78 * @details This call allows the application to initialize the Immediate Alert Service client.
jksoft 0:8468a4403fea 79 *
jksoft 0:8468a4403fea 80 * @param[out] p_ias_c Immediate Alert Service client structure. This structure will have to
jksoft 0:8468a4403fea 81 * be supplied by the application. It will be initialized by this
jksoft 0:8468a4403fea 82 * function, and will later be used to identify this particular client
jksoft 0:8468a4403fea 83 * instance.
jksoft 0:8468a4403fea 84 * @param[in] p_ias_c_init Information needed to initialize the Immediate Alert Service client.
jksoft 0:8468a4403fea 85 *
jksoft 0:8468a4403fea 86 * @return NRF_SUCCESS on successful initialization of service.
jksoft 0:8468a4403fea 87 */
jksoft 0:8468a4403fea 88 uint32_t ble_ias_c_init(ble_ias_c_t * p_ias_c, const ble_ias_c_init_t * p_ias_c_init);
jksoft 0:8468a4403fea 89
jksoft 0:8468a4403fea 90 /**@brief Function for sending alert level to the peer.
jksoft 0:8468a4403fea 91 *
jksoft 0:8468a4403fea 92 * @details This function allows the application to send an alert to the peer.
jksoft 0:8468a4403fea 93 *
jksoft 0:8468a4403fea 94 * @param[in] p_ias_c Immediate Alert Service client structure.
jksoft 0:8468a4403fea 95 * @param[in] alert_level Required alert level to be sent to the peer.
jksoft 0:8468a4403fea 96 *
jksoft 0:8468a4403fea 97 * @return NRF_SUCCESS on success, otherwise an error code.
jksoft 0:8468a4403fea 98 */
jksoft 0:8468a4403fea 99 uint32_t ble_ias_c_send_alert_level(const ble_ias_c_t * p_ias_c, uint8_t alert_level);
jksoft 0:8468a4403fea 100
jksoft 0:8468a4403fea 101 /**@brief Function for handling the Application's BLE Stack events for Immediate Alert Service client.
jksoft 0:8468a4403fea 102 *
jksoft 0:8468a4403fea 103 * @details Handles all events from the BLE stack of interest to the Immediate Alert Service client.
jksoft 0:8468a4403fea 104 *
jksoft 0:8468a4403fea 105 * @param[in] p_ias_c Immediate Alert Service client structure.
jksoft 0:8468a4403fea 106 * @param[in] p_ble_evt Event received from the BLE stack.
jksoft 0:8468a4403fea 107 */
jksoft 0:8468a4403fea 108 void ble_ias_c_on_ble_evt(ble_ias_c_t * p_ias_c, const ble_evt_t * p_ble_evt);
jksoft 0:8468a4403fea 109
jksoft 0:8468a4403fea 110 /**@brief Function for checking whether the peer's Immediate Alert Service instance and the alert level
jksoft 0:8468a4403fea 111 * characteristic have been discovered.
jksoft 0:8468a4403fea 112 * @param[in] p_ias_c Immediate Alert Service client structure.
jksoft 0:8468a4403fea 113 */
jksoft 0:8468a4403fea 114 static __INLINE bool ble_ias_c_is_ias_discovered(const ble_ias_c_t * p_ias_c)
jksoft 0:8468a4403fea 115 {
jksoft 0:8468a4403fea 116 return (p_ias_c->alert_level_handle != BLE_GATT_HANDLE_INVALID);
jksoft 0:8468a4403fea 117 }
jksoft 0:8468a4403fea 118
jksoft 0:8468a4403fea 119 #endif