![](/media/cache/profiles/5f14615696649541a025d3d0f8e0447f.jpg.50x50_q85.jpg)
iOSのBLEコントローラアプリ「RCBController」と接続し、コントローラの操作を取得するサンプルプログラムです。 mbed HRM1017で動作を確認しています。 2014.08.20時点でのBLEライブラリに対応しました。
Fork of BLE_RCBController by
HRM1017/nordic/nrf-sdk/ble/ble_services/ble_ias_c.h@4:ebda47d22091, 2014-08-20 (annotated)
- Committer:
- jksoft
- Date:
- Wed Aug 20 13:41:01 2014 +0000
- Revision:
- 4:ebda47d22091
- Parent:
- nRF51822/nordic/nrf-sdk/ble/ble_services/ble_ias_c.h@1:48f6e08a3ac2
?????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 1:48f6e08a3ac2 | 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. |
jksoft | 1:48f6e08a3ac2 | 2 | * |
jksoft | 1:48f6e08a3ac2 | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
jksoft | 1:48f6e08a3ac2 | 4 | * Terms and conditions of usage are described in detail in NORDIC |
jksoft | 1:48f6e08a3ac2 | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
jksoft | 1:48f6e08a3ac2 | 6 | * |
jksoft | 1:48f6e08a3ac2 | 7 | * Licensees are granted free, non-transferable use of the information. NO |
jksoft | 1:48f6e08a3ac2 | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
jksoft | 1:48f6e08a3ac2 | 9 | * the file. |
jksoft | 1:48f6e08a3ac2 | 10 | * |
jksoft | 1:48f6e08a3ac2 | 11 | */ |
jksoft | 1:48f6e08a3ac2 | 12 | |
jksoft | 1:48f6e08a3ac2 | 13 | /** @file |
jksoft | 1:48f6e08a3ac2 | 14 | * |
jksoft | 1:48f6e08a3ac2 | 15 | * @defgroup ble_sdk_srv_ias_c Immediate Alert Service Client |
jksoft | 1:48f6e08a3ac2 | 16 | * @{ |
jksoft | 1:48f6e08a3ac2 | 17 | * @ingroup ble_sdk_srv |
jksoft | 1:48f6e08a3ac2 | 18 | * @brief Immediate Alert Service Client module |
jksoft | 1:48f6e08a3ac2 | 19 | * |
jksoft | 1:48f6e08a3ac2 | 20 | * @details This module implements the Immediate Alert Service client - locator role of the Find Me |
jksoft | 1:48f6e08a3ac2 | 21 | * profile. On @ref BLE_GAP_EVT_CONNECTED event, this module starts discovery of the |
jksoft | 1:48f6e08a3ac2 | 22 | * Immediate Alert Service with Alert Level characteristic at the peer. This module will |
jksoft | 1:48f6e08a3ac2 | 23 | * indicate the application about a successful service & characteristic discovery using |
jksoft | 1:48f6e08a3ac2 | 24 | * @ref BLE_IAS_C_EVT_CHAR_DISCOVERED event. The application can use @ref |
jksoft | 1:48f6e08a3ac2 | 25 | * ble_ias_c_send_alert_level function to signal alerts to the peer. |
jksoft | 1:48f6e08a3ac2 | 26 | * |
jksoft | 1:48f6e08a3ac2 | 27 | * @note The application must propagate BLE stack events to this module by calling |
jksoft | 1:48f6e08a3ac2 | 28 | * ble_ias_c_on_ble_evt() from the from the @ref ble_stack_handler callback function. |
jksoft | 1:48f6e08a3ac2 | 29 | */ |
jksoft | 1:48f6e08a3ac2 | 30 | |
jksoft | 1:48f6e08a3ac2 | 31 | #ifndef BLE_IAS_C_H__ |
jksoft | 1:48f6e08a3ac2 | 32 | #define BLE_IAS_C_H__ |
jksoft | 1:48f6e08a3ac2 | 33 | |
jksoft | 1:48f6e08a3ac2 | 34 | #include "ble_srv_common.h" |
jksoft | 1:48f6e08a3ac2 | 35 | #include "ble_gattc.h" |
jksoft | 1:48f6e08a3ac2 | 36 | #include "ble.h" |
jksoft | 1:48f6e08a3ac2 | 37 | #include <stdint.h> |
jksoft | 1:48f6e08a3ac2 | 38 | |
jksoft | 1:48f6e08a3ac2 | 39 | // Forward declaration of the ble_ias_c_t type. |
jksoft | 1:48f6e08a3ac2 | 40 | typedef struct ble_ias_c_s ble_ias_c_t; |
jksoft | 1:48f6e08a3ac2 | 41 | |
jksoft | 1:48f6e08a3ac2 | 42 | /**@brief Immediate Alert Service client event type. */ |
jksoft | 1:48f6e08a3ac2 | 43 | typedef enum |
jksoft | 1:48f6e08a3ac2 | 44 | { |
jksoft | 1:48f6e08a3ac2 | 45 | BLE_IAS_C_EVT_SRV_DISCOVERED, /**< Event indicating that the Immediate Alert Service is found at the peer. */ |
jksoft | 1:48f6e08a3ac2 | 46 | BLE_IAS_C_EVT_SRV_NOT_FOUND, /**< Event indicating that the Immediate Alert Service is not found at the peer. */ |
jksoft | 1:48f6e08a3ac2 | 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 | 1:48f6e08a3ac2 | 48 | } ble_ias_c_evt_type_t; |
jksoft | 1:48f6e08a3ac2 | 49 | |
jksoft | 1:48f6e08a3ac2 | 50 | /**@brief Immediate Alert Service client event. */ |
jksoft | 1:48f6e08a3ac2 | 51 | typedef struct |
jksoft | 1:48f6e08a3ac2 | 52 | { |
jksoft | 1:48f6e08a3ac2 | 53 | ble_ias_c_evt_type_t evt_type; /**< Type of event. */ |
jksoft | 1:48f6e08a3ac2 | 54 | } ble_ias_c_evt_t; |
jksoft | 1:48f6e08a3ac2 | 55 | |
jksoft | 1:48f6e08a3ac2 | 56 | /**@brief Immediate Alert Service client event handler type. */ |
jksoft | 1:48f6e08a3ac2 | 57 | typedef void (*ble_ias_c_evt_handler_t) (ble_ias_c_t * p_ias_c, ble_ias_c_evt_t * p_evt); |
jksoft | 1:48f6e08a3ac2 | 58 | |
jksoft | 1:48f6e08a3ac2 | 59 | /**@brief IAS Client structure. This contains various status information for the client. */ |
jksoft | 1:48f6e08a3ac2 | 60 | typedef struct ble_ias_c_s |
jksoft | 1:48f6e08a3ac2 | 61 | { |
jksoft | 1:48f6e08a3ac2 | 62 | ble_ias_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Immediate Alert Service client. */ |
jksoft | 1:48f6e08a3ac2 | 63 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
jksoft | 1:48f6e08a3ac2 | 64 | uint16_t alert_level_handle; /**< Handle of Alert Level characteristic at peer (as provided by the BLE stack). */ |
jksoft | 1:48f6e08a3ac2 | 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 | 1:48f6e08a3ac2 | 66 | } ble_ias_c_t; |
jksoft | 1:48f6e08a3ac2 | 67 | |
jksoft | 1:48f6e08a3ac2 | 68 | /**@brief IAS Client init structure. This contains all options and data needed for initialization of |
jksoft | 1:48f6e08a3ac2 | 69 | * the client.*/ |
jksoft | 1:48f6e08a3ac2 | 70 | typedef struct |
jksoft | 1:48f6e08a3ac2 | 71 | { |
jksoft | 1:48f6e08a3ac2 | 72 | ble_ias_c_evt_handler_t evt_handler; /**< Event handler to be called for handling events from the Immediate Alert Service client. */ |
jksoft | 1:48f6e08a3ac2 | 73 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
jksoft | 1:48f6e08a3ac2 | 74 | } ble_ias_c_init_t; |
jksoft | 1:48f6e08a3ac2 | 75 | |
jksoft | 1:48f6e08a3ac2 | 76 | /**@brief Function for initializing the Immediate Alert Service client. |
jksoft | 1:48f6e08a3ac2 | 77 | * |
jksoft | 1:48f6e08a3ac2 | 78 | * @details This call allows the application to initialize the Immediate Alert Service client. |
jksoft | 1:48f6e08a3ac2 | 79 | * |
jksoft | 1:48f6e08a3ac2 | 80 | * @param[out] p_ias_c Immediate Alert Service client structure. This structure will have to |
jksoft | 1:48f6e08a3ac2 | 81 | * be supplied by the application. It will be initialized by this |
jksoft | 1:48f6e08a3ac2 | 82 | * function, and will later be used to identify this particular client |
jksoft | 1:48f6e08a3ac2 | 83 | * instance. |
jksoft | 1:48f6e08a3ac2 | 84 | * @param[in] p_ias_c_init Information needed to initialize the Immediate Alert Service client. |
jksoft | 1:48f6e08a3ac2 | 85 | * |
jksoft | 1:48f6e08a3ac2 | 86 | * @return NRF_SUCCESS on successful initialization of service. |
jksoft | 1:48f6e08a3ac2 | 87 | */ |
jksoft | 1:48f6e08a3ac2 | 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 | 1:48f6e08a3ac2 | 89 | |
jksoft | 1:48f6e08a3ac2 | 90 | /**@brief Function for sending alert level to the peer. |
jksoft | 1:48f6e08a3ac2 | 91 | * |
jksoft | 1:48f6e08a3ac2 | 92 | * @details This function allows the application to send an alert to the peer. |
jksoft | 1:48f6e08a3ac2 | 93 | * |
jksoft | 1:48f6e08a3ac2 | 94 | * @param[in] p_ias_c Immediate Alert Service client structure. |
jksoft | 1:48f6e08a3ac2 | 95 | * @param[in] alert_level Required alert level to be sent to the peer. |
jksoft | 1:48f6e08a3ac2 | 96 | * |
jksoft | 1:48f6e08a3ac2 | 97 | * @return NRF_SUCCESS on success, otherwise an error code. |
jksoft | 1:48f6e08a3ac2 | 98 | */ |
jksoft | 1:48f6e08a3ac2 | 99 | uint32_t ble_ias_c_send_alert_level(const ble_ias_c_t * p_ias_c, uint8_t alert_level); |
jksoft | 1:48f6e08a3ac2 | 100 | |
jksoft | 1:48f6e08a3ac2 | 101 | /**@brief Function for handling the Application's BLE Stack events for Immediate Alert Service client. |
jksoft | 1:48f6e08a3ac2 | 102 | * |
jksoft | 1:48f6e08a3ac2 | 103 | * @details Handles all events from the BLE stack of interest to the Immediate Alert Service client. |
jksoft | 1:48f6e08a3ac2 | 104 | * |
jksoft | 1:48f6e08a3ac2 | 105 | * @param[in] p_ias_c Immediate Alert Service client structure. |
jksoft | 1:48f6e08a3ac2 | 106 | * @param[in] p_ble_evt Event received from the BLE stack. |
jksoft | 1:48f6e08a3ac2 | 107 | */ |
jksoft | 1:48f6e08a3ac2 | 108 | void ble_ias_c_on_ble_evt(ble_ias_c_t * p_ias_c, const ble_evt_t * p_ble_evt); |
jksoft | 1:48f6e08a3ac2 | 109 | |
jksoft | 1:48f6e08a3ac2 | 110 | /**@brief Function for checking whether the peer's Immediate Alert Service instance and the alert level |
jksoft | 1:48f6e08a3ac2 | 111 | * characteristic have been discovered. |
jksoft | 1:48f6e08a3ac2 | 112 | * @param[in] p_ias_c Immediate Alert Service client structure. |
jksoft | 1:48f6e08a3ac2 | 113 | */ |
jksoft | 1:48f6e08a3ac2 | 114 | static __INLINE bool ble_ias_c_is_ias_discovered(const ble_ias_c_t * p_ias_c) |
jksoft | 1:48f6e08a3ac2 | 115 | { |
jksoft | 1:48f6e08a3ac2 | 116 | return (p_ias_c->alert_level_handle != BLE_GATT_HANDLE_INVALID); |
jksoft | 1:48f6e08a3ac2 | 117 | } |
jksoft | 1:48f6e08a3ac2 | 118 | |
jksoft | 1:48f6e08a3ac2 | 119 | #endif |