Features of Bluez: Bluetooth Programming in C For Linux
Features of Bluez: Bluetooth Programming in C For Linux
Features
of
BlueZ
Real
hardware
abstrac.on
More features
Future
protocols
TCS-BIN,
AVDTP,
AVCTP
Current
proles
GAP,
SDAP,SPP,
GOEP,DUN,
FAX,
LAN,
PUSH,
SYNC,
FTP,PAN,
CIP,HID,
HCR
Future
proles
CTP,
Intercom,
BPP,
BIP,HSP,
HFP,
SAPP
Advantages
of
BlueZ
Full
source
code
is
available
under
the
GPL
Socket
based
interfaces
Simple
API
for
special
HCI
or
SDP
tasks
Access
to
all
Bluetooth
host
layers
Big
user
and
developer
community
Very
good
interoperability
with
Bluetooth
devices
9/27/12
RFCOMM
Data
stream
(SOCK_STREAM)
Sockets
can
be
converted
to
a
TTY
device
Uses
the
L2CAP
in-kernel
socket
interface
9/27/12
rfcomm-server.c (Cont.)
Socket funcHon
Addressing structures
For
RFCOMM
AF_BLUETOOTH
species
that
it
should
be
a
Bluetooth
socket
SOCK_STREAM
requests
a
socket
with
streams-based
delivery
seman.cs
BTPROTO_RFCOMM
specically
requests
an
RFCOMM
socket
Establishing
a
connecHon
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
sock
should
be
the
server
socket
created
by
connect.
info
should
point
to
a
struct
sockaddr_rc
addressing
structure
lled
in
with
the
local
Bluetooth
adapter
to
use,
and
which
port
number
to
use.
addrlen
should
always
be
sizeof( struct sockaddr_rc ).
the
applica.on
takes
the
bound
socket
and
puts
it
into
listening
mode
with
the
listen
func.on.
In
between
the
.me
an
incoming
Bluetooth
connec.on
is
accepted
by
the
opera.ng
system
and
the
.me
that
the
server
applica.on
actually
takes
control,
the
new
connec.on
is
put
into
a
backlog
queue.
The
backlog
parameter
species
how
big
this
queue
should
be.
Usually,
a
value
of
1
or
2
is
ne.
struct sockaddr_rc {
sa_family_t rc_family;
bdaddr_t
rc_bdaddr;
uint8_t
rc_channel;
};
The
accept
func.on
waits
for
an
incoming
connec.on
and
returns
a
brand
new
socket.
The
returned
socket
represents
the
newly
established
connec.on
with
a
client,
and
is
what
the
server
applica.on
should
use
to
communicate
with
the
client.
If
client_info
points
to
a
valid
struct
sockaddr_rc
structure,
then
it
is
lled
in
with
the
clients
informa.on.
Addi.onally,
infolen
will
be
set
to
sizeof(struct sockaddr_rc).
The
server
applica.on
can
then
make
another
call
to
accept
more
connec.ons,
or
it
can
close
the
server
socket
when
nished.
9/27/12
The
write
func.on
transmits
data,
the
read
func.on
waits
for
and
receives
incoming
data
Both
func.ons
take
three
parameter,
the
rst
being
a
connected
Bluetooth
socket.
For
write,
the
next
two
parameters
should
be
a
pointer
to
a
buer
containing
the
data
to
send,
and
the
amount
of
the
buer
to
send,
in
bytes.
For
read,
the
second
two
parameters
should
be
a
pointer
to
a
buer
into
which
incoming
data
will
be
copied,
and
an
upper
limit
on
the
amount
of
data
to
receive
write
returns
the
number
of
bytes
actually
transmiAed,
which
may
be
less
than
the
amount
requested.
In
that
case,
the
program
should
just
try
again
star.ng
from
where
send
lej
o.
read
returns
the
number
of
bytes
actually
received,
which
may
be
less
than
the
maximum
amount
requested.
The
special
case
where
read
returns
0
indicates
that
the
connec.on
is
broken
and
no
more
data
can
be
transmiAed
or
received.