Move Bluetooth headers to system/bt (2/3)

Bug: 67853426
Test: run Bluetooth
Change-Id: If99fc83e08294cfc26608dcef88a5c3836d88863
This commit is contained in:
Jakub Pawlowski 2017-10-17 16:00:33 -07:00
parent 5ed611b618
commit 4d64b603db
18 changed files with 0 additions and 3369 deletions

View file

@ -1,108 +0,0 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BLE_ADVERTISER_H
#define ANDROID_INCLUDE_BLE_ADVERTISER_H
#include <base/callback_forward.h>
#include <stdint.h>
#include <vector>
#include "bt_common_types.h"
#include "bt_gatt_types.h"
struct AdvertiseParameters {
uint16_t advertising_event_properties;
uint32_t min_interval;
uint32_t max_interval;
uint8_t channel_map;
int8_t tx_power;
uint8_t primary_advertising_phy;
uint8_t secondary_advertising_phy;
uint8_t scan_request_notification_enable;
};
struct PeriodicAdvertisingParameters {
uint8_t enable;
uint16_t min_interval;
uint16_t max_interval;
uint16_t periodic_advertising_properties;
};
class BleAdvertiserInterface {
public:
virtual ~BleAdvertiserInterface() = default;
/** Callback invoked when multi-adv operation has completed */
using StatusCallback = base::Callback<void(uint8_t /* status */)>;
using IdStatusCallback =
base::Callback<void(uint8_t /* advertiser_id */, uint8_t /* status */)>;
using IdTxPowerStatusCallback =
base::Callback<void(uint8_t /* advertiser_id */, int8_t /* tx_power */, uint8_t /* status */)>;
using ParametersCallback =
base::Callback<void(uint8_t /* status */, int8_t /* tx_power */)>;
/** Registers an advertiser with the stack */
virtual void RegisterAdvertiser(IdStatusCallback) = 0;
using GetAddressCallback = base::Callback<void(uint8_t /* address_type*/, RawAddress /*address*/)>;
virtual void GetOwnAddress(uint8_t advertiser_id, GetAddressCallback cb) = 0;
/* Set the parameters as per spec, user manual specified values */
virtual void SetParameters(uint8_t advertiser_id, AdvertiseParameters params,
ParametersCallback cb) = 0;
/* Setup the data */
virtual void SetData(int advertiser_id, bool set_scan_rsp,
std::vector<uint8_t> data, StatusCallback cb) = 0;
/* Enable the advertising instance */
virtual void Enable(uint8_t advertiser_id, bool enable, StatusCallback cb,
uint16_t duration, uint8_t maxExtAdvEvents,
StatusCallback timeout_cb) = 0;
/* Unregisters an advertiser */
virtual void Unregister(uint8_t advertiser_id) = 0;
virtual void StartAdvertising(uint8_t advertiser_id, StatusCallback cb,
AdvertiseParameters params,
std::vector<uint8_t> advertise_data,
std::vector<uint8_t> scan_response_data,
int timeout_s, StatusCallback timeout_cb) = 0;
/** Start the advertising set. This include registering, setting all
* parameters and data, and enabling it. |register_cb| is called when the set
* is advertising. |timeout_cb| is called when the timeout_s have passed */
virtual void StartAdvertisingSet(
IdTxPowerStatusCallback register_cb, AdvertiseParameters params,
std::vector<uint8_t> advertise_data,
std::vector<uint8_t> scan_response_data,
PeriodicAdvertisingParameters periodic_params,
std::vector<uint8_t> periodic_data, uint16_t duration,
uint8_t maxExtAdvEvents, IdStatusCallback timeout_cb) = 0;
virtual void SetPeriodicAdvertisingParameters(
int advertiser_id, PeriodicAdvertisingParameters parameters,
StatusCallback cb) = 0;
virtual void SetPeriodicAdvertisingData(int advertiser_id,
std::vector<uint8_t> data,
StatusCallback cb) = 0;
virtual void SetPeriodicAdvertisingEnable(int advertiser_id, bool enable,
StatusCallback cb) = 0;
};
#endif /* ANDROID_INCLUDE_BLE_ADVERTISER_H */

View file

@ -1,139 +0,0 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BLE_SCANNER_H
#define ANDROID_INCLUDE_BLE_SCANNER_H
#include <stdint.h>
#include <vector>
#include "bt_common_types.h"
#include "bt_gatt_client.h"
#include "bt_gatt_types.h"
/** Callback invoked when batchscan reports are obtained */
typedef void (*batchscan_reports_callback)(int client_if, int status,
int report_format, int num_records,
std::vector<uint8_t> data);
/** Callback invoked when batchscan storage threshold limit is crossed */
typedef void (*batchscan_threshold_callback)(int client_if);
/** Track ADV VSE callback invoked when tracked device is found or lost */
typedef void (*track_adv_event_callback)(
btgatt_track_adv_info_t *p_track_adv_info);
/** Callback for scan results */
typedef void (*scan_result_callback)(uint16_t event_type, uint8_t addr_type,
RawAddress *bda, uint8_t primary_phy,
uint8_t secondary_phy,
uint8_t advertising_sid, int8_t tx_power,
int8_t rssi, uint16_t periodic_adv_int,
std::vector<uint8_t> adv_data);
typedef struct {
scan_result_callback scan_result_cb;
batchscan_reports_callback batchscan_reports_cb;
batchscan_threshold_callback batchscan_threshold_cb;
track_adv_event_callback track_adv_event_cb;
} btgatt_scanner_callbacks_t;
class BleScannerInterface {
public:
virtual ~BleScannerInterface() = default;
using RegisterCallback =
base::Callback<void(uint8_t /* scanner_id */, uint8_t /* status */)>;
using Callback = base::Callback<void(uint8_t /* status */)>;
using EnableCallback =
base::Callback<void(uint8_t /* action */, uint8_t /* status */)>;
using FilterParamSetupCallback =
base::Callback<void(uint8_t /* avbl_space */, uint8_t /* action_type */,
uint8_t /* status */)>;
using FilterConfigCallback =
base::Callback<void(uint8_t /* filt_type */, uint8_t /* avbl_space */,
uint8_t /* action */, uint8_t /* status */)>;
/** Registers a scanner with the stack */
virtual void RegisterScanner(RegisterCallback) = 0;
/** Unregister a scanner from the stack */
virtual void Unregister(int scanner_id) = 0;
/** Start or stop LE device scanning */
virtual void Scan(bool start) = 0;
/** Setup scan filter params */
virtual void ScanFilterParamSetup(
uint8_t client_if, uint8_t action, uint8_t filt_index,
std::unique_ptr<btgatt_filt_param_setup_t> filt_param,
FilterParamSetupCallback cb) = 0;
/** Configure a scan filter condition */
virtual void ScanFilterAddRemove(int action, int filt_type, int filt_index,
int company_id, int company_id_mask,
const bluetooth::Uuid *p_uuid,
const bluetooth::Uuid *p_uuid_mask,
const RawAddress *bd_addr, char addr_type,
std::vector<uint8_t> data,
std::vector<uint8_t> p_mask,
FilterConfigCallback cb) = 0;
/** Clear all scan filter conditions for specific filter index*/
virtual void ScanFilterClear(int filt_index, FilterConfigCallback cb) = 0;
/** Enable / disable scan filter feature*/
virtual void ScanFilterEnable(bool enable, EnableCallback cb) = 0;
/** Sets the LE scan interval and window in units of N*0.625 msec */
virtual void SetScanParameters(int scan_interval, int scan_window,
Callback cb) = 0;
/* Configure the batchscan storage */
virtual void BatchscanConfigStorage(int client_if, int batch_scan_full_max,
int batch_scan_trunc_max,
int batch_scan_notify_threshold,
Callback cb) = 0;
/* Enable batchscan */
virtual void BatchscanEnable(int scan_mode, int scan_interval,
int scan_window, int addr_type, int discard_rule,
Callback cb) = 0;
/* Disable batchscan */
virtual void BatchscanDisable(Callback cb) = 0;
/* Read out batchscan reports */
virtual void BatchscanReadReports(int client_if, int scan_mode) = 0;
using StartSyncCb =
base::Callback<void(uint8_t status, uint16_t sync_handle,
uint8_t advertising_sid, uint8_t address_type,
RawAddress address, uint8_t phy, uint16_t interval)>;
using SyncReportCb =
base::Callback<void(uint16_t sync_handle, int8_t tx_power, int8_t rssi,
uint8_t status, std::vector<uint8_t> data)>;
using SyncLostCb = base::Callback<void(uint16_t sync_handle)>;
virtual void StartSync(uint8_t sid, RawAddress address, uint16_t skip,
uint16_t timeout, StartSyncCb start_cb,
SyncReportCb report_cb, SyncLostCb lost_cb) = 0;
virtual void StopSync(uint16_t handle) = 0;
};
#endif /* ANDROID_INCLUDE_BLE_SCANNER_H */

View file

@ -1,242 +0,0 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_AV_H
#define ANDROID_INCLUDE_BT_AV_H
#include <vector>
#include <hardware/bluetooth.h>
__BEGIN_DECLS
/* Bluetooth AV connection states */
typedef enum {
BTAV_CONNECTION_STATE_DISCONNECTED = 0,
BTAV_CONNECTION_STATE_CONNECTING,
BTAV_CONNECTION_STATE_CONNECTED,
BTAV_CONNECTION_STATE_DISCONNECTING
} btav_connection_state_t;
/* Bluetooth AV datapath states */
typedef enum {
BTAV_AUDIO_STATE_REMOTE_SUSPEND = 0,
BTAV_AUDIO_STATE_STOPPED,
BTAV_AUDIO_STATE_STARTED,
} btav_audio_state_t;
/*
* Enum values for each A2DP supported codec.
* There should be a separate entry for each A2DP codec that is supported
* for encoding (SRC), and for decoding purpose (SINK).
*/
typedef enum {
BTAV_A2DP_CODEC_INDEX_SOURCE_MIN = 0,
// Add an entry for each source codec here.
// NOTE: The values should be same as those listed in the following file:
// BluetoothCodecConfig.java
BTAV_A2DP_CODEC_INDEX_SOURCE_SBC = 0,
BTAV_A2DP_CODEC_INDEX_SOURCE_AAC,
BTAV_A2DP_CODEC_INDEX_SOURCE_APTX,
BTAV_A2DP_CODEC_INDEX_SOURCE_APTX_HD,
BTAV_A2DP_CODEC_INDEX_SOURCE_LDAC,
BTAV_A2DP_CODEC_INDEX_SOURCE_MAX,
BTAV_A2DP_CODEC_INDEX_SINK_MIN = BTAV_A2DP_CODEC_INDEX_SOURCE_MAX,
// Add an entry for each sink codec here
BTAV_A2DP_CODEC_INDEX_SINK_SBC = BTAV_A2DP_CODEC_INDEX_SINK_MIN,
BTAV_A2DP_CODEC_INDEX_SINK_MAX,
BTAV_A2DP_CODEC_INDEX_MIN = BTAV_A2DP_CODEC_INDEX_SOURCE_MIN,
BTAV_A2DP_CODEC_INDEX_MAX = BTAV_A2DP_CODEC_INDEX_SINK_MAX
} btav_a2dp_codec_index_t;
typedef enum {
// Disable the codec.
// NOTE: This value can be used only during initialization when
// function btav_source_interface_t::init() is called.
BTAV_A2DP_CODEC_PRIORITY_DISABLED = -1,
// Reset the codec priority to its default value.
BTAV_A2DP_CODEC_PRIORITY_DEFAULT = 0,
// Highest codec priority.
BTAV_A2DP_CODEC_PRIORITY_HIGHEST = 1000 * 1000
} btav_a2dp_codec_priority_t;
typedef enum {
BTAV_A2DP_CODEC_SAMPLE_RATE_NONE = 0x0,
BTAV_A2DP_CODEC_SAMPLE_RATE_44100 = 0x1 << 0,
BTAV_A2DP_CODEC_SAMPLE_RATE_48000 = 0x1 << 1,
BTAV_A2DP_CODEC_SAMPLE_RATE_88200 = 0x1 << 2,
BTAV_A2DP_CODEC_SAMPLE_RATE_96000 = 0x1 << 3,
BTAV_A2DP_CODEC_SAMPLE_RATE_176400 = 0x1 << 4,
BTAV_A2DP_CODEC_SAMPLE_RATE_192000 = 0x1 << 5
} btav_a2dp_codec_sample_rate_t;
typedef enum {
BTAV_A2DP_CODEC_BITS_PER_SAMPLE_NONE = 0x0,
BTAV_A2DP_CODEC_BITS_PER_SAMPLE_16 = 0x1 << 0,
BTAV_A2DP_CODEC_BITS_PER_SAMPLE_24 = 0x1 << 1,
BTAV_A2DP_CODEC_BITS_PER_SAMPLE_32 = 0x1 << 2
} btav_a2dp_codec_bits_per_sample_t;
typedef enum {
BTAV_A2DP_CODEC_CHANNEL_MODE_NONE = 0x0,
BTAV_A2DP_CODEC_CHANNEL_MODE_MONO = 0x1 << 0,
BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO = 0x1 << 1
} btav_a2dp_codec_channel_mode_t;
/*
* Structure for representing codec capability or configuration.
* It is used for configuring A2DP codec preference, and for reporting back
* current configuration or codec capability.
* For codec capability, fields "sample_rate", "bits_per_sample" and
* "channel_mode" can contain bit-masks with all supported features.
*/
typedef struct {
btav_a2dp_codec_index_t codec_type;
btav_a2dp_codec_priority_t codec_priority; // Codec selection priority
// relative to other codecs: larger value
// means higher priority. If 0, reset to
// default.
btav_a2dp_codec_sample_rate_t sample_rate;
btav_a2dp_codec_bits_per_sample_t bits_per_sample;
btav_a2dp_codec_channel_mode_t channel_mode;
int64_t codec_specific_1; // Codec-specific value 1
int64_t codec_specific_2; // Codec-specific value 2
int64_t codec_specific_3; // Codec-specific value 3
int64_t codec_specific_4; // Codec-specific value 4
} btav_a2dp_codec_config_t;
/** Callback for connection state change.
* state will have one of the values from btav_connection_state_t
*/
typedef void (* btav_connection_state_callback)(btav_connection_state_t state,
RawAddress *bd_addr);
/** Callback for audiopath state change.
* state will have one of the values from btav_audio_state_t
*/
typedef void (* btav_audio_state_callback)(btav_audio_state_t state,
RawAddress *bd_addr);
/** Callback for audio configuration change.
* Used only for the A2DP Source interface.
*/
typedef void (* btav_audio_source_config_callback)(
btav_a2dp_codec_config_t codec_config,
std::vector<btav_a2dp_codec_config_t> codecs_local_capabilities,
std::vector<btav_a2dp_codec_config_t> codecs_selectable_capabilities);
/** Callback for audio configuration change.
* Used only for the A2DP Sink interface.
* sample_rate: sample rate in Hz
* channel_count: number of channels (1 for mono, 2 for stereo)
*/
typedef void (* btav_audio_sink_config_callback)(RawAddress *bd_addr,
uint32_t sample_rate,
uint8_t channel_count);
/** BT-AV A2DP Source callback structure. */
typedef struct {
/** set to sizeof(btav_source_callbacks_t) */
size_t size;
btav_connection_state_callback connection_state_cb;
btav_audio_state_callback audio_state_cb;
btav_audio_source_config_callback audio_config_cb;
} btav_source_callbacks_t;
/** BT-AV A2DP Sink callback structure. */
typedef struct {
/** set to sizeof(btav_sink_callbacks_t) */
size_t size;
btav_connection_state_callback connection_state_cb;
btav_audio_state_callback audio_state_cb;
btav_audio_sink_config_callback audio_config_cb;
} btav_sink_callbacks_t;
/**
* NOTE:
*
* 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands
* shall be handled internally via uinput
*
* 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger
* android_audio_hw library and the Bluetooth stack.
*
*/
/** Represents the standard BT-AV A2DP Source interface.
*/
typedef struct {
/** set to sizeof(btav_source_interface_t) */
size_t size;
/**
* Register the BtAv callbacks.
*/
bt_status_t (*init)(btav_source_callbacks_t* callbacks,
std::vector<btav_a2dp_codec_config_t> codec_priorities);
/** connect to headset */
bt_status_t (*connect)( RawAddress *bd_addr );
/** dis-connect from headset */
bt_status_t (*disconnect)( RawAddress *bd_addr );
/** configure the codecs settings preferences */
bt_status_t (*config_codec)(std::vector<btav_a2dp_codec_config_t> codec_preferences);
/** Closes the interface. */
void (*cleanup)( void );
} btav_source_interface_t;
/** Represents the standard BT-AV A2DP Sink interface.
*/
typedef struct {
/** set to sizeof(btav_sink_interface_t) */
size_t size;
/**
* Register the BtAv callbacks
*/
bt_status_t (*init)( btav_sink_callbacks_t* callbacks );
/** connect to headset */
bt_status_t (*connect)( RawAddress *bd_addr );
/** dis-connect from headset */
bt_status_t (*disconnect)( RawAddress *bd_addr );
/** Closes the interface. */
void (*cleanup)( void );
/** Sends Audio Focus State. */
void (*set_audio_focus_state)( int focus_state );
/** Sets the audio track gain. */
void (*set_audio_track_gain)( float gain );
} btav_sink_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_AV_H */

View file

@ -1,93 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/******************************************************************************
*
* This file contains constants and definitions that can be used commonly between JNI and stack layer
*
******************************************************************************/
#ifndef ANDROID_INCLUDE_BT_COMMON_TYPES_H
#define ANDROID_INCLUDE_BT_COMMON_TYPES_H
#include "bluetooth.h"
#include <bluetooth/uuid.h>
typedef struct
{
uint8_t client_if;
uint8_t filt_index;
uint8_t advertiser_state;
uint8_t advertiser_info_present;
uint8_t addr_type;
uint8_t tx_power;
int8_t rssi_value;
uint16_t time_stamp;
RawAddress bd_addr;
uint8_t adv_pkt_len;
uint8_t *p_adv_pkt_data;
uint8_t scan_rsp_len;
uint8_t *p_scan_rsp_data;
} btgatt_track_adv_info_t;
typedef enum
{
BTGATT_DB_PRIMARY_SERVICE,
BTGATT_DB_SECONDARY_SERVICE,
BTGATT_DB_INCLUDED_SERVICE,
BTGATT_DB_CHARACTERISTIC,
BTGATT_DB_DESCRIPTOR,
} bt_gatt_db_attribute_type_t;
typedef struct
{
uint16_t id;
bluetooth::Uuid uuid;
bt_gatt_db_attribute_type_t type;
uint16_t attribute_handle;
/*
* If |type| is |BTGATT_DB_PRIMARY_SERVICE|, or
* |BTGATT_DB_SECONDARY_SERVICE|, this contains the start and end attribute
* handles.
*/
uint16_t start_handle;
uint16_t end_handle;
/*
* If |type| is |BTGATT_DB_CHARACTERISTIC|, this contains the properties of
* the characteristic.
*/
uint8_t properties;
uint16_t permissions;
} btgatt_db_element_t;
typedef struct
{
uint16_t feat_seln;
uint16_t list_logic_type;
uint8_t filt_logic_type;
uint8_t rssi_high_thres;
uint8_t rssi_low_thres;
uint8_t dely_mode;
uint16_t found_timeout;
uint16_t lost_timeout;
uint8_t found_timeout_cnt;
uint16_t num_of_tracking_entries;
} btgatt_filt_param_setup_t;
#endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */

View file

@ -1,72 +0,0 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_GATT_H
#define ANDROID_INCLUDE_BT_GATT_H
#include <stdint.h>
#include "ble_advertiser.h"
#include "ble_scanner.h"
#include "bt_gatt_client.h"
#include "bt_gatt_server.h"
__BEGIN_DECLS
/** BT-GATT callbacks */
typedef struct {
/** Set to sizeof(btgatt_callbacks_t) */
size_t size;
/** GATT Client callbacks */
const btgatt_client_callbacks_t* client;
/** GATT Server callbacks */
const btgatt_server_callbacks_t* server;
/** LE scanner callbacks */
const btgatt_scanner_callbacks_t* scanner;
} btgatt_callbacks_t;
/** Represents the standard Bluetooth GATT interface. */
typedef struct {
/** Set to sizeof(btgatt_interface_t) */
size_t size;
/**
* Initializes the interface and provides callback routines
*/
bt_status_t (*init)( const btgatt_callbacks_t* callbacks );
/** Closes the interface */
void (*cleanup)( void );
/** Pointer to the GATT client interface methods.*/
const btgatt_client_interface_t* client;
/** Pointer to the GATT server interface methods.*/
const btgatt_server_interface_t* server;
/** Pointer to the LE scanner interface methods.*/
BleScannerInterface* scanner;
/** Pointer to the advertiser interface methods.*/
BleAdvertiserInterface* advertiser;
} btgatt_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_GATT_H */

View file

@ -1,299 +0,0 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_GATT_CLIENT_H
#define ANDROID_INCLUDE_BT_GATT_CLIENT_H
#include <stdint.h>
#include <vector>
#include "bt_gatt_types.h"
#include "bt_common_types.h"
#include <bluetooth/uuid.h>
__BEGIN_DECLS
/**
* Buffer sizes for maximum attribute length and maximum read/write
* operation buffer size.
*/
#define BTGATT_MAX_ATTR_LEN 600
/** Buffer type for unformatted reads/writes */
typedef struct
{
uint8_t value[BTGATT_MAX_ATTR_LEN];
uint16_t len;
} btgatt_unformatted_value_t;
/** Parameters for GATT read operations */
typedef struct
{
uint16_t handle;
btgatt_unformatted_value_t value;
uint16_t value_type;
uint8_t status;
} btgatt_read_params_t;
/** Parameters for GATT write operations */
typedef struct
{
btgatt_srvc_id_t srvc_id;
btgatt_gatt_id_t char_id;
btgatt_gatt_id_t descr_id;
uint8_t status;
} btgatt_write_params_t;
/** Attribute change notification parameters */
typedef struct
{
uint8_t value[BTGATT_MAX_ATTR_LEN];
RawAddress bda;
uint16_t handle;
uint16_t len;
uint8_t is_notify;
} btgatt_notify_params_t;
typedef struct
{
RawAddress *bda1;
bluetooth::Uuid *uuid1;
uint16_t u1;
uint16_t u2;
uint16_t u3;
uint16_t u4;
uint16_t u5;
} btgatt_test_params_t;
/* BT GATT client error codes */
typedef enum
{
BT_GATTC_COMMAND_SUCCESS = 0, /* 0 Command succeeded */
BT_GATTC_COMMAND_STARTED, /* 1 Command started OK. */
BT_GATTC_COMMAND_BUSY, /* 2 Device busy with another command */
BT_GATTC_COMMAND_STORED, /* 3 request is stored in control block */
BT_GATTC_NO_RESOURCES, /* 4 No resources to issue command */
BT_GATTC_MODE_UNSUPPORTED, /* 5 Request for 1 or more unsupported modes */
BT_GATTC_ILLEGAL_VALUE, /* 6 Illegal command /parameter value */
BT_GATTC_INCORRECT_STATE, /* 7 Device in wrong state for request */
BT_GATTC_UNKNOWN_ADDR, /* 8 Unknown remote BD address */
BT_GATTC_DEVICE_TIMEOUT, /* 9 Device timeout */
BT_GATTC_INVALID_CONTROLLER_OUTPUT,/* 10 An incorrect value was received from HCI */
BT_GATTC_SECURITY_ERROR, /* 11 Authorization or security failure or not authorized */
BT_GATTC_DELAYED_ENCRYPTION_CHECK, /*12 Delayed encryption check */
BT_GATTC_ERR_PROCESSING /* 12 Generic error */
} btgattc_error_t;
/** BT-GATT Client callback structure. */
/** Callback invoked in response to register_client */
typedef void (*register_client_callback)(int status, int client_if, const bluetooth::Uuid& app_uuid);
/** GATT open callback invoked in response to open */
typedef void (*connect_callback)(int conn_id, int status, int client_if, const RawAddress& bda);
/** Callback invoked in response to close */
typedef void (*disconnect_callback)(int conn_id, int status,
int client_if, const RawAddress& bda);
/**
* Invoked in response to search_service when the GATT service search
* has been completed.
*/
typedef void (*search_complete_callback)(int conn_id, int status);
/** Callback invoked in response to [de]register_for_notification */
typedef void (*register_for_notification_callback)(int conn_id,
int registered, int status, uint16_t handle);
/**
* Remote device notification callback, invoked when a remote device sends
* a notification or indication that a client has registered for.
*/
typedef void (*notify_callback)(int conn_id, const btgatt_notify_params_t& p_data);
/** Reports result of a GATT read operation */
typedef void (*read_characteristic_callback)(int conn_id, int status,
btgatt_read_params_t *p_data);
/** GATT write characteristic operation callback */
typedef void (*write_characteristic_callback)(int conn_id, int status, uint16_t handle);
/** GATT execute prepared write callback */
typedef void (*execute_write_callback)(int conn_id, int status);
/** Callback invoked in response to read_descriptor */
typedef void (*read_descriptor_callback)(int conn_id, int status,
const btgatt_read_params_t& p_data);
/** Callback invoked in response to write_descriptor */
typedef void (*write_descriptor_callback)(int conn_id, int status, uint16_t handle);
/** Callback triggered in response to read_remote_rssi */
typedef void (*read_remote_rssi_callback)(int client_if, const RawAddress& bda,
int rssi, int status);
/** Callback invoked when the MTU for a given connection changes */
typedef void (*configure_mtu_callback)(int conn_id, int status, int mtu);
/**
* Callback notifying an application that a remote device connection is currently congested
* and cannot receive any more data. An application should avoid sending more data until
* a further callback is received indicating the congestion status has been cleared.
*/
typedef void (*congestion_callback)(int conn_id, bool congested);
/** GATT get database callback */
typedef void (*get_gatt_db_callback)(int conn_id, const btgatt_db_element_t* db, int count);
/** GATT services between start_handle and end_handle were removed */
typedef void (*services_removed_callback)(int conn_id, uint16_t start_handle, uint16_t end_handle);
/** GATT services were added */
typedef void (*services_added_callback)(int conn_id, const btgatt_db_element_t& added, int added_count);
/** Callback invoked when the PHY for a given connection changes */
typedef void (*phy_updated_callback)(int conn_id, uint8_t tx_phy,
uint8_t rx_phy, uint8_t status);
/** Callback invoked when the connection parameters for a given connection changes */
typedef void (*conn_updated_callback)(int conn_id, uint16_t interval,
uint16_t latency, uint16_t timeout,
uint8_t status);
typedef struct {
register_client_callback register_client_cb;
connect_callback open_cb;
disconnect_callback close_cb;
search_complete_callback search_complete_cb;
register_for_notification_callback register_for_notification_cb;
notify_callback notify_cb;
read_characteristic_callback read_characteristic_cb;
write_characteristic_callback write_characteristic_cb;
read_descriptor_callback read_descriptor_cb;
write_descriptor_callback write_descriptor_cb;
execute_write_callback execute_write_cb;
read_remote_rssi_callback read_remote_rssi_cb;
configure_mtu_callback configure_mtu_cb;
congestion_callback congestion_cb;
get_gatt_db_callback get_gatt_db_cb;
services_removed_callback services_removed_cb;
services_added_callback services_added_cb;
phy_updated_callback phy_updated_cb;
conn_updated_callback conn_updated_cb;
} btgatt_client_callbacks_t;
/** Represents the standard BT-GATT client interface. */
typedef struct {
/** Registers a GATT client application with the stack */
bt_status_t (*register_client)(const bluetooth::Uuid& uuid);
/** Unregister a client application from the stack */
bt_status_t (*unregister_client)(int client_if);
/** Create a connection to a remote LE or dual-mode device */
bt_status_t (*connect)(int client_if, const RawAddress& bd_addr,
bool is_direct, int transport, bool opportunistic,
int initiating_phys);
/** Disconnect a remote device or cancel a pending connection */
bt_status_t (*disconnect)( int client_if, const RawAddress& bd_addr,
int conn_id);
/** Clear the attribute cache for a given device */
bt_status_t (*refresh)( int client_if, const RawAddress& bd_addr);
/**
* Enumerate all GATT services on a connected device.
* Optionally, the results can be filtered for a given UUID.
*/
bt_status_t (*search_service)(int conn_id, const bluetooth::Uuid *filter_uuid);
/**
* Sead "Find service by UUID" request. Used only for PTS tests.
*/
void (*btif_gattc_discover_service_by_uuid)(int conn_id, const bluetooth::Uuid& uuid);
/** Read a characteristic on a remote device */
bt_status_t (*read_characteristic)(int conn_id, uint16_t handle,
int auth_req);
/** Read a characteristic on a remote device */
bt_status_t (*read_using_characteristic_uuid)(
int conn_id, const bluetooth::Uuid& uuid, uint16_t s_handle,
uint16_t e_handle, int auth_req);
/** Write a remote characteristic */
bt_status_t (*write_characteristic)(int conn_id, uint16_t handle,
int write_type, int auth_req,
std::vector<uint8_t> value);
/** Read the descriptor for a given characteristic */
bt_status_t (*read_descriptor)(int conn_id, uint16_t handle, int auth_req);
/** Write a remote descriptor for a given characteristic */
bt_status_t (*write_descriptor)( int conn_id, uint16_t handle,
int auth_req, std::vector<uint8_t> value);
/** Execute a prepared write operation */
bt_status_t (*execute_write)(int conn_id, int execute);
/**
* Register to receive notifications or indications for a given
* characteristic
*/
bt_status_t (*register_for_notification)( int client_if,
const RawAddress& bd_addr, uint16_t handle);
/** Deregister a previous request for notifications/indications */
bt_status_t (*deregister_for_notification)( int client_if,
const RawAddress& bd_addr, uint16_t handle);
/** Request RSSI for a given remote device */
bt_status_t (*read_remote_rssi)(int client_if, const RawAddress& bd_addr);
/** Determine the type of the remote device (LE, BR/EDR, Dual-mode) */
int (*get_device_type)(const RawAddress &bd_addr);
/** Configure the MTU for a given connection */
bt_status_t (*configure_mtu)(int conn_id, int mtu);
/** Request a connection parameter update */
bt_status_t (*conn_parameter_update)(const RawAddress& bd_addr, int min_interval,
int max_interval, int latency, int timeout);
bt_status_t (*set_preferred_phy)(const RawAddress& bd_addr, uint8_t tx_phy,
uint8_t rx_phy, uint16_t phy_options);
bt_status_t (*read_phy)(
const RawAddress& bd_addr,
base::Callback<void(uint8_t tx_phy, uint8_t rx_phy, uint8_t status)>
cb);
/** Test mode interface */
bt_status_t (*test_command)( int command, const btgatt_test_params_t& params);
/** Get gatt db content */
bt_status_t (*get_gatt_db)( int conn_id);
} btgatt_client_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_GATT_CLIENT_H */

