blob: dca7e43be4dfa3f2ffab2fc4d8da271938b80874 [file] [log] [blame]
Jakub Pawlowski1e24ce92016-10-27 12:26:07 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_INCLUDE_BLE_SCANNER_H
18#define ANDROID_INCLUDE_BLE_SCANNER_H
19
20#include <stdint.h>
21#include <vector>
22#include "bt_gatt_types.h"
23#include "bt_common_types.h"
24#include "bt_gatt_client.h"
25
26/** Callback invoked in response to register_scanner */
27typedef void (*register_scanner_callback)(int status, int scanner_id,
28 bt_uuid_t *app_uuid);
29
30/** Callback invoked when batchscan storage config operation has completed */
31typedef void (*batchscan_cfg_storage_callback)(int client_if, int status);
32
33/** Callback invoked when batchscan enable / disable operation has completed */
34typedef void (*batchscan_enable_disable_callback)(int action, int client_if, int status);
35
36/** Callback invoked when batchscan reports are obtained */
37typedef void (*batchscan_reports_callback)(int client_if, int status, int report_format,
38 int num_records, std::vector<uint8_t> data);
39
40/** Callback invoked when batchscan storage threshold limit is crossed */
41typedef void (*batchscan_threshold_callback)(int client_if);
42
43/** Track ADV VSE callback invoked when tracked device is found or lost */
44typedef void (*track_adv_event_callback)(btgatt_track_adv_info_t *p_track_adv_info);
45
46/** Callback invoked when scan parameter setup has completed */
47typedef void (*scan_parameter_setup_completed_callback)(int client_if,
48 btgattc_error_t status);
49
50/** Callback for scan results */
51typedef void (*scan_result_callback)(bt_bdaddr_t* bda, int rssi, std::vector<uint8_t> adv_data);
52
53/** Callback invoked when a scan filter configuration command has completed */
54typedef void (*scan_filter_cfg_callback)(int action, int client_if, int status, int filt_type,
55 int avbl_space);
56
57/** Callback invoked when scan param has been added, cleared, or deleted */
58typedef void (*scan_filter_param_callback)(int action, int client_if, int status,
59 int avbl_space);
60
61/** Callback invoked when a scan filter configuration command has completed */
62typedef void (*scan_filter_status_callback)(int enable, int client_if, int status);
63
64typedef struct {
65 register_scanner_callback register_scanner_cb;
66 scan_result_callback scan_result_cb;
67 batchscan_cfg_storage_callback batchscan_cfg_storage_cb;
68 batchscan_enable_disable_callback batchscan_enb_disable_cb;
69 batchscan_reports_callback batchscan_reports_cb;
70 batchscan_threshold_callback batchscan_threshold_cb;
71 track_adv_event_callback track_adv_event_cb;
72 scan_parameter_setup_completed_callback scan_parameter_setup_completed_cb;
73 scan_filter_cfg_callback scan_filter_cfg_cb;
74 scan_filter_param_callback scan_filter_param_cb;
75 scan_filter_status_callback scan_filter_status_cb;
76} btgatt_scanner_callbacks_t;
77
78typedef struct {
79 /** Registers a scanner with the stack */
80 bt_status_t (*register_scanner)( bt_uuid_t *uuid );
81
82 /** Unregister a scanner from the stack */
83 bt_status_t (*unregister_scanner)(int scanner_id );
84
85 /** Start or stop LE device scanning */
86 bt_status_t (*scan)( bool start );
87
88 /** Setup scan filter params */
89 bt_status_t (*scan_filter_param_setup)(btgatt_filt_param_setup_t filt_param);
90
91
92 /** Configure a scan filter condition */
93 bt_status_t (*scan_filter_add_remove)(int client_if, int action, int filt_type,
94 int filt_index, int company_id,
95 int company_id_mask, const bt_uuid_t *p_uuid,
96 const bt_uuid_t *p_uuid_mask, const bt_bdaddr_t *bd_addr,
97 char addr_type, std::vector<uint8_t> data,
98 std::vector<uint8_t> p_mask);
99
100 /** Clear all scan filter conditions for specific filter index*/
101 bt_status_t (*scan_filter_clear)(int client_if, int filt_index);
102
103 /** Enable / disable scan filter feature*/
104 bt_status_t (*scan_filter_enable)(int client_if, bool enable);
105
106 /** Sets the LE scan interval and window in units of N*0.625 msec */
107 bt_status_t (*set_scan_parameters)(int client_if, int scan_interval, int scan_window);
108
109 /* Configure the batchscan storage */
110 bt_status_t (*batchscan_cfg_storage)(int client_if, int batch_scan_full_max,
111 int batch_scan_trunc_max, int batch_scan_notify_threshold);
112
113 /* Enable batchscan */
114 bt_status_t (*batchscan_enb_batch_scan)(int client_if, int scan_mode,
115 int scan_interval, int scan_window, int addr_type, int discard_rule);
116
117 /* Disable batchscan */
118 bt_status_t (*batchscan_dis_batch_scan)(int client_if);
119
120 /* Read out batchscan reports */
121 bt_status_t (*batchscan_read_reports)(int client_if, int scan_mode);
122
123} btgatt_scanner_interface_t;
124
125#endif /* ANDROID_INCLUDE_BLE_SCANNER_H */