{"id":141,"date":"2009-03-23T17:54:11","date_gmt":"2009-03-23T22:54:11","guid":{"rendered":"http:\/\/otac.isa-geek.net\/blog\/?p=141"},"modified":"2009-03-25T21:16:56","modified_gmt":"2009-03-26T02:16:56","slug":"tethering-a-ubuntu-laptop-to-the-internet-over-bluetooth-and-gprs","status":"publish","type":"post","link":"https:\/\/otac.isa-geek.net\/blog\/?p=141","title":{"rendered":"Tethering a Ubuntu Laptop to the Internet over Bluetooth and GPRS"},"content":{"rendered":"<p>I recently upgraded my mobile plan to include (almost) unlimited data &#8211; mainly to support increased email and browsing activities. Also, all the smaller packages were really a waste of money. However, a quick notebook calculation revealed that I would have to send thousands of emails a day in order to even come close to the limits of the new data package. With that in mind, I thought my new found bandwidth would be of more us to me, if I could use my renovated laptop with the mobile data package for roaming mobile internet access. As I have previously posted, my personal laptop is an off-lease Thinkpad X40, running Ubuntu Hardy (8.04). My preferred approach was to share the phone&#8217;s Internet connection over bluetooth with the laptop; so, the first step was to get a bluetooth adapter for the laptop. I purchased a no-name usb mini-bluetooth adapter for $10 from TechDirect (<a href=\"http:\/\/www.techdirectcanada.ca\/\">http:\/\/www.techdirectcanada.ca\/<\/a>), a discount electronics chain in Toronto.<\/p>\n<p>As is often the case with Ubuntu, the bluetooth adapter was detected immediately upon inserting into the usb slot on the laptop; the small bluetooth icon appeared in the toolbar tray, with various options for managing the device. The first step was to pair the laptop with my cell phone (a Palm Centro). This was a fairly simple process: on the phone, I navigated to the Bluetooth application on the Centro (see below), selected Setup Devices, and\u00a0 changed the Discovery pull-down list to show nearby devices. I then\u00a0 highlighted my laptop name in the device list, clicked OK, and entered the a pairing pin when prompted. I was then prompted on my laptop for the corresponding entry, to create the secure connection, which completed the permanent pair between my laptop and phone. This is relevant, since I have hard-coded my setup to work only with my phone. It should be possible to create a more generic setup to dynamically use any Bluetooth DUN-enabled\u00a0 phone for tethering, but that is probably going to be a phase II effort.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-161\" title=\"Centro Bluetooth Activation\" src=\"http:\/\/otac.isa-geek.net\/blog\/wp-content\/uploads\/2009\/03\/snap-c53b5bde.bmp\" alt=\"Centro Bluetooth Activation\" \/><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-160\" title=\"Centro Bluetooth Device setup.\" src=\"http:\/\/otac.isa-geek.net\/blog\/wp-content\/uploads\/2009\/03\/snap-c53b5bca.bmp\" alt=\"Centro Bluetooth Device setup.\" \/><\/p>\n<p>The next step was to identify the specific Bluetooth address for my cell phone, and ensure that a rfcomm serial emulation device was created for communication between the laptop and the phone over Bluetooth. In order to do this, I first ran the command:<\/p>\n<p><strong>$ hcitool scan<br \/>\nScanning &#8230;<br \/>\n00:1D:FE:06:A0:6B\u00a0\u00a0\u00a0 Duane Cato<br \/>\n<\/strong>This revealed that the address of my phone was 00:1D:FE:06:A0:6B. I then entered the following command to determine the profiles available on my phone:<\/p>\n<p><strong>$ sdptool browse 00:1D:FE:06:A0:6B<br \/>\nBrowsing 00:1D:FE:06:A0:6B &#8230;<br \/>\nService Name: Voice Gateway<br \/>\nService RecHandle: 0x10000<br \/>\nService Class ID List:<br \/>\n&#8220;Handsfree Audio Gateway&#8221; (0x111f)<br \/>\n&#8220;Generic Audio&#8221; (0x1203)<br \/>\nProtocol Descriptor List:<br \/>\n&#8220;L2CAP&#8221; (0x0100)<br \/>\n&#8220;RFCOMM&#8221; (0x0003)<br \/>\nChannel: 7<br \/>\nLanguage Base Attr List:<br \/>\ncode_ISO639: 0x656e<br \/>\nencoding:\u00a0\u00a0\u00a0 0x6a<br \/>\nbase_offset: 0x100<br \/>\nProfile Descriptor List:<br \/>\n&#8220;Handsfree&#8221; (0x111e)<br \/>\nVersion: 0x0101<\/strong><\/p>\n<p><strong>Service Name: AUDIO Gateway<br \/>\nService RecHandle: 0x10003<br \/>\nService Class ID List:<br \/>\n&#8220;Headset Audio Gateway&#8221; (0x1112)<br \/>\n&#8220;Generic Audio&#8221; (0x1203)<br \/>\nProtocol Descriptor List:<br \/>\n&#8220;L2CAP&#8221; (0x0100)<br \/>\n&#8220;RFCOMM&#8221; (0x0003)<br \/>\nChannel: 2<br \/>\nLanguage Base Attr List:<br \/>\ncode_ISO639: 0x656e<br \/>\nencoding:\u00a0\u00a0\u00a0 0x6a<br \/>\nbase_offset: 0x100<br \/>\nProfile Descriptor List:<br \/>\n&#8220;Headset&#8221; (0x1108)<br \/>\nVersion: 0x0100<\/strong><\/p>\n<p><strong>Service Name: OBEX Object Push<br \/>\nService RecHandle: 0x10004<br \/>\nService Class ID List:<br \/>\n&#8220;OBEX Object Push&#8221; (0x1105)<br \/>\nProtocol Descriptor List:<br \/>\n&#8220;L2CAP&#8221; (0x0100)<br \/>\n&#8220;RFCOMM&#8221; (0x0003)<br \/>\nChannel: 3<br \/>\n&#8220;OBEX&#8221; (0x0008)<br \/>\nLanguage Base Attr List:<br \/>\ncode_ISO639: 0x656e<br \/>\nencoding:\u00a0\u00a0\u00a0 0x8cc<br \/>\nbase_offset: 0x100<\/strong><\/p>\n<p><strong>Service Name: Dial-up networking<br \/>\nService RecHandle: 0x10006<br \/>\nService Class ID List:<br \/>\n&#8220;Dialup Networking&#8221; (0x1103)<br \/>\nProtocol Descriptor List:<br \/>\n&#8220;L2CAP&#8221; (0x0100)<br \/>\n&#8220;RFCOMM&#8221; (0x0003)<br \/>\nChannel: 1<br \/>\nLanguage Base Attr List:<br \/>\ncode_ISO639: 0x656e<br \/>\nencoding:\u00a0\u00a0\u00a0 0x8cc<br \/>\nbase_offset: 0x100<br \/>\nProfile Descriptor List:<br \/>\n&#8220;Dialup Networking&#8221; (0x1103)<br \/>\nVersion: 0x0100<\/strong><\/p>\n<p>From the above command results, we can see that I have the Dialup Networking profile available (which is what is needed to service PPP connections from a client, such as a laptop). So the next step was\u00a0 to configure a\u00a0 PPP connection profile to reach use the DUN profile on the cell phone over the rfcomm device.<\/p>\n<p>There are two ways to create a rfcomm device that makes use of Bluetooth. The first way requires editing the \/etc\/bluetooth\/rfcomm.conf file and adding the settings for the DUN profile found above. Thus for my phone I had:<\/p>\n<p><strong>$sudo vi \/etc\/bluetooth\/rfcomm.conf<\/strong><\/p>\n<p>and then added:<\/p>\n<p><strong>rfcomm0 {<br \/>\nbind yes;<br \/>\ndevice 00:1D:FE:06:A0:6B;<br \/>\nchannel 1;<br \/>\ncomment &#8220;Duane Cato Centro GPRS&#8221;;<br \/>\n}<br \/>\n<\/strong>The disadvantage of this approach is that it binds the rfcomm device permanently to channel 1 of the Bluetooth connection, which can dynamically change each time a connection is made. This would necessitate updating the \/etc\/bluetooth\/rfcomm.conf config file each time with the correct channel number; more than slightly arduous.<\/p>\n<p>The alternate approach (which I used), makes use of the\u00a0 <strong>rfcomm<\/strong> command to dynamically bind the rfcomm device to the channel each time I want a PPP connection:<\/p>\n<p><strong>$ rfcomm bind \/dev\/rfcomm0 00:1D:FE:06:A0:6B 1<\/strong><\/p>\n<p>where the channel number is 1.<\/p>\n<p>Now that I was able to dynamically create the rfcomm device connecting to my cell phone Bluetooth DUN, the next step was to create a PPP connection to run over the serial rfcomm device. This is often specific to your mobile provider; since I use Rogers for my cell service, the following worked for me:<\/p>\n<p><strong>$ vi \/etc\/ppp\/peers\/provider<br \/>\ndebug<br \/>\nnoauth<br \/>\nconnect &#8220;\/usr\/sbin\/chat -v -f \/etc\/chatscripts\/provider&#8221;<br \/>\nipcp-accept-local<br \/>\nnoipdefault<br \/>\n:10.0.0.1<br \/>\nlocal<br \/>\nusepeerdns<br \/>\n\/dev\/rfcomm0 1152000<br \/>\ndefaultroute<br \/>\ncrtscts<br \/>\nlcp-echo-failure 0<\/strong><\/p>\n<p>The entry above will create a default PPP connection over the \/dev\/rfcomm0 at 1152000 baud. The other options basically say to use the default routing and DNS provided by the PPP server, and make the client a private network client of the DUN provider.<\/p>\n<p>The final step was to edit the \/etc\/chatscripts\/provider file, which contains the modem\/GPRS commands to make the actual connection from the cell phone to the service provider:<\/p>\n<p><strong>$ vi \/etc\/chatscripts\/provider<\/strong><\/p>\n<p>then put the following in the file:<\/p>\n<p><strong>TIMEOUT 35<br \/>\nECHO\u00a0\u00a0\u00a0 ON<br \/>\nABORT\u00a0\u00a0 &#8216;nBUSYr&#8217;<br \/>\nABORT\u00a0\u00a0 &#8216;nERRORr&#8217;<br \/>\nABORT\u00a0\u00a0 &#8216;nNO ANSWERr&#8217;<br \/>\nABORT\u00a0\u00a0 &#8216;nNO CARRIERr&#8217;<br \/>\nABORT\u00a0\u00a0 &#8216;nNO DIALTONEr&#8217;<br \/>\nABORT\u00a0\u00a0 &#8216;nRINGINGrnrnRINGINGr&#8217;<br \/>\n&#8221;\u00a0\u00a0\u00a0\u00a0\u00a0 rAT<br \/>\nOK\u00a0\u00a0\u00a0\u00a0\u00a0 &#8216;AT+CGDCONT=2,&#8221;IP&#8221;,&#8221;internet.com&#8221;&#8216;<br \/>\nOK\u00a0\u00a0\u00a0\u00a0\u00a0 ATD*99***1#<br \/>\nCONNECT &#8220;&#8221;<br \/>\n<\/strong>Again, keep in mind that these settings are specific to Rogers communicatoin. Essentially they are the values that are used by your cell phone to make an Internet connection, and can ususally be found in your cell phone internet settings or obtained directly from your mobile providers technical support.<\/p>\n<p>To make the actual connection from the laptop, the bundled \/usr\/bin\/pon command will initiate the PPP call over the Bluetooth DUN to the cell provider. To deactivate the connection , the \/usr\/bin\/poff command is used. In order to tie this whole process together, and reduce it to a simple command for activation\/deactivation, I created a script that automatically gets my channel number, passes it to the rfcomm command, then calls the \/usr\/bin\/pon program:<\/p>\n<p><strong>$ vi \/usr\/bin\/pon2.sh<br \/>\n#get the channel for the connection<br \/>\nCHAN=`sdptool search &#8211;bdaddr 00:1D:FE:06:A0:6B DUN|grep Channel|cut -f2 -d:`<br \/>\n#release channel if in use<br \/>\nrfcomm release \/dev\/rfcomm0<br \/>\n#bind the channel<br \/>\nrfcomm bind \/dev\/rfcomm0 00:1D:FE:06:A0:6B $CHAN<br \/>\n#run the ppp connection<br \/>\n\/usr\/bin\/pon<\/strong><\/p>\n<p>Now,\u00a0 to make an internet connectioon from my Ubuntu laptop over my cell, all I need to do is type the command:<\/p>\n<p><strong>$ pon2.sh<\/strong><\/p>\n<p>To disconnect, I enter:<\/p>\n<p><strong>$ poff<\/strong><\/p>\n<p>To make it even simpler, one can add these commands as icon&#8217;s on the desktop, making a mobile net connection just a click away. Remember that your browser expects a network connection to use the internet, so it may say that it is working in off-line mode, even though your mobile Internet is working fine. Just change the off line\u00a0 status for\u00a0 the browser, and you sould be good to go!<\/p>\n<p><strong>References<\/strong><\/p>\n<p><a href=\"http:\/\/www.spiration.co.uk\/post\/1307\/Ubuntu%20Linux%20-%20Bluetooth%20and%20GPRS%20dialup%20connection\"><span style=\"font-family: Arial; font-size: x-small;\"><a href=\"http:\/\/www.spiration.co.uk\/post\/1307\/Ubuntu%20Linux%20-%20Bluetooth%20and%20GPRS%20dialup%20connection\" target=\"_blank\"><span id=\"lw_1227099412_0\" class=\"yshortcuts\">http:\/\/www.spiration.co.uk\/post\/1307\/Ubuntu Linux &#8211; Bluetooth and GPRS dialup connection<\/span><\/a><\/span><br \/>\n<a href=\"https:\/\/help.ubuntu.com\/community\/BluetoothDialup\/Vodafone\"><span style=\"font-family: Arial; font-size: x-small;\"><a href=\"https:\/\/help.ubuntu.com\/community\/BluetoothDialup\/Vodafone\" target=\"_blank\"><span id=\"lw_1227099412_1\" class=\"yshortcuts\">https:\/\/help.ubuntu.com\/community\/BluetoothDialup\/Vodafone<\/span><\/a><\/span><\/a><\/a><br \/>\n<a href=\"http:\/\/www.smartphonethoughts.com\/news\/show\/15564\/3\/1\/5\"><span style=\"font-family: Arial; font-size: x-small;\"><a href=\"http:\/\/www.smartphonethoughts.com\/news\/show\/15564\/3\/1\/5\" target=\"_blank\"><span id=\"lw_1227099412_2\" class=\"yshortcuts\">http:\/\/www.smartphonethoughts.com\/news\/show\/15564\/3\/1\/5<\/span><\/a><\/span><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently upgraded my mobile plan to include (almost) unlimited data &#8211; mainly to support increased email and browsing activities. Also, all the smaller packages were really a waste of money. However, a quick notebook calculation revealed that I would have to send thousands of emails a day in order to even come close to [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47,8,10,44],"tags":[],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-bluetooth","category-linux","category-mobile","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/otac.isa-geek.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/otac.isa-geek.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/otac.isa-geek.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/otac.isa-geek.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/otac.isa-geek.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=141"}],"version-history":[{"count":15,"href":"https:\/\/otac.isa-geek.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":168,"href":"https:\/\/otac.isa-geek.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions\/168"}],"wp:attachment":[{"href":"https:\/\/otac.isa-geek.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/otac.isa-geek.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/otac.isa-geek.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}