View file

@ -1,181 +0,0 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_GATT_SERVER_H
#define ANDROID_INCLUDE_BT_GATT_SERVER_H
#include <stdint.h>
#include <vector>
#include "bt_gatt_types.h"
__BEGIN_DECLS
/** GATT value type used in response to remote read requests */
typedef struct
{
uint8_t value[BTGATT_MAX_ATTR_LEN];
uint16_t handle;
uint16_t offset;
uint16_t len;
uint8_t auth_req;
} btgatt_value_t;
/** GATT remote read request response type */
typedef union
{
btgatt_value_t attr_value;
uint16_t handle;
} btgatt_response_t;
/** BT-GATT Server callback structure. */
/** Callback invoked in response to register_server */
typedef void (*register_server_callback)(int status, int server_if,
const bluetooth::Uuid& app_uuid);
/** Callback indicating that a remote device has connected or been disconnected */
typedef void (*connection_callback)(int conn_id, int server_if, int connected,
const RawAddress& bda);
/** Callback invoked in response to create_service */
typedef void (*service_added_callback)(int status, int server_if,
std::vector<btgatt_db_element_t> service);
/** Callback invoked in response to stop_service */
typedef void (*service_stopped_callback)(int status, int server_if,
int srvc_handle);
/** Callback triggered when a service has been deleted */
typedef void (*service_deleted_callback)(int status, int server_if,
int srvc_handle);
/**
* Callback invoked when a remote device has requested to read a characteristic
* or descriptor. The application must respond by calling send_response
*/
typedef void (*request_read_callback)(int conn_id, int trans_id, const RawAddress& bda,
int attr_handle, int offset, bool is_long);
/**
* Callback invoked when a remote device has requested to write to a
* characteristic or descriptor.
*/
typedef void (*request_write_callback)(int conn_id, int trans_id, const RawAddress& bda,
int attr_handle, int offset, bool need_rsp,
bool is_prep, std::vector<uint8_t> value);
/** Callback invoked when a previously prepared write is to be executed */
typedef void (*request_exec_write_callback)(int conn_id, int trans_id,
const RawAddress& bda, int exec_write);
/**
* Callback triggered in response to send_response if the remote device
* sends a confirmation.
*/
typedef void (*response_confirmation_callback)(int status, int handle);
/**
* Callback confirming that a notification or indication has been sent
* to a remote device.
*/
typedef void (*indication_sent_callback)(int conn_id, int status);
/**
* Callback notifying an application that a remote device connection is currently congested
* and cannot receive any more data. An application should avoid sending more data until
* a further callback is received indicating the congestion status has been cleared.
*/
typedef void (*congestion_callback)(int conn_id, bool congested);
/** Callback invoked when the MTU for a given connection changes */
typedef void (*mtu_changed_callback)(int conn_id, int mtu);
/** Callback invoked when the PHY for a given connection changes */
typedef void (*phy_updated_callback)(int conn_id, uint8_t tx_phy,
uint8_t rx_phy, uint8_t status);
/** Callback invoked when the connection parameters for a given connection changes */
typedef void (*conn_updated_callback)(int conn_id, uint16_t interval,
uint16_t latency, uint16_t timeout,
uint8_t status);
typedef struct {
register_server_callback register_server_cb;
connection_callback connection_cb;
service_added_callback service_added_cb;
service_stopped_callback service_stopped_cb;
service_deleted_callback service_deleted_cb;
request_read_callback request_read_characteristic_cb;
request_read_callback request_read_descriptor_cb;
request_write_callback request_write_characteristic_cb;
request_write_callback request_write_descriptor_cb;
request_exec_write_callback request_exec_write_cb;
response_confirmation_callback response_confirmation_cb;
indication_sent_callback indication_sent_cb;
congestion_callback congestion_cb;
mtu_changed_callback mtu_changed_cb;
phy_updated_callback phy_updated_cb;
conn_updated_callback conn_updated_cb;
} btgatt_server_callbacks_t;
/** Represents the standard BT-GATT server interface. */
typedef struct {
/** Registers a GATT server application with the stack */
bt_status_t (*register_server)(const bluetooth::Uuid& uuid);
/** Unregister a server application from the stack */
bt_status_t (*unregister_server)(int server_if );
/** Create a connection to a remote peripheral */
bt_status_t (*connect)(int server_if, const RawAddress& bd_addr,
bool is_direct, int transport);
/** Disconnect an established connection or cancel a pending one */
bt_status_t (*disconnect)(int server_if, const RawAddress& bd_addr,
int conn_id );
/** Create a new service */
bt_status_t (*add_service)(int server_if, std::vector<btgatt_db_element_t> service);
/** Stops a local service */
bt_status_t (*stop_service)(int server_if, int service_handle);
/** Delete a local service */
bt_status_t (*delete_service)(int server_if, int service_handle);
/** Send value indication to a remote device */
bt_status_t (*send_indication)(int server_if, int attribute_handle,
int conn_id, int confirm,
std::vector<uint8_t> value);
/** Send a response to a read/write operation */
bt_status_t (*send_response)(int conn_id, int trans_id,
int status, const btgatt_response_t& response);
bt_status_t (*set_preferred_phy)(const RawAddress& bd_addr, uint8_t tx_phy,
uint8_t rx_phy, uint16_t phy_options);
bt_status_t (*read_phy)(
const RawAddress& bd_addr,
base::Callback<void(uint8_t tx_phy, uint8_t rx_phy, uint8_t status)>
cb);
} btgatt_server_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_GATT_CLIENT_H */

View file

@ -1,58 +0,0 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_GATT_TYPES_H
#define ANDROID_INCLUDE_BT_GATT_TYPES_H
#include <stdint.h>
#include <stdbool.h>
#include <bluetooth/uuid.h>
__BEGIN_DECLS
/**
* GATT Service types
*/
#define BTGATT_SERVICE_TYPE_PRIMARY 0
#define BTGATT_SERVICE_TYPE_SECONDARY 1
/** GATT ID adding instance id tracking to the UUID */
typedef struct
{
bluetooth::Uuid uuid;
uint8_t inst_id;
} btgatt_gatt_id_t;
/** GATT Service ID also identifies the service type (primary/secondary) */
typedef struct
{
btgatt_gatt_id_t id;
uint8_t is_primary;
} btgatt_srvc_id_t;
/** Preferred physical Transport for GATT connection */
typedef enum
{
GATT_TRANSPORT_AUTO,
GATT_TRANSPORT_BREDR,
GATT_TRANSPORT_LE
} btgatt_transport_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_GATT_TYPES_H */

View file

@ -1,127 +0,0 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_HD_H
#define ANDROID_INCLUDE_BT_HD_H
#include <stdint.h>
__BEGIN_DECLS
typedef enum
{
BTHD_REPORT_TYPE_OTHER = 0,
BTHD_REPORT_TYPE_INPUT,
BTHD_REPORT_TYPE_OUTPUT,
BTHD_REPORT_TYPE_FEATURE,
BTHD_REPORT_TYPE_INTRDATA // special value for reports to be sent on INTR (INPUT is assumed)
} bthd_report_type_t;
typedef enum
{
BTHD_APP_STATE_NOT_REGISTERED,
BTHD_APP_STATE_REGISTERED
} bthd_application_state_t;
typedef enum
{
BTHD_CONN_STATE_CONNECTED,
BTHD_CONN_STATE_CONNECTING,
BTHD_CONN_STATE_DISCONNECTED,
BTHD_CONN_STATE_DISCONNECTING,
BTHD_CONN_STATE_UNKNOWN
} bthd_connection_state_t;
typedef struct
{
const char *name;
const char *description;
const char *provider;
uint8_t subclass;
uint8_t *desc_list;
int desc_list_len;
} bthd_app_param_t;
typedef struct
{
uint8_t service_type;
uint32_t token_rate;
uint32_t token_bucket_size;
uint32_t peak_bandwidth;
uint32_t access_latency;
uint32_t delay_variation;
} bthd_qos_param_t;
typedef void (* bthd_application_state_callback)(RawAddress *bd_addr, bthd_application_state_t state);
typedef void (* bthd_connection_state_callback)(RawAddress *bd_addr, bthd_connection_state_t state);
typedef void (* bthd_get_report_callback)(uint8_t type, uint8_t id, uint16_t buffer_size);
typedef void (* bthd_set_report_callback)(uint8_t type, uint8_t id, uint16_t len, uint8_t *p_data);
typedef void (* bthd_set_protocol_callback)(uint8_t protocol);
typedef void (* bthd_intr_data_callback)(uint8_t report_id, uint16_t len, uint8_t *p_data);
typedef void (* bthd_vc_unplug_callback)(void);
/** BT-HD callbacks */
typedef struct {
size_t size;
bthd_application_state_callback application_state_cb;
bthd_connection_state_callback connection_state_cb;
bthd_get_report_callback get_report_cb;
bthd_set_report_callback set_report_cb;
bthd_set_protocol_callback set_protocol_cb;
bthd_intr_data_callback intr_data_cb;
bthd_vc_unplug_callback vc_unplug_cb;
} bthd_callbacks_t;
/** BT-HD interface */
typedef struct {
size_t size;
/** init interface and register callbacks */
bt_status_t (*init)(bthd_callbacks_t* callbacks);
/** close interface */
void (*cleanup)(void);
/** register application */
bt_status_t (*register_app)(bthd_app_param_t *app_param, bthd_qos_param_t *in_qos,
bthd_qos_param_t *out_qos);
/** unregister application */
bt_status_t (*unregister_app)(void);
/** connects to host with virtual cable */
bt_status_t (*connect)(RawAddress *bd_addr);
/** disconnects from currently connected host */
bt_status_t (*disconnect)(void);
/** send report */
bt_status_t (*send_report)(bthd_report_type_t type, uint8_t id, uint16_t len, uint8_t *p_data);
/** notifies error for invalid SET_REPORT */
bt_status_t (*report_error)(uint8_t error);
/** send Virtual Cable Unplug */
bt_status_t (*virtual_cable_unplug)(void);
} bthd_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_HD_H */

View file

