1 /** @file 2 * @brief Internal APIs for Bluetooth VOCS. 3 * 4 * Copyright (c) 2020 Bose Corporation 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 9 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_VOCS_INTERNAL_ 10 #define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_VOCS_INTERNAL_ 11 #include <zephyr/types.h> 12 13 #if defined(CONFIG_BT_VOCS) 14 #define BT_VOCS_MAX_DESC_SIZE CONFIG_BT_VOCS_MAX_OUTPUT_DESCRIPTION_SIZE 15 #else 16 #define BT_VOCS_MAX_DESC_SIZE 1 17 #endif /* CONFIG_BT_VOCS */ 18 19 /* VOCS opcodes */ 20 #define BT_VOCS_OPCODE_SET_OFFSET 0x01 21 22 struct bt_vocs_control { 23 uint8_t opcode; 24 uint8_t counter; 25 int16_t offset; 26 } __packed; 27 28 struct bt_vocs_state { 29 int16_t offset; 30 uint8_t change_counter; 31 } __packed; 32 33 struct bt_vocs_client { 34 struct bt_vocs_state state; 35 bool location_writable; 36 uint32_t location; 37 bool desc_writable; 38 bool active; 39 40 uint16_t start_handle; 41 uint16_t end_handle; 42 uint16_t state_handle; 43 uint16_t location_handle; 44 uint16_t control_handle; 45 uint16_t desc_handle; 46 struct bt_gatt_subscribe_params state_sub_params; 47 struct bt_gatt_subscribe_params location_sub_params; 48 struct bt_gatt_subscribe_params desc_sub_params; 49 uint8_t subscribe_cnt; 50 bool cp_retried; 51 52 bool busy; 53 struct bt_vocs_control cp; 54 struct bt_gatt_write_params write_params; 55 struct bt_gatt_read_params read_params; 56 struct bt_vocs_cb *cb; 57 struct bt_gatt_discover_params discover_params; 58 struct bt_conn *conn; 59 }; 60 61 struct bt_vocs_server { 62 struct bt_vocs_state state; 63 uint32_t location; 64 bool initialized; 65 char output_desc[BT_VOCS_MAX_DESC_SIZE]; 66 struct bt_vocs_cb *cb; 67 68 struct bt_gatt_service *service_p; 69 }; 70 71 struct bt_vocs { 72 bool client_instance; 73 union { 74 struct bt_vocs_server srv; 75 struct bt_vocs_client cli; 76 }; 77 }; 78 79 int bt_vocs_client_state_get(struct bt_vocs *inst); 80 int bt_vocs_client_state_set(struct bt_vocs *inst, int16_t offset); 81 int bt_vocs_client_location_get(struct bt_vocs *inst); 82 int bt_vocs_client_location_set(struct bt_vocs *inst, uint32_t location); 83 int bt_vocs_client_description_get(struct bt_vocs *inst); 84 int bt_vocs_client_description_set(struct bt_vocs *inst, 85 const char *description); 86 87 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_VOCS_INTERNAL_ */ 88