am 35550a10
: Merge changes from topic \'system-bt\'
* commit '35550a1030879bd3cb74f10f0cadb6e6f660bffb': L2CAP and SDP Search API for BT profiles (1/2) Incorrect RSSI value in onlost/onfound OnFound/OnLost feature API changes based on spec v0.90
This commit is contained in:
commit
067f3f78d0
5 changed files with 237 additions and 20 deletions
|
@ -46,7 +46,7 @@ __BEGIN_DECLS
|
|||
#define BT_PROFILE_HIDHOST_ID "hidhost"
|
||||
#define BT_PROFILE_PAN_ID "pan"
|
||||
#define BT_PROFILE_MAP_CLIENT_ID "map_client"
|
||||
|
||||
#define BT_PROFILE_SDP_CLIENT_ID "sdp"
|
||||
#define BT_PROFILE_GATT_ID "gatt"
|
||||
#define BT_PROFILE_AV_RC_ID "avrcp"
|
||||
#define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
|
||||
|
@ -143,14 +143,15 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t version_supported;
|
||||
uint8_t local_privacy_enabled;
|
||||
uint8_t max_adv_instance;
|
||||
uint8_t rpa_offload_supported;
|
||||
uint8_t max_irk_list_size;
|
||||
uint8_t max_adv_filter_supported;
|
||||
uint8_t scan_result_storage_size_lobyte;
|
||||
uint8_t scan_result_storage_size_hibyte;
|
||||
uint8_t activity_energy_info_supported;
|
||||
uint16_t scan_result_storage_size;
|
||||
uint16_t total_trackable_advertisers;
|
||||
}bt_local_le_features_t;
|
||||
|
||||
/* Bluetooth Adapter and Remote Device property types */
|
||||
|
@ -545,6 +546,8 @@ typedef struct {
|
|||
} bluetooth_device_t;
|
||||
|
||||
typedef bluetooth_device_t bluetooth_module_t;
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* ANDROID_INCLUDE_BLUETOOTH_H */
|
||||
|
|
44
include/hardware/bt_common_types.h
Normal file
44
include/hardware/bt_common_types.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* 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"
|
||||
|
||||
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;
|
||||
bt_bdaddr_t 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;
|
||||
|
||||
#endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include "bt_gatt_types.h"
|
||||
#include "bt_common_types.h"
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
|
@ -67,6 +68,23 @@ typedef struct
|
|||
uint8_t is_notify;
|
||||
} btgatt_notify_params_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t client_if;
|
||||
uint8_t action;
|
||||
uint8_t filt_index;
|
||||
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;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bt_bdaddr_t *bda1;
|
||||
|
@ -202,8 +220,7 @@ typedef void (*batchscan_reports_callback)(int client_if, int status, int report
|
|||
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)(int client_if, int filt_index, int addr_type,
|
||||
bt_bdaddr_t* bda, int adv_state);
|
||||
typedef void (*track_adv_event_callback)(btgatt_track_adv_info_t *p_track_adv_info);
|
||||
|
||||
typedef struct {
|
||||
register_client_callback register_client_cb;
|
||||
|
@ -336,10 +353,7 @@ typedef struct {
|
|||
bt_status_t (*read_remote_rssi)( int client_if, const bt_bdaddr_t *bd_addr);
|
||||
|
||||
/** Setup scan filter params */
|
||||
bt_status_t (*scan_filter_param_setup)(int client_if, int action, int filt_index, int feat_seln,
|
||||
int list_logic_type, int filt_logic_type, int rssi_high_thres,
|
||||
int rssi_low_thres, int dely_mode, int found_timeout,
|
||||
int lost_timeout, int found_timeout_cnt);
|
||||
bt_status_t (*scan_filter_param_setup)(btgatt_filt_param_setup_t filt_param);
|
||||
|
||||
|
||||
/** Configure a scan filter condition */
|
||||
|
|
144
include/hardware/bt_sdp.h
Normal file
144
include/hardware/bt_sdp.h
Normal file
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* 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 UUID's
|
||||
SDP_TYPE_MAP_MAS,
|
||||
SDP_TYPE_MAP_MNS,
|
||||
SDP_TYPE_PBAP_PSE,
|
||||
SDP_TYPE_PBAP_PCE,
|
||||
SDP_TYPE_OPP_SERVER
|
||||
} bluetooth_sdp_types;
|
||||
|
||||
typedef struct _bluetooth_sdp_hdr {
|
||||
bluetooth_sdp_types type;
|
||||
bt_uuid_t 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;
|
||||
bt_uuid_t 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 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_record;
|
||||
|
||||
|
||||
/** Callback for SDP search */
|
||||
typedef void (*btsdp_search_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, uint8_t* 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)(bt_bdaddr_t *bd_addr, const uint8_t* 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
|
||||
|
|
@ -14,13 +14,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_INCLUDE_BT_SOCK_H
|
||||
#define ANDROID_INCLUDE_BT_SOCK_H
|
||||
#pragma once
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define BTSOCK_FLAG_ENCRYPT 1
|
||||
#define BTSOCK_FLAG_AUTH (1 << 1)
|
||||
#define BTSOCK_FLAG_NO_SDP (1 << 2)
|
||||
|
||||
typedef enum {
|
||||
BTSOCK_RFCOMM = 1,
|
||||
|
@ -34,25 +34,37 @@ typedef struct {
|
|||
bt_bdaddr_t 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
|
||||
* 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.
|
||||
*/
|
||||
bt_status_t (*listen)(btsock_type_t type, const char* service_name, const uint8_t* service_uuid, int channel, int* sock_fd, int flags);
|
||||
/*
|
||||
* connect to a rfcomm uuid channel of remote device, It returns the socket fd from which
|
||||
bt_status_t (*listen)(btsock_type_t type, const char* service_name,
|
||||
const uint8_t* service_uuid, int channel, int* sock_fd, int flags);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid, int channel, int* sock_fd, int flags);
|
||||
|
||||
bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid,
|
||||
int channel, int* sock_fd, int flags);
|
||||
} btsock_interface_t;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* ANDROID_INCLUDE_BT_SOCK_H */
|
||||
|
|
Loading…
Reference in a new issue