@ -1,333 +0,0 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_HF_H
#define ANDROID_INCLUDE_BT_HF_H
__BEGIN_DECLS
/* AT response code - OK/Error */
typedef enum {
BTHF_AT_RESPONSE_ERROR = 0,
BTHF_AT_RESPONSE_OK
} bthf_at_response_t;
typedef enum {
BTHF_CONNECTION_STATE_DISCONNECTED = 0,
BTHF_CONNECTION_STATE_CONNECTING,
BTHF_CONNECTION_STATE_CONNECTED,
BTHF_CONNECTION_STATE_SLC_CONNECTED,
BTHF_CONNECTION_STATE_DISCONNECTING
} bthf_connection_state_t;
typedef enum {
BTHF_AUDIO_STATE_DISCONNECTED = 0,
BTHF_AUDIO_STATE_CONNECTING,
BTHF_AUDIO_STATE_CONNECTED,
BTHF_AUDIO_STATE_DISCONNECTING
} bthf_audio_state_t;
typedef enum {
BTHF_VR_STATE_STOPPED = 0,
BTHF_VR_STATE_STARTED
} bthf_vr_state_t;
typedef enum {
BTHF_VOLUME_TYPE_SPK = 0,
BTHF_VOLUME_TYPE_MIC
} bthf_volume_type_t;
/* Noise Reduction and Echo Cancellation */
typedef enum
{
BTHF_NREC_STOP,
BTHF_NREC_START
} bthf_nrec_t;
/* WBS codec setting */
typedef enum
{
BTHF_WBS_NONE,
BTHF_WBS_NO,
BTHF_WBS_YES
}bthf_wbs_config_t;
/* CHLD - Call held handling */
typedef enum
{
BTHF_CHLD_TYPE_RELEASEHELD, // Terminate all held or set UDUB("busy") to a waiting call
BTHF_CHLD_TYPE_RELEASEACTIVE_ACCEPTHELD, // Terminate all active calls and accepts a waiting/held call
BTHF_CHLD_TYPE_HOLDACTIVE_ACCEPTHELD, // Hold all active calls and accepts a waiting/held call
BTHF_CHLD_TYPE_ADDHELDTOCONF, // Add all held calls to a conference
} bthf_chld_type_t;
/* HF Indicators HFP 1.7 */
typedef enum
{
BTHF_HF_IND_ENHANCED_DRIVER_SAFETY = 1,
BTHF_HF_IND_BATTERY_LEVEL_STATUS = 2,
} bthf_hf_ind_type_t;
typedef enum
{
BTHF_HF_IND_DISABLED = 0,
BTHF_HF_IND_ENABLED,
} bthf_hf_ind_status_t;
/** Callback for connection state change.
* state will have one of the values from BtHfConnectionState
*/
typedef void (* bthf_connection_state_callback)(bthf_connection_state_t state, RawAddress *bd_addr);
/** Callback for audio connection state change.
* state will have one of the values from BtHfAudioState
*/
typedef void (* bthf_audio_state_callback)(bthf_audio_state_t state, RawAddress *bd_addr);
/** Callback for VR connection state change.
* state will have one of the values from BtHfVRState
*/
typedef void (* bthf_vr_cmd_callback)(bthf_vr_state_t state, RawAddress *bd_addr);
/** Callback for answer incoming call (ATA)
*/
typedef void (* bthf_answer_call_cmd_callback)(RawAddress *bd_addr);
/** Callback for disconnect call (AT+CHUP)
*/
typedef void (* bthf_hangup_call_cmd_callback)(RawAddress *bd_addr);
/** Callback for disconnect call (AT+CHUP)
* type will denote Speaker/Mic gain (BtHfVolumeControl).
*/
typedef void (* bthf_volume_cmd_callback)(bthf_volume_type_t type, int volume, RawAddress *bd_addr);
/** Callback for dialing an outgoing call
* If number is NULL, redial
*/
typedef void (* bthf_dial_call_cmd_callback)(char *number, RawAddress *bd_addr);
/** Callback for sending DTMF tones
* tone contains the dtmf character to be sent
*/
typedef void (* bthf_dtmf_cmd_callback)(char tone, RawAddress *bd_addr);
/** Callback for enabling/disabling noise reduction/echo cancellation
* value will be 1 to enable, 0 to disable
*/
typedef void (* bthf_nrec_cmd_callback)(bthf_nrec_t nrec, RawAddress *bd_addr);
/** Callback for AT+BCS and event from BAC
* WBS enable, WBS disable
*/
typedef void (* bthf_wbs_callback)(bthf_wbs_config_t wbs, RawAddress *bd_addr);
/** Callback for call hold handling (AT+CHLD)
* value will contain the call hold command (0, 1, 2, 3)
*/
typedef void (* bthf_chld_cmd_callback)(bthf_chld_type_t chld, RawAddress *bd_addr);
/** Callback for CNUM (subscriber number)
*/
typedef void (* bthf_cnum_cmd_callback)(RawAddress *bd_addr);
/** Callback for indicators (CIND)
*/
typedef void (* bthf_cind_cmd_callback)(RawAddress *bd_addr);
/** Callback for operator selection (COPS)
*/
typedef void (* bthf_cops_cmd_callback)(RawAddress *bd_addr);
/** Callback for call list (AT+CLCC)
*/
typedef void (* bthf_clcc_cmd_callback) (RawAddress *bd_addr);
/** Callback for unknown AT command recd from HF
* at_string will contain the unparsed AT string
*/
typedef void (* bthf_unknown_at_cmd_callback)(char *at_string, RawAddress *bd_addr);
/** Callback for keypressed (HSP) event.
*/
typedef void (* bthf_key_pressed_cmd_callback)(RawAddress *bd_addr);
/** Callback for BIND. Pass the remote HF Indicators supported.
*/
typedef void (* bthf_bind_cmd_callback)(char *at_string, RawAddress *bd_addr);
/** Callback for BIEV. Pass the change in the Remote HF indicator values
*/
typedef void (* bthf_biev_cmd_callback)(bthf_hf_ind_type_t ind_id, int ind_value,
RawAddress *bd_addr);
/** BT-HF callback structure. */
typedef struct {
/** set to sizeof(BtHfCallbacks) */
size_t size;
bthf_connection_state_callback connection_state_cb;
bthf_audio_state_callback audio_state_cb;
bthf_vr_cmd_callback vr_cmd_cb;
bthf_answer_call_cmd_callback answer_call_cmd_cb;
bthf_hangup_call_cmd_callback hangup_call_cmd_cb;
bthf_volume_cmd_callback volume_cmd_cb;
bthf_dial_call_cmd_callback dial_call_cmd_cb;
bthf_dtmf_cmd_callback dtmf_cmd_cb;
bthf_nrec_cmd_callback nrec_cmd_cb;
bthf_wbs_callback wbs_cb;
bthf_chld_cmd_callback chld_cmd_cb;
bthf_cnum_cmd_callback cnum_cmd_cb;
bthf_cind_cmd_callback cind_cmd_cb;
bthf_cops_cmd_callback cops_cmd_cb;
bthf_clcc_cmd_callback clcc_cmd_cb;
bthf_unknown_at_cmd_callback unknown_at_cmd_cb;
bthf_bind_cmd_callback bind_cb;
bthf_biev_cmd_callback biev_cb;
bthf_key_pressed_cmd_callback key_pressed_cmd_cb;
} bthf_callbacks_t;
/** Network Status */
typedef enum
{
BTHF_NETWORK_STATE_NOT_AVAILABLE = 0,
BTHF_NETWORK_STATE_AVAILABLE
} bthf_network_state_t;
/** Service type */
typedef enum
{
BTHF_SERVICE_TYPE_HOME = 0,
BTHF_SERVICE_TYPE_ROAMING
} bthf_service_type_t;
typedef enum {
BTHF_CALL_STATE_ACTIVE = 0,
BTHF_CALL_STATE_HELD,
BTHF_CALL_STATE_DIALING,
BTHF_CALL_STATE_ALERTING,
BTHF_CALL_STATE_INCOMING,
BTHF_CALL_STATE_WAITING,
BTHF_CALL_STATE_IDLE
} bthf_call_state_t;
typedef enum {
BTHF_CALL_DIRECTION_OUTGOING = 0,
BTHF_CALL_DIRECTION_INCOMING
} bthf_call_direction_t;
typedef enum {
BTHF_CALL_TYPE_VOICE = 0,
BTHF_CALL_TYPE_DATA,
BTHF_CALL_TYPE_FAX
} bthf_call_mode_t;
typedef enum {
BTHF_CALL_MPTY_TYPE_SINGLE = 0,
BTHF_CALL_MPTY_TYPE_MULTI
} bthf_call_mpty_type_t;
typedef enum {
BTHF_CALL_ADDRTYPE_UNKNOWN = 0x81,
BTHF_CALL_ADDRTYPE_INTERNATIONAL = 0x91
} bthf_call_addrtype_t;
/** Represents the standard BT-HF interface. */
typedef struct {
/** set to sizeof(BtHfInterface) */
size_t size;
/**
* Register the BtHf callbacks
*/
bt_status_t (*init)( bthf_callbacks_t* callbacks, int max_hf_clients, bool inband_ringing_supported);
/** connect to headset */
bt_status_t (*connect)( RawAddress *bd_addr );
/** dis-connect from headset */
bt_status_t (*disconnect)( RawAddress *bd_addr );
/** create an audio connection */
bt_status_t (*connect_audio)( RawAddress *bd_addr );
/** close the audio connection */
bt_status_t (*disconnect_audio)( RawAddress *bd_addr );
/** start voice recognition */
bt_status_t (*start_voice_recognition)( RawAddress *bd_addr );
/** stop voice recognition */
bt_status_t (*stop_voice_recognition)( RawAddress *bd_addr );
/** volume control */
bt_status_t (*volume_control) (bthf_volume_type_t type, int volume, RawAddress *bd_addr );
/** Combined device status change notification */
bt_status_t (*device_status_notification)(bthf_network_state_t ntk_state, bthf_service_type_t svc_type, int signal,
int batt_chg);
/** Response for COPS command */
bt_status_t (*cops_response)(const char *cops, RawAddress *bd_addr );
/** Response for CIND command */
bt_status_t (*cind_response)(int svc, int num_active, int num_held, bthf_call_state_t call_setup_state,
int signal, int roam, int batt_chg, RawAddress *bd_addr );
/** Pre-formatted AT response, typically in response to unknown AT cmd */
bt_status_t (*formatted_at_response)(const char *rsp, RawAddress *bd_addr );
/** ok/error response
* ERROR (0)
* OK (1)
*/
bt_status_t (*at_response) (bthf_at_response_t response_code, int error_code, RawAddress *bd_addr );
/** response for CLCC command
* Can be iteratively called for each call index
* Call index of 0 will be treated as NULL termination (Completes response)
*/
bt_status_t (*clcc_response) (int index, bthf_call_direction_t dir,
bthf_call_state_t state, bthf_call_mode_t mode,
bthf_call_mpty_type_t mpty, const char *number,
bthf_call_addrtype_t type, RawAddress *bd_addr );
/** notify of a call state change
* Each update notifies
* 1. Number of active/held/ringing calls
* 2. call_state: This denotes the state change that triggered this msg
* This will take one of the values from BtHfCallState
* 3. number & type: valid only for incoming & waiting call
*/
bt_status_t (*phone_state_change) (int num_active, int num_held, bthf_call_state_t call_setup_state,
const char *number, bthf_call_addrtype_t type);
/** Closes the interface. */
void (*cleanup)( void );
/** configuration for the SCO codec */
bt_status_t (*configure_wbs)( RawAddress *bd_addr ,bthf_wbs_config_t config );
/** Response for HF Indicator change (+BIND) */
bt_status_t (*bind_response)(bthf_hf_ind_type_t ind_id, bthf_hf_ind_status_t ind_status,
RawAddress *bd_addr);
/** Whether we will initiate SCO or not **/
bt_status_t (*set_sco_allowed)(bool value);
} bthf_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_HF_H */

View file

