def on_gap_evt_sec_params_request(self, ble_driver, conn_handle, **kwargs):
        sec_params = BLEGapSecParams.from_c(kwargs['peer_params'])

        sec_params.io_caps = BLEGapIOCaps.display_only
        sec_params.min_key_size = 7
        sec_params.kdist_own = BLEGapSecKDist(False, False, False, False)
        sec_params.kdist_peer = BLEGapSecKDist(False, False, False, False)

        self.adapter.driver.ble_gap_sec_params_reply(conn_handle,
                                                     BLEGapSecStatus.success,
                                                     sec_params=sec_params)
    def on_gap_evt_sec_params_request(self, ble_driver, conn_handle, **kwargs):
        logger.info("Peripheral: on_gap_evt_sec_params_request.")
        sec_params = BLEGapSecParams.from_c(kwargs['peer_params'])

        sec_params.io_caps = BLEGapIOCaps.display_only
        sec_params.lesc = True
        sec_params.min_key_size = 7
        sec_params.kdist_own = BLEGapSecKDist(True, True, False, False)
        sec_params.kdist_peer = BLEGapSecKDist(True, True, False, False)

        logger.debug(
            "Generate LE Secure Connection ECDH private and public key.")
        keyset = self.adapter.driver.generate_lesc_keyset()
        ble_driver.ble_gap_sec_params_reply(conn_handle,
                                            BLEGapSecStatus.success,
                                            sec_params, keyset)
示例#3
0
    def setup_sec_params(self):
        """ Setup Security parameters.

        """

        self.kdist_own = BLEGapSecKDist(enc=True,
                                        id=True,
                                        sign=False,
                                        link=False)
        self.kdist_peer = BLEGapSecKDist(enc=True,
                                         id=True,
                                         sign=False,
                                         link=False)
        self.sec_params = BLEGapSecParams(bond=True,
                                          mitm=False,
                                          lesc=False,
                                          keypress=False,
                                          io_caps=BLEGapIOCaps.none,
                                          oob=False,
                                          min_key_size=7,
                                          max_key_size=16,
                                          kdist_own=self.kdist_own,
                                          kdist_peer=self.kdist_peer)