bluetooth
index
/build/buildd/pybluez-0.9.1/build/lib.linux-parisc64-2.3/bluetooth.py

 
Modules
       
_bluetooth
array
binascii
fcntl
struct
sys

 
Classes
       
BluetoothSocket
DeviceDiscoverer
exceptions.IOError(exceptions.EnvironmentError)
BluetoothError

 
class BluetoothError(exceptions.IOError)
    
Method resolution order:
BluetoothError
exceptions.IOError
exceptions.EnvironmentError
exceptions.StandardError
exceptions.Exception

Methods inherited from exceptions.EnvironmentError:
__init__(...)
__str__(...)

Methods inherited from exceptions.Exception:
__getitem__(...)

 
class BluetoothSocket
    BluetoothSocket(proto=RFCOMM) -> bluetooth socket object
 
Open a socket of the given protocol.  proto must be one of
HCI, L2CAP, RFCOMM, or SCO.  SCO sockets have
not been tested at all yet.
 
BluetoothSocket object represents one endpoint of a bluetooth connection.
 
Methods of BluetoothSocket objects (keyword arguments not allowed):
 
accept() -- accept a connection, returning new socket and client address
bind(addr) -- bind the socket to a local address
close() -- close the socket
connect(addr) -- connect the socket to a remote address
connect_ex(addr) -- connect, return an error code instead of an exception
dup() -- return a new socket object identical to the current one
fileno() -- return underlying file descriptor
getpeername() -- return remote address
getsockname() -- return local address
getsockopt(level, optname[, buflen]) -- get socket options
gettimeout() -- return timeout or None
listen(n) -- start listening for incoming connections
makefile([mode, [bufsize]]) -- return a file object for the socket
recv(buflen[, flags]) -- receive data
recvfrom(buflen[, flags]) -- receive data and sender's address
sendall(data[, flags]) -- send all data
send(data[, flags]) -- send data, may not send all of it
sendto(data[, flags], addr) -- send data to a given address
setblocking(0 | 1) -- set or clear the blocking I/O flag
setsockopt(level, optname, value) -- set socket options
settimeout(None | float) -- set or clear the timeout
shutdown(how) -- shut down traffic in one or both directions
 
  Methods defined here:
__init__(self, proto=3, _sock=None)
accept(self)
accept() -> (socket object, address info)
 
Wait for an incoming connection.  Return a new socket representing the
connection, and the address of the client.  For L2CAP sockets, the address
is a (host, psm) tuple.  For RFCOMM sockets, the address is a (host, channel)
tuple.  For SCO sockets, the address is just a host.
bind(self, addrport)
close(self, *args, **kwargs)
connect(self, *args, **kwargs)
connect_ex(self, *args, **kwargs)
dup(self)
dup() -> socket object
 
Return a new socket object connected to the same system resource.
fileno(self, *args, **kwargs)
getpeername(self, *args, **kwargs)
getsockname(self, *args, **kwargs)
getsockopt(self, *args, **kwargs)
gettimeout(self, *args, **kwargs)
listen(self, *args, **kwargs)
makefile(self, *args, **kwargs)
recv(self, *args, **kwargs)
recvfrom(self, *args, **kwargs)
send(self, *args, **kwargs)
sendall(self, *args, **kwargs)
sendto(self, *args, **kwargs)
setblocking(self, *args, **kwargs)
setsockopt(self, *args, **kwargs)
settimeout(self, *args, **kwargs)
shutdown(self, *args, **kwargs)

 
class DeviceDiscoverer
    Skeleton class for finer control of the device discovery process.
 
To implement asynchronous device discovery (e.g. if you want to do
something *as soon as* a device is discovered), subclass
DeviceDiscoverer and override device_discovered() and
inquiry_complete()
 
  Methods defined here:
__init__(self)
cancel_inquiry(self)
Call this method to cancel an inquiry in process.  inquiry_complete 
will still be called.
device_discovered(self, address, device_class, name)
Called when a bluetooth device is discovered.
 
address is the bluetooth address of the device
 
