(self, permanent=False)
Create a bond and encrypted connection with the device.
Create a bond and encrypted connection with the device.
Create a bond and encrypted connection with the device .
def bond(self, permanent=False):
        """
        Create a bond and encrypted connection with the device.
        """

        # Set to bondable mode so bonds are store permanently
        if permanent:
            self._backend.set_bondable(True)
        log.debug("Bonding to %s", self._address)
        self._backend.send_command(
            CommandBuilder.sm_encrypt_start(
                self._handle, constants.bonding['create_bonding']))
        self._backend.expect(ResponsePacketType.sm_encrypt_start)

        packet_type, response = self._backend.expect_any(
            [EventPacketType.connection_status,
             EventPacketType.sm_bonding_fail])
        if packet_type == EventPacketType.sm_bonding_fail:
            raise BGAPIError("Bonding failed")
        log.info("Bonded to %s", self._address)
def bond ( self , permanent = False ) : # Set to bondable mode so bonds are store permanently if permanent : self . _backend . set_bondable ( True ) log . debug ( "Bonding to %s" , self . _address ) self . _backend . send_command ( CommandBuilder . sm_encrypt_start ( self . _handle , constants . bonding [ 'create_bonding' ] ) ) self . _backend . expect ( ResponsePacketType . sm_encrypt_start ) packet_type , response = self . _backend . expect_any ( [ EventPacketType . connection_status , EventPacketType . sm_bonding_fail ] ) if packet_type == EventPacketType . sm_bonding_fail : raise BGAPIError ( "Bonding failed" ) log . info ( "Bonded to %s" , self . _address )