SG RFID nRF51822 fork

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ble_lls.h Source File

ble_lls.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_lls Link Loss Service
00016  * @{
00017  * @ingroup ble_sdk_srv
00018  * @brief Link Loss Service module.
00019  *
00020  * @details This module implements the Link Loss Service with the Alert Level characteristic.
00021  *          During initialization it adds the Link Loss Service and Alert Level characteristic
00022  *          to the BLE stack database.
00023  *
00024  *          The application must supply an event handler for receiving Link Loss Service 
00025  *          events. Using this handler, the service will notify the application when the 
00026  *          link has been lost, and which Alert Level has been set.
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 Link Loss Service
00032  *       module by calling ble_lls_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_LLS_H__
00040 #define BLE_LLS_H__
00041 
00042 #include <stdint.h>
00043 #include "ble.h"
00044 #include "ble_srv_common.h "
00045 
00046 /**@brief Link Loss Service event type. */
00047 typedef enum
00048 {
00049     BLE_LLS_EVT_LINK_LOSS_ALERT                         /**< Alert Level Updated event. */
00050 } ble_lls_evt_type_t;
00051 
00052 /**@brief Link Loss Service event. */
00053 typedef struct
00054 {
00055     ble_lls_evt_type_t evt_type;                        /**< Type of event. */
00056     union
00057     {
00058         uint8_t alert_level;                            /**< New Alert Level value. */
00059     } params;
00060 } ble_lls_evt_t;
00061 
00062 // Forward declaration of the ble_lls_t type.
00063 typedef struct ble_lls_s ble_lls_t;
00064 
00065 /**@brief Link Loss Service event handler type. */
00066 typedef void (*ble_lls_evt_handler_t) (ble_lls_t * p_lls, ble_lls_evt_t * p_evt);
00067 
00068 /**@brief Link Loss Service init structure. This contains all options and data needed for initialization of the service. */
00069 typedef struct
00070 {
00071     ble_lls_evt_handler_t     evt_handler;              /**< Event handler to be called for handling events in the Link Loss Service. */
00072     ble_srv_error_handler_t   error_handler;            /**< Function to be called in case of an error. */
00073     uint8_t                   initial_alert_level;      /**< Initial value of the Alert Level characteristic. */
00074     ble_srv_security_mode_t   lls_attr_md;              /**< Initial Security Setting for Link Loss Service Characteristics. */
00075 } ble_lls_init_t;
00076 
00077 /**@brief Link Loss Service structure. This contains various status information for the service. */
00078 typedef struct ble_lls_s
00079 {
00080     ble_lls_evt_handler_t     evt_handler;              /**< Event handler to be called for handling events in the Link Loss Service. */
00081     ble_srv_error_handler_t   error_handler;            /**< Function to be called in case of an error. */
00082     uint16_t                  service_handle;           /**< Handle of Link Loss Service (as provided by the BLE stack). */
00083     ble_gatts_char_handles_t  alert_level_handles;      /**< Handles related to the Alert Level characteristic. */
00084 } ble_lls_t;
00085 
00086 /**@brief Function for initializing the Link Loss Service.
00087  *
00088  * @param[out]  p_lls       Link Loss Service structure. This structure will have to be supplied by
00089  *                          the application. It will be initialized by this function, and will later
00090  *                          be used to identify this particular service instance.
00091  * @param[in]   p_lls_init  Information needed to initialize the service.
00092  *
00093  * @return      NRF_SUCCESS on successful initialization of service, otherwise an error code.
00094  */
00095 uint32_t ble_lls_init(ble_lls_t * p_lls, const ble_lls_init_t * p_lls_init);
00096 
00097 /**@brief Function for handling the Application's BLE Stack events.
00098  *
00099  * @details Handles all events from the BLE stack of interest to the Link Loss Service.
00100  *
00101  * @param[in]   p_lls      Link Loss Service structure.
00102  * @param[in]   p_ble_evt  Event received from the BLE stack.
00103  */
00104 void ble_lls_on_ble_evt(ble_lls_t * p_lls, ble_evt_t * p_ble_evt);
00105 
00106 /**@brief Function for getting current value of the Alert Level characteristic.
00107  *
00108  * @param[in]   p_lls          Link Loss Service structure.
00109  * @param[out]  p_alert_level  Current Alert Level value.
00110  */
00111 uint32_t ble_lls_alert_level_get(ble_lls_t * p_lls, uint8_t * p_alert_level);
00112 
00113 #endif // BLE_LLS_H__
00114 
00115 /** @} */