• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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 #pragma once
18 
19 #include "include/phy.h"
20 #include "packets/link_layer/link_layer_packet_builder.h"
21 #include "packets/link_layer/link_layer_packet_view.h"
22 
23 namespace test_vendor_lib {
24 
25 class PhyLayer {
26  public:
PhyLayer(Phy::Type phy_type,uint32_t id,const std::function<void (packets::LinkLayerPacketView)> & device_receive)27   PhyLayer(Phy::Type phy_type, uint32_t id, const std::function<void(packets::LinkLayerPacketView)>& device_receive)
28       : phy_type_(phy_type), id_(id), transmit_to_device_(device_receive) {}
29 
30   virtual void Send(const std::shared_ptr<packets::LinkLayerPacketBuilder> packet) = 0;
31 
32   virtual void Receive(packets::LinkLayerPacketView packet) = 0;
33 
34   virtual void TimerTick() = 0;
35 
GetType()36   Phy::Type GetType() {
37     return phy_type_;
38   }
39 
GetId()40   uint32_t GetId() {
41     return id_;
42   }
43 
44   virtual ~PhyLayer() = default;
45 
46  private:
47   Phy::Type phy_type_;
48   uint32_t id_;
49 
50  protected:
51   const std::function<void(packets::LinkLayerPacketView)> transmit_to_device_;
52 };
53 
54 }  // namespace test_vendor_lib
55