Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the BAS CPF PR for split battery work #27

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions subsys/bluetooth/services/bas.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ static ssize_t read_blvl(struct bt_conn *conn,
sizeof(lvl8));
}

/* Constant values from the Assigned Numbers specification:
* https://www.bluetooth.com/wp-content/uploads/Files/Specification/Assigned_Numbers.pdf?id=89
*/
static const struct bt_gatt_cpf level_cpf = {
.format = 0x04, /* uint8 */
.exponent = 0x0,
.unit = 0x27AD, /* Percentage */
.name_space = 0x01, /* Bluetooth SIG */
.description = 0x0106, /* "main" */
};

BT_GATT_SERVICE_DEFINE(bas,
BT_GATT_PRIMARY_SERVICE(BT_UUID_BAS),
BT_GATT_CHARACTERISTIC(BT_UUID_BAS_BATTERY_LEVEL,
Expand All @@ -55,6 +66,7 @@ BT_GATT_SERVICE_DEFINE(bas,
&battery_level),
BT_GATT_CCC(blvl_ccc_cfg_changed,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
BT_GATT_CPF(&level_cpf),
);

static int bas_init(const struct device *dev)
Expand Down
Loading