4.2.3. find_service

bluetooth.find_service(name=None, uuid=None, address=None)

Use to find available Bluetooth services.

This function uses the service discovery protocol (SDP) to search for Bluetooth services matching the specified criteria and returns the search results.

The search criteria are defined by passing one or more parameters to the function.

If no criteria are specified then a list of all nearby services detected is returned. If more than one criteria is specified, then the search results will match all the criteria specified.

Parameters:
  • name (str or None) – The friendly name of a Bluetooth device.
  • uuid (str or None) –

    A valid 16-bit or 128-bit UUID.

    UUID Type Format
    Short 16-bit XXXX
    Full 128-bit XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

    where each ‘X’ is a hexadecimal digit.

  • address (str or None) – The Bluetooth address of a device or “localhost”. If “localhost” is provided the function will search for Bluetooth services on the local machine.
Returns:

The search results will be a list of dictionaries. Each dictionary represents a search match having the following key/value pairs.

Key Value
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 number if the protocol is ‘L2CAP’,

the RFCOMM channel number if the protocol is ‘RFCOMM’,

or None if the protocol wasn’t specified.

service-classes a list of service class IDs (UUID strings). Possibly empty
profiles

a list of profiles the service claims to support.

a profile takes the form of (UUID, version) pairs.

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

Return type:

list