PyBluez
latest
  • 1. Installing PyBluez
  • 2. Contributors
  • 3. Contributing to PyBluez
  • 4. PyBluez API
    • 4.1. Classes
    • 4.2. Functions
      • 4.2.1. advertise_service
      • 4.2.2. discover_devices
      • 4.2.3. find_service
      • 4.2.4. lookup_name
      • 4.2.5. stop_advertising
    • 4.3. Exceptions
  • 5. License
PyBluez
  • Docs »
  • 4. PyBluez API »
  • 4.2.1. advertise_service
  • Edit on GitHub

4.2.1. advertise_service¶

bluetooth.advertise_service(sock, name, service_id='', service_classes=[], profiles=[], provider='', description='', protocols=[])¶

Advertise a service with the local SDP server.

Parameters:
  • sock (BluetoothSocket) – The BluetoothSocket to use for advertising a service. The socket must be a bound, listening socket.
  • name (str) – The name of the service and service_id (if specified). This should be a string of the form “XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX”, where each ‘X’ is a hexadecimal digit.
  • service_classes (list) –

    a list of service classes belonging to the advertised service.

    Each service class is represented by a 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.

    There are some constants for standard services, e.g. SERIAL_PORT_CLASS that equals to “1101”. Some class constants provided by PyBluez are:

    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 (list) –

    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 (str) – A text string specifying the provider of the service
  • description (str) – A text string describing the service
  • protocols (list) – A list of protocols

Note

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

Next Previous

© Copyright 2004 - 2019, Albert Haung & contributors Revision adbbbdd7.

Built with Sphinx using a theme provided by Read the Docs.