Python Bluetooth LinkListener

The listener is used to observe the Link events. Abstract base class for linklistener. Defines the blue print for linklistening. Class and methods to be implemented by the app as defined here. The Link is described in the Link

Callbacks

Callback: Link has received a command

Declaration

def command_incoming(self, link, cmd):

Parameters

link

The link that received the command. :class:link object

cmd

The commands bytes that can correspond to the Auto API.

Discussion

Abstract Method part of ABC class, to be implemented by the App

Example

# Example: Handle received commands from Vehicle
# Commands will be received through the registered Link_Listener() class
# Callbacks methods
class Link_Listener(hmkit.linklistener.LinkListener):

    def __init__(self):
        pass

    def command_incoming(self, link, cmdbytes):
        """
        Callback for incoming commands received from bluetooth link.
        Change in States will be received in this callback

        :param link Link: :class:`link` object
        :param bytearray cmd: data received
        :rtype: None
        """

        hmkit_inst = hmkit.get_instance()
        #hmkit_inst.autoapi_dump.message_dump(cmd)

        # resolve the received command bytes to the
        # corresponding Autoapi handler class object
        cmd_obj = CommandResolver.resolve(cmdbytes)

        if isinstance(cmd_obj, capabilities.Capabilities):
        print("Capabilities received ")

        # Example: Capability Checks
        doorlock_capability = cmd_obj.get_capability(Identifiers.DOOR_LOCKS)
        .....
        elif ____ :
        .....

Callback: Link has received a response

Declaration

def command_response(self, link, cmd):

Parameters

link

The link that received a response for the command. :class:link object

cmd

The response bytes for the command sent

Discussion

Abstract Method part of ABC class, to be implemented by the App