32 const std::string WifiP2PManager::TAG =
"WifiP2PManager";
36 :
_running(false), _timeout(120), _priority(10),
37 ce(ctrlpath, dtn::core::
BundleCore::local.getString(), *this, *this)
39 ce.setTime_ST_SCAN(20);
66 ce.addService(
"IBRDTN");
68 }
catch (wifip2p::SupplicantHandleException &ex) {
70 <<
"CoreEngine is not able to successfully communicate with SupplicantHandle. "
71 <<
"Exception raised: " << ex.what()
83 list<wifip2p::Connection>::iterator conn_it = connections.begin();
85 for (; conn_it != connections.end(); ++conn_it) {
88 ce.disconnect(*conn_it);
89 }
catch (wifip2p::SupplicantHandleException &ex) {
91 <<
"could not remove " << conn_it->getNetworkIntf().getName()
92 <<
" due to some exception: " << ex.what()
110 return WifiP2PManager::TAG;
122 wifip2p::Peer p(uri.
value);
124 list<wifip2p::Peer>::iterator peer_it = peers.begin();
125 bool contained =
false;
127 for (; peer_it != peers.end(); ++peer_it) {
139 }
catch (wifip2p::SupplicantHandleException &ex) {
141 <<
"could not connect to peer " << p.getName()
142 <<
"@" << p.getMacAddr()
143 <<
" due to some exception: " << ex.what()
148 <<
"could not connect to peer " << p.getName()
149 <<
"@" << p.getMacAddr()
159 wifip2p::Peer p(uri.
value);
163 }
catch (wifip2p::SupplicantHandleException &ex) {
165 <<
"could not disconnect from peer " << p.getName()
166 <<
"@" << p.getMacAddr()
167 <<
" due to some exception: " << ex.what()
176 std::cout <<
"Found peer " << peer.getName() <<
" reported as discovered." << std::endl;
178 list<wifip2p::Peer>::iterator peer_it = peers.begin();
179 bool contained =
false;
181 for (; peer_it != peers.end(); ++peer_it) {
182 if (*peer_it == peer) {
192 std::cout <<
"Peer discovered as new peer." << std::endl;
194 peers.push_back(peer);
204 std::cout <<
"Peer is still available." << std::endl;
219 list<wifip2p::Connection>::iterator conn_it = connections.begin();
220 bool contained =
false;
222 for (; conn_it != connections.end(); ++conn_it) {
223 if (conn_it->getPeer() == peer) {
234 }
catch (wifip2p::SupplicantHandleException &ex) {
236 <<
"could not connect to peer " << peer.getName()
237 <<
"@" << peer.getMacAddr()
238 <<
" due to some exception: " << ex.what()
243 <<
"peer " << peer.getName() <<
"@" << peer.getMacAddr()
244 <<
" already connected through p2p group interface "
255 std::cout <<
"Will fire interface " << conn.getNetworkIntf().getName()<<
" up." << std::endl;
258 connections.push_back(conn);
272 std::cout <<
"Connection at interface " << conn.getNetworkIntf().getName()
273 <<
" lost. Will fire interface down." << std::endl;
275 list<wifip2p::Connection>::iterator conn_it = connections.begin();
278 for (; conn_it != connections.end(); ++conn_it) {
279 if (conn_it->getNetworkIntf() == conn.getNetworkIntf()) {
280 connections.erase(conn_it++);
281 std::cout <<
"Connection removed from being locally registered." << std::endl;
287 }
catch (wifip2p::SupplicantHandleException &ex) {
289 <<
"could not remove " << conn.getNetworkIntf().getName()
290 <<
" due to some exception: " << ex.what()