1 /** 2 ***************************************************************************************** 3 * 4 * @file ias.h 5 * 6 * @brief Immediate Alarm Service API 7 * 8 ***************************************************************************************** 9 * @attention 10 #####Copyright (c) 2019 GOODIX 11 All rights reserved. 12 13 Redistribution and use in source and binary forms, with or without 14 modification, are permitted provided that the following conditions are met: 15 * Redistributions of source code must retain the above copyright 16 notice, this list of conditions and the following disclaimer. 17 * Redistributions in binary form must reproduce the above copyright 18 notice, this list of conditions and the following disclaimer in the 19 documentation and/or other materials provided with the distribution. 20 * Neither the name of GOODIX nor the names of its contributors may be used 21 to endorse or promote products derived from this software without 22 specific prior written permission. 23 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 POSSIBILITY OF SUCH DAMAGE. 35 ***************************************************************************************** 36 */ 37 38 /** 39 * @addtogroup BLE_SRV BLE Services 40 * @{ 41 * @brief Definitions and prototypes for the BLE Service interface. 42 */ 43 44 /** 45 * @defgroup BLE_SDK_IAS Immediate Alarm Service (IAS) 46 * @{ 47 * @brief Definitions and prototypes for the IAS interface. 48 * 49 * @details The Immediate Alert Service exposes a control point to allow a peer device to cause 50 * the device to immediately alert. 51 * 52 * The application must provide an event handler to set \ref ias_init_t.evt_handler. 53 * After \ref ias_init_t variable is initialized, the application must call \ref ias_service_init() 54 * to add the Immediate Alert Service and Alert Level characteristic to the BLE Stack database, 55 * the service will notify the application when the value of Alert Level characteristic is changed 56 * by the peer device. 57 * 58 * This module also provides \ref ias_alert_level_get() function to the 59 * application to poll the current value of Alert Level characteristic. 60 * 61 */ 62 63 #ifndef __IAS_H__ 64 #define __IAS_H__ 65 66 #include <stdint.h> 67 #include "gr55xx_sys.h" 68 #include "custom_config.h" 69 70 /** 71 * @defgroup IAS_ENUM Enumerations 72 * @{ 73 */ 74 /**@brief Immediate Alert Service Alert levels. */ 75 enum { 76 IAS_ALERT_NONE, /**< No alert. */ 77 IAS_ALERT_MILD, /**< Mild alert. */ 78 IAS_ALERT_HIGH, /**< High alert. */ 79 }; 80 81 /**@brief Immediate Alert Service event type. */ 82 typedef enum { 83 IAS_EVT_INVALID, /**< Invalid IAS event. */ 84 IAS_EVT_ALERT_LEVEL_UPDATED, /**< Alert Level Updated event. */ 85 } ias_evt_type_t; 86 /** @} */ 87 88 /** 89 * @defgroup IAS_STRUCT Structures 90 * @{ 91 */ 92 /**@brief Immediate Alert Service event. */ 93 typedef struct { 94 ias_evt_type_t evt_type; /**< Type of event. */ 95 uint8_t alert_level; /**< New value of Alert level. */ 96 } ias_evt_t; 97 /** @} */ 98 99 /** 100 * @defgroup IAS_TYPEDEF Typedefs 101 * @{ 102 */ 103 /**@brief Immediate Alert Service event handler type. */ 104 typedef void (*ias_evt_handler_t)(ias_evt_t *p_evt); 105 /** @} */ 106 107 /** 108 * @addtogroup IAS_STRUCT Structures 109 * @{ 110 */ 111 /**@brief Immediate Alert Service init stucture. 112 * This contains all option and data needed for initialization of the service. */ 113 typedef struct { 114 ias_evt_handler_t evt_handler; /**< Immediate Alert Service event handler. */ 115 } ias_init_t; 116 /** @} */ 117 118 /** 119 * @defgroup IAS_FUNCTION Functions 120 * @{ 121 */ 122 /** 123 ***************************************************************************************** 124 * @brief Initialize a Immediate Alert Service instance and add in the BLE Stack database. 125 * 126 * @param[in] p_ias_init: Pointer to Immediate Aler Service initialization variable. 127 * 128 * @return Result of service initialization. 129 ***************************************************************************************** 130 */ 131 sdk_err_t ias_service_init(ias_init_t *p_ias_init); 132 133 /** 134 ***************************************************************************************** 135 * @brief Get current value of alert level characteristic. 136 * 137 * @param[out] p_alert_level: Pointer to the current value of alert level. 138 * 139 * @return BLE_SDK_SUCCESS on success, otherwise an error code. 140 ***************************************************************************************** 141 */ 142 sdk_err_t ias_alert_level_get(uint8_t *p_alert_level); 143 /** @} */ 144 145 #endif 146 /** @} */ 147 /** @} */ 148