mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 19:20:54 +00:00
pts/sm_test: first SC test working
This commit is contained in:
parent
5b6c930de2
commit
a359d9e749
@ -89,6 +89,8 @@ include ${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/Makefile.inc
|
|||||||
CFLAGS += -g -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wunused-variable -Wunused-parameter
|
CFLAGS += -g -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wunused-variable -Wunused-parameter
|
||||||
# -Werror
|
# -Werror
|
||||||
CFLAGS += -D ENABLE_LE_DATA_CHANNELS
|
CFLAGS += -D ENABLE_LE_DATA_CHANNELS
|
||||||
|
CFLAGS += -D ENABLE_LE_SECURE_CONNECTIONS
|
||||||
|
CFLAGS += -D ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS
|
||||||
CFLAGS += -I..
|
CFLAGS += -I..
|
||||||
CFLAGS += -I${BTSTACK_ROOT}/src
|
CFLAGS += -I${BTSTACK_ROOT}/src
|
||||||
CFLAGS += -I${BTSTACK_ROOT}/src/classic
|
CFLAGS += -I${BTSTACK_ROOT}/src/classic
|
||||||
|
@ -266,12 +266,12 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
// parse command line flags
|
// parse command line flags
|
||||||
|
|
||||||
printf("Security Managet Tester starting up...\n");
|
printf("Security Managet Tester starting up...\n");
|
||||||
printf("IO_CAPABILITIES: %u\n", sm_io_capabilities);
|
log_info("IO_CAPABILITIES: %u", sm_io_capabilities);
|
||||||
printf("AUTH_REQ: %u\n", sm_auth_req);
|
log_info("AUTH_REQ: %u", sm_auth_req);
|
||||||
if (we_are_central){
|
if (we_are_central){
|
||||||
printf("ROLE: CENTRAL\n");
|
log_info("ROLE: CENTRAL");
|
||||||
} else {
|
} else {
|
||||||
printf("ROLE: PERIPHERAL\n");
|
log_info("ROLE: PERIPHERAL");
|
||||||
|
|
||||||
// setup advertisements
|
// setup advertisements
|
||||||
uint16_t adv_int_min = 0x0030;
|
uint16_t adv_int_min = 0x0030;
|
||||||
@ -294,10 +294,10 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
// setup le device db
|
// setup le device db
|
||||||
le_device_db_init();
|
le_device_db_init();
|
||||||
|
|
||||||
// setup SM: Display only
|
// setup SM io capabilities & auth req
|
||||||
sm_init();
|
sm_init();
|
||||||
sm_set_io_capabilities(sm_io_capabilities);
|
sm_set_io_capabilities(sm_io_capabilities);
|
||||||
sm_set_authentication_requirements( sm_auth_req);
|
sm_set_authentication_requirements(sm_auth_req);
|
||||||
sm_register_oob_data_callback(get_oob_data_callback);
|
sm_register_oob_data_callback(get_oob_data_callback);
|
||||||
|
|
||||||
sm_event_callback_registration.callback = &app_packet_handler;
|
sm_event_callback_registration.callback = &app_packet_handler;
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name
|
name,iut_io_capabilities,tester_io_capabilities,iut_auth_req,tester_auth_req,
|
||||||
SM/MAS/SCJW/BV-01-C
|
SM/MAS/SCJW/BV-01-C,0,0,8,8,
|
||||||
|
|
@ -15,7 +15,8 @@ import fcntl
|
|||||||
import csv
|
import csv
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
usb_paths = ['3', '5']
|
usb_paths = ['4', '6']
|
||||||
|
# usb_paths = ['3', '5']
|
||||||
|
|
||||||
class Node:
|
class Node:
|
||||||
|
|
||||||
@ -30,6 +31,15 @@ class Node:
|
|||||||
def set_name(self, name):
|
def set_name(self, name):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
|
def set_auth_req(self, auth_req):
|
||||||
|
self.auth_req = auth_req
|
||||||
|
|
||||||
|
def set_io_capabilities(self, io_capabilities):
|
||||||
|
self.io_capabilities = io_capabilities
|
||||||
|
|
||||||
|
def set_oob_data(self, oob_data):
|
||||||
|
self.oob_data = oob_data
|
||||||
|
|
||||||
def set_usb_path(self, path):
|
def set_usb_path(self, path):
|
||||||
self.usb_path = path
|
self.usb_path = path
|
||||||
|
|
||||||
@ -60,6 +70,8 @@ class Node:
|
|||||||
if self.peer_addr != None:
|
if self.peer_addr != None:
|
||||||
args.append('-a')
|
args.append('-a')
|
||||||
args.append(self.peer_addr)
|
args.append(self.peer_addr)
|
||||||
|
args.append('-r')
|
||||||
|
args.append(self.auth_req)
|
||||||
print('%s - "%s"' % (self.name, ' '.join(args)))
|
print('%s - "%s"' % (self.name, ' '.join(args)))
|
||||||
self.p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
self.p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
(self.stdin, self.stdout) = (self.p.stdin, self.p.stdout)
|
(self.stdin, self.stdout) = (self.p.stdin, self.p.stdout)
|
||||||
@ -87,7 +99,7 @@ class Node:
|
|||||||
self.write('x')
|
self.write('x')
|
||||||
self.p.terminate()
|
self.p.terminate()
|
||||||
|
|
||||||
def run(nodes):
|
def run(test_descriptor, nodes):
|
||||||
state = 'W4_SLAVE_BD_ADDR'
|
state = 'W4_SLAVE_BD_ADDR'
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@ -112,12 +124,16 @@ def run(nodes):
|
|||||||
if state == 'W4_SLAVE_BD_ADDR':
|
if state == 'W4_SLAVE_BD_ADDR':
|
||||||
# peripheral started, start central
|
# peripheral started, start central
|
||||||
state = 'W4_CONNECTED'
|
state = 'W4_CONNECTED'
|
||||||
node = Node()
|
master_role = test_descriptor['master_role']
|
||||||
node.set_name('Master')
|
master = Node()
|
||||||
node.usb_path = usb_paths[1]
|
# configure master
|
||||||
node.set_peer_addr(addr)
|
master.set_name(master_role)
|
||||||
node.start_process()
|
master.usb_path = usb_paths[1]
|
||||||
nodes.append(node)
|
master.set_peer_addr(addr)
|
||||||
|
master.set_auth_req(test_descriptor[master_role + '_auth_req'])
|
||||||
|
master.set_io_capabilities(test_descriptor[master_role + '_io_capabilities'])
|
||||||
|
master.start_process()
|
||||||
|
nodes.append(master)
|
||||||
if line.startswith('CONNECTED:'):
|
if line.startswith('CONNECTED:'):
|
||||||
print('%s connected' % node.get_name())
|
print('%s connected' % node.get_name())
|
||||||
if state == 'W4_CONNECTED':
|
if state == 'W4_CONNECTED':
|
||||||
@ -139,22 +155,36 @@ def run_test(test_descriptor):
|
|||||||
test_name = test_descriptor['name']
|
test_name = test_descriptor['name']
|
||||||
print('Test: %s' % test_name)
|
print('Test: %s' % test_name)
|
||||||
|
|
||||||
# start up slave process
|
if '/SLA/' in test_descriptor['name']:
|
||||||
|
iut_role = 'SLAVE'
|
||||||
|
slave_role = 'iut'
|
||||||
|
test_descriptor['master_role'] = 'tester'
|
||||||
|
else:
|
||||||
|
iut_role = 'MASTER'
|
||||||
|
slave_role = 'tester'
|
||||||
|
test_descriptor['master_role'] = 'iut'
|
||||||
|
|
||||||
slave = Node()
|
slave = Node()
|
||||||
slave.set_name('Slave')
|
|
||||||
|
# configure slave
|
||||||
|
slave.set_name(slave_role)
|
||||||
slave.usb_path = usb_paths[0]
|
slave.usb_path = usb_paths[0]
|
||||||
|
slave.set_auth_req(test_descriptor[slave_role + '_auth_req'])
|
||||||
|
slave.set_io_capabilities(test_descriptor[slave_role + '_io_capabilities'])
|
||||||
|
|
||||||
|
# start up slave
|
||||||
slave.start_process()
|
slave.start_process()
|
||||||
|
|
||||||
nodes = [slave]
|
nodes = [slave]
|
||||||
|
|
||||||
# run test
|
# run test
|
||||||
try:
|
try:
|
||||||
run(nodes)
|
run(test_descriptor, nodes)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# identify iut and tester
|
# identify iut and tester
|
||||||
if '/SLA/' in test_descriptor['name']:
|
if iut_role == 'SLAVE':
|
||||||
iut = nodes[0]
|
iut = nodes[0]
|
||||||
tester = nodes[1]
|
tester = nodes[1]
|
||||||
else:
|
else:
|
||||||
@ -186,5 +216,6 @@ with open('sm_test.csv') as csvfile:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# run test
|
# run test
|
||||||
|
print(test_descriptor)
|
||||||
run_test(test_descriptor)
|
run_test(test_descriptor)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user