@ -1,383 +0,0 @@
/*
* Copyright (C) 2012-2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_HF_CLIENT_H
#define ANDROID_INCLUDE_BT_HF_CLIENT_H
__BEGIN_DECLS
typedef enum {
BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED = 0,
BTHF_CLIENT_CONNECTION_STATE_CONNECTING,
BTHF_CLIENT_CONNECTION_STATE_CONNECTED,
BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED,
BTHF_CLIENT_CONNECTION_STATE_DISCONNECTING
} bthf_client_connection_state_t;
typedef enum {
BTHF_CLIENT_AUDIO_STATE_DISCONNECTED = 0,
BTHF_CLIENT_AUDIO_STATE_CONNECTING,
BTHF_CLIENT_AUDIO_STATE_CONNECTED,
BTHF_CLIENT_AUDIO_STATE_CONNECTED_MSBC,
} bthf_client_audio_state_t;
typedef enum {
BTHF_CLIENT_VR_STATE_STOPPED = 0,
BTHF_CLIENT_VR_STATE_STARTED
} bthf_client_vr_state_t;
typedef enum {
BTHF_CLIENT_VOLUME_TYPE_SPK = 0,
BTHF_CLIENT_VOLUME_TYPE_MIC
} bthf_client_volume_type_t;
typedef enum
{
BTHF_CLIENT_NETWORK_STATE_NOT_AVAILABLE = 0,
BTHF_CLIENT_NETWORK_STATE_AVAILABLE
} bthf_client_network_state_t;
typedef enum
{
BTHF_CLIENT_SERVICE_TYPE_HOME = 0,
BTHF_CLIENT_SERVICE_TYPE_ROAMING
} bthf_client_service_type_t;
typedef enum {
BTHF_CLIENT_CALL_STATE_ACTIVE = 0,
BTHF_CLIENT_CALL_STATE_HELD,
BTHF_CLIENT_CALL_STATE_DIALING,
BTHF_CLIENT_CALL_STATE_ALERTING,
BTHF_CLIENT_CALL_STATE_INCOMING,
BTHF_CLIENT_CALL_STATE_WAITING,
BTHF_CLIENT_CALL_STATE_HELD_BY_RESP_HOLD,
} bthf_client_call_state_t;
typedef enum {
BTHF_CLIENT_CALL_NO_CALLS_IN_PROGRESS = 0,
BTHF_CLIENT_CALL_CALLS_IN_PROGRESS
} bthf_client_call_t;
typedef enum {
BTHF_CLIENT_CALLSETUP_NONE = 0,
BTHF_CLIENT_CALLSETUP_INCOMING,
BTHF_CLIENT_CALLSETUP_OUTGOING,
BTHF_CLIENT_CALLSETUP_ALERTING
} bthf_client_callsetup_t;
typedef enum {
BTHF_CLIENT_CALLHELD_NONE = 0,
BTHF_CLIENT_CALLHELD_HOLD_AND_ACTIVE,
BTHF_CLIENT_CALLHELD_HOLD,
} bthf_client_callheld_t;
typedef enum {
BTHF_CLIENT_RESP_AND_HOLD_HELD = 0,
BTRH_CLIENT_RESP_AND_HOLD_ACCEPT,
BTRH_CLIENT_RESP_AND_HOLD_REJECT,
} bthf_client_resp_and_hold_t;
typedef enum {
BTHF_CLIENT_CALL_DIRECTION_OUTGOING = 0,
BTHF_CLIENT_CALL_DIRECTION_INCOMING
} bthf_client_call_direction_t;
typedef enum {
BTHF_CLIENT_CALL_MPTY_TYPE_SINGLE = 0,
BTHF_CLIENT_CALL_MPTY_TYPE_MULTI
} bthf_client_call_mpty_type_t;
typedef enum {
BTHF_CLIENT_CMD_COMPLETE_OK = 0,
BTHF_CLIENT_CMD_COMPLETE_ERROR,
BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_CARRIER,
BTHF_CLIENT_CMD_COMPLETE_ERROR_BUSY,
BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_ANSWER,
BTHF_CLIENT_CMD_COMPLETE_ERROR_DELAYED,
BTHF_CLIENT_CMD_COMPLETE_ERROR_BLACKLISTED,
BTHF_CLIENT_CMD_COMPLETE_ERROR_CME
} bthf_client_cmd_complete_t;
typedef enum {
BTHF_CLIENT_CALL_ACTION_CHLD_0 = 0,
BTHF_CLIENT_CALL_ACTION_CHLD_1,
BTHF_CLIENT_CALL_ACTION_CHLD_2,
BTHF_CLIENT_CALL_ACTION_CHLD_3,
BTHF_CLIENT_CALL_ACTION_CHLD_4,
BTHF_CLIENT_CALL_ACTION_CHLD_1x,
BTHF_CLIENT_CALL_ACTION_CHLD_2x,
BTHF_CLIENT_CALL_ACTION_ATA,
BTHF_CLIENT_CALL_ACTION_CHUP,
BTHF_CLIENT_CALL_ACTION_BTRH_0,
BTHF_CLIENT_CALL_ACTION_BTRH_1,
BTHF_CLIENT_CALL_ACTION_BTRH_2,
} bthf_client_call_action_t;
typedef enum {
BTHF_CLIENT_SERVICE_UNKNOWN = 0,
BTHF_CLIENT_SERVICE_VOICE,
BTHF_CLIENT_SERVICE_FAX
} bthf_client_subscriber_service_type_t;
typedef enum {
BTHF_CLIENT_IN_BAND_RINGTONE_NOT_PROVIDED = 0,
BTHF_CLIENT_IN_BAND_RINGTONE_PROVIDED,
} bthf_client_in_band_ring_state_t;
/* Peer features masks */
#define BTHF_CLIENT_PEER_FEAT_3WAY 0x00000001 /* Three-way calling */
#define BTHF_CLIENT_PEER_FEAT_ECNR 0x00000002 /* Echo cancellation and/or noise reduction */
#define BTHF_CLIENT_PEER_FEAT_VREC 0x00000004 /* Voice recognition */
#define BTHF_CLIENT_PEER_FEAT_INBAND 0x00000008 /* In-band ring tone */
#define BTHF_CLIENT_PEER_FEAT_VTAG 0x00000010 /* Attach a phone number to a voice tag */
#define BTHF_CLIENT_PEER_FEAT_REJECT 0x00000020 /* Ability to reject incoming call */
#define BTHF_CLIENT_PEER_FEAT_ECS 0x00000040 /* Enhanced Call Status */
#define BTHF_CLIENT_PEER_FEAT_ECC 0x00000080 /* Enhanced Call Control */
#define BTHF_CLIENT_PEER_FEAT_EXTERR 0x00000100 /* Extended error codes */
#define BTHF_CLIENT_PEER_FEAT_CODEC 0x00000200 /* Codec Negotiation */
/* Peer call handling features masks */
#define BTHF_CLIENT_CHLD_FEAT_REL 0x00000001 /* 0 Release waiting call or held calls */
#define BTHF_CLIENT_CHLD_FEAT_REL_ACC 0x00000002 /* 1 Release active calls and accept other
(waiting or held) cal */
#define BTHF_CLIENT_CHLD_FEAT_REL_X 0x00000004 /* 1x Release specified active call only */
#define BTHF_CLIENT_CHLD_FEAT_HOLD_ACC 0x00000008 /* 2 Active calls on hold and accept other
(waiting or held) call */
#define BTHF_CLIENT_CHLD_FEAT_PRIV_X 0x00000010 /* 2x Request private mode with specified
call (put the rest on hold) */
#define BTHF_CLIENT_CHLD_FEAT_MERGE 0x00000020 /* 3 Add held call to multiparty */
#define BTHF_CLIENT_CHLD_FEAT_MERGE_DETACH 0x00000040 /* 4 Connect two calls and leave
(disconnect from) multiparty */
/** Callback for connection state change.
* state will have one of the values from BtHfConnectionState
* peer/chld_features are valid only for BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED state
*/
typedef void (* bthf_client_connection_state_callback)(const RawAddress *bd_addr,
bthf_client_connection_state_t state,
unsigned int peer_feat,
unsigned int chld_feat);
/** Callback for audio connection state change.
* state will have one of the values from BtHfAudioState
*/
typedef void (* bthf_client_audio_state_callback)(const RawAddress *bd_addr,
bthf_client_audio_state_t state);
/** Callback for VR connection state change.
* state will have one of the values from BtHfVRState
*/
typedef void (* bthf_client_vr_cmd_callback)(const RawAddress *bd_addr, bthf_client_vr_state_t state);
/** Callback for network state change
*/
typedef void (* bthf_client_network_state_callback) (const RawAddress *bd_addr,
bthf_client_network_state_t state);
/** Callback for network roaming status change
*/
typedef void (* bthf_client_network_roaming_callback) (const RawAddress *bd_addr,
bthf_client_service_type_t type);
/** Callback for signal strength indication
*/
typedef void (* bthf_client_network_signal_callback) (const RawAddress *bd_addr,
int signal_strength);
/** Callback for battery level indication
*/
typedef void (* bthf_client_battery_level_callback) (const RawAddress *bd_addr,
int battery_level);
/** Callback for current operator name
*/
typedef void (* bthf_client_current_operator_callback) (const RawAddress *bd_addr,
const char *name);
/** Callback for call indicator
*/
typedef void (* bthf_client_call_callback) (const RawAddress *bd_addr, bthf_client_call_t call);
/** Callback for callsetup indicator
*/
typedef void (* bthf_client_callsetup_callback) (const RawAddress *bd_addr,
bthf_client_callsetup_t callsetup);
/** Callback for callheld indicator
*/
typedef void (* bthf_client_callheld_callback) (const RawAddress *bd_addr,
bthf_client_callheld_t callheld);
/** Callback for response and hold
*/
typedef void (* bthf_client_resp_and_hold_callback) (const RawAddress *bd_addr,
bthf_client_resp_and_hold_t resp_and_hold);
/** Callback for Calling Line Identification notification
* Will be called only when there is an incoming call and number is provided.
*/
typedef void (* bthf_client_clip_callback) (const RawAddress *bd_addr, const char *number);
/**
* Callback for Call Waiting notification
*/
typedef void (* bthf_client_call_waiting_callback) (const RawAddress *bd_addr, const char *number);
/**
* Callback for listing current calls. Can be called multiple time.
* If number is unknown NULL is passed.
*/
typedef void (*bthf_client_current_calls) (const RawAddress *bd_addr, int index,
bthf_client_call_direction_t dir,
bthf_client_call_state_t state,
bthf_client_call_mpty_type_t mpty,
const char *number);
/** Callback for audio volume change
*/
typedef void (*bthf_client_volume_change_callback) (const RawAddress *bd_addr,
bthf_client_volume_type_t type,
int volume);
/** Callback for command complete event
* cme is valid only for BTHF_CLIENT_CMD_COMPLETE_ERROR_CME type
*/
typedef void (*bthf_client_cmd_complete_callback) (const RawAddress *bd_addr,
bthf_client_cmd_complete_t type,
int cme);
/** Callback for subscriber information
*/
typedef void (* bthf_client_subscriber_info_callback) (const RawAddress *bd_addr,
const char *name,
bthf_client_subscriber_service_type_t type);
/** Callback for in-band ring tone settings
*/
typedef void (* bthf_client_in_band_ring_tone_callback) (const RawAddress *bd_addr,
bthf_client_in_band_ring_state_t state);
/**
* Callback for requested number from AG
*/
typedef void (* bthf_client_last_voice_tag_number_callback) (const RawAddress *bd_addr,
const char *number);
/**
* Callback for sending ring indication to app
*/
typedef void (* bthf_client_ring_indication_callback) (const RawAddress *bd_addr);
/** BT-HF callback structure. */
typedef struct {
/** set to sizeof(BtHfClientCallbacks) */
size_t size;
bthf_client_connection_state_callback connection_state_cb;
bthf_client_audio_state_callback audio_state_cb;
bthf_client_vr_cmd_callback vr_cmd_cb;
bthf_client_network_state_callback network_state_cb;
bthf_client_network_roaming_callback network_roaming_cb;
bthf_client_network_signal_callback network_signal_cb;
bthf_client_battery_level_callback battery_level_cb;
bthf_client_current_operator_callback current_operator_cb;
bthf_client_call_callback call_cb;
bthf_client_callsetup_callback callsetup_cb;
bthf_client_callheld_callback callheld_cb;
bthf_client_resp_and_hold_callback resp_and_hold_cb;
bthf_client_clip_callback clip_cb;
bthf_client_call_waiting_callback call_waiting_cb;
bthf_client_current_calls current_calls_cb;
bthf_client_volume_change_callback volume_change_cb;
bthf_client_cmd_complete_callback cmd_complete_cb;
bthf_client_subscriber_info_callback subscriber_info_cb;
bthf_client_in_band_ring_tone_callback in_band_ring_tone_cb;
bthf_client_last_voice_tag_number_callback last_voice_tag_number_callback;
bthf_client_ring_indication_callback ring_indication_cb;
} bthf_client_callbacks_t;
/** Represents the standard BT-HF interface. */
typedef struct {
/** set to sizeof(BtHfClientInterface) */
size_t size;
/**
* Register the BtHf callbacks
*/
bt_status_t (*init)(bthf_client_callbacks_t* callbacks);
/** connect to audio gateway */
bt_status_t (*connect)(RawAddress *bd_addr);
/** disconnect from audio gateway */
bt_status_t (*disconnect)(const RawAddress *bd_addr);
/** create an audio connection */
bt_status_t (*connect_audio)(const RawAddress *bd_addr);
/** close the audio connection */
bt_status_t (*disconnect_audio)(const RawAddress *bd_addr);
/** start voice recognition */
bt_status_t (*start_voice_recognition)(const RawAddress *bd_addr);
/** stop voice recognition */
bt_status_t (*stop_voice_recognition)(const RawAddress *bd_addr);
/** volume control */
bt_status_t (*volume_control) (const RawAddress *bd_addr,
bthf_client_volume_type_t type,
int volume);
/** place a call with number a number
* if number is NULL last called number is called (aka re-dial)*/
bt_status_t (*dial) (const RawAddress *bd_addr, const char *number);
/** place a call with number specified by location (speed dial) */
bt_status_t (*dial_memory) (const RawAddress *bd_addr, int location);
/** perform specified call related action
* idx is limited only for enhanced call control related action
*/
bt_status_t (*handle_call_action) (const RawAddress *bd_addr,
bthf_client_call_action_t action,
int idx);
/** query list of current calls */
bt_status_t (*query_current_calls) (const RawAddress *bd_addr);
/** query name of current selected operator */
bt_status_t (*query_current_operator_name) (const RawAddress *bd_addr);
/** Retrieve subscriber information */
bt_status_t (*retrieve_subscriber_info) (const RawAddress *bd_addr);
/** Send DTMF code*/
bt_status_t (*send_dtmf) (const RawAddress *bd_addr, char code);
/** Request a phone number from AG corresponding to last voice tag recorded */
bt_status_t (*request_last_voice_tag_number) (const RawAddress *bd_addr);
/** Closes the interface. */
void (*cleanup)(void);
/** Send AT Command. */
bt_status_t (*send_at_cmd) (const RawAddress *bd_addr, int cmd, int val1, int val2, const char *arg);
} bthf_client_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_HF_CLIENT_H */

View file

@ -1,191 +0,0 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_HH_H
#define ANDROID_INCLUDE_BT_HH_H
#include <stdint.h>
__BEGIN_DECLS
#define BTHH_MAX_DSC_LEN 884
/* HH connection states */
typedef enum
{
BTHH_CONN_STATE_CONNECTED = 0,
BTHH_CONN_STATE_CONNECTING,
BTHH_CONN_STATE_DISCONNECTED,
BTHH_CONN_STATE_DISCONNECTING,
BTHH_CONN_STATE_FAILED_MOUSE_FROM_HOST,
BTHH_CONN_STATE_FAILED_KBD_FROM_HOST,
BTHH_CONN_STATE_FAILED_TOO_MANY_DEVICES,
BTHH_CONN_STATE_FAILED_NO_BTHID_DRIVER,
BTHH_CONN_STATE_FAILED_GENERIC,
BTHH_CONN_STATE_UNKNOWN
} bthh_connection_state_t;
typedef enum
{
BTHH_OK = 0,
BTHH_HS_HID_NOT_READY, /* handshake error : device not ready */
BTHH_HS_INVALID_RPT_ID, /* handshake error : invalid report ID */
BTHH_HS_TRANS_NOT_SPT, /* handshake error : transaction not spt */
BTHH_HS_INVALID_PARAM, /* handshake error : invalid paremter */
BTHH_HS_ERROR, /* handshake error : unspecified HS error */
BTHH_ERR, /* general BTA HH error */
BTHH_ERR_SDP, /* SDP error */
BTHH_ERR_PROTO, /* SET_Protocol error,
only used in BTA_HH_OPEN_EVT callback */
BTHH_ERR_DB_FULL, /* device database full error, used */
BTHH_ERR_TOD_UNSPT, /* type of device not supported */
BTHH_ERR_NO_RES, /* out of system resources */
BTHH_ERR_AUTH_FAILED, /* authentication fail */
BTHH_ERR_HDL
}bthh_status_t;
/* Protocol modes */
typedef enum {
BTHH_REPORT_MODE = 0x00,
BTHH_BOOT_MODE = 0x01,
BTHH_UNSUPPORTED_MODE = 0xff
}bthh_protocol_mode_t;
/* Report types */
typedef enum {
BTHH_INPUT_REPORT = 1,
BTHH_OUTPUT_REPORT,
BTHH_FEATURE_REPORT
}bthh_report_type_t;
typedef struct
{
int attr_mask;
uint8_t sub_class;
uint8_t app_id;
int vendor_id;
int product_id;
int version;
uint8_t ctry_code;
int dl_len;
uint8_t dsc_list[BTHH_MAX_DSC_LEN];
} bthh_hid_info_t;
/** Callback for connection state change.
* state will have one of the values from bthh_connection_state_t
*/
typedef void (* bthh_connection_state_callback)(RawAddress *bd_addr, bthh_connection_state_t state);
/** Callback for vitual unplug api.
* the status of the vitual unplug
*/
typedef void (* bthh_virtual_unplug_callback)(RawAddress *bd_addr, bthh_status_t hh_status);
/** Callback for get hid info
* hid_info will contain attr_mask, sub_class, app_id, vendor_id, product_id, version, ctry_code, len
*/
typedef void (* bthh_hid_info_callback)(RawAddress *bd_addr, bthh_hid_info_t hid_info);
/** Callback for get protocol api.
* the protocol mode is one of the value from bthh_protocol_mode_t
*/
typedef void (* bthh_protocol_mode_callback)(RawAddress *bd_addr, bthh_status_t hh_status, bthh_protocol_mode_t mode);
/** Callback for get/set_idle_time api.
*/
typedef void (* bthh_idle_time_callback)(RawAddress *bd_addr, bthh_status_t hh_status, int idle_rate);
/** Callback for get report api.
* if staus is ok rpt_data contains the report data
*/
typedef void (* bthh_get_report_callback)(RawAddress *bd_addr, bthh_status_t hh_status, uint8_t* rpt_data, int rpt_size);
/** Callback for set_report/set_protocol api and if error
* occurs for get_report/get_protocol api.
*/
typedef void (* bthh_handshake_callback)(RawAddress *bd_addr, bthh_status_t hh_status);
/** BT-HH callback structure. */
typedef struct {
/** set to sizeof(BtHfCallbacks) */
size_t size;
bthh_connection_state_callback connection_state_cb;
bthh_hid_info_callback hid_info_cb;
bthh_protocol_mode_callback protocol_mode_cb;
bthh_idle_time_callback idle_time_cb;
bthh_get_report_callback get_report_cb;
bthh_virtual_unplug_callback virtual_unplug_cb;
bthh_handshake_callback handshake_cb;
} bthh_callbacks_t;
/** Represents the standard BT-HH interface. */
typedef struct {
/** set to sizeof(BtHhInterface) */
size_t size;
/**
* Register the BtHh callbacks
*/
bt_status_t (*init)( bthh_callbacks_t* callbacks );
/** connect to hid device */
bt_status_t (*connect)( RawAddress *bd_addr);
/** dis-connect from hid device */
bt_status_t (*disconnect)( RawAddress *bd_addr );
/** Virtual UnPlug (VUP) the specified HID device */
bt_status_t (*virtual_unplug)(RawAddress *bd_addr);
/** Set the HID device descriptor for the specified HID device. */
bt_status_t (*set_info)(RawAddress *bd_addr, bthh_hid_info_t hid_info );
/** Get the HID proto mode. */
bt_status_t (*get_protocol) (RawAddress *bd_addr, bthh_protocol_mode_t protocolMode);
/** Set the HID proto mode. */
bt_status_t (*set_protocol)(RawAddress *bd_addr, bthh_protocol_mode_t protocolMode);
/** Get the HID Idle Time */
bt_status_t (*get_idle_time)(RawAddress *bd_addr);
/** Set the HID Idle Time */
bt_status_t (*set_idle_time)(RawAddress *bd_addr, uint8_t idleTime);
/** Send a GET_REPORT to HID device. */
bt_status_t (*get_report)(RawAddress *bd_addr, bthh_report_type_t reportType, uint8_t reportId, int bufferSize);
/** Send a SET_REPORT to HID device. */
bt_status_t (*set_report)(RawAddress *bd_addr, bthh_report_type_t reportType, char* report);
/** Send data to HID device. */
bt_status_t (*send_data)(RawAddress *bd_addr, char* data);
/** Closes the interface. */
void (*cleanup)( void );
} bthh_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_HH_H */

