Code


BLOG
About Matthias Nott
SAP
Picture Galleries
Code
Technical





Locations of visitors to this page

This is a short how2 on using a Sony Ericsson P900 mobile phone on an IBM Thinkpad T41p using GPRS through Bluetooth.

 

I assume that you have Bluetooth set up correctly. There are plenty of resources on the internet on how to do this.

 

Here is a Perl script that wraps a pppd call to initiate the connection:

  1. #!/usr/bin/perl -w
  2. #
  3. # This is a script that connects to the gprs network.
  4. #
  5. # (c) 2004, Matthias Nott, MN Soft Branchensoftware
  6.  
  7. use strict;
  8. use warnings;
  9.  
  10. # Make sure the rfcomm module is loaded.
  11. system("modprobe rfcomm");
  12.  
  13. # Make sure that bluetooth is restarted.
  14. system("/etc/rc.d/bluetooth restart");
  15.  
  16. # Make sure no devices are locked.
  17. system("rfcomm release all");
  18.  
  19. # Detect the channel that the phone is working on.
  20. # We do not detect the phone in the first place,
  21. # to find out its MAC address, as this takes a
  22. # long time. We can do so manually using the
  23. # command
  24. #
  25. # hcitool scan
  26. #
  27. # from the command line.
  28.  
  29. my $channel = -2;
  30. for(`sdptool browser 00:0A:D9:E9:2C:78`) {
  31.   chomp;
  32.   next if($channel == -2 && !/^Service Name: Dial-up Networking.*$/);
  33.   $channel = -1;
  34.   next if($channel == -1 && !/^.*Channel: (\d+).*$/);
  35.   $channel = $1;
  36.   last if($channel >= 0);
  37. }
  38. print "The Mobile is having a modem on channel #$channel.\n";
  39.  
  40. # Bind the rfcomm communication channel to the mobile's
  41. # communication channel.
  42. system("rfcomm bind 0 00:0A:D9:E9:2C:78 $channel");
  43.  
  44. # We now have to wait for some time for the connection to
  45. # be established.
  46. sleep 10;
  47.  
  48. # Finally, we open the connection.
  49. print "Opening the connection. Press Ctrl+C to hangup.\n";
  50. system("pppd call gprs");

00:0A:D9:E9:2C:78 is the Bluetooth ID of the mobile phone. When you connect, you'll have to allow the incoming connection from BlueZ on the Mobile (you can set this to "always").

 

For the connect scripts, cf. www.mnsoft.org/319.0.html

 


11.01.2006, 15:30 Copyright © 2005 MN Soft Industry Software, 8a, Chemin de la Tarpa, CH-1872 Troistorrents-Chenarlier
Tel.: +41 797 844554; Fax: +41 860 797 844554, Responsible: Matthias Nott., mn(at)mnsoft.org
Top of Page