Low power Bluetooth 4.0BLE programming-nrf51822 Development (6)-battery Service

Source: Internet
Author: User

The Battery service is about battery characteristics, and if it is needed, it is added to the Bluetooth protocol stack at initialization time.

If the battery level is notified via Ble_bas_battery_level_update (), the battery service sends the event to the application.

(1) Battery Service event Type

[CPP]  View plain copy/** @brief  Battery Service event type. */   typedef  enum   {       BLE_BAS_EVT_NOTIFICATION_ENABLED,                               /**< Battery value notification enabled  event. */       BLE_BAS_EVT_NOTIFICATION_DISABLED                               /**< battery value notification disabled  event. */  } ble_bas_evt_type_t;     /** @brief  Battery  service event. */   typedef struct   {  (2) Battery Service event handler function

[CPP] view plain copy//Forward declaration of the ble_bas_t type.      typedef struct BLE_BAS_S ble_bas_t; /** @brief Battery Service event handler type.   * * typedef void (*ble_bas_evt_handler_t) (ble_bas_t * P_bas, ble_bas_evt_t * p_evt); (3) ble_bas_init_t: Initialization of the structure used

[CPP]  View plain copy/** @brief  Battery Service init structure. This contains  all options and data needed for   *         initialization of the service.*/   typedef struct   {        ble_bas_evt_handler_t         evt_ handler;                     /**< Event handler to be called for handling  events in the battery service. */       bool                            support_notification;            /**< true if notification of battery level measurement is  supported. */       ble_srv_report_ref_t *         p_report_ref;                    /**< If not NULL, a Report  Reference descriptor with the specified value will be added to  the Battery Level characteristic */       uint8_t                         initial_batt_level;              /**< Initial battery level */       ble_srv_ Cccd_security_mode_t  baTtery_level_char_attr_md;     /**< initial security level for  battery characteristics attribute */       ble_gap_conn_sec_ Mode_t       battery_level_report_read_perm; /**< initial  security level for battery report read attribute */  }  ble_bas_in (4) structural body ble_bas_t with variable state information:

[CPP] view plain copy/** @brief Battery Service structure. This contains various status information for the service.                    */typedef struct BLE_BAS_S {ble_bas_evt_handler_t evt_handler; /**< Event Handler to is called for handling events in the Battery Service. */uint16_t

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.