View file

@ -1,123 +0,0 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_HL_H
#define ANDROID_INCLUDE_BT_HL_H
__BEGIN_DECLS
/* HL connection states */
typedef enum
{
BTHL_MDEP_ROLE_SOURCE,
BTHL_MDEP_ROLE_SINK
} bthl_mdep_role_t;
typedef enum {
BTHL_APP_REG_STATE_REG_SUCCESS,
BTHL_APP_REG_STATE_REG_FAILED,
BTHL_APP_REG_STATE_DEREG_SUCCESS,
BTHL_APP_REG_STATE_DEREG_FAILED
} bthl_app_reg_state_t;
typedef enum
{
BTHL_CHANNEL_TYPE_RELIABLE,
BTHL_CHANNEL_TYPE_STREAMING,
BTHL_CHANNEL_TYPE_ANY
} bthl_channel_type_t;
/* HL connection states */
typedef enum {
BTHL_CONN_STATE_CONNECTING,
BTHL_CONN_STATE_CONNECTED,
BTHL_CONN_STATE_DISCONNECTING,
BTHL_CONN_STATE_DISCONNECTED,
BTHL_CONN_STATE_DESTROYED
} bthl_channel_state_t;
typedef struct
{
bthl_mdep_role_t mdep_role;
int data_type;
bthl_channel_type_t channel_type;
const char *mdep_description; /* MDEP description to be used in the SDP (optional); null terminated */
} bthl_mdep_cfg_t;
typedef struct
{
const char *application_name;
const char *provider_name; /* provider name to be used in the SDP (optional); null terminated */
const char *srv_name; /* service name to be used in the SDP (optional); null terminated*/
const char *srv_desp; /* service description to be used in the SDP (optional); null terminated */
int number_of_mdeps;
bthl_mdep_cfg_t *mdep_cfg; /* Dynamic array */
} bthl_reg_param_t;
/** Callback for application registration status.
* state will have one of the values from bthl_app_reg_state_t
*/
typedef void (* bthl_app_reg_state_callback)(int app_id, bthl_app_reg_state_t state);
/** Callback for channel connection state change.
* state will have one of the values from
* bthl_connection_state_t and fd (file descriptor)
*/
typedef void (* bthl_channel_state_callback)(int app_id, RawAddress *bd_addr, int mdep_cfg_index, int channel_id, bthl_channel_state_t state, int fd);
/** BT-HL callback structure. */
typedef struct {
/** set to sizeof(bthl_callbacks_t) */
size_t size;
bthl_app_reg_state_callback app_reg_state_cb;
bthl_channel_state_callback channel_state_cb;
} bthl_callbacks_t;
/** Represents the standard BT-HL interface. */
typedef struct {
/** set to sizeof(bthl_interface_t) */
size_t size;
/**
* Register the Bthl callbacks
*/
bt_status_t (*init)( bthl_callbacks_t* callbacks );
/** Register HL application */
bt_status_t (*register_application) ( bthl_reg_param_t *p_reg_param, int *app_id);
/** Unregister HL application */
bt_status_t (*unregister_application) (int app_id);
/** connect channel */
bt_status_t (*connect_channel)(int app_id, RawAddress *bd_addr, int mdep_cfg_index, int *channel_id);
/** destroy channel */
bt_status_t (*destroy_channel)(int channel_id);
/** Close the Bthl callback **/
void (*cleanup)(void);
} bthl_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_HL_H */

View file

@ -1,54 +0,0 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_MCE_H
#define ANDROID_INCLUDE_BT_MCE_H
__BEGIN_DECLS
/** MAS instance description */
typedef struct
{
int id;
int scn;
int msg_types;
char *p_name;
} btmce_mas_instance_t;
/** callback for get_remote_mas_instances */
typedef void (*btmce_remote_mas_instances_callback)(bt_status_t status, RawAddress *bd_addr,
int num_instances, btmce_mas_instance_t *instances);
typedef struct {
/** set to sizeof(btmce_callbacks_t) */
size_t size;
btmce_remote_mas_instances_callback remote_mas_instances_cb;
} btmce_callbacks_t;
typedef struct {
/** set to size of this struct */
size_t size;
/** register BT MCE callbacks */
bt_status_t (*init)(btmce_callbacks_t *callbacks);
/** search for MAS instances on remote device */
bt_status_t (*get_remote_mas_instances)(RawAddress *bd_addr);
} btmce_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_MCE_H */

View file

@ -1,87 +0,0 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_PAN_H
#define ANDROID_INCLUDE_BT_PAN_H
__BEGIN_DECLS
#define BTPAN_ROLE_NONE 0
#define BTPAN_ROLE_PANNAP 1
#define BTPAN_ROLE_PANU 2
typedef enum {
BTPAN_STATE_CONNECTED = 0,
BTPAN_STATE_CONNECTING = 1,
BTPAN_STATE_DISCONNECTED = 2,
BTPAN_STATE_DISCONNECTING = 3
} btpan_connection_state_t;
typedef enum {
BTPAN_STATE_ENABLED = 0,
BTPAN_STATE_DISABLED = 1
} btpan_control_state_t;
/**
* Callback for pan connection state
*/
typedef void (*btpan_connection_state_callback)(btpan_connection_state_t state, bt_status_t error,
const RawAddress *bd_addr, int local_role, int remote_role);
typedef void (*btpan_control_state_callback)(btpan_control_state_t state, int local_role,
bt_status_t error, const char* ifname);
typedef struct {
size_t size;
btpan_control_state_callback control_state_cb;
btpan_connection_state_callback connection_state_cb;
} btpan_callbacks_t;
typedef struct {
/** set to size of this struct*/
size_t size;
/**
* Initialize the pan interface and register the btpan callbacks
*/
bt_status_t (*init)(const btpan_callbacks_t* callbacks);
/*
* enable the pan service by specified role. The result state of
* enabl will be returned by btpan_control_state_callback. when pan-nap is enabled,
* the state of connecting panu device will be notified by btpan_connection_state_callback
*/
bt_status_t (*enable)(int local_role);
/*
* get current pan local role
*/
int (*get_local_role)(void);
/**
* start bluetooth pan connection to the remote device by specified pan role. The result state will be
* returned by btpan_connection_state_callback
*/
bt_status_t (*connect)(const RawAddress *bd_addr, int local_role, int remote_role);
/**
* stop bluetooth pan connection. The result state will be returned by btpan_connection_state_callback
*/
bt_status_t (*disconnect)(const RawAddress *bd_addr);
/**
* Cleanup the pan interface
*/
void (*cleanup)(void);
} btpan_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_PAN_H */

View file

