Battery Service (BAS).
More...
|
| enum | bt_bas_bcs_flags { BT_BAS_BCS_BATTERY_CRITICAL_STATE = BIT(0)
, BT_BAS_BCS_IMMEDIATE_SERVICE_REQUIRED = BIT(1)
} |
| | Battery Critical Status Characteristic flags. More...
|
| enum | bt_bas_bls_flags { BT_BAS_BLS_FLAG_IDENTIFIER_PRESENT = BIT(0)
, BT_BAS_BLS_FLAG_BATTERY_LEVEL_PRESENT = BIT(1)
, BT_BAS_BLS_FLAG_ADDITIONAL_STATUS_PRESENT = BIT(2)
} |
| | Battery Level Status Characteristic flags. More...
|
| enum | bt_bas_bls_battery_present { BT_BAS_BLS_BATTERY_NOT_PRESENT = 0
, BT_BAS_BLS_BATTERY_PRESENT = 1
} |
| | Battery Present Status. More...
|
| enum | bt_bas_bls_wired_power_source { BT_BAS_BLS_WIRED_POWER_NOT_CONNECTED = 0
, BT_BAS_BLS_WIRED_POWER_CONNECTED = 1
, BT_BAS_BLS_WIRED_POWER_UNKNOWN = 2
} |
| | Wired External Power Source Status. More...
|
| enum | bt_bas_bls_wireless_power_source { BT_BAS_BLS_WIRELESS_POWER_NOT_CONNECTED = 0
, BT_BAS_BLS_WIRELESS_POWER_CONNECTED = 1
, BT_BAS_BLS_WIRELESS_POWER_UNKNOWN = 2
} |
| | Wireless External Power Source Status. More...
|
| enum | bt_bas_bls_battery_charge_state { BT_BAS_BLS_CHARGE_STATE_UNKNOWN = 0
, BT_BAS_BLS_CHARGE_STATE_CHARGING = 1
, BT_BAS_BLS_CHARGE_STATE_DISCHARGING_ACTIVE = 2
, BT_BAS_BLS_CHARGE_STATE_DISCHARGING_INACTIVE = 3
} |
| | Battery Charge State. More...
|
| enum | bt_bas_bls_battery_charge_level { BT_BAS_BLS_CHARGE_LEVEL_UNKNOWN = 0
, BT_BAS_BLS_CHARGE_LEVEL_GOOD = 1
, BT_BAS_BLS_CHARGE_LEVEL_LOW = 2
, BT_BAS_BLS_CHARGE_LEVEL_CRITICAL = 3
} |
| | Battery Charge Level. More...
|
| enum | bt_bas_bls_battery_charge_type {
BT_BAS_BLS_CHARGE_TYPE_UNKNOWN = 0
, BT_BAS_BLS_CHARGE_TYPE_CONSTANT_CURRENT = 1
, BT_BAS_BLS_CHARGE_TYPE_CONSTANT_VOLTAGE = 2
, BT_BAS_BLS_CHARGE_TYPE_TRICKLE = 3
,
BT_BAS_BLS_CHARGE_TYPE_FLOAT = 4
} |
| | Battery Charge Type. More...
|
| enum | bt_bas_bls_charging_fault_reason { BT_BAS_BLS_FAULT_REASON_NONE = 0
, BT_BAS_BLS_FAULT_REASON_BATTERY = BIT(0)
, BT_BAS_BLS_FAULT_REASON_EXTERNAL_POWER = BIT(1)
, BT_BAS_BLS_FAULT_REASON_OTHER = BIT(2)
} |
| | Charging Fault Reason. More...
|
| enum | bt_bas_bls_service_required { BT_BAS_BLS_SERVICE_REQUIRED_FALSE = 0
, BT_BAS_BLS_SERVICE_REQUIRED_TRUE = 1
, BT_BAS_BLS_SERVICE_REQUIRED_UNKNOWN = 2
} |
| | Service Required Status. More...
|
| enum | bt_bas_bls_battery_fault { BT_BAS_BLS_BATTERY_FAULT_NO = 0
, BT_BAS_BLS_BATTERY_FAULT_YES = 1
} |
| | Battery Fault Status. More...
|
Battery Service (BAS).
[Experimental] Users should note that the APIs can change as a part of ongoing development.
◆ bt_bas_bcs_flags
#include <bas.h>
Battery Critical Status Characteristic flags.
Enumeration for the flags indicating the presence of various fields in the Battery Critical Status characteristic.
| Enumerator |
|---|
| BT_BAS_BCS_BATTERY_CRITICAL_STATE | Battery Critical Status Bit 0: Critical Power State.
|
| BT_BAS_BCS_IMMEDIATE_SERVICE_REQUIRED | Battery Critical Status Bit 1: Immediate Service Required.
|
◆ bt_bas_bls_battery_charge_level
#include <bas.h>
Battery Charge Level.
Enumeration for the level of charge in the battery.
| Enumerator |
|---|
| BT_BAS_BLS_CHARGE_LEVEL_UNKNOWN | Battery charge level is unknown.
|
| BT_BAS_BLS_CHARGE_LEVEL_GOOD | Battery charge level is good.
|
| BT_BAS_BLS_CHARGE_LEVEL_LOW | Battery charge level is low.
|
| BT_BAS_BLS_CHARGE_LEVEL_CRITICAL | Battery charge level is critical.
|
◆ bt_bas_bls_battery_charge_state
#include <bas.h>
Battery Charge State.
Enumeration for the charge state of the battery.
| Enumerator |
|---|
| BT_BAS_BLS_CHARGE_STATE_UNKNOWN | Battery charge state is unknown.
|
| BT_BAS_BLS_CHARGE_STATE_CHARGING | Battery is currently charging.
|
| BT_BAS_BLS_CHARGE_STATE_DISCHARGING_ACTIVE | Battery is discharging actively.
|
| BT_BAS_BLS_CHARGE_STATE_DISCHARGING_INACTIVE | Battery is discharging but inactive.
|
◆ bt_bas_bls_battery_charge_type
#include <bas.h>
Battery Charge Type.
Enumeration for the type of charging applied to the battery.
| Enumerator |
|---|
| BT_BAS_BLS_CHARGE_TYPE_UNKNOWN | Battery charge type is unknown or not charging.
|
| BT_BAS_BLS_CHARGE_TYPE_CONSTANT_CURRENT | Battery is charged using constant current.
|
| BT_BAS_BLS_CHARGE_TYPE_CONSTANT_VOLTAGE | Battery is charged using constant voltage.
|
| BT_BAS_BLS_CHARGE_TYPE_TRICKLE | Battery is charged using trickle charge.
|
| BT_BAS_BLS_CHARGE_TYPE_FLOAT | Battery is charged using float charge.
|
◆ bt_bas_bls_battery_fault
#include <bas.h>
Battery Fault Status.
Enumeration for the fault status of the battery.
| Enumerator |
|---|
| BT_BAS_BLS_BATTERY_FAULT_NO | No battery fault.
|
| BT_BAS_BLS_BATTERY_FAULT_YES | Battery fault present.
|
◆ bt_bas_bls_battery_present
#include <bas.h>
Battery Present Status.
Enumeration for the presence of the battery.
| Enumerator |
|---|
| BT_BAS_BLS_BATTERY_NOT_PRESENT | Battery is not present.
|
| BT_BAS_BLS_BATTERY_PRESENT | Battery is present.
|
◆ bt_bas_bls_charging_fault_reason
#include <bas.h>
Charging Fault Reason.
Enumeration for the reasons of charging faults.
| Enumerator |
|---|
| BT_BAS_BLS_FAULT_REASON_NONE | No charging fault.
|
| BT_BAS_BLS_FAULT_REASON_BATTERY | Charging fault due to battery issue.
|
| BT_BAS_BLS_FAULT_REASON_EXTERNAL_POWER | Charging fault due to external power source issue.
|
| BT_BAS_BLS_FAULT_REASON_OTHER | Charging fault for other reasons.
|
◆ bt_bas_bls_flags
#include <bas.h>
Battery Level Status Characteristic flags.
Enumeration for the flags indicating the presence of various fields in the Battery Level Status characteristic.
| Enumerator |
|---|
| BT_BAS_BLS_FLAG_IDENTIFIER_PRESENT | Bit indicating that the Battery Level Status identifier is present.
|
| BT_BAS_BLS_FLAG_BATTERY_LEVEL_PRESENT | Bit indicating that the Battery Level is present.
|
| BT_BAS_BLS_FLAG_ADDITIONAL_STATUS_PRESENT | Bit indicating that additional status information is present.
|
◆ bt_bas_bls_service_required
#include <bas.h>
Service Required Status.
Enumeration for whether the service is required.
| Enumerator |
|---|
| BT_BAS_BLS_SERVICE_REQUIRED_FALSE | Service is not required.
|
| BT_BAS_BLS_SERVICE_REQUIRED_TRUE | Service is required.
|
| BT_BAS_BLS_SERVICE_REQUIRED_UNKNOWN | Service requirement is unknown.
|
◆ bt_bas_bls_wired_power_source
#include <bas.h>
Wired External Power Source Status.
Enumeration for the status of the wired external power source.
| Enumerator |
|---|
| BT_BAS_BLS_WIRED_POWER_NOT_CONNECTED | Wired external power source is not connected.
|
| BT_BAS_BLS_WIRED_POWER_CONNECTED | Wired external power source is connected.
|
| BT_BAS_BLS_WIRED_POWER_UNKNOWN | Wired external power source status is unknown.
|
◆ bt_bas_bls_wireless_power_source
#include <bas.h>
Wireless External Power Source Status.
Enumeration for the status of the wireless external power source.
| Enumerator |
|---|
| BT_BAS_BLS_WIRELESS_POWER_NOT_CONNECTED | Wireless external power source is not connected.
|
| BT_BAS_BLS_WIRELESS_POWER_CONNECTED | Wireless external power source is connected.
|
| BT_BAS_BLS_WIRELESS_POWER_UNKNOWN | Wireless external power source status is unknown.
|
◆ bt_bas_bls_set_battery_charge_level()
#include <bas.h>
Set the battery charge level.
- Parameters
-
| level | The battery charge level to set. |
◆ bt_bas_bls_set_battery_charge_state()
#include <bas.h>
Set the battery charge state.
- Parameters
-
| state | The battery charge state to set. |
◆ bt_bas_bls_set_battery_charge_type()
#include <bas.h>
Set the battery charge type.
- Parameters
-
| type | The battery charge type to set. |
◆ bt_bas_bls_set_battery_fault()
#include <bas.h>
Set the battery fault status.
- Attention
- Available only when the following Kconfig option is enabled:
CONFIG_BT_BAS_BLS_ADDITIONAL_STATUS_PRESENT
.
- Parameters
-
| value | Battery fault status to set. |
◆ bt_bas_bls_set_battery_present()
#include <bas.h>
Set the battery present status.
- Parameters
-
| present | The battery present status to set. |
◆ bt_bas_bls_set_charging_fault_reason()
#include <bas.h>
Set the charging fault reason.
- Parameters
-
| reason | The charging fault reason to set. |
◆ bt_bas_bls_set_identifier()
| void bt_bas_bls_set_identifier |
( |
uint16_t | identifier | ) |
|
#include <bas.h>
Set the identifier of the battery.
- Attention
- Available only when the following Kconfig option is enabled:
CONFIG_BT_BAS_BLS_IDENTIFIER_PRESENT
.
- Parameters
-
| identifier | Identifier to set. |
◆ bt_bas_bls_set_service_required()
#include <bas.h>
Set the service required status.
- Attention
- Available only when the following Kconfig option is enabled:
CONFIG_BT_BAS_BLS_ADDITIONAL_STATUS_PRESENT
.
- Parameters
-
| value | Service required status to set. |
◆ bt_bas_bls_set_wired_external_power_source()
#include <bas.h>
Set the wired external power source status.
- Parameters
-
| source | The wired external power source status to set. |
◆ bt_bas_bls_set_wireless_external_power_source()
#include <bas.h>
Set the wireless external power source status.
- Parameters
-
| source | The wireless external power source status to set. |
◆ bt_bas_get_battery_level()
| uint8_t bt_bas_get_battery_level |
( |
void | | ) |
|
#include <bas.h>
Read battery level value.
Read the characteristic value of the battery level
- Returns
- The battery level in percent.
◆ bt_bas_set_battery_level()
| int bt_bas_set_battery_level |
( |
uint8_t | level | ) |
|
#include <bas.h>
Update battery level value.
Update the characteristic value of the battery level This will send a GATT notification to all current subscribers.
- Parameters
-
| level | The battery level in percent. |
- Returns
- Zero in case of success and error code in case of error.