device_class is the Class of Device, as specified in [1]
             passed in as a 3-byte string
 
name is the user-friendly name of the device if lookup_names was
set when the inquiry was started.  otherwise None
 
This method exists to be overriden.
 
[1] https://www.bluetooth.org/foundry/assignnumb/document/baseband
fileno(self)
find_devices(self, lookup_names=True, duration=8, flush_cache=True)
find_devices( lookup_names=True, service_name=None, 
               duration=8, flush_cache=True )
 
Call this method to initiate the device discovery process
 
lookup_names - set to True if you want to lookup the user-friendly 
               names for each device found.
 
service_name - set to the name of a service you're looking for.
               only devices with a service of this name will be 
               returned in device_discovered() NOT YET IMPLEMENTED
 
 
ADVANCED PARAMETERS:  (don't change these unless you know what 
                    you're doing)
 
duration - the number of 1.2 second units to spend searching for
           bluetooth devices.  If lookup_names is True, then the 
           inquiry process can take a lot longer.
 
flush_cache - return devices discovered in previous inquiries
inquiry_complete(self)
Called when an inquiry started by find_devices has completed.
pre_inquiry(self)
Called just after find_devices is invoked, but just before the
inquiry is started.
 
This method exists to be overriden
process_event(self)
Waits for one event to happen, and proceses it.  The event will be
either a device discovery, or an inquiry completion.
process_inquiry(self)
Repeatedly calls process_event() until the device inquiry has 
completed.

 
Functions
       
advertise_service(sock, name, service_id='', service_classes=[], profiles=[], provider='', description='', protocols=[])
Advertises a service with the local SDP server.  sock must be a bound,
listening socket.  name should be the name of the service, and service_id 
(if specified) should be a string of the form 
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", where each 'X' is a hexadecimal
digit.
 
service_classes is a list of service classes whose this service belongs to.
Each class service is a 16-bit UUID in the form "XXXX", where each 'X' is a
hexadecimal digit, or a 128-bit UUID in the form
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX". There are some constants for
standard services, e.g. SERIAL_PORT_CLASS that equals to "1101". Some class
constants:
 
SERIAL_PORT_CLASS        LAN_ACCESS_CLASS         DIALUP_NET_CLASS 
HEADSET_CLASS            CORDLESS_TELEPHONY_CLASS AUDIO_SOURCE_CLASS
AUDIO_SINK_CLASS         PANU_CLASS               NAP_CLASS
GN_CLASS
 
profiles is a list of service profiles that thie service fulfills. Each
profile is a tuple with ( uuid, version ). Most standard profiles use
standard classes as UUIDs. PyBluez offers a list of standard profiles,
for example SERIAL_PORT_PROFILE. All standard profiles have the same
name as the classes, except that _CLASS suffix is replaced by _PROFILE.
 
provider is a text string specifying the provider of the service
 
description is a text string describing the service
 
A note on working with Symbian smartphones:
    bt_discover in Python for Series 60 will only detect service records
    with service class SERIAL_PORT_CLASS and profile SERIAL_PORT_PROFILE
discover_devices(duration=8, flush_cache=True, lookup_names=False)
performs a bluetooth device discovery using the first available bluetooth
resource.
 
if lookup_names is False, returns a list of bluetooth addresses.
if lookup_names is True, returns a list of (address, name) tuples
 
duration=8 
    how long, in units of 1.28 seconds, to search for devices.  To find as
    many devices as possible, you should set this to at least 8.  
    Linux only
flush_cache=True 
    if set to False, then discover_devices may return devices found during
    previous discoveries.
lookup_names=False
    if set to True, then discover_devices also attempts to lookup the
    display name of each detected device.
find_service(name=None, uuid=None, address=None)
find_service( name = None, uuid = None, address = None )
 
Searches for SDP services that match the specified criteria and returns
the search results.  If no criteria are specified, then returns a list of
all nearby services detected.  If more than one is specified, then
the search results will match all the criteria specified.  If uuid is
specified, it must be either a 16-bit UUID in the form "XXXX", where each
'X' is a hexadecimal digit, or as a 128-bit UUID in the form
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX".  A special case of address is
"localhost", which will search for services on the local machine.
 
The search results will be a list of dictionaries.  Each dictionary
represents a search match and will have the following key/value pairs:
 
  host          - the bluetooth address of the device advertising the
                  service
  name          - the name of the service being advertised
  description   - a description of the service being advertised
  provider      - the name of the person/organization providing the service
  protocol      - either 'RFCOMM', 'L2CAP', None if the protocol was not
                  specified, or 'UNKNOWN' if the protocol was specified but
                  unrecognized
  port          - the L2CAP PSM # if the protocol is 'L2CAP', the RFCOMM
                  channel # if the protocol is 'RFCOMM', or None if it
                  wasn't specified
  service-classes - a list of service class IDs (UUID strings).  possibly
                    empty
  profiles        - a list of profiles - (UUID, version) pairs - the
                    service claims to support.  possibly empty.
  service-id      - the Service ID of the service.  None if it wasn't set
                    See the Bluetooth spec for the difference between
                    Service ID and Service Class ID List
get_available_port(protocol)
deprecated.  bind to PORT_ANY instead.
is_valid_address(s)
returns True if address is a valid Bluetooth address
 
valid address are always strings of the form XX:XX:XX:XX:XX:XX
where X is a hexadecimal character.  For example,
    01:23:45:67:89:AB is a valid address, but
    IN:VA:LI:DA:DD:RE is not
is_valid_uuid(uuid)
is_valid_uuid(uuid) -> bool
 
returns True if uuid is a valid 128-bit UUID.
 
valid UUIDs are always strings taking one of the following forms:
    XXXX
    XXXXXXXX
    XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
where each X is a hexadecimal digit (case insensitive)
lookup_name(address, timeout=10)
Linux only
 
Tries to determine the friendly name (human readable) of the device with
the specified bluetooth address.  Returns the name on success, and None
on failure.
 
timeout=10   how many seconds to search before giving up.
sdp_make_data_element(type, value)
sdp_parse_data_element(data)
sdp_parse_data_elementSequence(data)
sdp_parse_int(data, size, signed)
sdp_parse_raw_record(data)
sdp_parse_size_desc(data)
sdp_parse_uuid(data, size)
set_l2cap_mtu(sock, mtu)
set_l2cap_mtu( sock, mtu )
 
Adjusts the MTU for the specified L2CAP socket.  This method needs to be
invoked on both sides of the connection for it to work!  The default mtu
that all L2CAP connections start with is 672 bytes.
 
mtu must be between 48 and 65535, inclusive.
set_packet_timeout(address, timeout)
Adjusts the ACL flush timeout for the ACL connection to the specified
device.  This means that all L2CAP and RFCOMM data being sent to that
device will be dropped if not acknowledged in timeout milliseconds (maximum
1280).  A timeout of 0 means to never drop packets.
 
Since this affects all Bluetooth connections to that device, and not just
those initiated by this process or PyBluez, a call to this method requires
superuser privileges.
 
You must have an active connection to the specified device before invoking
this method
stop_advertising(sock)
Instructs the local SDP server to stop advertising the service associated
with sock.  You should typically call this right before you close sock.
to_full_uuid(uuid)
converts a short 16-bit or 32-bit reserved UUID to a full 128-bit Bluetooth
UUID.

 
Data
        ADVANCED_AUDIO_CLASS = '110d'
ADVANCED_AUDIO_PROFILE = ('110d', 256)
AUDIO_SINK_CLASS = '110b'
AUDIO_SINK_PROFILE = ('110b', 256)
AUDIO_SOURCE_CLASS = '110a'
AUDIO_SOURCE_PROFILE = ('110a', 256)
AVCTP_UUID = '0017'
AVDTP_UUID = '0019'
AV_CLASS = '112c'
AV_PROFILE = ('112c', 256)
AV_REMOTE_CLASS = '110e'
AV_REMOTE_PROFILE = ('110e', 256)
AV_REMOTE_TARGET_CLASS = '110c'
AV_REMOTE_TARGET_PROFILE = ('110c', 256)
BASIC_PRINTING_CLASS = '1122'
BASIC_PRINTING_PROFILE = ('1122', 256)
BLUETOOTH_PROFILE_DESCRIPTOR_LIST_ATTRID = 9
BNEP_UUID = '000f'
BROWSE_GROUP_LIST_ATTRID = 5
BROWSE_GRP_DESC_CLASS = '1001'
BROWSE_GRP_DESC_PROFILE = ('1001', 256)
CIP_CLASS = '1128'
CIP_PROFILE = ('1128', 256)
CLIENT_EXECUTABLE_URL_ATTRID = 11
CMTP_UUID = '001b'
CORDLESS_TELEPHONY_CLASS = '1109'
CORDLESS_TELEPHONY_PROFILE = ('1109', 256)
DIALUP_NET_CLASS = '1103'
DIALUP_NET_PROFILE = ('1103', 256)
DIRECT_PRINTING_CLASS = '1118'
DIRECT_PRINTING_PROFILE = ('1118', 256)
DIRECT_PRT_REFOBJS_CLASS = '1120'
DIRECT_PRT_REFOBJS_PROFILE = ('1120', 256)
DOCUMENTATION_URL_ATTRID = 10
FAX_CLASS = '1111'
FAX_PROFILE = ('1111', 256)
FTP_UUID = '000a'
GENERIC_AUDIO_CLASS = '1203'
GENERIC_AUDIO_PROFILE = ('1203', 256)
GENERIC_FILETRANS_CLASS = '1202'
GENERIC_FILETRANS_PROFILE = ('1202', 256)
GENERIC_NETWORKING_CLASS = '1201'
GENERIC_NETWORKING_PROFILE = ('1201', 256)
GENERIC_TELEPHONY_CLASS = '1204'
GENERIC_TELEPHONY_PROFILE = ('1204', 256)
GN_CLASS = '1117'
GN_PROFILE = ('1117', 256)
HANDSFREE_AGW_CLASS = '111f'
HANDSFREE_AGW_PROFILE = ('111f', 256)
HANDSFREE_CLASS = '111e'
HANDSFREE_PROFILE = ('111e', 256)
HCI = 1
HCRP_CTRL_UUID = '0012'
HCRP_DATA_UUID = '0014'
HCRP_NOTE_UUID = '0016'
HCR_CLASS = '1125'
HCR_PRINT_CLASS = '1126'
HCR_PRINT_PROFILE = ('1126', 256)
HCR_PROFILE = ('1127', 256)
HCR_SCAN_CLASS = '1127'
HCR_SCAN_PROFILE = ('1127', 256)
HEADSET_AGW_CLASS = '1112'
HEADSET_AGW_PROFILE = ('1112', 256)
HEADSET_CLASS = '1108'
HEADSET_PROFILE = ('1108', 256)
HIDP_UUID = '0011'
HID_CLASS = '1124'
HID_PROFILE = ('1124', 256)
HTTP_UUID = '000c'
ICON_URL_ATTRID = 12
IMAGING_ARCHIVE_CLASS = '111c'
IMAGING_ARCHIVE_PROFILE = ('111c', 256)
IMAGING_CLASS = '111a'
IMAGING_PROFILE = ('111a', 256)
IMAGING_REFOBJS_CLASS = '111d'
IMAGING_REFOBJS_PROFILE = ('111d', 256)
IMAGING_RESPONDER_CLASS = '111b'
IMAGING_RESPONDER_PROFILE = ('111b', 256)
INTERCOM_CLASS = '1110'
INTERCOM_PROFILE = ('1110', 256)
IP_UUID = '0009'
IRMC_SYNC_CLASS = '1104'
IRMC_SYNC_CMD_CLASS = '1107'
IRMC_SYNC_CMD_PROFILE = ('1107', 256)
IRMC_SYNC_PROFILE = ('1104', 256)
L2CAP = 0
L2CAP_OPTIONS = 1
L2CAP_UUID = '0100'
LANGUAGE_BASE_ATTRID_LIST_ATTRID = 6
LAN_ACCESS_CLASS = '1102'
LAN_ACCESS_PROFILE = ('1102', 256)
NAP_CLASS = '1116'
NAP_PROFILE = ('1116', 256)
OBEX_FILETRANS_CLASS = '1106'
OBEX_FILETRANS_PROFILE = ('1106', 256)
OBEX_OBJPUSH_CLASS = '1105'
OBEX_OBJPUSH_PROFILE = ('1105', 256)
OBEX_UUID = '0008'
PANU_CLASS = '1115'
PANU_PROFILE = ('1115', 256)
PNP_INFO_CLASS = '1200'
PNP_INFO_PROFILE = ('1200', 256)
PORT_ANY = 0
PRINTING_STATUS_CLASS = '1123'
PRINTING_STATUS_PROFILE = ('1123', 256)
PROTOCOL_DESCRIPTOR_LIST_ATTRID = 4
PROVIDER_NAME_ATTRID = 258
PUBLIC_BROWSE_GROUP = '1002'
REFERENCE_PRINTING_CLASS = '1119'
REFERENCE_PRINTING_PROFILE = ('1119', 256)
REFLECTED_UI_CLASS = '1121'
REFLECTED_UI_PROFILE = ('1121', 256)
RFCOMM = 3
RFCOMM_UUID = '0003'
SAP_CLASS = '112d'
SAP_PROFILE = ('112d', 256)
SCO = 2
SDP_SERVER_CLASS = '1000'
SDP_SERVER_PROFILE = ('1000', 256)
SDP_UUID = '0001'
SERIAL_PORT_CLASS = '1101'
SERIAL_PORT_PROFILE = ('1101', 256)
SERVICE_AVAILABILITY_ATTRID = 8
SERVICE_CLASS_ID_LIST_ATTRID = 1
SERVICE_DESCRIPTION_ATTRID = 257
SERVICE_ID_ATTRID = 3
SERVICE_INFO_TIME_TO_LIVE_ATTRID = 7
SERVICE_NAME_ATTRID = 256
SERVICE_RECORD_HANDLE_ATTRID = 0
SERVICE_RECORD_STATE_ATTRID = 2
SOL_L2CAP = 6
SOL_RFCOMM = 18
TCP_UUID = '0004'
TCS_AT_UUID = '0006'
TCS_BIN_UUID = '0005'
UDI_MT_CLASS = '112a'
UDI_MT_PROFILE = ('112a', 256)
UDI_TA_CLASS = '112b'
UDI_TA_PROFILE = ('112b', 256)
UDI_UUID = '001d'
UDP_UUID = '0002'
UPNP_CLASS = '1205'
UPNP_IP_CLASS = '1206'
UPNP_IP_PROFILE = ('1206', 256)
UPNP_L2CAP_CLASS = '1302'
UPNP_L2CAP_PROFILE = ('1302', 256)
UPNP_LAP_CLASS = '1301'
UPNP_LAP_PROFILE = ('1301', 256)
UPNP_PAN_CLASS = '1300'
UPNP_PAN_PROFILE = ('1300', 256)
UPNP_PROFILE = ('1205', 256)
UPNP_UUID = '0010'
VIDEO_CONF_CLASS = '110f'
VIDEO_CONF_GW_CLASS = '1129'
VIDEO_CONF_GW_PROFILE = ('1129', 256)
VIDEO_CONF_PROFILE = ('110f', 256)
VIDEO_SINK_CLASS = '1304'
VIDEO_SINK_PROFILE = ('1304', 256)
VIDEO_SOURCE_CLASS = '1303'
VIDEO_SOURCE_PROFILE = ('1303', 256)
WAP_CLASS = '1113'
WAP_CLIENT_CLASS = '1114'
WAP_CLIENT_PROFILE = ('1114', 256)
WAP_PROFILE = ('1113', 256)
WSP_UUID = '000e'