@ -1,649 +0,0 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_RC_H
#define ANDROID_INCLUDE_BT_RC_H
__BEGIN_DECLS
/* Change this macro to use multiple RC */
#define BT_RC_NUM_APP 1
/* Macros */
#define BTRC_MAX_ATTR_STR_LEN (1 << 16)
#define BTRC_UID_SIZE 8
#define BTRC_MAX_APP_SETTINGS 8
#define BTRC_MAX_FOLDER_DEPTH 4
#define BTRC_MAX_APP_ATTR_SIZE 16
#define BTRC_MAX_ELEM_ATTR_SIZE 8
#define BTRC_FEATURE_BIT_MASK_SIZE 16
/* Macros for valid scopes in get_folder_items */
#define BTRC_SCOPE_PLAYER_LIST 0x00 /* Media Player List */
#define BTRC_SCOPE_FILE_SYSTEM 0x01 /* Virtual File System */
#define BTRC_SCOPE_SEARCH 0x02 /* Search */
#define BTRC_SCOPE_NOW_PLAYING 0x03 /* Now Playing */
/* Macros for supported character encoding */
#define BTRC_CHARSET_ID_UTF8 0x006A
/* Macros for item types */
#define BTRC_ITEM_PLAYER 0x01 /* Media Player */
#define BTRC_ITEM_FOLDER 0x02 /* Folder */
#define BTRC_ITEM_MEDIA 0x03 /* Media File */
/* Macros for media attribute IDs */
#define BTRC_MEDIA_ATTR_ID_INVALID -1
#define BTRC_MEDIA_ATTR_ID_TITLE 0x00000001
#define BTRC_MEDIA_ATTR_ID_ARTIST 0x00000002
#define BTRC_MEDIA_ATTR_ID_ALBUM 0x00000003
#define BTRC_MEDIA_ATTR_ID_TRACK_NUM 0x00000004
#define BTRC_MEDIA_ATTR_ID_NUM_TRACKS 0x00000005
#define BTRC_MEDIA_ATTR_ID_GENRE 0x00000006
#define BTRC_MEDIA_ATTR_ID_PLAYING_TIME 0x00000007 /* in miliseconds */
/* Macros for folder types */
#define BTRC_FOLDER_TYPE_MIXED 0x00
#define BTRC_FOLDER_TYPE_TITLES 0x01
#define BTRC_FOLDER_TYPE_ALBUMS 0x02
#define BTRC_FOLDER_TYPE_ARTISTS 0x03
#define BTRC_FOLDER_TYPE_GENRES 0x04
#define BTRC_FOLDER_TYPE_PLAYLISTS 0x05
#define BTRC_FOLDER_TYPE_YEARS 0x06
/* Macros for media types */
#define BTRC_MEDIA_TYPE_AUDIO 0x00 /* audio */
#define BTRC_MEDIA_TYPE_VIDEO 0x01 /* video */
/* Macros for num attributes */
#define BTRC_NUM_ATTR_NONE 0xFF /* No attributes required */
#define BTRC_NUM_ATTR_ALL 0X00 /* All attributes required */
#define BTRC_HANDLE_NONE 0xFF
typedef uint8_t btrc_uid_t[BTRC_UID_SIZE];
typedef enum {
BTRC_CONNECTION_STATE_DISCONNECTED = 0,
BTRC_CONNECTION_STATE_CONNECTED
} btrc_connection_state_t;
typedef enum {
BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */
BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */
BTRC_FEAT_ABSOLUTE_VOLUME = 0x02, /* Supports TG role and volume sync */
BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */
} btrc_remote_features_t;
typedef enum {
BTRC_PLAYSTATE_STOPPED = 0x00, /* Stopped */
BTRC_PLAYSTATE_PLAYING = 0x01, /* Playing */
BTRC_PLAYSTATE_PAUSED = 0x02, /* Paused */
BTRC_PLAYSTATE_FWD_SEEK = 0x03, /* Fwd Seek*/
BTRC_PLAYSTATE_REV_SEEK = 0x04, /* Rev Seek*/
BTRC_PLAYSTATE_ERROR = 0xFF, /* Error */
} btrc_play_status_t;
typedef enum {
BTRC_EVT_PLAY_STATUS_CHANGED = 0x01,
BTRC_EVT_TRACK_CHANGE = 0x02,
BTRC_EVT_TRACK_REACHED_END = 0x03,
BTRC_EVT_TRACK_REACHED_START = 0x04,
BTRC_EVT_PLAY_POS_CHANGED = 0x05,
BTRC_EVT_APP_SETTINGS_CHANGED = 0x08,
BTRC_EVT_NOW_PLAYING_CONTENT_CHANGED = 0x09,
BTRC_EVT_AVAL_PLAYER_CHANGE = 0x0a,
BTRC_EVT_ADDR_PLAYER_CHANGE = 0x0b,
BTRC_EVT_UIDS_CHANGED = 0x0c,
BTRC_EVT_VOL_CHANGED = 0x0d,
} btrc_event_id_t;
typedef enum {
BTRC_NOTIFICATION_TYPE_INTERIM = 0,
BTRC_NOTIFICATION_TYPE_CHANGED = 1,
} btrc_notification_type_t;
typedef enum {
BTRC_PLAYER_ATTR_EQUALIZER = 0x01,
BTRC_PLAYER_ATTR_REPEAT = 0x02,
BTRC_PLAYER_ATTR_SHUFFLE = 0x03,
BTRC_PLAYER_ATTR_SCAN = 0x04,
} btrc_player_attr_t;
typedef enum {
BTRC_MEDIA_ATTR_TITLE = 0x01,
BTRC_MEDIA_ATTR_ARTIST = 0x02,
BTRC_MEDIA_ATTR_ALBUM = 0x03,
BTRC_MEDIA_ATTR_TRACK_NUM = 0x04,
BTRC_MEDIA_ATTR_NUM_TRACKS = 0x05,
BTRC_MEDIA_ATTR_GENRE = 0x06,
BTRC_MEDIA_ATTR_PLAYING_TIME = 0x07,
} btrc_media_attr_t;
typedef enum {
BTRC_PLAYER_VAL_OFF_REPEAT = 0x01,
BTRC_PLAYER_VAL_SINGLE_REPEAT = 0x02,
BTRC_PLAYER_VAL_ALL_REPEAT = 0x03,
BTRC_PLAYER_VAL_GROUP_REPEAT = 0x04
} btrc_player_repeat_val_t;
typedef enum {
BTRC_PLAYER_VAL_OFF_SHUFFLE = 0x01,
BTRC_PLAYER_VAL_ALL_SHUFFLE = 0x02,
BTRC_PLAYER_VAL_GROUP_SHUFFLE = 0x03
} btrc_player_shuffle_val_t;
typedef enum {
BTRC_STS_BAD_CMD = 0x00, /* Invalid command */
BTRC_STS_BAD_PARAM = 0x01, /* Invalid parameter */
BTRC_STS_NOT_FOUND = 0x02, /* Specified parameter is wrong or not found */
BTRC_STS_INTERNAL_ERR = 0x03, /* Internal Error */
BTRC_STS_NO_ERROR = 0x04, /* Operation Success */
BTRC_STS_UID_CHANGED = 0x05, /* UIDs changed */
BTRC_STS_RESERVED = 0x06, /* Reserved */
BTRC_STS_INV_DIRN = 0x07, /* Invalid direction */
BTRC_STS_INV_DIRECTORY = 0x08, /* Invalid directory */
BTRC_STS_INV_ITEM = 0x09, /* Invalid Item */
BTRC_STS_INV_SCOPE = 0x0a, /* Invalid scope */
BTRC_STS_INV_RANGE = 0x0b, /* Invalid range */
BTRC_STS_DIRECTORY = 0x0c, /* UID is a directory */
BTRC_STS_MEDIA_IN_USE = 0x0d, /* Media in use */
BTRC_STS_PLAY_LIST_FULL = 0x0e, /* Playing list full */
BTRC_STS_SRCH_NOT_SPRTD = 0x0f, /* Search not supported */
BTRC_STS_SRCH_IN_PROG = 0x10, /* Search in progress */
BTRC_STS_INV_PLAYER = 0x11, /* Invalid player */
BTRC_STS_PLAY_NOT_BROW = 0x12, /* Player not browsable */
BTRC_STS_PLAY_NOT_ADDR = 0x13, /* Player not addressed */
BTRC_STS_INV_RESULTS = 0x14, /* Invalid results */
BTRC_STS_NO_AVBL_PLAY = 0x15, /* No available players */
BTRC_STS_ADDR_PLAY_CHGD = 0x16, /* Addressed player changed */
} btrc_status_t;
typedef struct {
uint16_t player_id;
uint16_t uid_counter;
} btrc_addr_player_changed_t;
typedef struct {
uint8_t num_attr;
uint8_t attr_ids[BTRC_MAX_APP_SETTINGS];
uint8_t attr_values[BTRC_MAX_APP_SETTINGS];
} btrc_player_settings_t;
typedef struct {
uint8_t val;
uint16_t charset_id;
uint16_t str_len;
uint8_t *p_str;
} btrc_player_app_ext_attr_val_t;
typedef struct {
uint8_t attr_id;
uint16_t charset_id;
uint16_t str_len;
uint8_t *p_str;
uint8_t num_val;
btrc_player_app_ext_attr_val_t ext_attr_val[BTRC_MAX_APP_ATTR_SIZE];
} btrc_player_app_ext_attr_t;
typedef struct {
uint8_t attr_id;
uint8_t num_val;
uint8_t attr_val[BTRC_MAX_APP_ATTR_SIZE];
} btrc_player_app_attr_t;
typedef struct {
uint32_t start_item;
uint32_t end_item;
uint32_t size;
uint32_t attrs[BTRC_MAX_ELEM_ATTR_SIZE];
uint8_t attr_count;
} btrc_getfolderitem_t;
typedef struct {
uint16_t type;
uint16_t uid_counter;
} btrc_uids_changed_t;
typedef struct {
uint16_t type;
} btrc_now_playing_changed_t;
typedef union
{
btrc_play_status_t play_status;
btrc_uid_t track; /* queue position in NowPlaying */
uint32_t song_pos;
uint16_t uid_counter;
btrc_player_settings_t player_setting;
btrc_addr_player_changed_t addr_player_changed;
btrc_uids_changed_t uids_changed;
btrc_now_playing_changed_t now_playing_changed;
} btrc_register_notification_t;
typedef struct {
uint8_t id; /* can be attr_id or value_id */
uint8_t text[BTRC_MAX_ATTR_STR_LEN];
} btrc_player_setting_text_t;
typedef struct {
uint32_t attr_id;
uint8_t text[BTRC_MAX_ATTR_STR_LEN];
} btrc_element_attr_val_t;
typedef struct {
uint16_t player_id;
uint8_t major_type;
uint32_t sub_type;
uint8_t play_status;
uint8_t features[BTRC_FEATURE_BIT_MASK_SIZE];
uint16_t charset_id;
uint8_t name[BTRC_MAX_ATTR_STR_LEN];
} btrc_item_player_t;
typedef struct {
uint8_t uid[BTRC_UID_SIZE];
uint8_t type;
uint8_t playable;
uint16_t charset_id;
uint8_t name[BTRC_MAX_ATTR_STR_LEN];
} btrc_item_folder_t;
typedef struct {
uint8_t uid[BTRC_UID_SIZE];
uint8_t type;
uint16_t charset_id;
uint8_t name[BTRC_MAX_ATTR_STR_LEN];
int num_attrs;
btrc_element_attr_val_t* p_attrs;
} btrc_item_media_t;
typedef struct {
uint8_t item_type;
union
{
btrc_item_player_t player;
btrc_item_folder_t folder;
btrc_item_media_t media;
};
} btrc_folder_items_t;
typedef struct {
uint16_t str_len;
uint8_t p_str[BTRC_MAX_ATTR_STR_LEN];
} btrc_br_folder_name_t;
/** Callback for the controller's supported feautres */
typedef void (* btrc_remote_features_callback)(RawAddress *bd_addr,
btrc_remote_features_t features);
/** Callback for play status request */
typedef void (* btrc_get_play_status_callback)(RawAddress *bd_addr);
/** Callback for list player application attributes (Shuffle, Repeat,...) */
typedef void (* btrc_list_player_app_attr_callback)(RawAddress *bd_addr);
/** Callback for list player application attributes (Shuffle, Repeat,...) */
typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id,
RawAddress *bd_addr);
/** Callback for getting the current player application settings value
** num_attr: specifies the number of attribute ids contained in p_attrs
*/
typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr,
btrc_player_attr_t *p_attrs, RawAddress *bd_addr);
/** Callback for getting the player application settings attributes' text
** num_attr: specifies the number of attribute ids contained in p_attrs
*/
typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr,
btrc_player_attr_t *p_attrs, RawAddress *bd_addr);
/** Callback for getting the player application settings values' text
** num_attr: specifies the number of value ids contained in p_vals
*/
typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id, uint8_t num_val,
uint8_t *p_vals, RawAddress *bd_addr);
/** Callback for setting the player application settings values */
typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals,
RawAddress *bd_addr);
/** Callback to fetch the get element attributes of the current song
** num_attr: specifies the number of attributes requested in p_attrs
*/
typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs,
RawAddress *bd_addr);
/** Callback for register notification (Play state change/track change/...)
** param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED
*/
typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param,
RawAddress *bd_addr);
/* AVRCP 1.4 Enhancements */
/** Callback for volume change on CT
** volume: Current volume setting on the CT (0-127)
*/
typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype, RawAddress *bd_addr);
/** Callback for passthrough commands */
typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state, RawAddress *bd_addr);
/** Callback for set addressed player response on TG **/
typedef void (* btrc_set_addressed_player_callback) (uint16_t player_id, RawAddress *bd_addr);
/** Callback for set browsed player response on TG **/
typedef void (* btrc_set_browsed_player_callback) (uint16_t player_id, RawAddress *bd_addr);
/** Callback for get folder items on TG
** num_attr: specifies the number of attributes requested in p_attr_ids
*/
typedef void (* btrc_get_folder_items_callback) (uint8_t scope, uint32_t start_item,
uint32_t end_item, uint8_t num_attr, uint32_t *p_attr_ids, RawAddress *bd_addr);
/** Callback for changing browsed path on TG **/
typedef void (* btrc_change_path_callback) (uint8_t direction,
uint8_t* folder_uid, RawAddress *bd_addr);
/** Callback to fetch the get item attributes of the media item
** num_attr: specifies the number of attributes requested in p_attrs
*/
typedef void (* btrc_get_item_attr_callback) (uint8_t scope, uint8_t* uid, uint16_t uid_counter,
uint8_t num_attr, btrc_media_attr_t *p_attrs, RawAddress *bd_addr);
/** Callback for play request for the media item indicated by an identifier */
typedef void (* btrc_play_item_callback) (uint8_t scope,
uint16_t uid_counter, uint8_t* uid, RawAddress *bd_addr);
/** Callback to fetch total number of items from a folder **/
typedef void (* btrc_get_total_num_of_items_callback) (uint8_t scope, RawAddress *bd_addr);
/** Callback for conducting recursive search on a current browsed path for a specified string */
typedef void (* btrc_search_callback) (uint16_t charset_id,
uint16_t str_len, uint8_t* p_str, RawAddress *bd_addr);
/** Callback to add a specified media item indicated by an identifier to now playing queue. */
typedef void (* btrc_add_to_now_playing_callback) (uint8_t scope,
uint8_t* uid, uint16_t uid_counter, RawAddress *bd_addr);
/** BT-RC Target callback structure. */
typedef struct {
/** set to sizeof(BtRcCallbacks) */
size_t size;
btrc_remote_features_callback remote_features_cb;
btrc_get_play_status_callback get_play_status_cb;
btrc_list_player_app_attr_callback list_player_app_attr_cb;
btrc_list_player_app_values_callback list_player_app_values_cb;
btrc_get_player_app_value_callback get_player_app_value_cb;
btrc_get_player_app_attrs_text_callback get_player_app_attrs_text_cb;
btrc_get_player_app_values_text_callback get_player_app_values_text_cb;
btrc_set_player_app_value_callback set_player_app_value_cb;
btrc_get_element_attr_callback get_element_attr_cb;
btrc_register_notification_callback register_notification_cb;
btrc_volume_change_callback volume_change_cb;
btrc_passthrough_cmd_callback passthrough_cmd_cb;
btrc_set_addressed_player_callback set_addressed_player_cb;
btrc_set_browsed_player_callback set_browsed_player_cb;
btrc_get_folder_items_callback get_folder_items_cb;
btrc_change_path_callback change_path_cb;
btrc_get_item_attr_callback get_item_attr_cb;
btrc_play_item_callback play_item_cb;
btrc_get_total_num_of_items_callback get_total_num_of_items_cb;
btrc_search_callback search_cb;
btrc_add_to_now_playing_callback add_to_now_playing_cb;
} btrc_callbacks_t;
/** Represents the standard BT-RC AVRCP Target interface. */
typedef struct {
/** set to sizeof(BtRcInterface) */
size_t size;
/**
* Register the BtRc callbacks
*/
bt_status_t (*init)( btrc_callbacks_t* callbacks );
/** Respose to GetPlayStatus request. Contains the current
** 1. Play status
** 2. Song duration/length
** 3. Song position
*/
bt_status_t (*get_play_status_rsp)( RawAddress *bd_addr, btrc_play_status_t play_status,
uint32_t song_len, uint32_t song_pos);
/** Lists the support player application attributes (Shuffle/Repeat/...)
** num_attr: Specifies the number of attributes contained in the pointer p_attrs
*/
bt_status_t (*list_player_app_attr_rsp)( RawAddress *bd_addr, int num_attr,
btrc_player_attr_t *p_attrs);
/** Lists the support player application attributes (Shuffle Off/On/Group)
** num_val: Specifies the number of values contained in the pointer p_vals
*/
bt_status_t (*list_player_app_value_rsp)( RawAddress *bd_addr, int num_val, uint8_t *p_vals);
/** Returns the current application attribute values for each of the specified attr_id */
bt_status_t (*get_player_app_value_rsp)( RawAddress *bd_addr, btrc_player_settings_t *p_vals);
/** Returns the application attributes text ("Shuffle"/"Repeat"/...)
** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
*/
bt_status_t (*get_player_app_attr_text_rsp)( RawAddress *bd_addr, int num_attr,
btrc_player_setting_text_t *p_attrs);
/** Returns the application attributes text ("Shuffle"/"Repeat"/...)
** num_attr: Specifies the number of attribute values' text contained in the pointer p_vals
*/
bt_status_t (*get_player_app_value_text_rsp)( RawAddress *bd_addr, int num_val,
btrc_player_setting_text_t *p_vals);
/** Returns the current songs' element attributes text ("Title"/"Album"/"Artist")
** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
*/
bt_status_t (*get_element_attr_rsp)( RawAddress *bd_addr, uint8_t num_attr,
btrc_element_attr_val_t *p_attrs);
/** Response to set player attribute request ("Shuffle"/"Repeat")
** rsp_status: Status of setting the player attributes for the current media player
*/
bt_status_t (*set_player_app_value_rsp)(RawAddress *bd_addr, btrc_status_t rsp_status);
/* Response to the register notification request (Play state change/track change/...).
** event_id: Refers to the event_id this notification change corresponds too
** type: Response type - interim/changed
** p_params: Based on the event_id, this parameter should be populated
*/
bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id,
btrc_notification_type_t type,
btrc_register_notification_t *p_param);
/* AVRCP 1.4 enhancements */
/**Send current volume setting to remote side. Support limited to SetAbsoluteVolume
** This can be enhanced to support Relative Volume (AVRCP 1.0).
** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level
** volume: Should be in the range 0-127. bit7 is reseved and cannot be set
*/
bt_status_t (*set_volume)(uint8_t volume);
/* Set addressed player response from TG to CT */
bt_status_t (*set_addressed_player_rsp)(RawAddress *bd_addr, btrc_status_t rsp_status);
/* Set browsed player response from TG to CT */
bt_status_t (*set_browsed_player_rsp)(RawAddress *bd_addr, btrc_status_t rsp_status,
uint32_t num_items, uint16_t charset_id, uint8_t folder_depth,
btrc_br_folder_name_t *p_folders);
/* Get folder item list response from TG to CT */
bt_status_t (*get_folder_items_list_rsp)(RawAddress *bd_addr, btrc_status_t rsp_status,
uint16_t uid_counter, uint8_t num_items, btrc_folder_items_t *p_items);
/* Change path response from TG to CT */
bt_status_t (*change_path_rsp)(RawAddress *bd_addr, btrc_status_t rsp_status,
uint32_t num_items);
/** Returns the element's attributes num_attr: Specifies the number of attributes' text
* contained in the pointer p_attrs
*/
bt_status_t (*get_item_attr_rsp)(RawAddress *bd_addr, btrc_status_t rsp_status,
uint8_t num_attr, btrc_element_attr_val_t *p_attrs);
/* play media item response from TG to CT */
bt_status_t (*play_item_rsp)(RawAddress *bd_addr, btrc_status_t rsp_status);
/* get total number of items response from TG to CT*/
bt_status_t (*get_total_num_of_items_rsp)(RawAddress *bd_addr, btrc_status_t rsp_status,
uint32_t uid_counter, uint32_t num_items);
/* Search VFS response from TG to CT */
bt_status_t (*search_rsp)(RawAddress *bd_addr, btrc_status_t rsp_status, uint32_t uid_counter,
uint32_t num_items);
/* add_to_now playing list response from TG to CT */
bt_status_t (*add_to_now_playing_rsp)(RawAddress *bd_addr, btrc_status_t rsp_status);
/** Closes the interface. */
void (*cleanup)( void );
} btrc_interface_t;
typedef void (* btrc_passthrough_rsp_callback) (RawAddress *bd_addr, int id, int key_state);
typedef void (* btrc_groupnavigation_rsp_callback) (int id, int key_state);
typedef void (* btrc_connection_state_callback) (
bool rc_connect, bool bt_connect, RawAddress *bd_addr);
typedef void (* btrc_ctrl_getrcfeatures_callback) (RawAddress *bd_addr, int features);
typedef void (* btrc_ctrl_setabsvol_cmd_callback) (RawAddress *bd_addr, uint8_t abs_vol, uint8_t label);
typedef void (* btrc_ctrl_registernotification_abs_vol_callback) (RawAddress *bd_addr, uint8_t label);
typedef void (* btrc_ctrl_setplayerapplicationsetting_rsp_callback) (RawAddress *bd_addr,
uint8_t accepted);
typedef void (* btrc_ctrl_playerapplicationsetting_callback)(RawAddress *bd_addr,
uint8_t num_attr,
btrc_player_app_attr_t *app_attrs,
uint8_t num_ext_attr,
btrc_player_app_ext_attr_t *ext_attrs);
typedef void (* btrc_ctrl_playerapplicationsetting_changed_callback)(RawAddress *bd_addr,
btrc_player_settings_t *p_vals);
typedef void (* btrc_ctrl_track_changed_callback)(RawAddress *bd_addr, uint8_t num_attr,
btrc_element_attr_val_t *p_attrs);
typedef void (* btrc_ctrl_play_position_changed_callback)(RawAddress *bd_addr,
uint32_t song_len, uint32_t song_pos);
typedef void (* btrc_ctrl_play_status_changed_callback)(RawAddress *bd_addr,
btrc_play_status_t play_status);
typedef void (* btrc_ctrl_get_folder_items_callback )(RawAddress *bd_addr,
btrc_status_t status,
const btrc_folder_items_t *folder_items,
uint8_t count);
typedef void (* btrc_ctrl_change_path_callback)(RawAddress *bd_addr, uint8_t count);
typedef void (* btrc_ctrl_set_browsed_player_callback )(
RawAddress *bd_addr, uint8_t num_items, uint8_t depth);
typedef void (* btrc_ctrl_set_addressed_player_callback)(RawAddress *bd_addr, uint8_t status);
/** BT-RC Controller callback structure. */
typedef struct {
/** set to sizeof(BtRcCallbacks) */
size_t size;
btrc_passthrough_rsp_callback passthrough_rsp_cb;
btrc_groupnavigation_rsp_callback groupnavigation_rsp_cb;
btrc_connection_state_callback connection_state_cb;
btrc_ctrl_getrcfeatures_callback getrcfeatures_cb;
btrc_ctrl_setplayerapplicationsetting_rsp_callback setplayerappsetting_rsp_cb;
btrc_ctrl_playerapplicationsetting_callback playerapplicationsetting_cb;
btrc_ctrl_playerapplicationsetting_changed_callback playerapplicationsetting_changed_cb;
btrc_ctrl_setabsvol_cmd_callback setabsvol_cmd_cb;
btrc_ctrl_registernotification_abs_vol_callback registernotification_absvol_cb;
btrc_ctrl_track_changed_callback track_changed_cb;
btrc_ctrl_play_position_changed_callback play_position_changed_cb;
btrc_ctrl_play_status_changed_callback play_status_changed_cb;
btrc_ctrl_get_folder_items_callback get_folder_items_cb;
btrc_ctrl_change_path_callback change_folder_path_cb;
btrc_ctrl_set_browsed_player_callback set_browsed_player_cb;
btrc_ctrl_set_addressed_player_callback set_addressed_player_cb;
} btrc_ctrl_callbacks_t;
/** Represents the standard BT-RC AVRCP Controller interface. */
typedef struct {
/** set to sizeof(BtRcInterface) */
size_t size;
/**
* Register the BtRc callbacks
*/
bt_status_t (*init)( btrc_ctrl_callbacks_t* callbacks );
/** send pass through command to target */
bt_status_t (*send_pass_through_cmd) (RawAddress *bd_addr, uint8_t key_code,
uint8_t key_state );
/** send group navigation command to target */
bt_status_t (*send_group_navigation_cmd) (RawAddress *bd_addr, uint8_t key_code,
uint8_t key_state );
/** send command to set player applicaiton setting attributes to target */
bt_status_t (*set_player_app_setting_cmd) (RawAddress *bd_addr, uint8_t num_attrib,
uint8_t* attrib_ids, uint8_t* attrib_vals);
/** send command to play a particular item */
bt_status_t (*play_item_cmd) (
RawAddress *bd_addr, uint8_t scope, uint8_t *uid, uint16_t uid_counter);
/** get the playback state */
bt_status_t (*get_playback_state_cmd) (RawAddress *bd_addr);
/** get the now playing list */
bt_status_t (*get_now_playing_list_cmd) (RawAddress *bd_addr, uint8_t start, uint8_t items);
/** get the folder list */
bt_status_t (*get_folder_list_cmd) (RawAddress *bd_addr, uint8_t start, uint8_t items);
/** get the folder list */
bt_status_t (*get_player_list_cmd) (RawAddress *bd_addr, uint8_t start, uint8_t items);
/** get the folder list */
bt_status_t (*change_folder_path_cmd) (RawAddress *bd_addr, uint8_t direction, uint8_t * uid);
/** set browsed player */
bt_status_t (*set_browsed_player_cmd) (RawAddress *bd_addr, uint16_t player_id);
/** set addressed player */
bt_status_t (*set_addressed_player_cmd) (RawAddress *bd_addr, uint16_t player_id);
/** send rsp to set_abs_vol received from target */
bt_status_t (*set_volume_rsp) (RawAddress *bd_addr, uint8_t abs_vol, uint8_t label);
/** send notificaiton rsp for abs vol to target */
bt_status_t (*register_abs_vol_rsp) (RawAddress *bd_addr, btrc_notification_type_t rsp_type,
uint8_t abs_vol, uint8_t label);
/** Closes the interface. */
void (*cleanup)( void );
} btrc_ctrl_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_RC_H */

