libbluetooth2 and Net::Bluetooth

View: New views
7 Messages — Rating Filter:   Alert me  

libbluetooth2 and Net::Bluetooth

by Oliver Fromme :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I'm new to bluetooth (read: I know almost nothing about
it), so I have a few questions.

First, is there a recommended bluetooth USB dongle that's
guaranteed to work with FreeBSD (7-stable) and that's
not too expensive?  I've seen a lot of really cheap and
small dongles recently at online shops, but I assume not
all of them work fine, right?

Second, I would like to use this software (perl script):

http://lukas.internet-freaks.net/nxtmanager.php

(Sorry, the page is in German, but the .tar.gz download
at the bottom of the page contains an English README.)

As far as I can tell, the software requires libbluetooth2
and the CPAN module Net::Bluetooth.  I searched the ports,
but they're not there.  I assume those don't work with
FreeBSD, right?  Any idea whether porting them would be
feasible?

Best regards
   Oliver

--
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

(On the statement print "42 monkeys" + "1 snake":)  By the way,
both perl and Python get this wrong.  Perl gives 43 and Python
gives "42 monkeys1 snake", when the answer is clearly "41 monkeys
and 1 fat snake".        -- Jim Fulton
_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."

bluetooth USB dongles

by Iain Hibbert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 8 Dec 2008, Oliver Fromme wrote:

> First, is there a recommended bluetooth USB dongle that's
> guaranteed to work with FreeBSD (7-stable) and that's
> not too expensive?  I've seen a lot of really cheap and
> small dongles recently at online shops, but I assume not
> all of them work fine, right?

the vast majority of USB dongles will work just fine

if you are buying something, there are different selling points that can
be confusing.

Class 1 - 100m range
Class 2 - 10m range
Class 3 - 1m range

I've never seen a class 3 device, and although I do have a class 1
controller it doesn't seem to make much difference as to signal quality at
close range (I guess its just more powerful radio). Then there is
Bluetooth version, so you might see

v1.0b
v1.2
v2.0 + EDR
v2.1 + EDR

If you see a v1.x device for sale then don't be tempted. v2.x devices are
vastly better at making and maintaining connections, and the 'Enhanced
Data Rate' gives much faster transfers. I've not seen a v2.1 dongle in the
real world though they may exist (ditto for v2.2 as spec is availabe)

I have seen (recently!) a v1.0b device advertised as "BLUETOOTH CLASS 2"
with the v1.0b in really small writing on the case, I guess that these are
old stock dressed up to sell rather than new manufactures but its good to
be aware :)

iain
_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."

Re: libbluetooth2 and Net::Bluetooth

by Iain Hibbert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 8 Dec 2008, Oliver Fromme wrote:

> Second, I would like to use this software (perl script):
>
> http://lukas.internet-freaks.net/nxtmanager.php
>
> As far as I can tell, the software requires libbluetooth2
> and the CPAN module Net::Bluetooth.  I searched the ports,
> but they're not there.  I assume those don't work with
> FreeBSD, right?  Any idea whether porting them would be
> feasible?

The problem with this libbluetooth2 is that it forms the interface to the
linux kernel for the BlueZ system and as such, large parts of it are not
relevant to any other operating system.

The way that this Lego Mindstorms NXT module speaks through bluetooth is
using RFCOMM with the SerialPortProfile, so of course it is possible to
talk to that from FreeBSD using an RFCOMM socket directly, or by using
rfcomm_sppd(1) to open a pty with a connection to the NXT and using stdio.

I don't know what this perl script needs to use the libbluetooth2 for,
probably the module just lumps all bluetooth together. If you know how to
make bindings then perhaps you can make a RFCOMM sockets module that will
fulfil the requirements?

iain
_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."

Re: bluetooth USB dongles

by Vladimir Botka-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 8 Dec 2008 12:35:41 +0000 (GMT)
Iain Hibbert <plunky@...> wrote:

> On Mon, 8 Dec 2008, Oliver Fromme wrote:
>
> > First, is there a recommended bluetooth USB dongle that's
> > guaranteed to work with FreeBSD (7-stable) and that's
> > not too expensive?  I've seen a lot of really cheap and
> > small dongles recently at online shops, but I assume not
> > all of them work fine, right?
>
> the vast majority of USB dongles will work just fine
>
> if you are buying something, there are different selling points that
> can be confusing.
>
> Class 1 - 100m range
> Class 2 - 10m range
> Class 3 - 1m range
>
> I've never seen a class 3 device, and although I do have a class 1
> controller it doesn't seem to make much difference as to signal
> quality at close range (I guess its just more powerful radio). Then
> there is Bluetooth version, so you might see
>
> v1.0b
> v1.2
> v2.0 + EDR
> v2.1 + EDR
>
> If you see a v1.x device for sale then don't be tempted. v2.x devices
> are vastly better at making and maintaining connections, and the
> 'Enhanced Data Rate' gives much faster transfers. I've not seen a
> v2.1 dongle in the real world though they may exist (ditto for v2.2
> as spec is availabe)
>
> I have seen (recently!) a v1.0b device advertised as "BLUETOOTH CLASS
> 2" with the v1.0b in really small writing on the case, I guess that
> these are old stock dressed up to sell rather than new manufactures
> but its good to be aware :)
>
> iain
> _______________________________________________
> freebsd-bluetooth@... mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
> To unsubscribe, send any mail to
> "freebsd-bluetooth-unsubscribe@..."
>

I can recommend "cambridge silicon radio". The best choice up till now.

--
        -vlado
        Vladimir Botka

_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."

Re: bluetooth USB dongles

by Oliver Fromme :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Vladimir Botka wrote:
 > Iain Hibbert wrote:
 > > the vast majority of USB dongles will work just fine
 > >
 > > if you are buying something, there are different selling points that
 > > can be confusing.
 > >
 > > Class 1       - 100m range
 > > Class 2       - 10m range
 > > Class 3 - 1m range
 > >
 > > I've never seen a class 3 device, and although I do have a class 1
 > > controller it doesn't seem to make much difference as to signal
 > > quality at close range (I guess its just more powerful radio).

The device I'm going to use is class 2, so I guess it's
sufficient to buy a class 2 controller.  In order to be
able to support the 100m range, both device _and_ controller
have to be class 1, I assume.  (Please correct me if I'm
wrong.)

 > > Then there is Bluetooth version, so you might see
 > >
 > > v1.0b
 > > v1.2
 > > v2.0 + EDR
 > > v2.1 + EDR
 > >
 > > If you see a v1.x device for sale then don't be tempted. v2.x devices
 > > are vastly better at making and maintaining connections, and the
 > > 'Enhanced Data Rate' gives much faster transfers. I've not seen a
 > > v2.1 dongle in the real world though they may exist (ditto for v2.2
 > > as spec is availabe)
 > >
 > > I have seen (recently!) a v1.0b device advertised as "BLUETOOTH CLASS
 > > 2" with the v1.0b in really small writing on the case, I guess that
 > > these are old stock dressed up to sell rather than new manufactures
 > > but its good to be aware :)

Thanks Iain for the explanations.  That's very helpful.
Indeed I noticed there are still 1.x dongles offered for
sale.  Good thing you warned me.

 > I can recommend "cambridge silicon radio". The best choice up till now.

Thanks Vladimir for the suggestion.  Unfortunately it is
difficult to find a product by chipset name.  Most online
shops don't list such technical details, and even the
manufacturers' web sites don't mention it.

After some searching, I finally ordered a "LogiLink Ultra
Mini Bluetooth 2.0 USB Adapter BT0007".  According to the
manufacturer's web page it is Bluetooth V2.0 with 20m
range (so I assume it's class 2, even though they don't
mention this), and they even say that the chipset is "CSR"
(which I assume means cambridge silicon radio).

Surprisingly this little fella is so small it seems to
almost completely disappear inside the USB slot.
Amazing.  What's even better, it costs only 6 Euros.

Thanks everybody for your suggestions!

Best regards
   Oliver

--
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"Python tricks" is a tough one, cuz the language is so clean. E.g.,
C makes an art of confusing pointers with arrays and strings, which
leads to lotsa neat pointer tricks; APL mistakes everything for an
array, leading to neat one-liners; and Perl confuses everything
period, making each line a joyous adventure <wink>.
        -- Tim Peters
_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."

Re: bluetooth USB dongles

