我试着连接到我的
LegoBoost
Perl
在
Debian 4.9.110-3+deb9u4
。它是一种低能耗蓝牙(BLE)设备。我可以使用
gatttool
hci*
实用程序,但我没有Perl的运气。我尝试了以下代码:
use Net::Bluetooth;
use Data::Dumper;
print "Get remote devices...\n";
my $rDevice = get_remote_devices();
print Dumper $rDevice;
my $addr = "00:16:53:A5:3E:50";
print "SDP search...\n";
my @spd = sdp_search($addr, "", ""); # LegoBoost
print Dumper \@spd;
回报
undef
[undef]
我还尝试连接到该设备:
print "Connect to device...\n";
my $obj = Net::Bluetooth->newsocket("RFCOMM");
defined($obj) or die "socket error $!\n";
print "Socket got ", Dumper $obj;
system 'lsof', '-p', $$;
my $port = 14;
if($obj->connect($addr, $port) != 0) { die "connect error: $!\n";}
print "Connected...\n";
sleep 5;
#### create a Perl filehandle for reading and writing
my $fd = $obj->perlfh();
print Dumper $fd;
close $fd or die;
Connect to device...
Socket got $VAR1 = bless( {
'PROTO' => 'RFCOMM',
'SOCK_FD' => 4
}, 'Net::Bluetooth' );
connect error: Host is down
任何想法都是值得赞赏的!
提前谢谢你!