pages tagged networkrohieb.namehttps://rohieb.name/blag/tag/network/rohieb.nameikiwiki2013-11-09T04:11:26ZBluetooth tethering via PAN with Windows Mobile and Ubuntuhttps://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/rohieb
CC-BY-SA 3.0
2013-11-09T04:11:26Z2010-11-07T23:00:00Z
<p>I was on the train today, needed some of the <a href="http://www.boost.org/">Boost</a> manuals, and had
no internet connection. So I wanted to use my phone (an old HTC Prophet
with Windows Mobile 6.1) as a network access point to browse over
GPRS/EDGE. As I found out, it is fairly simple with <a href="https://launchpad.net/blueman">Blueman</a> and it
even provides <a href="http://projects.gnome.org/NetworkManager/">NetworkManager</a> integration, so all
NetworkManager-capable applications can be notified about the
connectivity. Windows Mobile 6.1 allows tethering over a Bluetooth PAN
(<a href="http://en.wikipedia.org/wiki/Personal_area_network">Personal Area Network</a>); but there is another method called DUN
(<a href="http://en.wikipedia.org/wiki/Bluetooth_profile#Dial-up_Networking_Profile_.28DUN.29">Dial Up Networking</a>), which I will not describe here. So here is a
step-by-step tutorial what I did for my PAN approach, with a few
(german) screenshots, tested on Ubuntu 10.04 Lucid:</p>
<p><ul>
<li><p>Since my laptop was running on Ubuntu Lucid, there was already a
recent Blueman version in the Ubuntu repos available. On older
systems, you may want to add the <a href="https://launchpad.net/~blueman/+archive/ppa">Blueman Launchpad PPA</a>.</p></p>
<pre><code>$ sudo apt-add-repository ppa:blueman/ppa # only necessary on pre-lucid systems
$ sudo aptitude update
$ sudo aptitude install blueman
</code></pre>
<p></li>
<li><p>Note that this also removes possibly installed <code>gnome-bluetooth</code>
packages since Blueman is an adequate replacement for the GNOME
Bluetooth UI.</p></li>
<li><p>After the installation has finished, I had to enable the NMPANSupport
plugin for NetworkManager 0.8 by right-clicking on the Blueman icon in
the GNOME notification area and selecting “Plugins”. For older
NetworkManager versions, there is also a plugin for NetworkManager
0.7, called NMIntegration.</p></p>
<div class="gallery">
<a href="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/blueman-menu.png"><img src="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/x200-blueman-menu.png" width="140" height="199" alt="Blueman context menu" class="img" /></a>
<a href="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/blueman-plugins.png"><img src="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/x200-blueman-plugins.png" width="286" height="200" alt="Blueman plugin page" class="img" /></a>
</div>
<p></li>
<li><p>Then I activated tethering on my phone (“Programs” → “Internet
Sharing” on my Windows Mobile 6.1, but YMMV). Apparently this was
neccesary with my model, because without tethering enabled I could not
get a Bluetooth PAN connection in the next step.</p></p>
<p><p><div class="gallery">
<a href="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/winmo-program-menu.png"><img src="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/x200-winmo-program-menu.png" width="150" height="200" alt="Windows Mobile Program screen" class="img" /></a>
<a href="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/winmo-connection-sharing.png"><img src="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/x200-winmo-connection-sharing.png" width="150" height="200" alt="Windows Mobile Internet
Sharing application" class="img" /></a>
</div ></p></li>
<li><p>I paired the phone and my laptop via Bluetooth, and created a PAN
(Personal Area Network) by connecting to the “Network Access Point”
service on the phone. In Blueman, all you have to do after pairing is
right-click on the device and select “Connect To: Network Access
Point”. This creates a new network device <code>bnep0</code> which is
automagically configured through NetworkManager (using <a href="http://en.wikipedia.org/wiki/Link-local%20address">stateless
address autoconfiguration</a>).</p></p>
<div class="gallery">
<a href="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/blueman-pan.png"><img src="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/x100-blueman-pan.png" width="219" height="100" alt="Blueman: Context menu for device
“Leia”, menu entry “Network Access Point” is selected" class="img" /></a>
</div>
<p>(Yes, my phone is called <a href="http://en.wikipedia.org/wiki/Leia_Skywalker">Leia</a>… I also have a yet another HTC
Prophet for testing purposes, which is called <a href="http://en.wikipedia.org/wiki/Luke_Skywalker">Luke</a> <img src="https://rohieb.name/smileys/smile.png" alt=":-)" /> )</p>
<p></li>
<li><p>However, in my setup, though I was able to ping certain IP adresses on
the internet, DNS lookups timed out for some reason. It got better
when I explicitly set an IP address for the Bluetooth PAN driver on my
phone, and did the tethering process all over again.</p></p>
<div class="gallery">
<a href="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/winmo-connections.png"><img src="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/x200-winmo-connections.png" width="150" height="200" alt="Windows Mobile System Settings
Screen, with item “Wi-Fi” selected" class="img" /></a>
<a href="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/winmo-networkdrivers.png"><img src="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/x200-winmo-networkdrivers.png" width="150" height="200" alt="Windows Mobile Network Driver
settings screen, with menu item “Bluetooth PAN Driver” selected" class="img" /></a>
<a href="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/winmo-bluetooth-ip.png"><img src="https://rohieb.name/blag/post/bluetooth-tethering-via-pan-with-windows-mobile-and-ubuntu/x200-winmo-bluetooth-ip.png" width="150" height="200" alt="Windows Mobile Bluetooth PAN Driver
settings screen" class="img" /></a>
</div>
<p></li>
<li><p>And off I went with mobile internet access. Woo-hoo! \o/</p></li>
</ul>
I may also add that the NetUsage plugin in Blueman is very reasonable to
use <img src="https://rohieb.name/smileys/smile4.png" alt=";-)" /> After activated, the network usage can be viewed by
right-clicking on the Blueman icon and selecting “Network Usage”.</p>
Qt: (Nearly) synchronous QNetworkAccessManager callshttps://rohieb.name/blag/post/qt-nearly-synchronous-qnetworkaccessmanager-calls/rohieb
CC-BY-SA 3.0
2013-09-19T05:04:01Z2010-07-07T22:00:00Z
<p>The <a href="http://doc.qt.nokia.com/4.6/qnetworkaccessmanager.html">QNetworkAccessManager</a> class is very user-friendly, but it makes
asynchronous calls. I was in the need for synchronous calls to handle my
HTTP communication, but I did not want the overhead of another thread,
so I googled a bit and finally came up with a short call to an event
loop that processed the request. Like this:</p>
<div class="highlight-c"><pre class="hl">QNetworkAccessManager <span class="hl opt">*</span> pnam <span class="hl opt">=</span> <span class="hl kwa">new</span> <span class="hl kwd">QNetworkAccessManager</span><span class="hl opt">(</span><span class="hl kwa">this</span><span class="hl opt">);</span>
<span class="hl slc">// the slot was declared at another place</span>
<span class="hl kwd">connect</span><span class="hl opt">(</span>pnam<span class="hl opt">,</span> <span class="hl kwd">SIGNAL</span><span class="hl opt">(</span><span class="hl kwd">finished</span><span class="hl opt">(</span>QNetworkReply <span class="hl opt">*)),</span> <span class="hl kwa">this</span><span class="hl opt">,</span>
<span class="hl kwd">SLOT</span><span class="hl opt">(</span><span class="hl kwd">loginFinished</span><span class="hl opt">(</span>QNetworkReply<span class="hl opt">*)));</span>
QNetworkRequest <span class="hl kwd">req</span><span class="hl opt">(</span><span class="hl kwd">QUrl</span><span class="hl opt">(</span><span class="hl str">"http://foo.bar"</span><span class="hl opt">));</span>
pnam<span class="hl opt">-></span><span class="hl kwd">post</span><span class="hl opt">(</span>req<span class="hl opt">,</span> postData<span class="hl opt">);</span>
<span class="hl slc">// execute an event loop to process the request (nearly-synchronous)</span>
QEventLoop eventLoop<span class="hl opt">;</span>
<span class="hl slc">// also dispose the event loop after the reply has arrived</span>
<span class="hl kwd">connect</span><span class="hl opt">(</span>pnam<span class="hl opt">,</span> <span class="hl kwd">SIGNAL</span><span class="hl opt">(</span><span class="hl kwd">finished</span><span class="hl opt">(</span>QNetworkReply <span class="hl opt">*)), &</span>eventLoop<span class="hl opt">,</span> <span class="hl kwd">SLOT</span><span class="hl opt">(</span><span class="hl kwd">quit</span><span class="hl opt">()));</span>
eventLoop<span class="hl opt">.</span><span class="hl kwd">exec</span><span class="hl opt">();</span>
</pre></div>
<p>This way my user-defined slot for the <code>pnam->finished()</code> signal was
called immediately, and I could be sure to have the HTTP reply at the
end of this code snippet.</p>
<p>Found here: <a href="http://lists.qt.nokia.com/public/qt-interest/2010-April/022031.html">Qt-Interest Mailing List: QNetworkAccessManager and
QNetworkReply, synchronous</a></p>