summaryrefslogtreecommitdiffstats
path: root/lib/network/connection/cellular_bluetooth.pm
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2007-05-25 15:39:46 +0000
committerOlivier Blin <oblin@mandriva.com>2007-05-25 15:39:46 +0000
commit1d37bfdbbe874abd6dcb5563eea19f531de09e1c (patch)
tree74845e43ed8fa59c7aaafd1a87efaa6b0c83c228 /lib/network/connection/cellular_bluetooth.pm
parentc6ba983db7d5a82ee63599e775be0f8211447c72 (diff)
downloaddrakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar.gz
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar.bz2
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar.xz
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.zip
sync with 2007.1 (because of SVN loss)2007.1
Diffstat (limited to 'lib/network/connection/cellular_bluetooth.pm')
-rw-r--r--lib/network/connection/cellular_bluetooth.pm94
1 files changed, 94 insertions, 0 deletions
diff --git a/lib/network/connection/cellular_bluetooth.pm b/lib/network/connection/cellular_bluetooth.pm
new file mode 100644
index 0000000..1457795
--- /dev/null
+++ b/lib/network/connection/cellular_bluetooth.pm
@@ -0,0 +1,94 @@
+package network::connection::cellular_bluetooth;
+
+use base qw(network::connection::cellular);
+
+use strict;
+use common;
+
+my $rfcomm_dev_prefix = "/dev/rfcomm";
+
+sub get_type_name { N("Bluetooth") }
+sub get_type_description { N("Bluetooth Dial Up Networking") }
+sub get_type_icon { 'bluetooth-24.png' }
+sub get_devices { search_services('DUN') }
+sub get_metric { 45 }
+sub get_interface { "ppp0" }
+
+sub get_rfcomm_device {
+ my ($self) = @_;
+ $self->{rfcomm_device} ||= find { ! -e ($rfcomm_dev_prefix . $_) } 0 .. 99;
+}
+
+sub get_tty_device {
+ my ($self) = @_;
+ $rfcomm_dev_prefix . $self->get_rfcomm_device;
+}
+
+# http://www.hingston.demon.co.uk/mike/nokia6680.html
+# http://kapsi.fi/~mcfrisk/linux_gprs.html
+# GPRS specific commands http://www.phonestar.com.my/s_at_10.html
+
+sub search_services {
+ my ($service_type) = @_;
+ my (@services);
+ my $service = {};
+ my ($key, $value);
+ my $push_service = sub { push @services, $service if exists $service->{class} };
+ my $use_key = sub { $key = $_[0]; undef $value };
+ foreach (run_program::rooted_get_stdout($::prefix, 'sdptool', 'search', $service_type)) {
+ if (/^Searching for $service_type on (.+) \.\.\.$/) {
+ $push_service->();
+ $service = { addr => $1 };
+ } elsif (/^Service Name:\s+(.*)$/) {
+ $service->{name} = $1;
+ } elsif (/^Service Provider:\s+(.*)$/) {
+ $service->{name} = $1;
+ } elsif (/^\s*Channel:\s*(\d+)$/) {
+ $service->{channel} = $1;
+ } elsif (/^Service Class ID List/) {
+ $use_key->('class');
+ } else {
+ $value = chomp_($_);
+ }
+ if ($key && $value) {
+ $service->{$key} = $value;
+ $use_key->(undef);
+ }
+ }
+ $push_service->();
+ my %names;
+ foreach (@services) {
+ $names{$_->{addr}} ||= chomp_(run_program::rooted_get_stdout($::prefix, 'hcitool', 'name', $_->{addr}));
+ $_->{description} = $names{$_->{addr}};
+ }
+ @services;
+}
+
+sub write_settings {
+ my ($self) = @_;
+
+ $self->write_cellular_settings;
+
+ my $dev = $self->get_rfcomm_device;
+ output("$::prefix/etc/bluetooth/rfcomm.conf", qq(
+rfcomm$dev {
+ bind yes;
+ device $self->{device}{addr};
+ channel $self->{device}{channel};
+ comment "Dial-up networking";
+}
+));
+
+ my $cid = 1;
+ $self->{access}{at_commands} = [ qq(AT+CGDCONT=$cid,"IP","$self->{access}{apn}") ];
+ $self->{access}{dial_number} = "*99***$cid#";
+
+ $self->SUPER::write_settings;
+}
+
+sub prepare_connection {
+ my ($self) = @_;
+ run_program::rooted_get_stdout($::prefix, 'rfcomm', 'bind', $self->get_rfcomm_device);
+}
+
+1;