View file

@ -1,154 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "bluetooth.h"
#define SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH 15
__BEGIN_DECLS
/**
* These events are handled by the state machine
*/
typedef enum {
SDP_TYPE_RAW, // Used to carry raw SDP search data for unknown UUIDs
SDP_TYPE_MAP_MAS, // Message Access Profile - Server
SDP_TYPE_MAP_MNS, // Message Access Profile - Client (Notification Server)
SDP_TYPE_PBAP_PSE, // Phone Book Profile - Server
SDP_TYPE_PBAP_PCE, // Phone Book Profile - Client
SDP_TYPE_OPP_SERVER, // Object Push Profile
SDP_TYPE_SAP_SERVER // SIM Access Profile
} bluetooth_sdp_types;
typedef struct _bluetooth_sdp_hdr {
bluetooth_sdp_types type;
bluetooth::Uuid uuid;
uint32_t service_name_length;
char *service_name;
int32_t rfcomm_channel_number;
int32_t l2cap_psm;
int32_t profile_version;
} bluetooth_sdp_hdr;
/**
* Some signals need additional pointers, hence we introduce a
* generic way to handle these pointers.
*/
typedef struct _bluetooth_sdp_hdr_overlay {
bluetooth_sdp_types type;
bluetooth::Uuid uuid;
uint32_t service_name_length;
char *service_name;
int32_t rfcomm_channel_number;
int32_t l2cap_psm;
int32_t profile_version;
// User pointers, only used for some signals - see bluetooth_sdp_ops_record
int user1_ptr_len;
uint8_t *user1_ptr;
int user2_ptr_len;
uint8_t *user2_ptr;
} bluetooth_sdp_hdr_overlay;
typedef struct _bluetooth_sdp_mas_record {
bluetooth_sdp_hdr_overlay hdr;
uint32_t mas_instance_id;
uint32_t supported_features;
uint32_t supported_message_types;
} bluetooth_sdp_mas_record;
typedef struct _bluetooth_sdp_mns_record {
bluetooth_sdp_hdr_overlay hdr;
uint32_t supported_features;
} bluetooth_sdp_mns_record;
typedef struct _bluetooth_sdp_pse_record {
bluetooth_sdp_hdr_overlay hdr;
uint32_t supported_features;
uint32_t supported_repositories;
} bluetooth_sdp_pse_record;
typedef struct _bluetooth_sdp_pce_record {
bluetooth_sdp_hdr_overlay hdr;
} bluetooth_sdp_pce_record;
typedef struct _bluetooth_sdp_ops_record {
bluetooth_sdp_hdr_overlay hdr;
int supported_formats_list_len;
uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH];
} bluetooth_sdp_ops_record;
typedef struct _bluetooth_sdp_sap_record {
bluetooth_sdp_hdr_overlay hdr;
} bluetooth_sdp_sap_record;
typedef union {
bluetooth_sdp_hdr_overlay hdr;
bluetooth_sdp_mas_record mas;
bluetooth_sdp_mns_record mns;
bluetooth_sdp_pse_record pse;
bluetooth_sdp_pce_record pce;
bluetooth_sdp_ops_record ops;
bluetooth_sdp_sap_record sap;
} bluetooth_sdp_record;
/** Callback for SDP search */
typedef void (*btsdp_search_callback)(bt_status_t status,
const RawAddress &bd_addr,
const bluetooth::Uuid &uuid,
int num_records,
bluetooth_sdp_record *records);
typedef struct {
/** Set to sizeof(btsdp_callbacks_t) */
size_t size;
btsdp_search_callback sdp_search_cb;
} btsdp_callbacks_t;
typedef struct {
/** Set to size of this struct */
size_t size;
/** Register BT SDP search callbacks */
bt_status_t (*init)(btsdp_callbacks_t *callbacks);
/** Unregister BT SDP */
bt_status_t (*deinit)();
/** Search for SDP records with specific uuid on remote device */
bt_status_t (*sdp_search)(RawAddress *bd_addr, const bluetooth::Uuid& uuid);
/**
* Use listen in the socket interface to create rfcomm and/or l2cap PSM channels,
* (without UUID and service_name and set the BTSOCK_FLAG_NO_SDP flag in flags).
* Then use createSdpRecord to create the SDP record associated with the rfcomm/l2cap channels.
*
* Returns a handle to the SDP record, which can be parsed to remove_sdp_record.
*
* record (in) The SDP record to create
* record_handle (out)The corresponding record handle will be written to this pointer.
*/
bt_status_t (*create_sdp_record)(bluetooth_sdp_record *record, int* record_handle);
/** Remove a SDP record created by createSdpRecord */
bt_status_t (*remove_sdp_record)(int sdp_handle);
} btsdp_interface_t;
__END_DECLS

View file

@ -1,76 +0,0 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
__BEGIN_DECLS
#define BTSOCK_FLAG_ENCRYPT 1
#define BTSOCK_FLAG_AUTH (1 << 1)
#define BTSOCK_FLAG_NO_SDP (1 << 2)
#define BTSOCK_FLAG_AUTH_MITM (1 << 3)
#define BTSOCK_FLAG_AUTH_16_DIGIT (1 << 4)
typedef enum {
BTSOCK_RFCOMM = 1,
BTSOCK_SCO = 2,
BTSOCK_L2CAP = 3
} btsock_type_t;
/** Represents the standard BT SOCKET interface. */
typedef struct {
short size;
RawAddress bd_addr;
int channel;
int status;
// The writer must make writes using a buffer of this maximum size
// to avoid loosing data. (L2CAP only)
unsigned short max_tx_packet_size;
// The reader must read using a buffer of at least this size to avoid
// loosing data. (L2CAP only)
unsigned short max_rx_packet_size;
} __attribute__((packed)) sock_connect_signal_t;
typedef struct {
/** set to size of this struct*/
size_t size;
/**
* Listen to a RFCOMM UUID or channel. It returns the socket fd from which
* btsock_connect_signal can be read out when a remote device connected.
* If neither a UUID nor a channel is provided, a channel will be allocated
* and a service record can be created providing the channel number to
* create_sdp_record(...) in bt_sdp.
* The callingUid is the UID of the application which is requesting the socket. This is
* used for traffic accounting purposes.
*/
bt_status_t (*listen)(btsock_type_t type, const char* service_name,
const bluetooth::Uuid* service_uuid, int channel, int* sock_fd, int flags, int callingUid);
/**
* Connect to a RFCOMM UUID channel of remote device, It returns the socket fd from which
* the btsock_connect_signal and a new socket fd to be accepted can be read out when connected.
* The callingUid is the UID of the application which is requesting the socket. This is
* used for traffic accounting purposes.
*/
bt_status_t (*connect)(const RawAddress *bd_addr, btsock_type_t type, const bluetooth::Uuid* uuid,
int channel, int* sock_fd, int flags, int callingUid);
} btsock_interface_t;
__END_DECLS