I'm trying to connect to a Bluetooth LE (low energy) device, specifically the MXTP-100 printer (that extremely cheap thermal printer with the cat ears). I tried Net::Bluetooth, but that doesn't seem to support Low Energy devices.

I can connect and print just fine to an old Epson bluetooth printer (not LE), but newer LE devices don't seem to work with Net::Bluetooth.

To be honest, i have absolutely no idea what i'm doing. Does anyone have any suggestions?

EDIT: Ooops, sorry, forgot to include my test code:

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 = <DATA>; 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.

(I just hacked one of the examples, so code quality is low. Also please ignore the mentioning of GPS, i just didn't bother to update all variable names and comments)

PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Also check out my sisters artwork and my weekly webcomics

In reply to Bluetooth LE? by cavac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.