How to use the aioblescan.aioblescan.HCI_Command function in aioblescan

To help you get started, we’ve selected a few aioblescan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frawau / aioblescan / aioblescan / aioblescan.py View on Github external
class HCI_Cmd_LE_Advertise(HCI_Command):
    """Class representing a command HCI command to enable/disable BLE advertising.

        :param enable: enable/disable advertising.
        :type enable: bool
        :returns: HCI_Cmd_LE_Scan_Enable instance.
        :rtype: HCI_Cmd_LE_Scan_Enable

    """

    def __init__(self,enable=True):
        super(self.__class__, self).__init__(b"\x08",b"\x0a")
        self.payload.append(Bool("enable",enable))

class HCI_Cmd_LE_Set_Advertised_Msg(HCI_Command):
    """Class representing an HCI command to set the advertised content.

        :param enable: enable/disable advertising.
        :type enable: bool
        :returns: HCI_Cmd_LE_Scan_Enable instance.
        :rtype: HCI_Cmd_LE_Scan_Enable

    """

    def __init__(self,msg=EmptyPayload()):
        super(self.__class__, self).__init__(b"\x08",b"\x08")
        self.payload.append(msg)

class HCI_Cmd_LE_Set_Advertised_Params(HCI_Command):
    """Class representing an HCI command to set the advertised parameters.
github frawau / aioblescan / aioblescan / aioblescan.py View on Github external
self.payload = []

    def encode(self):
        pld=b""
        for x in self.payload:
            pld+=x.encode()
        plen=len(pld)
        pld=b"".join([super().encode(),self.cmd.encode(),pack(">B",plen),pld])
        return pld

    def show(self,depth=0):
        self.cmd.show(depth)
        for x in self.payload:
            x.show(depth+1)

class HCI_Cmd_LE_Scan_Enable(HCI_Command):
    """Class representing a command HCI command to enable/disable BLE scanning.

        :param enable: enable/disable scanning.
        :type enable: bool
        :param filter_dups: filter duplicates.
        :type filter_dups: bool
        :returns: HCI_Cmd_LE_Scan_Enable instance.
        :rtype: HCI_Cmd_LE_Scan_Enable

    """

    def __init__(self,enable=True,filter_dups=False):
        super(self.__class__, self).__init__(b"\x08",b"\x0c")
        self.payload.append(Bool("enable",enable))
        self.payload.append(Bool("filter",filter_dups))
github frawau / aioblescan / aioblescan / aioblescan.py View on Github external
1: "Random",
                                      2: "Private IRK or Public",
                                      3: "Private IRK or Random"}))
        self.payload.append(EnumByte("peer addresss type",oaddr_type,
                                     {0: "Public",
                                      1: "Random"}))
        self.payload.append(MACAddr("peer",mac=peer_addr))
        self.payload.append(BitFieldByte("Channels",cmap,["Channel 37","Channel 38","Channel 39","RFU","RFU","RFU","RFU", "RFU"]))

        self.payload.append(EnumByte("filter policy",filter,
                                     {0: "None",
                                      1: "Scan",
                                      2: "Connection",
                                      3: "Scan and Connection"}))

class HCI_Cmd_Reset(HCI_Command):
    """Class representing an HCI command to reset the adapater.


        :returns: HCI_Cmd_Reset instance.
        :rtype: HCI_Cmd_Reset

    """

    def __init__(self):
        super(self.__class__, self).__init__(b"\x03",b"\x03")


####
# HCI EVents
####
github frawau / aioblescan / aioblescan / aioblescan.py View on Github external
:param enable: enable/disable scanning.
        :type enable: bool
        :param filter_dups: filter duplicates.
        :type filter_dups: bool
        :returns: HCI_Cmd_LE_Scan_Enable instance.
        :rtype: HCI_Cmd_LE_Scan_Enable

    """

    def __init__(self,enable=True,filter_dups=False):
        super(self.__class__, self).__init__(b"\x08",b"\x0c")
        self.payload.append(Bool("enable",enable))
        self.payload.append(Bool("filter",filter_dups))

class HCI_Cmd_LE_Set_Scan_Params(HCI_Command):
    """Class representing an HCI command to set the scanning parameters.

    This will set a number of parameters related to the scanning functions. For the
    interval and window, it will always silently enforce the Specs that says it should be >= 2.5 ms
    and <= 10.24s. It will also silently enforce window <= interval

        :param scan_type: Type of scanning. 0 => Passive (default)
                                            1 => Active
        :type scan_type: int
        :param interval: Time in ms between the start of a scan and the next scan start. Default 10
        :type interval: int/float
        :param window: maximum advertising interval in ms. Default 10
        :type window: int.float
        :param oaddr_type: Type of own address Value 0 => public (default)
                                                     1 => Random
                                                     2 => Private with public fallback
github frawau / aioblescan / aioblescan / aioblescan.py View on Github external
1: "Active"}))
        self.payload.append(UShortInt("Interval",int(round(min(10240,max(2.5,interval))/0.625)),endian="little"))
        self.payload.append(UShortInt("Window",int(round(min(10240,max(2.5,min(interval,window)))/0.625)),endian="little"))
        self.payload.append(EnumByte("own addresss type",oaddr_type,
                                     {0: "Public",
                                      1: "Random",
                                      2: "Private IRK or Public",
                                      3: "Private IRK or Random"}))
        self.payload.append(EnumByte("filter policy",filter,
                                     {0: "None",
                                      1: "Sender In White List",
                                      2: "Almost None",
                                      3: "SIWL and some"}))


class HCI_Cmd_LE_Advertise(HCI_Command):
    """Class representing a command HCI command to enable/disable BLE advertising.

        :param enable: enable/disable advertising.
        :type enable: bool
        :returns: HCI_Cmd_LE_Scan_Enable instance.
        :rtype: HCI_Cmd_LE_Scan_Enable

    """

    def __init__(self,enable=True):
        super(self.__class__, self).__init__(b"\x08",b"\x0a")
        self.payload.append(Bool("enable",enable))

class HCI_Cmd_LE_Set_Advertised_Msg(HCI_Command):
    """Class representing an HCI command to set the advertised content.
github frawau / aioblescan / aioblescan / aioblescan.py View on Github external
class HCI_Cmd_LE_Set_Advertised_Msg(HCI_Command):
    """Class representing an HCI command to set the advertised content.

        :param enable: enable/disable advertising.
        :type enable: bool
        :returns: HCI_Cmd_LE_Scan_Enable instance.
        :rtype: HCI_Cmd_LE_Scan_Enable

    """

    def __init__(self,msg=EmptyPayload()):
        super(self.__class__, self).__init__(b"\x08",b"\x08")
        self.payload.append(msg)

class HCI_Cmd_LE_Set_Advertised_Params(HCI_Command):
    """Class representing an HCI command to set the advertised parameters.

    This will set a number of parameters relted to the advertising functions. For the
    min and max intervals, it will always silently enforce the Specs that says it should be >= 20ms
    and <= 10.24s. It will also silently enforce interval_max >= interval_min

        :param interval_min: minimum advertising interval in ms. Default 500
        :type interval_min: int/float
        :param interval_max: maximum advertising interval in ms. Default 750
        :type interval_max: int/float
        :param adv_type: Type of advertising. Value 0 +> Connectable, Scannable advertising
                                                    1 => Connectable directed advertising (High duty cycle)
                                                    2 => Scannable Undirected advertising
                                                    3 => Non connectable undirected advertising (default)
        :type adv_type: int
        :param oaddr_type: Type of own address Value 0 => public (default)