![](/media/cache/profiles/5f14615696649541a025d3d0f8e0447f.jpg.50x50_q85.jpg)
テスト用です。
nRF51822_wallbot/nordic/nrf-sdk/ble/ble_services/ble_lls.h@0:8468a4403fea, 2016-10-11 (annotated)
- Committer:
- jksoft
- Date:
- Tue Oct 11 11:09:42 2016 +0000
- Revision:
- 0:8468a4403fea
SB??ver;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:8468a4403fea | 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. |
jksoft | 0:8468a4403fea | 2 | * |
jksoft | 0:8468a4403fea | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
jksoft | 0:8468a4403fea | 4 | * Terms and conditions of usage are described in detail in NORDIC |
jksoft | 0:8468a4403fea | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
jksoft | 0:8468a4403fea | 6 | * |
jksoft | 0:8468a4403fea | 7 | * Licensees are granted free, non-transferable use of the information. NO |
jksoft | 0:8468a4403fea | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
jksoft | 0:8468a4403fea | 9 | * the file. |
jksoft | 0:8468a4403fea | 10 | * |
jksoft | 0:8468a4403fea | 11 | */ |
jksoft | 0:8468a4403fea | 12 | |
jksoft | 0:8468a4403fea | 13 | /** @file |
jksoft | 0:8468a4403fea | 14 | * |
jksoft | 0:8468a4403fea | 15 | * @defgroup ble_sdk_srv_lls Link Loss Service |
jksoft | 0:8468a4403fea | 16 | * @{ |
jksoft | 0:8468a4403fea | 17 | * @ingroup ble_sdk_srv |
jksoft | 0:8468a4403fea | 18 | * @brief Link Loss Service module. |
jksoft | 0:8468a4403fea | 19 | * |
jksoft | 0:8468a4403fea | 20 | * @details This module implements the Link Loss Service with the Alert Level characteristic. |
jksoft | 0:8468a4403fea | 21 | * During initialization it adds the Link Loss Service and Alert Level characteristic |
jksoft | 0:8468a4403fea | 22 | * to the BLE stack database. |
jksoft | 0:8468a4403fea | 23 | * |
jksoft | 0:8468a4403fea | 24 | * The application must supply an event handler for receiving Link Loss Service |
jksoft | 0:8468a4403fea | 25 | * events. Using this handler, the service will notify the application when the |
jksoft | 0:8468a4403fea | 26 | * link has been lost, and which Alert Level has been set. |
jksoft | 0:8468a4403fea | 27 | * |
jksoft | 0:8468a4403fea | 28 | * The service also provides a function for letting the application poll the current |
jksoft | 0:8468a4403fea | 29 | * value of the Alert Level characteristic. |
jksoft | 0:8468a4403fea | 30 | * |
jksoft | 0:8468a4403fea | 31 | * @note The application must propagate BLE stack events to the Link Loss Service |
jksoft | 0:8468a4403fea | 32 | * module by calling ble_lls_on_ble_evt() from the @ref ble_stack_handler callback. |
jksoft | 0:8468a4403fea | 33 | * |
jksoft | 0:8468a4403fea | 34 | * @note Attention! |
jksoft | 0:8468a4403fea | 35 | * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile |
jksoft | 0:8468a4403fea | 36 | * qualification listings, this section of source code must not be modified. |
jksoft | 0:8468a4403fea | 37 | */ |
jksoft | 0:8468a4403fea | 38 | |
jksoft | 0:8468a4403fea | 39 | #ifndef BLE_LLS_H__ |
jksoft | 0:8468a4403fea | 40 | #define BLE_LLS_H__ |
jksoft | 0:8468a4403fea | 41 | |
jksoft | 0:8468a4403fea | 42 | #include <stdint.h> |
jksoft | 0:8468a4403fea | 43 | #include "ble.h" |
jksoft | 0:8468a4403fea | 44 | #include "ble_srv_common.h" |
jksoft | 0:8468a4403fea | 45 | |
jksoft | 0:8468a4403fea | 46 | /**@brief Link Loss Service event type. */ |
jksoft | 0:8468a4403fea | 47 | typedef enum |
jksoft | 0:8468a4403fea | 48 | { |
jksoft | 0:8468a4403fea | 49 | BLE_LLS_EVT_LINK_LOSS_ALERT /**< Alert Level Updated event. */ |
jksoft | 0:8468a4403fea | 50 | } ble_lls_evt_type_t; |
jksoft | 0:8468a4403fea | 51 | |
jksoft | 0:8468a4403fea | 52 | /**@brief Link Loss Service event. */ |
jksoft | 0:8468a4403fea | 53 | typedef struct |
jksoft | 0:8468a4403fea | 54 | { |
jksoft | 0:8468a4403fea | 55 | ble_lls_evt_type_t evt_type; /**< Type of event. */ |
jksoft | 0:8468a4403fea | 56 | union |
jksoft | 0:8468a4403fea | 57 | { |
jksoft | 0:8468a4403fea | 58 | uint8_t alert_level; /**< New Alert Level value. */ |
jksoft | 0:8468a4403fea | 59 | } params; |
jksoft | 0:8468a4403fea | 60 | } ble_lls_evt_t; |
jksoft | 0:8468a4403fea | 61 | |
jksoft | 0:8468a4403fea | 62 | // Forward declaration of the ble_lls_t type. |
jksoft | 0:8468a4403fea | 63 | typedef struct ble_lls_s ble_lls_t; |
jksoft | 0:8468a4403fea | 64 | |
jksoft | 0:8468a4403fea | 65 | /**@brief Link Loss Service event handler type. */ |
jksoft | 0:8468a4403fea | 66 | typedef void (*ble_lls_evt_handler_t) (ble_lls_t * p_lls, ble_lls_evt_t * p_evt); |
jksoft | 0:8468a4403fea | 67 | |
jksoft | 0:8468a4403fea | 68 | /**@brief Link Loss Service init structure. This contains all options and data needed for initialization of the service. */ |
jksoft | 0:8468a4403fea | 69 | typedef struct |
jksoft | 0:8468a4403fea | 70 | { |
jksoft | 0:8468a4403fea | 71 | ble_lls_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Link Loss Service. */ |
jksoft | 0:8468a4403fea | 72 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
jksoft | 0:8468a4403fea | 73 | uint8_t initial_alert_level; /**< Initial value of the Alert Level characteristic. */ |
jksoft | 0:8468a4403fea | 74 | ble_srv_security_mode_t lls_attr_md; /**< Initial Security Setting for Link Loss Service Characteristics. */ |
jksoft | 0:8468a4403fea | 75 | } ble_lls_init_t; |
jksoft | 0:8468a4403fea | 76 | |
jksoft | 0:8468a4403fea | 77 | /**@brief Link Loss Service structure. This contains various status information for the service. */ |
jksoft | 0:8468a4403fea | 78 | typedef struct ble_lls_s |
jksoft | 0:8468a4403fea | 79 | { |
jksoft | 0:8468a4403fea | 80 | ble_lls_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Link Loss Service. */ |
jksoft | 0:8468a4403fea | 81 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
jksoft | 0:8468a4403fea | 82 | uint16_t service_handle; /**< Handle of Link Loss Service (as provided by the BLE stack). */ |
jksoft | 0:8468a4403fea | 83 | ble_gatts_char_handles_t alert_level_handles; /**< Handles related to the Alert Level characteristic. */ |
jksoft | 0:8468a4403fea | 84 | } ble_lls_t; |
jksoft | 0:8468a4403fea | 85 | |
jksoft | 0:8468a4403fea | 86 | /**@brief Function for initializing the Link Loss Service. |
jksoft | 0:8468a4403fea | 87 | * |
jksoft | 0:8468a4403fea | 88 | * @param[out] p_lls Link Loss Service structure. This structure will have to be supplied by |
jksoft | 0:8468a4403fea | 89 | * the application. It will be initialized by this function, and will later |
jksoft | 0:8468a4403fea | 90 | * be used to identify this particular service instance. |
jksoft | 0:8468a4403fea | 91 | * @param[in] p_lls_init Information needed to initialize the service. |
jksoft | 0:8468a4403fea | 92 | * |
jksoft | 0:8468a4403fea | 93 | * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. |
jksoft | 0:8468a4403fea | 94 | */ |
jksoft | 0:8468a4403fea | 95 | uint32_t ble_lls_init(ble_lls_t * p_lls, const ble_lls_init_t * p_lls_init); |
jksoft | 0:8468a4403fea | 96 | |
jksoft | 0:8468a4403fea | 97 | /**@brief Function for handling the Application's BLE Stack events. |
jksoft | 0:8468a4403fea | 98 | * |
jksoft | 0:8468a4403fea | 99 | * @details Handles all events from the BLE stack of interest to the Link Loss Service. |
jksoft | 0:8468a4403fea | 100 | * |
jksoft | 0:8468a4403fea | 101 | * @param[in] p_lls Link Loss Service structure. |
jksoft | 0:8468a4403fea | 102 | * @param[in] p_ble_evt Event received from the BLE stack. |
jksoft | 0:8468a4403fea | 103 | */ |
jksoft | 0:8468a4403fea | 104 | void ble_lls_on_ble_evt(ble_lls_t * p_lls, ble_evt_t * p_ble_evt); |
jksoft | 0:8468a4403fea | 105 | |
jksoft | 0:8468a4403fea | 106 | /**@brief Function for getting current value of the Alert Level characteristic. |
jksoft | 0:8468a4403fea | 107 | * |
jksoft | 0:8468a4403fea | 108 | * @param[in] p_lls Link Loss Service structure. |
jksoft | 0:8468a4403fea | 109 | * @param[out] p_alert_level Current Alert Level value. |
jksoft | 0:8468a4403fea | 110 | */ |
jksoft | 0:8468a4403fea | 111 | uint32_t ble_lls_alert_level_get(ble_lls_t * p_lls, uint8_t * p_alert_level); |
jksoft | 0:8468a4403fea | 112 | |
jksoft | 0:8468a4403fea | 113 | #endif // BLE_LLS_H__ |
jksoft | 0:8468a4403fea | 114 | |
jksoft | 0:8468a4403fea | 115 | /** @} */ |