public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Balazs Fulop <admin@guardware.com>
To: bluez-devel@lists.sourceforge.net
Subject: [Bluez-devel] PIN requester
Date: 26 Dec 2004 00:21:12 +0100	[thread overview]
Message-ID: <1104016872.835.1.camel@bigwig> (raw)

[-- Attachment #1: Type: text/plain, Size: 1626 bytes --]

Dear BlueZ Developers! 

My name is Fulop Balazs. I study at the Budapest University of
Technology and Economics. 

As a Christmas present, I got a Bluetooth USB adapter yesterday. I
wanted to see it in action immediately so I booted up my Linux box
(running 2.4.28) and started to look for the necessary tools. 

After some workaround I had a feeling that I was close to the solution
but something was wrong. I loaded the necessary modules, and I started
the required daemons. When I started gnokii, it connected to my mobile
phone, and I was asked to enter a PIN code on the phone. It did not
matter what I gave it, it did not work. The computer did not ask me to
give a code. 

I knew I needed to specify the PIN, but I did not know how, because I
did not get any error messages about this. After a while I realised that
/usr/bin/bluepin is invoked in the situation. It is a Python script and
it imports the pygtk module which was not available on my machine. After
installing the python-gtk package on my Debian Woody, nothing changed. 

I am not familiar with Python but I think it needs a Gtk 2.0 module
which is not available as a package for Debian Woody 3.0 r1. Because of
this I wrote a Perl-tk script to do the job and now it just works fine. 

If you are interested in my solution, take a look at the attachment. It
is not a big deal, but I am quite proud of it. Moreover, if you would
like to include it in bluez-utils go right ahead. It is released under
GPL ;-) 

I am not on the list, so please reply to admin@guardware.com. Sorry for
the long letter, and Merry Christmas to Everyone. 

Hail, 
Fulop Balazs 



[-- Attachment #2: pincode --]
[-- Type: text/x-perl, Size: 1089 bytes --]

#!/usr/bin/perl -w

# PIN code requester
# Satisfies BlueZ requirements
# Written by Fulop Balazs <fb554@hszk.bme.hu>, 2004

use strict;
use Tk;


my $mainwin = new MainWindow ( -title => "Enter PIN", -borderwidth => 20 );

my $frame = $mainwin -> Frame ( -borderwidth => 5 );

$frame -> Label ( -text => "PIN:" ) -> pack ( -side => "left" );

my $pin = $frame -> Entry (
    -justify => "center",
    -validate => "key",
    -validatecommand => \&check
) -> pack ( -side => "right" );
$pin -> bind ( "<Return>" => \&ok );
$pin -> bind ( "<Escape>" => \&cancel );
$pin -> focus;

$frame -> pack ( -side => "top" );

$mainwin -> Button ( -text => "Ok", -command => \&ok ) ->
    pack ( -side => "left" );
$mainwin -> Button ( -text => "Cancel", -command => \&cancel ) ->
    pack ( -side => "right" );

MainLoop;


sub check {
    return 1 if ($_[1] =~ /[0-9]/);
    return 0;
}

sub ok {
    my $code = $pin -> get;
    cancel () if ("" eq $code);
    print "PIN:" . $code . "\n";
    exit;
}

sub cancel {
    print "ERR\n";
    exit;
}

                 reply	other threads:[~2004-12-25 23:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1104016872.835.1.camel@bigwig \
    --to=admin@guardware.com \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox