2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief EmulatedWirelessInterface inline non-template implementation */
19 #define prefix_ inline
20 //-/////////////////////////////////////////////////////////////////////////////////////////////////
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 // senf::emu::detail::EmulatedWirelessInterfaceTransmitFilter
26 senf::emu::detail::EmulatedWirelessInterfaceTransmitFilter::
27 EmulatedWirelessInterfaceTransmitFilter(EmulatedWirelessTransmitter & iface)
31 input.onRequest(&EmulatedWirelessInterfaceTransmitFilter::request);
34 //-/////////////////////////////////////////////////////////////////////////////////////////////////
35 // senf::emu::detail::EmulatedWirelessInterfaceReceiveFilter
38 senf::emu::detail::EmulatedWirelessInterfaceReceiveFilter::
39 EmulatedWirelessInterfaceReceiveFilter(EmulatedWirelessReceiver & iface)
43 input.onRequest(&EmulatedWirelessInterfaceReceiveFilter::request);
46 //-/////////////////////////////////////////////////////////////////////////////////////////////////
47 // senf::emu::EmulatedFrequencyRegistry::Entry
49 prefix_ senf::emu::EmulatedFrequencyRegistry::Entry::Entry()
50 : frequency (), bandwidth (), address (), nUsers (), ownerNodeId ()
53 prefix_ senf::emu::EmulatedFrequencyRegistry::Entry::Entry(unsigned frequency_,
55 : frequency (frequency_), bandwidth (bandwidth_), address (), nUsers (), ownerNodeId ()
58 prefix_ senf::emu::EmulatedFrequencyRegistry::Entry::Entry(unsigned frequency_,
60 UDPClientHandle::Address address_,
62 unsigned ownerNodeId_)
63 : frequency (frequency_), bandwidth (bandwidth_), address (address_), nUsers (nUsers_),
64 ownerNodeId (ownerNodeId_)
67 //-/////////////////////////////////////////////////////////////////////////////////////////////////
68 // senf::emu::EmulatedFrequencyRegistry::User
70 prefix_ senf::emu::EmulatedFrequencyRegistry::User::User()
71 : entry(), interfaceId(), callback()
74 prefix_ senf::emu::EmulatedFrequencyRegistry::User::
75 User(Entries::index_iterator<ByFrequency>::type entry_, unsigned interfaceId_, UserCallback callback_)
76 : entry(entry_), interfaceId(interfaceId_), callback(callback_)
79 //-/////////////////////////////////////////////////////////////////////////////////////////////////
80 // senf::emu::EmulatedFrequencyRegistry::AddrCompare
82 prefix_ bool senf::emu::EmulatedFrequencyRegistry::AddrCompare::
83 operator()(Entries::index_iterator<ByFrequency>::type a,
84 Entries::index_iterator<ByFrequency>::type b)
90 prefix_ bool senf::emu::EmulatedFrequencyRegistry::AddrCompare::
91 operator()(Entries::index_iterator<ByFrequency>::type a, Entry const * b)
97 prefix_ bool senf::emu::EmulatedFrequencyRegistry::AddrCompare::
98 operator()(Entry const * a, Entries::index_iterator<ByFrequency>::type b)
104 //-/////////////////////////////////////////////////////////////////////////////////////////////////
105 // senf::emu::EmulatedFrequencyRegistry
107 prefix_ senf::emu::UDPClientHandle::Address senf::emu::EmulatedFrequencyRegistry::consoleGroup()
114 senf::emu::EmulatedFrequencyRegistry::consoleGroup(UDPClientHandle::Address const & group)
117 /// FIXME: How to change the group address after entering the scheduler ??
118 /// (need to change the address of a running socket)
121 prefix_ std::pair<senf::INet4Network, unsigned> senf::emu::EmulatedFrequencyRegistry::addressRange()
124 return std::make_pair(channelGroupRange_, portbase_);
127 prefix_ void senf::emu::EmulatedFrequencyRegistry::addressRange(INet4Network const & range,
130 channelGroupRange_ = range;
131 portbase_ = portbase;
134 prefix_ void senf::emu::EmulatedFrequencyRegistry::nextAddress(unsigned index)
136 lastAddress_ = index-1;
139 prefix_ void senf::emu::EmulatedFrequencyRegistry::collisionCallback(CollisionCallback cb)
144 prefix_ senf::emu::EmulatedFrequencyRegistry::EntriesRange
145 senf::emu::EmulatedFrequencyRegistry::entries()
148 return boost::make_iterator_range(
149 entries_.get<ByFrequency>().begin(), entries_.get<ByFrequency>().end());
152 prefix_ senf::emu::EmulatedFrequencyRegistry::UsersRange
153 senf::emu::EmulatedFrequencyRegistry::users(EntriesRange::iterator i)
156 return senf::make_transform_range(users_.get<ByEntry>().equal_range(i), GetInterfaceId());
159 //-/////////////////////////////////////////////////////////////////////////////////////////////////
160 // senf::emu::EmulatedWirelessInterface
162 prefix_ void senf::emu::EmulatedWirelessInterface::registerFrequency(unsigned frequency,
165 interface().registerFrequency(frequency, bandwidth);
168 prefix_ void senf::emu::EmulatedWirelessInterface::registerFrequency(unsigned frequencyLower,
169 unsigned frequencyUpper,
170 unsigned bandwidthLower,
171 unsigned bandwidthUpper)
173 interface().registerFrequency(frequencyLower, frequencyUpper, bandwidthLower, bandwidthUpper);
176 prefix_ senf::emu::EmulatedWirelessInterface::EmulatedWirelessInterface()
177 : frequency_ (0u), bandwidth_ (0u), index_ (0u), distanceCallback_()
180 prefix_ unsigned senf::emu::EmulatedWirelessInterface::emulatedFrequency()
186 prefix_ unsigned senf::emu::EmulatedWirelessInterface::emulatedBandwidth()
192 prefix_ void senf::emu::EmulatedWirelessInterface::distanceCallback(DistanceCallback cb)
194 distanceCallback_ = cb;
196 //-/////////////////////////////////////////////////////////////////////////////////////////////////
197 // senf::emu::EmulatedWirelessReceiver
199 prefix_ senf::emu::EmulatedWirelessReceiver::EmulatedWirelessReceiver()
200 : receiverJack(filter_.output), filter_ (*this),
201 rssiRandomnessRange_(0), noiseRandomnessRange_(0)
203 ppi::connect(EmulatedReceiver::receiverJack, filter_);
205 //-/////////////////////////////////////////////////////////////////////////////////////////////////
206 // senf::emu::EmulatedWirelessTransmitter
208 prefix_ void senf::emu::EmulatedWirelessTransmitter::registerTxPower(int power)
210 basei::interface().transmitter().registerTxPower(power);
213 prefix_ void senf::emu::EmulatedWirelessTransmitter::registerTxPower(int powerLow,
216 basei::interface().transmitter().registerTxPower(powerLow, powerHigh);
219 prefix_ senf::emu::EmulatedWirelessTransmitter::EmulatedWirelessTransmitter()
220 : transmitterJack(filter_.input), filter_ (*this)
222 ppi::connect(filter_, EmulatedTransmitter::transmitterJack);
225 //-/////////////////////////////////////////////////////////////////////////////////////////////////
227 prefix_ senf::emu::EmulatedFrequencyRegistry & senf::emu::emulatedFrequencyRegistry()
229 return EmulatedFrequencyRegistry::instance();
232 //-/////////////////////////////////////////////////////////////////////////////////////////////////
239 // comment-column: 40
240 // c-file-style: "senf"
241 // indent-tabs-mode: nil
242 // ispell-local-dictionary: "american"
243 // compile-command: "scons -u test"