Пример #1
0
    def ble_gap_encrypt(self, conn_handle, ediv, rand, ltk, lesc, auth):
        # TODO: Clean up
        # assert isinstance(sec_params, (BLEGapSecParams, NoneType)), 'Invalid argument type'
        # assert isinstance(sec_keyset, BLEGapSecKeyset), 'Invalid argument type'
        # print 'ediv %r' % master_id.ediv
        # print 'rand %r' % util.uint8_array_to_list(master_id.rand, 8)
        # print 'ltk  %r' % util.uint8_array_to_list(enc_info.ltk, enc_info.ltk_len)
        # print 'len  %r' % enc_info.ltk_len
        # print 'lesc %r' % enc_info.lesc
        # print 'auth %r' % enc_info.auth

        rand_arr = util.list_to_uint8_array(rand)
        ltk_arr = util.list_to_uint8_array(ltk)
        master_id = driver.ble_gap_master_id_t()
        master_id.ediv = ediv
        master_id.rand = rand_arr.cast()
        enc_info = driver.ble_gap_enc_info_t()
        enc_info.ltk_len = len(ltk)
        enc_info.ltk = ltk_arr.cast()
        enc_info.lesc = lesc
        enc_info.auth = auth
        return driver.sd_ble_gap_encrypt(self.rpc_adapter, conn_handle,
                                         master_id, enc_info)
Пример #2
0
    def ble_gap_encrypt(self, conn_handle, master_id, enc_info):
        assert isinstance(master_id, BLEGapMasterId)
        assert isinstance(enc_info, BLEGapEncryptInfo)

        return driver.sd_ble_gap_encrypt(self.rpc_adapter, conn_handle,
                                         master_id.to_c(), enc_info.to_c())