Nordic stack and drivers for the mbed BLE API

Dependents:   idd_hw5_bleFanProto

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ble_ias.h Source File

ble_ias.h

Go to the documentation of this file.
00001 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
00002  *
00003  * The information contained herein is property of Nordic Semiconductor ASA.
00004  * Terms and conditions of usage are described in detail in NORDIC
00005  * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
00006  *
00007  * Licensees are granted free, non-transferable use of the information. NO
00008  * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
00009  * the file.
00010  *
00011  */
00012 
00013 /** @file
00014  *
00015  * @defgroup ble_sdk_srv_ias Immediate Alert Service
00016  * @{
00017  * @ingroup ble_sdk_srv
00018  * @brief Immediate Alert Service module.
00019  *
00020  * @details This module implements the Immediate Alert Service with the Alert Level characteristic.
00021  *          During initialization it adds the Immediate Alert Service and Alert Level characteristic
00022  *          to the BLE stack database.
00023  *
00024  *          The application must supply an event handler for receiving Immediate Alert Service 
00025  *          events. Using this handler, the service will notify the application when the 
00026  *          Alert Level characteristic value changes.
00027  *
00028  *          The service also provides a function for letting the application poll the current
00029  *          value of the Alert Level characteristic.
00030  *
00031  * @note The application must propagate BLE stack events to the Immediate Alert Service
00032  *       module by calling ble_ias_on_ble_evt() from the @ref ble_stack_handler callback.
00033  *
00034  * @note Attention! 
00035  *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 
00036  *  qualification listings, this section of source code must not be modified.
00037 */
00038 
00039 #ifndef BLE_IAS_H__
00040 #define BLE_IAS_H__
00041 
00042 #include <stdint.h>
00043 #include "ble.h"
00044 
00045 /**@brief Immediate Alert Service event type. */
00046 typedef enum
00047 {
00048     BLE_IAS_EVT_ALERT_LEVEL_UPDATED                     /**< Alert Level Updated event. */
00049 } ble_ias_evt_type_t;
00050 
00051 /**@brief Immediate Alert Service event. */
00052 typedef struct
00053 {
00054     ble_ias_evt_type_t evt_type;                        /**< Type of event. */
00055     union
00056     {
00057         uint8_t alert_level;                            /**< New Alert Level value. */
00058     } params;
00059 } ble_ias_evt_t;
00060 
00061 // Forward declaration of the ble_ias_t type. 
00062 typedef struct ble_ias_s ble_ias_t;
00063 
00064 /**@brief Immediate Alert Service event handler type. */
00065 typedef void (*ble_ias_evt_handler_t) (ble_ias_t * p_ias, ble_ias_evt_t * p_evt);
00066 
00067 /**@brief Immediate Alert Service init structure. This contains all options and data needed for
00068  *        initialization of the service. */
00069 typedef struct
00070 {
00071     ble_ias_evt_handler_t evt_handler;                  /**< Event handler to be called for handling events in the Immediate Alert Service. */
00072 } ble_ias_init_t;
00073 
00074 /**@brief Immediate Alert Service structure. This contains various status information for the
00075  *        service. */
00076 typedef struct ble_ias_s
00077 {
00078     ble_ias_evt_handler_t     evt_handler;              /**< Event handler to be called for handling events in the Immediate Alert Service. */
00079     uint16_t                  service_handle;           /**< Handle of Immediate Alert Service (as provided by the BLE stack). */
00080     ble_gatts_char_handles_t  alert_level_handles;      /**< Handles related to the Alert Level characteristic. */
00081 } ble_ias_t;
00082 
00083 /**@brief Function for initializing the Immediate Alert Service.
00084  *
00085  * @param[out]  p_ias       Immediate Alert Service structure. This structure will have to be
00086  *                          supplied by the application. It will be initialized by this function,
00087  *                          and will later be used to identify this particular service instance.
00088  * @param[in]   p_ias_init  Information needed to initialize the service.
00089  *
00090  * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
00091  */
00092 uint32_t ble_ias_init(ble_ias_t * p_ias, const ble_ias_init_t * p_ias_init);
00093 
00094 /**@brief Function for handling the Application's BLE Stack events.
00095  *
00096  * @details Handles all events from the BLE stack of interest to the Immediate Alert Service.
00097  *
00098  * @param[in]   p_ias      Immediate Alert Service structure.
00099  * @param[in]   p_ble_evt  Event received from the BLE stack.
00100  */
00101 void ble_ias_on_ble_evt(ble_ias_t * p_ias, ble_evt_t * p_ble_evt);
00102 
00103 /**@brief Function for getting current value of the Alert Level characteristic.
00104  *
00105  * @param[in]   p_ias          Immediate Alert Service structure.
00106  * @param[out]  p_alert_level  Current Alert Level value.
00107  */
00108 uint32_t ble_ias_alert_level_get(ble_ias_t * p_ias, uint8_t * p_alert_level);
00109 
00110 #endif // BLE_IAS_H__
00111 
00112 /** @} */