1 /*
2  * Copyright 2019 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 #pragma once
17 
18 #include <memory>
19 
20 #include "common/callback.h"
21 #include "hci/hci_packets.h"
22 #include "hci/le_report.h"
23 #include "module.h"
24 
25 namespace bluetooth {
26 namespace hci {
27 
28 class LeScanningManagerCallbacks {
29  public:
30   virtual ~LeScanningManagerCallbacks() = default;
31   virtual void on_advertisements(std::vector<std::shared_ptr<LeReport>>) = 0;
32   virtual void on_timeout() = 0;
33   virtual os::Handler* Handler() = 0;
34 };
35 
36 class LeScanningManager : public bluetooth::Module {
37  public:
38   LeScanningManager();
39 
40   void StartScan(LeScanningManagerCallbacks* callbacks);
41 
42   void StopScan(common::Callback<void()> on_stopped);
43 
44   static const ModuleFactory Factory;
45 
46  protected:
47   void ListDependencies(ModuleList* list) override;
48 
49   void Start() override;
50 
51   void Stop() override;
52 
53   std::string ToString() const override;
54 
55  private:
56   struct impl;
57   std::unique_ptr<impl> pimpl_;
58   DISALLOW_COPY_AND_ASSIGN(LeScanningManager);
59 };
60 
61 }  // namespace hci
62 }  // namespace bluetooth
63