by Oliver Fromme :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oliver Fromme wrote:
 > After some searching, I finally ordered a "LogiLink Ultra
 > Mini Bluetooth 2.0 USB Adapter BT0007".  According to the
 > manufacturer's web page it is Bluetooth V2.0 with 20m
 > range (so I assume it's class 2, even though they don't
 > mention this), and they even say that the chipset is "CSR"
 > (which I assume means cambridge silicon radio).

Okay, basically it seems to work, but I have a few
questions ...

So I loaded the KLD modules manually (because I didn't
want to reboot) and inserted the dongle.  This is what
I get in dmesg:

WARNING: attempt to net_add_domain(netgraph) after domainfinalize()
ubt0: <vendor 0x0a12 BT2.0, class 224/1, rev 2.00/31.64, addr 3> on uhub0
ubt0: Interface 0 endpoints: interrupt=0x81, bulk-in=0x82, bulk-out=0x2
ubt0: Interface 1 (alt.config 5) endpoints: isoc-in=0x83, isoc-out=0x3; wMaxPacketSize=49; nframes=6, buffer size=294
hardware_error:  - hardware error 0x37

I'm a bit worried about the warning line and the hardware
error line.  Is this normal and to be expected?

Anyway, I followed the instructions in the Handbook and
ran "/etc/rc.d/bluetooth start ubt0".  I expected to get
a few lines of output, according to the Handbook chapter
32.4.  But I got nothing at all.  Am I missing something,
or should the Handbook get a fix?

Still it seems to work:  When I enable BT on my mobile
phone, FreeBSD finds it:

# hccontrol inquiry
Inquiry result, num_responses=1
Inquiry result #0
        BD_ADDR: 00:60:57:2e:27:de
        Page Scan Rep. Mode: 0x1
        Page Scan Period Mode: 00
        Page Scan Mode: 00
        Class: 50:02:04
        Clock offset: 0x18a1
Inquiry complete. Status: No error [00]

And vice versa:  The phone lists my FreeBSD box when I
initiate a scan.

The next thing I'm going to try is to connect to the
NXT brick.

Best regards
   Oliver

--
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"The scanf() function is a large and complex beast that often does
something almost but not quite entirely unlike what you desired."
        -- Chris Torek
_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."

Re: libbluetooth2 and Net::Bluetooth

by Oliver Fromme :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Iain Hibbert wrote:
 > On Mon, 8 Dec 2008, Oliver Fromme wrote:
 >
 > > Second, I would like to use this software (perl script):
 > >
 > > http://lukas.internet-freaks.net/nxtmanager.php
 > >
 > > As far as I can tell, the software requires libbluetooth2
 > > and the CPAN module Net::Bluetooth.  I searched the ports,
 > > but they're not there.  I assume those don't work with
 > > FreeBSD, right?  Any idea whether porting them would be
 > > feasible?
 >
 > The problem with this libbluetooth2 is that it forms the interface to the
 > linux kernel for the BlueZ system and as such, large parts of it are not
 > relevant to any other operating system.

I see.

 > The way that this Lego Mindstorms NXT module speaks through bluetooth is
 > using RFCOMM with the SerialPortProfile, so of course it is possible to
 > talk to that from FreeBSD using an RFCOMM socket directly, or by using
 > rfcomm_sppd(1) to open a pty with a connection to the NXT and using stdio.
 >
 > I don't know what this perl script needs to use the libbluetooth2 for,
 > probably the module just lumps all bluetooth together. If you know how to
 > make bindings then perhaps you can make a RFCOMM sockets module that will
 > fulfil the requirements?

Thanks for pointing me in the right direction.  I decided
to stop being a Bluetooth newbie and start programming the
darn thing myself.  :-)

So I downloaded the NXT developers kit and started to make
myself familiar with the API and protocols.  My programming
language of choice is Python, so I decided not to waste any
more time with the existing (and rather unreadable) Perl
code, and instead start from scratch.

Python supports Bluetooth sockets natively on FreeBSD,
without having to install any additional modules.  In fact
I found out that it's ridiculuously simple to open and
access a Bluetooth RFCOMM socket from Python and talk to
devices.

I'll probably release my code under BSD license and submit
it to the Ports collection as soon as it's ready.

Thanks again for helping me to start off with this!

Best regards
   Oliver

--
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"What is this talk of 'release'?  We do not make software 'releases'.
Our software 'escapes', leaving a bloody trail of designers and quality
assurance people in its wake."
_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."