tree: 3933ad396407d3bf0d4a78348a3671d243bbe746 [path history] [tgz]
  1. config/
  2. meta/
  3. src/
  4. BUILD.gn
  5. README.md
src/connectivity/bluetooth/examples/bt-le-battery-service/README.md

BT LE Battery Service

This example demonstrates how to publish the system's battery level in a GATT battery service. When run, it adds the service to the local device database. It then responds to clients that make requests to this GATT service.

Build

The bt-le-battery-service relies on the fuchsia.bluetooth.gatt2.Server capability to publish a GATT server. It also relies on the fuchsia.power.battery.BatteryManager capability to receive updates about the system's battery level.

Add the example to your Fuchsia configuration. Note, because the component is eagerly started, make sure to include the package in the cached set of packages. For example, for the workstation configuration, add the bt-le-battery-service to the legacy_cache_package_labels.

Include the example core_shard in your target product configuration. For example, for the workstation configuration, add the core shard to the core_realm_shards list in workstation.gni.

Component configuration

The security level of the published GATT battery service can be configured via structured configuration. Update the default configuration file with the desired security level.

Component startup

The example bt-le-battery-service is implemented as a Component Framework v2 component. This component is eagerly started on device boot. To start the service, reboot the device.