Yutaka Yoshida / Mbed 2 deprecated BLE_WallbotBLE_Challenge_byYUTAKA

Dependencies:   mbed

Fork of BLE_WallbotBLE_Challenge_byYUTAKA by keisuke Yoshida

Committer:
Dyotty
Date:
Mon Jun 18 06:18:04 2018 +0000
Revision:
10:d443aea353a2
Parent:
0:76dfa9657d9d
6/18

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:76dfa9657d9d 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
jksoft 0:76dfa9657d9d 2 *
jksoft 0:76dfa9657d9d 3 * The information contained herein is property of Nordic Semiconductor ASA.
jksoft 0:76dfa9657d9d 4 * Terms and conditions of usage are described in detail in NORDIC
jksoft 0:76dfa9657d9d 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
jksoft 0:76dfa9657d9d 6 *
jksoft 0:76dfa9657d9d 7 * Licensees are granted free, non-transferable use of the information. NO
jksoft 0:76dfa9657d9d 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jksoft 0:76dfa9657d9d 9 * the file.
jksoft 0:76dfa9657d9d 10 *
jksoft 0:76dfa9657d9d 11 */
jksoft 0:76dfa9657d9d 12
jksoft 0:76dfa9657d9d 13 /** @file
jksoft 0:76dfa9657d9d 14 *
jksoft 0:76dfa9657d9d 15 * @defgroup ble_sdk_srv_ias Immediate Alert Service
jksoft 0:76dfa9657d9d 16 * @{
jksoft 0:76dfa9657d9d 17 * @ingroup ble_sdk_srv
jksoft 0:76dfa9657d9d 18 * @brief Immediate Alert Service module.
jksoft 0:76dfa9657d9d 19 *
jksoft 0:76dfa9657d9d 20 * @details This module implements the Immediate Alert Service with the Alert Level characteristic.
jksoft 0:76dfa9657d9d 21 * During initialization it adds the Immediate Alert Service and Alert Level characteristic
jksoft 0:76dfa9657d9d 22 * to the BLE stack database.
jksoft 0:76dfa9657d9d 23 *
jksoft 0:76dfa9657d9d 24 * The application must supply an event handler for receiving Immediate Alert Service
jksoft 0:76dfa9657d9d 25 * events. Using this handler, the service will notify the application when the
jksoft 0:76dfa9657d9d 26 * Alert Level characteristic value changes.
jksoft 0:76dfa9657d9d 27 *
jksoft 0:76dfa9657d9d 28 * The service also provides a function for letting the application poll the current
jksoft 0:76dfa9657d9d 29 * value of the Alert Level characteristic.
jksoft 0:76dfa9657d9d 30 *
jksoft 0:76dfa9657d9d 31 * @note The application must propagate BLE stack events to the Immediate Alert Service
jksoft 0:76dfa9657d9d 32 * module by calling ble_ias_on_ble_evt() from the @ref ble_stack_handler callback.
jksoft 0:76dfa9657d9d 33 *
jksoft 0:76dfa9657d9d 34 * @note Attention!
jksoft 0:76dfa9657d9d 35 * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile
jksoft 0:76dfa9657d9d 36 * qualification listings, this section of source code must not be modified.
jksoft 0:76dfa9657d9d 37 */
jksoft 0:76dfa9657d9d 38
jksoft 0:76dfa9657d9d 39 #ifndef BLE_IAS_H__
jksoft 0:76dfa9657d9d 40 #define BLE_IAS_H__
jksoft 0:76dfa9657d9d 41
jksoft 0:76dfa9657d9d 42 #include <stdint.h>
jksoft 0:76dfa9657d9d 43 #include "ble.h"
jksoft 0:76dfa9657d9d 44
jksoft 0:76dfa9657d9d 45 /**@brief Immediate Alert Service event type. */
jksoft 0:76dfa9657d9d 46 typedef enum
jksoft 0:76dfa9657d9d 47 {
jksoft 0:76dfa9657d9d 48 BLE_IAS_EVT_ALERT_LEVEL_UPDATED /**< Alert Level Updated event. */
jksoft 0:76dfa9657d9d 49 } ble_ias_evt_type_t;
jksoft 0:76dfa9657d9d 50
jksoft 0:76dfa9657d9d 51 /**@brief Immediate Alert Service event. */
jksoft 0:76dfa9657d9d 52 typedef struct
jksoft 0:76dfa9657d9d 53 {
jksoft 0:76dfa9657d9d 54 ble_ias_evt_type_t evt_type; /**< Type of event. */
jksoft 0:76dfa9657d9d 55 union
jksoft 0:76dfa9657d9d 56 {
jksoft 0:76dfa9657d9d 57 uint8_t alert_level; /**< New Alert Level value. */
jksoft 0:76dfa9657d9d 58 } params;
jksoft 0:76dfa9657d9d 59 } ble_ias_evt_t;
jksoft 0:76dfa9657d9d 60
jksoft 0:76dfa9657d9d 61 // Forward declaration of the ble_ias_t type.
jksoft 0:76dfa9657d9d 62 typedef struct ble_ias_s ble_ias_t;
jksoft 0:76dfa9657d9d 63
jksoft 0:76dfa9657d9d 64 /**@brief Immediate Alert Service event handler type. */
jksoft 0:76dfa9657d9d 65 typedef void (*ble_ias_evt_handler_t) (ble_ias_t * p_ias, ble_ias_evt_t * p_evt);
jksoft 0:76dfa9657d9d 66
jksoft 0:76dfa9657d9d 67 /**@brief Immediate Alert Service init structure. This contains all options and data needed for
jksoft 0:76dfa9657d9d 68 * initialization of the service. */
jksoft 0:76dfa9657d9d 69 typedef struct
jksoft 0:76dfa9657d9d 70 {
jksoft 0:76dfa9657d9d 71 ble_ias_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Immediate Alert Service. */
jksoft 0:76dfa9657d9d 72 } ble_ias_init_t;
jksoft 0:76dfa9657d9d 73
jksoft 0:76dfa9657d9d 74 /**@brief Immediate Alert Service structure. This contains various status information for the
jksoft 0:76dfa9657d9d 75 * service. */
jksoft 0:76dfa9657d9d 76 typedef struct ble_ias_s
jksoft 0:76dfa9657d9d 77 {
jksoft 0:76dfa9657d9d 78 ble_ias_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Immediate Alert Service. */
jksoft 0:76dfa9657d9d 79 uint16_t service_handle; /**< Handle of Immediate Alert Service (as provided by the BLE stack). */
jksoft 0:76dfa9657d9d 80 ble_gatts_char_handles_t alert_level_handles; /**< Handles related to the Alert Level characteristic. */
jksoft 0:76dfa9657d9d 81 } ble_ias_t;
jksoft 0:76dfa9657d9d 82
jksoft 0:76dfa9657d9d 83 /**@brief Function for initializing the Immediate Alert Service.
jksoft 0:76dfa9657d9d 84 *
jksoft 0:76dfa9657d9d 85 * @param[out] p_ias Immediate Alert Service structure. This structure will have to be
jksoft 0:76dfa9657d9d 86 * supplied by the application. It will be initialized by this function,
jksoft 0:76dfa9657d9d 87 * and will later be used to identify this particular service instance.
jksoft 0:76dfa9657d9d 88 * @param[in] p_ias_init Information needed to initialize the service.
jksoft 0:76dfa9657d9d 89 *
jksoft 0:76dfa9657d9d 90 * @return NRF_SUCCESS on successful initialization of service, otherwise an error code.
jksoft 0:76dfa9657d9d 91 */
jksoft 0:76dfa9657d9d 92 uint32_t ble_ias_init(ble_ias_t * p_ias, const ble_ias_init_t * p_ias_init);
jksoft 0:76dfa9657d9d 93
jksoft 0:76dfa9657d9d 94 /**@brief Function for handling the Application's BLE Stack events.
jksoft 0:76dfa9657d9d 95 *
jksoft 0:76dfa9657d9d 96 * @details Handles all events from the BLE stack of interest to the Immediate Alert Service.
jksoft 0:76dfa9657d9d 97 *
jksoft 0:76dfa9657d9d 98 * @param[in] p_ias Immediate Alert Service structure.
jksoft 0:76dfa9657d9d 99 * @param[in] p_ble_evt Event received from the BLE stack.
jksoft 0:76dfa9657d9d 100 */
jksoft 0:76dfa9657d9d 101 void ble_ias_on_ble_evt(ble_ias_t * p_ias, ble_evt_t * p_ble_evt);
jksoft 0:76dfa9657d9d 102
jksoft 0:76dfa9657d9d 103 /**@brief Function for getting current value of the Alert Level characteristic.
jksoft 0:76dfa9657d9d 104 *
jksoft 0:76dfa9657d9d 105 * @param[in] p_ias Immediate Alert Service structure.
jksoft 0:76dfa9657d9d 106 * @param[out] p_alert_level Current Alert Level value.
jksoft 0:76dfa9657d9d 107 */
jksoft 0:76dfa9657d9d 108 uint32_t ble_ias_alert_level_get(ble_ias_t * p_ias, uint8_t * p_alert_level);
jksoft 0:76dfa9657d9d 109
jksoft 0:76dfa9657d9d 110 #endif // BLE_IAS_H__
jksoft 0:76dfa9657d9d 111
jksoft 0:76dfa9657d9d 112 /** @} */