use Net::Bluetooth; use strict; use warnings; use Time::HiRes qw(sleep); use Data::Dumper; #my $printer_addr='00:01:90:AE:B5:9C'; # Epson my $printer_addr='68:08:09:14:B7:4F'; # MXTP-100 #### Could retry here instead of exiting. die "BT GPS not found." unless(defined($printer_addr)); #### Search for the serial service (0x1101) on my printer my @sdp_array = sdp_search($printer_addr, "1101", ""); die "No service records found" unless(@sdp_array); my $port = 0; #### Loop through all the service records. #### foreach service record .... print Dumper(@sdp_array); foreach my $rec_ref (@sdp_array) { #### Get the RFCOMM port number for the service. if(exists($rec_ref->{RFCOMM})) { $port = $rec_ref->{RFCOMM}; last; } } die "No RFCOMM record found." unless($port > 0); print "BT Serial port found $printer_addr $port \n"; my $obj = Net::Bluetooth->newsocket("RFCOMM"); die "socket error: $!\n" unless(defined($obj)); die "connect error: $!\n" if($obj->connect($printer_addr, $port) != 0); #### Create a Perl filehandle for reading and writing. *SERVER = $obj->perlfh(); SERVER->autoflush(1); my @lines = ; foreach my $line (@lines) { #print $line; #print SERVER $line; SERVER->write($line); #sleep(0.1); } for(1..8) { SERVER->write("\n"); } __DATA__ This was a triumph. I'm making a note here: huge success. It's hard to overstate My satisfaction.