Usando o Perl Net::Bluetooth
parece promissor ... Estou brincando com o código a seguir, principalmente copiei e colei dos exemplos e montei de várias fontes.
cat rfcomm-fake-server.pl
#! /usr/bin/perl -w
# Information Sources:
# http://search.cpan.org/~iguthrie/Net-Bluetooth-0.40/Bluetooth.pm
# http://people.csail.mit.edu/albert/bluez-intro/x290.html#py-rfcomm-server-sdp
# http://people.csail.mit.edu/albert/bluez-intro/x232.html#rfcomm-server.py
# http://linuxdevcenter.com/pub/a/linux/2006/09/21/rediscovering-bluetooth.html?page=last
use Net::Bluetooth;
#### create a RFCOMM server
print "create rfcomm server\n";
$obj = Net::Bluetooth->newsocket("RFCOMM");
#### bind to port 1
print "binding to port 1\n";
if($obj->bind(1) != 0) {
die "bind error: $!\n";
}
print "listening with backlog 2\n";
#### listen with a backlog of 2
if($obj->listen(2) != 0) {
die "listen error: $!\n";
}
print "register UUID\n";
#### register a service
#### $obj must be a open and bound socket
# UUID Format: 00000000-0000-0000-0000-000000000000
# RFCOMM: 00001101-0000-1000-8000-00805F9B34FB
my $service_obj = Net::Bluetooth->newservice($obj, "00001101-0000-1000-8000-00805F9B34FB", "FAKEOBD", "Fake OBD Adapter");
print "Now what?\n";
unless(defined($service_obj)) {
print "There was a problem registering the UUID...\n";
die ("Couldn't register UUID/service");
#### couldn't register service
}
#### accept a client connection
print "Blocking until we receive an incoming connection";
$client_obj = $obj->accept();
unless(defined($client_obj)) {
die "client accept failed: $!\n";
}
#### get client information
my ($caddr, $port) = $client_obj->getpeername();
print "Connected to $caddr on port $port\n";
#### create a Perl filehandle for reading and writing
*CLIENT = $client_obj->perlfh();
print CLIENT "Hello there?";
while (<CLIENT>) {
print "Data: "
}