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