|
| 1 | +/* |
| 2 | + * Copyright (c) 2024 Demant A/S |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +#ifndef BTP_BAS_H_ |
| 8 | +#define BTP_BAS_H_ |
| 9 | + |
| 10 | +#include <stdint.h> |
| 11 | +#include <stddef.h> |
| 12 | + |
| 13 | +/* BTP BAS Service Opcodes */ |
| 14 | +#define BTP_BAS_READ_SUPPORTED_COMMANDS 0x01 |
| 15 | +#define BTP_BAS_SET_BATTERY_LEVEL 0x02 |
| 16 | +#define BTP_BAS_BLS_SET_BATTERY_PRESENT 0x03 |
| 17 | +#define BTP_BAS_BLS_SET_WIRED_POWER_SOURCE 0x04 |
| 18 | +#define BTP_BAS_BLS_SET_WIRELESS_POWER_SOURCE 0x05 |
| 19 | +#define BTP_BAS_BLS_SET_BATTERY_CHARGE_STATE 0x06 |
| 20 | +#define BTP_BAS_BLS_SET_BATTERY_CHARGE_LEVEL 0x07 |
| 21 | +#define BTP_BAS_BLS_SET_BATTERY_CHARGE_TYPE 0x08 |
| 22 | +#define BTP_BAS_BLS_SET_CHARGING_FAULT_REASON 0x09 |
| 23 | +#define BTP_BAS_BLS_SET_IDENTIFIER 0x0A |
| 24 | +#define BTP_BAS_BLS_SET_SERVICE_REQUIRED 0x0B |
| 25 | +#define BTP_BAS_BLS_SET_BATTERY_FAULT 0x0C |
| 26 | + |
| 27 | +/* Command structures */ |
| 28 | +struct btp_bas_read_supported_commands_rp { |
| 29 | + uint8_t data[0]; |
| 30 | +} __packed; |
| 31 | + |
| 32 | +struct btp_bas_set_battery_level_cmd { |
| 33 | + uint8_t level; |
| 34 | +} __packed; |
| 35 | + |
| 36 | +struct btp_bas_bls_set_battery_present_cmd { |
| 37 | + uint8_t present; |
| 38 | +} __packed; |
| 39 | + |
| 40 | +struct btp_bas_bls_set_wired_power_source_cmd { |
| 41 | + uint8_t source; |
| 42 | +} __packed; |
| 43 | + |
| 44 | +struct btp_bas_bls_set_wireless_power_source_cmd { |
| 45 | + uint8_t source; |
| 46 | +} __packed; |
| 47 | + |
| 48 | +struct btp_bas_bls_set_battery_charge_state_cmd { |
| 49 | + uint8_t state; |
| 50 | +} __packed; |
| 51 | + |
| 52 | +struct btp_bas_bls_set_battery_charge_level_cmd { |
| 53 | + uint8_t level; |
| 54 | +} __packed; |
| 55 | + |
| 56 | +struct btp_bas_bls_set_battery_charge_type_cmd { |
| 57 | + uint8_t type; |
| 58 | +} __packed; |
| 59 | + |
| 60 | +struct btp_bas_bls_set_charging_fault_reason_cmd { |
| 61 | + uint8_t reason; |
| 62 | +} __packed; |
| 63 | + |
| 64 | +struct btp_bas_bls_set_identifier_cmd { |
| 65 | + uint16_t identifier; |
| 66 | +} __packed; |
| 67 | + |
| 68 | +struct btp_bas_bls_set_service_required_cmd { |
| 69 | + uint8_t service_required; |
| 70 | +} __packed; |
| 71 | + |
| 72 | +struct btp_bas_bls_set_battery_fault_cmd { |
| 73 | + uint8_t battery_fault; |
| 74 | +} __packed; |
| 75 | + |
| 76 | +/** |
| 77 | + * @brief Initialize the Battery Service (BAS) tester. |
| 78 | + * |
| 79 | + * @return Status of the initialization. Returns `BTP_STATUS_SUCCESS` |
| 80 | + * if the initialization is successful. Other values indicate failure. |
| 81 | + */ |
| 82 | +uint8_t tester_init_bas(void); |
| 83 | + |
| 84 | +/** |
| 85 | + * @brief Unregister the Battery Service (BAS) tester. |
| 86 | + * |
| 87 | + * @return Status of the unregistration. Returns `BTP_STATUS_SUCCESS` |
| 88 | + * if the unregistration is successful. Other values indicate failure. |
| 89 | + */ |
| 90 | +uint8_t tester_unregister_bas(void); |
| 91 | + |
| 92 | +#endif /* BTP_BAS_H_ */ |
0 commit comments