1 /****************************************************************************** 2 * 3 * Copyright 2014 Google, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 #pragma once 20 21 #include <stdbool.h> 22 #include <stdint.h> 23 24 #include "bt_types.h" 25 #include "bt_vendor_lib.h" 26 #include "hci_internals.h" 27 #include "hci_layer.h" 28 29 typedef enum { 30 VENDOR_CHIP_POWER_CONTROL = BT_VND_OP_POWER_CTRL, 31 VENDOR_OPEN_USERIAL = BT_VND_OP_USERIAL_OPEN, 32 VENDOR_CLOSE_USERIAL = BT_VND_OP_USERIAL_CLOSE, 33 VENDOR_GET_LPM_IDLE_TIMEOUT = BT_VND_OP_GET_LPM_IDLE_TIMEOUT, 34 VENDOR_SET_LPM_WAKE_STATE = BT_VND_OP_LPM_WAKE_SET_STATE, 35 VENDOR_SET_AUDIO_STATE = BT_VND_OP_SET_AUDIO_STATE 36 } vendor_opcode_t; 37 38 typedef enum { 39 VENDOR_CONFIGURE_FIRMWARE = BT_VND_OP_FW_CFG, 40 VENDOR_CONFIGURE_SCO = BT_VND_OP_SCO_CFG, 41 VENDOR_SET_LPM_MODE = BT_VND_OP_LPM_SET_MODE, 42 VENDOR_DO_EPILOG = BT_VND_OP_EPILOG, 43 VENDOR_A2DP_OFFLOAD_START = BT_VND_OP_A2DP_OFFLOAD_START, 44 VENDOR_A2DP_OFFLOAD_STOP = BT_VND_OP_A2DP_OFFLOAD_STOP, 45 VENDOR_LAST_OP 46 } vendor_async_opcode_t; 47 48 typedef void (*vendor_cb)(bool success); 49 50 typedef struct vendor_t { 51 // Opens the vendor-specific library and sets the Bluetooth 52 // address of the adapter to |local_bdaddr|. |hci_interface| is 53 // used to send commands on behalf of the vendor library. 54 bool (*open)(const uint8_t* local_bdaddr, const hci_t* hci_interface); 55 56 // Closes the vendor-specific library and frees all associated resources. 57 // Only |vendor_open| may be called after |vendor_close|. 58 void (*close)(void); 59 60 // Sends a vendor-specific command to the library. 61 int (*send_command)(vendor_opcode_t opcode, void* param); 62 63 // Sends an asynchronous vendor-specific command to the library. 64 int (*send_async_command)(vendor_async_opcode_t opcode, void* param); 65 66 // Registers a callback for an asynchronous vendor-specific command. 67 void (*set_callback)(vendor_async_opcode_t opcode, vendor_cb callback); 68 } vendor_t; 69 70 const vendor_t* vendor_get_interface(); 71