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 21 #include "packets/link_layer_packets.h" 22 namespace test_vendor_lib { 23 24 class PhyLayer { 25 public: PhyLayer(Phy::Type phy_type,uint32_t id,const std::function<void (model::packets::LinkLayerPacketView)> & device_receive,uint32_t device_id)26 PhyLayer(Phy::Type phy_type, uint32_t id, 27 const std::function<void(model::packets::LinkLayerPacketView)>& 28 device_receive, 29 uint32_t device_id) 30 : phy_type_(phy_type), 31 id_(id), 32 device_id_(device_id), 33 transmit_to_device_(device_receive) {} 34 35 virtual void Send( 36 std::shared_ptr<model::packets::LinkLayerPacketBuilder> packet) = 0; 37 virtual void Send(model::packets::LinkLayerPacketView packet) = 0; 38 39 virtual void Receive(model::packets::LinkLayerPacketView packet) = 0; 40 41 virtual void TimerTick() = 0; 42 43 virtual bool IsFactoryId(uint32_t factory_id) = 0; 44 45 virtual void Unregister() = 0; 46 GetType()47 Phy::Type GetType() { 48 return phy_type_; 49 } 50 GetId()51 uint32_t GetId() { 52 return id_; 53 } 54 GetDeviceId()55 uint32_t GetDeviceId() { return device_id_; } 56 57 virtual ~PhyLayer() = default; 58 59 private: 60 Phy::Type phy_type_; 61 uint32_t id_; 62 uint32_t device_id_; 63 64 protected: 65 const std::function<void(model::packets::LinkLayerPacketView)> 66 transmit_to_device_; 67 }; 68 69 } // namespace test_vendor_lib 70