summaryrefslogtreecommitdiff
path: root/system/gd/hci/le_scanning_callback.h
blob: 9ad0157acb74ab8407d67f24426e666432a4e40f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
 * Copyright 2022 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 <memory>

#include "common/callback.h"
#include "hci/address_with_type.h"
#include "hci/hci_packets.h"
#include "hci/uuid.h"

namespace bluetooth {
namespace hci {

using ScannerId = uint8_t;

class AdvertisingFilterOnFoundOnLostInfo {
 public:
  uint8_t scanner_id;
  uint8_t filter_index;
  uint8_t advertiser_state;
  AdvtInfoPresent advertiser_info_present;
  Address advertiser_address;
  uint8_t advertiser_address_type;
  uint8_t tx_power;
  int8_t rssi;
  uint16_t time_stamp;
  std::vector<uint8_t> adv_packet;
  std::vector<uint8_t> scan_response;
};

class ScanningCallback {
 public:
  enum ScanningStatus {
    SUCCESS,
    NO_RESOURCES = 0x80,
    INTERNAL_ERROR = 0x85,
    ILLEGAL_PARAMETER = 0x87,
  };

  virtual ~ScanningCallback() = default;
  virtual void OnScannerRegistered(
      const bluetooth::hci::Uuid app_uuid, ScannerId scanner_id, ScanningStatus status) = 0;
  virtual void OnSetScannerParameterComplete(ScannerId scanner_id, ScanningStatus status) = 0;
  virtual void OnScanResult(
      uint16_t event_type,
      uint8_t address_type,
      Address address,
      uint8_t primary_phy,
      uint8_t secondary_phy,
      uint8_t advertising_sid,
      int8_t tx_power,
      int8_t rssi,
      uint16_t periodic_advertising_interval,
      std::vector<uint8_t> advertising_data) = 0;
  virtual void OnTrackAdvFoundLost(AdvertisingFilterOnFoundOnLostInfo on_found_on_lost_info) = 0;
  virtual void OnBatchScanReports(
      int client_if, int status, int report_format, int num_records, std::vector<uint8_t> data) = 0;
  virtual void OnBatchScanThresholdCrossed(int client_if) = 0;
  virtual void OnTimeout() = 0;
  virtual void OnFilterEnable(Enable enable, uint8_t status) = 0;
  virtual void OnFilterParamSetup(uint8_t available_spaces, ApcfAction action, uint8_t status) = 0;
  virtual void OnFilterConfigCallback(
      ApcfFilterType filter_type, uint8_t available_spaces, ApcfAction action, uint8_t status) = 0;
  virtual void OnPeriodicSyncStarted(
      int request_id,
      uint8_t status,
      uint16_t sync_handle,
      uint8_t advertising_sid,
      AddressWithType address_with_type,
      uint8_t phy,
      uint16_t interval) = 0;
  virtual void OnPeriodicSyncReport(
      uint16_t sync_handle, int8_t tx_power, int8_t rssi, uint8_t status, std::vector<uint8_t> data) = 0;
  virtual void OnPeriodicSyncLost(uint16_t sync_handle) = 0;
  virtual void OnPeriodicSyncTransferred(int pa_source, uint8_t status, Address address) = 0;
};

class AdvertisingPacketContentFilterCommand {
 public:
  ApcfFilterType filter_type;
  Address address;
  ApcfApplicationAddressType application_address_type;
  Uuid uuid;
  Uuid uuid_mask;
  std::vector<uint8_t> name;
  uint16_t company;
  uint16_t company_mask;
  std::vector<uint8_t> data;
  std::vector<uint8_t> data_mask;
  std::array<uint8_t, 16> irk;
};

class AdvertisingFilterParameter {
 public:
  uint16_t feature_selection;
  uint16_t list_logic_type;
  uint8_t filter_logic_type;
  uint8_t rssi_high_thresh;
  DeliveryMode delivery_mode;
  uint16_t onfound_timeout;
  uint8_t onfound_timeout_cnt;
  uint8_t rssi_low_thresh;
  uint16_t onlost_timeout;
  uint16_t num_of_tracking_entries;
};

}  // namespace hci
}  // namespace bluetooth