Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### HEADER ##############################################################################
- #
- # @name synopsis_smp
- # @grp p2p
- # @sgrp jw
- # @type f
- # @role peripheral / central
- # @feat 39-0201
- # @brief Just works initiator
- # @param no specific
- # @time 2
- #
- ### END ##################################################################################
- ##########################################################################################
- # IMPORTS
- ##########################################################################################
- #hci and fe defines
- from api.hci.hci_def import *
- from api.fe.fe_def import *
- from api.fe.fe import *
- #title print functions
- from co.wvt_hdr import *
- #multiple objects functions
- from tc_utils.bt_utils import *
- ##########################################################################################
- ##@brief SMP Test Case for Valid Behavior : Just Works STK generation method 01.
- ##########################################################################################
- class synopsis_smp:
- ######################################################################################
- ##@brief Class Constructor - Initialization of Test Case.
- #
- # @param env Environment with device instances and log
- ######################################################################################
- def __init__(self, env):
- #at least one device needed
- assert(env.devs != [])
- #TC name for titles
- self.tcname = '['+self.__class__.__name__+']'
- #init log
- self.logfile = None
- #recover the device instance - the 1st in environment
- self.dph = env.devs[0]
- #For final print out checks ok per device
- self.nbdevs = 2
- #log file descriptor
- if env.dirpath != None: self.logfile= (env.dirpath+'log_'+self.tcname+'.txt')
- self.log = wvt_log(self.logfile, 'a')
- #change log for device
- self.dph.set_log(self.log)
- #reset device checks_ok
- self.dph.checks_ok = 0
- #INIT DEVICE PARAMS FOR TEST
- #Peripheral 0-----------------------------------------------------------------------
- self.dph.adv_intv_min = 160
- self.dph.adv_intv_max = 160
- self.dph.adv_type = ADVCUND
- self.dph.adv_ch_map = ADV3789
- self.dph.adv_pol = ADVALL
- self.dph.adv_data = '\x0A\x09\x52\x57\x20\x42\x4C\x45\x20\x49\x50\x03\xFF\x00\x60'
- self.dph.le_scanrsp_data = '\x03\x08\x52\x57\x05\x14\x20\x00\x20\x01'
- ######################################################################################
- ##@brief TC Scenario
- ######################################################################################
- def run(self):
- #title of TC
- H1(self.log, self.tcname)
- self.dph.fe_set_config(role = gap_role.GAP_PERIPHERAL)
- self.dph.fe_start_advertise(adv_type = gapm.op.GAPM_ADV_UNDIRECT)
- firstConnection = True
- firstBonding = False
- while True:
- lrx = self.dph.recv_evt()
- if lrx[0] == gapc.GAPC_CONNECTION_REQ_IND:
- conidx = lrx[3]
- conhdl = lrx[4]
- if firstConnection:
- auth = 0
- firstConnection = False
- else:
- auth = 1
- self.dph.fe.gapc.h2f_connection_cfm(conidx, auth)
- if lrx[0] == gapc.GAPC_DISCONNECT_IND:
- import time
- time.sleep(2)
- self.dph.fe_start_advertise(adv_type = gapm.op.GAPM_ADV_UNDIRECT)
- if lrx[0] == gapc.GAPC_BOND_REQ_IND:
- if lrx[4] == gapc_bond.GAPC_PAIRING_REQ:
- if firstBonding:
- firstBonding = False
- auth = gap_auth.GAP_AUTH_REQ_NO_MITM_NO_BOND
- else:
- auth = gap_auth.GAP_AUTH_REQ_NO_MITM_BOND
- self.dph.fe.gapc.h2f_bond_cfm_pairing_accept(conidx, OOB_NONE, gap_io_cap.GAP_IO_CAP_NO_INPUT_NO_OUTPUT, auth, 16, KEY_ENC, KEY_ENC, SEC_NONE)
- if lrx[4] == gapc_bond.GAPC_TK_EXCH:
- tk_ct = self.dph.rand_ltk_gen()
- self.dph.fe.gapc.h2f_bond_cfm_tk_exch_accept(conidx, tk_ct)
- if lrx[4] == gapc_bond.GAPC_LTK_EXCH:
- ltk = self.dph.rand_ltk_gen()
- randnb = self.dph.rand_ltk_gen()[0:8]
- ediv = 0x1234
- self.dph.fe.gapc.h2f_bond_cfm_ltk_exch(conidx, ltk, ediv, randnb, 16)
- print lrx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement