mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-31 01:20:44 +00:00
Merge branch 'master' of https://github.com/bluekitchen/btstack
This commit is contained in:
commit
6f692ea796
@ -90,7 +90,7 @@
|
|||||||
// store
|
// store
|
||||||
if (result == 6){
|
if (result == 6){
|
||||||
for (i = 0; i < BD_ADDR_LEN; i++) {
|
for (i = 0; i < BD_ADDR_LEN; i++) {
|
||||||
(*address)[i] = (uint8_t) bd_addr_buffer[i];
|
address[i] = (uint8_t) bd_addr_buffer[i];
|
||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) addressString{
|
- (NSString *) addressString{
|
||||||
return [BTDevice stringForAddress:&_address];
|
return [BTDevice stringForAddress:_address];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BluetoothDeviceType) deviceType{
|
- (BluetoothDeviceType) deviceType{
|
||||||
@ -117,7 +117,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
- (NSString *) toString{
|
- (NSString *) toString{
|
||||||
return [NSString stringWithFormat:@"Device addr %@ name %@ COD %x", [BTDevice stringForAddress:&_address], name, classOfDevice];
|
return [NSString stringWithFormat:@"Device addr %@ name %@ COD %x", [BTDevice stringForAddress:_address], name, classOfDevice];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
=== BTstack for iOS ===
|
=== BTstack for iOS ===
|
||||||
|
|
||||||
BTstack for iOS provides an alternative Bluetooth stack for iOS devices with a public and complete API.
|
BTstack for iOS provides an alternative Bluetooth stack for iOS devices with a public API.
|
||||||
|
|
||||||
It supports the following protocols:
|
It supports the following Bluetooth Classic protocols:
|
||||||
- L2CAP
|
- L2CAP
|
||||||
- RFCOMM
|
- RFCOMM
|
||||||
- SDP
|
- SDP
|
||||||
|
|
||||||
Based on these protocols, applications or daemons can implement various Bluetooth profiles.
|
Based on these protocols, applications or daemons can implement various Bluetooth profiles.
|
||||||
You need to install other packages like BTstack GPS, Blutrol, or WeBe++ to make use of
|
Packages that already use BTstack are: BTstack GPS, Blutrol, WeBe++, and various game emulators.
|
||||||
BTstack.
|
|
||||||
|
|
||||||
Note: As BTstack directly uses the Bluetooth hardware, the iOS Bluetooth is automatically disabled for BTstack applications & services.
|
Note: As BTstack directly uses the Bluetooth hardware, the iOS Bluetooth is automatically disabled for BTstack applications & services. You can always turn BTstack off in Settings->BTstack.
|
||||||
|
|
||||||
|
Please visit the [project page at GitHub](https://github.com/bluekitchen/btstack/) for technical information and check the platform/ios subfolder.
|
||||||
|
|
||||||
Please visit the [project page at GitHub](https://github.com/bluekitchen/btstack/) for technical information.
|
|
||||||
|
@ -847,10 +847,13 @@ static void hci_initializing_run(void){
|
|||||||
switch (hci_stack->substate){
|
switch (hci_stack->substate){
|
||||||
case HCI_INIT_SEND_RESET:
|
case HCI_INIT_SEND_RESET:
|
||||||
hci_state_reset();
|
hci_state_reset();
|
||||||
|
|
||||||
|
#ifndef USE_BLUETOOL
|
||||||
// prepare reset if command complete not received in 100ms
|
// prepare reset if command complete not received in 100ms
|
||||||
run_loop_set_timer(&hci_stack->timeout, 100);
|
run_loop_set_timer(&hci_stack->timeout, 100);
|
||||||
run_loop_set_timer_handler(&hci_stack->timeout, hci_initialization_timeout_handler);
|
run_loop_set_timer_handler(&hci_stack->timeout, hci_initialization_timeout_handler);
|
||||||
run_loop_add_timer(&hci_stack->timeout);
|
run_loop_add_timer(&hci_stack->timeout);
|
||||||
|
#endif
|
||||||
// send command
|
// send command
|
||||||
hci_stack->substate = HCI_INIT_W4_SEND_RESET;
|
hci_stack->substate = HCI_INIT_W4_SEND_RESET;
|
||||||
hci_send_cmd(&hci_reset);
|
hci_send_cmd(&hci_reset);
|
||||||
|
@ -9,7 +9,8 @@ SUBDIRS = \
|
|||||||
linked_list \
|
linked_list \
|
||||||
remote_device_db \
|
remote_device_db \
|
||||||
sdp_client \
|
sdp_client \
|
||||||
security_manager \
|
|
||||||
|
# security_manager \
|
||||||
|
|
||||||
EXCLUDED = ios
|
EXCLUDED = ios
|
||||||
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
CC = g++
|
CC = g++
|
||||||
|
|
||||||
# Requirements: http://www.cpputest.org/ should be placed in btstack/test
|
# Requirements: cpputest.github.io
|
||||||
|
|
||||||
BTSTACK_ROOT = ../..
|
BTSTACK_ROOT = ../..
|
||||||
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
|
||||||
|
|
||||||
CFLAGS = -g -Wall -I.. -I${BTSTACK_ROOT}/example/libusb -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/ble -I${BTSTACK_ROOT}/include -I$(CPPUTEST_HOME)/include
|
CFLAGS = -g -Wall -I.. -I${BTSTACK_ROOT}/example/libusb -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/ble -I${BTSTACK_ROOT}/include
|
||||||
# -L$(CPPUTEST_HOME)/lib
|
|
||||||
LDFLAGS += -lCppUTest -lCppUTestExt
|
LDFLAGS += -lCppUTest -lCppUTestExt
|
||||||
|
|
||||||
VPATH += ${BTSTACK_ROOT}/ble
|
VPATH += ${BTSTACK_ROOT}/ble
|
||||||
@ -24,7 +22,7 @@ all: att_db_util_test
|
|||||||
att_db_util_test: ${COMMON_OBJ} att_db_util_test.c
|
att_db_util_test: ${COMMON_OBJ} att_db_util_test.c
|
||||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||||
|
|
||||||
test:
|
test: all
|
||||||
./att_db_util_test
|
./att_db_util_test
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
CC = g++
|
CC = g++
|
||||||
|
|
||||||
# Requirements: http://www.cpputest.org/ should be placed in btstack/test
|
# Requirements: cpputest.github.io
|
||||||
|
|
||||||
BTSTACK_ROOT = ../..
|
BTSTACK_ROOT = ../..
|
||||||
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
|
||||||
|
|
||||||
CFLAGS = -g -Wall -I.. -I${BTSTACK_ROOT}/example/libusb -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/ble -I${BTSTACK_ROOT}/include -I$(CPPUTEST_HOME)/include
|
CFLAGS = -g -Wall -I.. -I${BTSTACK_ROOT}/example/libusb -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/ble -I${BTSTACK_ROOT}/include
|
||||||
LDFLAGS += -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt
|
LDFLAGS += -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt
|
||||||
|
|
||||||
VPATH += ${BTSTACK_ROOT}/ble
|
VPATH += ${BTSTACK_ROOT}/ble
|
||||||
@ -33,7 +32,7 @@ all: ad_parser
|
|||||||
ad_parser: ${CORE_OBJ} ${COMMON_OBJ} advertising_data_parser.c
|
ad_parser: ${CORE_OBJ} ${COMMON_OBJ} advertising_data_parser.c
|
||||||
${CC} ${CORE_OBJ} ${COMMON_OBJ} advertising_data_parser.c ${CFLAGS} ${LDFLAGS} -o $@
|
${CC} ${CORE_OBJ} ${COMMON_OBJ} advertising_data_parser.c ${CFLAGS} ${LDFLAGS} -o $@
|
||||||
|
|
||||||
test:
|
test: all
|
||||||
./ad_parser
|
./ad_parser
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
CC = g++
|
CC = g++
|
||||||
|
|
||||||
# Requirements: http://www.cpputest.org/ should be placed in btstack/test
|
# Requirements: cpputest.github.io
|
||||||
|
|
||||||
BTSTACK_ROOT = ../..
|
BTSTACK_ROOT = ../..
|
||||||
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
|
||||||
|
|
||||||
CFLAGS = -g -Wall -I. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/include -I$(CPPUTEST_HOME)/include
|
CFLAGS = -g -Wall -I. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/include
|
||||||
LDFLAGS += -lCppUTest -lCppUTestExt
|
LDFLAGS += -lCppUTest -lCppUTestExt
|
||||||
# -L$(CPPUTEST_HOME)
|
|
||||||
|
|
||||||
VPATH += ${BTSTACK_ROOT}/ble
|
VPATH += ${BTSTACK_ROOT}/ble
|
||||||
VPATH += ${BTSTACK_ROOT}/src
|
VPATH += ${BTSTACK_ROOT}/src
|
||||||
@ -24,7 +22,7 @@ all: des_iterator_test
|
|||||||
des_iterator_test: ${COMMON_OBJ} des_iterator_test.c
|
des_iterator_test: ${COMMON_OBJ} des_iterator_test.c
|
||||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||||
|
|
||||||
test:
|
test: all
|
||||||
./des_iterator_test
|
./des_iterator_test
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
CC = g++
|
CC = g++
|
||||||
|
|
||||||
# Requirements: http://www.cpputest.org/ should be placed in btstack/test
|
# Requirements: cpputest.github.io
|
||||||
|
|
||||||
BTSTACK_ROOT = ../..
|
BTSTACK_ROOT = ../..
|
||||||
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
|
||||||
|
|
||||||
CFLAGS = -DUNIT_TEST -x c++ -g -Wall -I. -I../ -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/ble -I${BTSTACK_ROOT}/include -I$(CPPUTEST_HOME)/include
|
CFLAGS = -DUNIT_TEST -x c++ -g -Wall -I. -I../ -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/ble -I${BTSTACK_ROOT}/include
|
||||||
LDFLAGS += -lCppUTest -lCppUTestExt
|
LDFLAGS += -lCppUTest -lCppUTestExt
|
||||||
# -L$(CPPUTEST_HOME)
|
|
||||||
|
|
||||||
VPATH += ${BTSTACK_ROOT}/ble
|
VPATH += ${BTSTACK_ROOT}/ble
|
||||||
VPATH += ${BTSTACK_ROOT}/src
|
VPATH += ${BTSTACK_ROOT}/src
|
||||||
@ -44,7 +42,7 @@ gatt_client_test: profile.h ${CORE_OBJ} ${COMMON_OBJ} gatt_client_test.o expecte
|
|||||||
le_central: ${CORE_OBJ} ${COMMON_OBJ} le_central.o
|
le_central: ${CORE_OBJ} ${COMMON_OBJ} le_central.o
|
||||||
${CC} ${CORE_OBJ} ${COMMON_OBJ} le_central.o ${CFLAGS} ${LDFLAGS} -o $@
|
${CC} ${CORE_OBJ} ${COMMON_OBJ} le_central.o ${CFLAGS} ${LDFLAGS} -o $@
|
||||||
|
|
||||||
test:
|
test: all
|
||||||
./gatt_client_test
|
./gatt_client_test
|
||||||
./le_central
|
./le_central
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
CC=g++
|
CC=g++
|
||||||
|
|
||||||
# Requirements: http://www.cpputest.org/ should be placed in btstack/test
|
# Requirements: cpputest.github.io
|
||||||
|
|
||||||
BTSTACK_ROOT = ../..
|
BTSTACK_ROOT = ../..
|
||||||
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
||||||
|
|
||||||
CFLAGS = -g -Wall -I. -I../ -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/include -I$(CPPUTEST_HOME)/include
|
CFLAGS = -g -Wall -I. -I../ -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/include
|
||||||
LDFLAGS += -lCppUTest -lCppUTestExt
|
LDFLAGS += -lCppUTest -lCppUTestExt
|
||||||
# -L$(CPPUTEST_HOME)/lib
|
|
||||||
|
|
||||||
VPATH += ${BTSTACK_ROOT}/ble
|
VPATH += ${BTSTACK_ROOT}/ble
|
||||||
VPATH += ${BTSTACK_ROOT}/src
|
VPATH += ${BTSTACK_ROOT}/src
|
||||||
@ -23,7 +22,7 @@ all: linked_list_test
|
|||||||
linked_list_test: ${COMMON_OBJ} linked_list_test.c
|
linked_list_test: ${COMMON_OBJ} linked_list_test.c
|
||||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||||
|
|
||||||
test:
|
test: all
|
||||||
./linked_list_test
|
./linked_list_test
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
CC=g++
|
CC=g++
|
||||||
|
|
||||||
# Requirements: http://www.cpputest.org/ should be placed in btstack/test
|
# Requirements: cpputest.github.io
|
||||||
|
|
||||||
BTSTACK_ROOT = ../..
|
BTSTACK_ROOT = ../..
|
||||||
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
||||||
|
|
||||||
CFLAGS = -g -Wall -I. -I../ -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/include -I${BTSTACK_ROOT}/ble -I$(CPPUTEST_HOME)/include
|
CFLAGS = -g -Wall -I. -I../ -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/include -I${BTSTACK_ROOT}/ble
|
||||||
LDFLAGS += -lCppUTest -lCppUTestExt
|
LDFLAGS += -lCppUTest -lCppUTestExt
|
||||||
# -L$(CPPUTEST_HOME)
|
|
||||||
|
|
||||||
VPATH += ${BTSTACK_ROOT}/ble
|
VPATH += ${BTSTACK_ROOT}/ble
|
||||||
VPATH += ${BTSTACK_ROOT}/src
|
VPATH += ${BTSTACK_ROOT}/src
|
||||||
@ -36,7 +35,7 @@ remote_device_db_memory_test: ${MEMORY_OBJ} remote_device_db_memory_test.c
|
|||||||
remote_device_db_fs_test: ${FS_OBJ} remote_device_db_fs_test.c
|
remote_device_db_fs_test: ${FS_OBJ} remote_device_db_fs_test.c
|
||||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||||
|
|
||||||
test:
|
test: all
|
||||||
./remote_device_db_memory_test
|
./remote_device_db_memory_test
|
||||||
./remote_device_db_fs_test
|
./remote_device_db_fs_test
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
CC = g++
|
CC = g++
|
||||||
|
|
||||||
# Requirements: http://www.cpputest.org/ should be placed in btstack/test
|
# Requirements: cpputest.github.io
|
||||||
|
|
||||||
BTSTACK_ROOT = ../..
|
BTSTACK_ROOT = ../..
|
||||||
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
||||||
|
|
||||||
CFLAGS = -g -Wall -I. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/include -I$(CPPUTEST_HOME)/include
|
CFLAGS = -g -Wall -I. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/include
|
||||||
LDFLAGS += -lCppUTest -lCppUTestExt
|
LDFLAGS += -lCppUTest -lCppUTestExt
|
||||||
# -L$(CPPUTEST_HOME)
|
# -L$(CPPUTEST_HOME)
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ service_attribute_search_query: ${COMMON_OBJ} service_attribute_search_query.c
|
|||||||
service_search_query: ${COMMON_OBJ} service_search_query.c
|
service_search_query: ${COMMON_OBJ} service_search_query.c
|
||||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||||
|
|
||||||
test:
|
test: all
|
||||||
./sdp_rfcomm_query
|
./sdp_rfcomm_query
|
||||||
./general_sdp_query
|
./general_sdp_query
|
||||||
./service_attribute_search_query
|
./service_attribute_search_query
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
CC = g++
|
CC = g++
|
||||||
|
|
||||||
# Requirements: http://www.cpputest.org/ should be placed in btstack/test
|
# Requirements: cpputest.github.io
|
||||||
|
|
||||||
BTSTACK_ROOT = ../..
|
BTSTACK_ROOT = ../..
|
||||||
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
|
||||||
|
|
||||||
CFLAGS = -DUNIT_TEST -x c++ -g -Wall -Wno-unused -I. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/ble -I${BTSTACK_ROOT}/include -I$(CPPUTEST_HOME)/include
|
CFLAGS = -DUNIT_TEST -x c++ -g -Wall -Wno-unused -I. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/ble -I${BTSTACK_ROOT}/include
|
||||||
LDFLAGS += -lCppUTest -lCppUTestExt
|
LDFLAGS += -lCppUTest -lCppUTestExt
|
||||||
# -L$(CPPUTEST_HOME)/lib
|
|
||||||
|
|
||||||
VPATH += ${BTSTACK_ROOT}/ble
|
VPATH += ${BTSTACK_ROOT}/ble
|
||||||
VPATH += ${BTSTACK_ROOT}/src
|
VPATH += ${BTSTACK_ROOT}/src
|
||||||
@ -39,7 +37,7 @@ security_manager: ${CORE_OBJ} ${COMMON_OBJ} security_manager.c
|
|||||||
aestest: aestest.c rijndael.c
|
aestest: aestest.c rijndael.c
|
||||||
${CC} ${CFLAGS} -m32 rijndael.c aestest.c -o $@
|
${CC} ${CFLAGS} -m32 rijndael.c aestest.c -o $@
|
||||||
|
|
||||||
test:
|
test: all
|
||||||
./security_manager
|
./security_manager
|
||||||
./aestest
|
./aestest
|
||||||
|
|
||||||
|
@ -129,150 +129,160 @@ void CHECK_EQUAL_ARRAY(uint8_t * expected, uint8_t * actual, int size){
|
|||||||
#define CHECK_ACL_PACKET(packet) { printf("check " #packet "\n") ; CHECK_EQUAL_ARRAY(packet, mock_packet_buffer(), sizeof(packet)); mock_clear_packet_buffer(); }
|
#define CHECK_ACL_PACKET(packet) { printf("check " #packet "\n") ; CHECK_EQUAL_ARRAY(packet, mock_packet_buffer(), sizeof(packet)); mock_clear_packet_buffer(); }
|
||||||
|
|
||||||
|
|
||||||
TEST_GROUP(GATTClient){
|
TEST_GROUP(SecurityManager){
|
||||||
void setup(void){
|
void setup(void){
|
||||||
btstack_memory_init();
|
btstack_memory_init();
|
||||||
run_loop_init(RUN_LOOP_POSIX);
|
run_loop_init(RUN_LOOP_POSIX);
|
||||||
sm_init();
|
sm_init();
|
||||||
sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
|
sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
|
||||||
sm_set_authentication_requirements( SM_AUTHREQ_BONDING );
|
sm_set_authentication_requirements( SM_AUTHREQ_BONDING );
|
||||||
|
|
||||||
mock_simulate_hci_state_working();
|
|
||||||
|
|
||||||
// expect le encrypt commmand
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_01);
|
|
||||||
|
|
||||||
aes128_report_result();
|
|
||||||
|
|
||||||
// expect le encrypt commmand
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_02);
|
|
||||||
|
|
||||||
aes128_report_result();
|
|
||||||
|
|
||||||
mock_simulate_connected();
|
|
||||||
|
|
||||||
uint8_t test_pairing_request_command[] = { 0x01, 0x04, 0x00, 0x01, 0x10, 0x07, 0x07 };
|
|
||||||
mock_simulate_sm_data_packet(&test_pairing_request_command[0], sizeof(test_pairing_request_command));
|
|
||||||
|
|
||||||
// expect send pairing response command
|
|
||||||
CHECK_ACL_PACKET(test_acl_packet_03);
|
|
||||||
|
|
||||||
uint8_t test_pairing_confirm_command[] = { 0x03, 0x84, 0x5a, 0x87, 0x9a, 0x0f, 0xa9, 0x42, 0xba, 0x48, 0xc5, 0x79, 0xa0, 0x70, 0x70, 0xa9, 0xc8 };
|
|
||||||
mock_simulate_sm_data_packet(&test_pairing_confirm_command[0], sizeof(test_pairing_confirm_command));
|
|
||||||
|
|
||||||
// expect le random command
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_04);
|
|
||||||
|
|
||||||
uint8_t rand1_data_event[] = { 0x0e, 0x0c, 0x01, 0x18, 0x20, 0x00, 0x2f, 0x04, 0x82, 0x84, 0x72, 0x46, 0x9c, 0x93 };
|
|
||||||
mock_simulate_hci_event(&rand1_data_event[0], sizeof(rand1_data_event));
|
|
||||||
|
|
||||||
// expect le random command
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_05);
|
|
||||||
|
|
||||||
uint8_t rand2_data_event[] = { 0x0e, 0x0c,0x01, 0x18,0x20, 0x00,0x48, 0x3f,0x27, 0x0e,0xeb, 0xd5,0x05, 0x7a };
|
|
||||||
mock_simulate_hci_event(&rand2_data_event[0], sizeof(rand2_data_event));
|
|
||||||
|
|
||||||
// expect le encrypt command
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_06);
|
|
||||||
|
|
||||||
aes128_report_result();
|
|
||||||
|
|
||||||
// expect le encrypt command
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_07);
|
|
||||||
|
|
||||||
aes128_report_result();
|
|
||||||
|
|
||||||
// expect send paring confirm command
|
|
||||||
CHECK_ACL_PACKET(test_acl_packet_08);
|
|
||||||
|
|
||||||
uint8_t test_pairing_random_command[] ={0x04, 0xfd, 0xd4, 0x06, 0x45, 0x0f, 0x1e, 0xdc, 0x84, 0xd5, 0x43, 0xac, 0xf7, 0x5e, 0xc0, 0x36, 0x29};
|
|
||||||
mock_simulate_sm_data_packet(&test_pairing_random_command[0], sizeof(test_pairing_random_command));
|
|
||||||
|
|
||||||
// expect le encrypt command
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_09);
|
|
||||||
|
|
||||||
aes128_report_result();
|
|
||||||
|
|
||||||
// expect le encrypt command
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_10);
|
|
||||||
|
|
||||||
aes128_report_result();
|
|
||||||
|
|
||||||
// expect send pairing random command
|
|
||||||
CHECK_ACL_PACKET(test_acl_packet_11);
|
|
||||||
|
|
||||||
// NOTE: SM also triggered for wrong handle
|
|
||||||
|
|
||||||
uint8_t test_le_ltk_request[] = { 0x3e, 0x0d, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00 };
|
|
||||||
mock_simulate_hci_event(&test_le_ltk_request[0], sizeof(test_le_ltk_request));
|
|
||||||
|
|
||||||
// expect le encrypt command
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_12);
|
|
||||||
|
|
||||||
aes128_report_result();
|
|
||||||
|
|
||||||
// expect le ltk reply
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_13);
|
|
||||||
|
|
||||||
uint8_t test_ecnryption_change_event[] = { 0x08, 0x04, 0x00, 0x40, 0x00, 0x01 };
|
|
||||||
mock_simulate_hci_event(&test_ecnryption_change_event[0], sizeof(test_ecnryption_change_event));
|
|
||||||
|
|
||||||
// expect le random command
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_14);
|
|
||||||
|
|
||||||
uint8_t rand3_data_event[] = { 0x0e, 0x0c, 0x01, 0x18, 0x20, 0x00, 0xc0, 0x10, 0x70, 0x5f, 0x3c, 0x2d, 0xe3, 0xb3 };
|
|
||||||
mock_simulate_hci_event(&rand3_data_event[0], sizeof(rand3_data_event));
|
|
||||||
|
|
||||||
// expect le random command
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_15);
|
|
||||||
|
|
||||||
uint8_t rand4_data_event[] = { 0x0e, 0x0c, 0x01, 0x18, 0x20, 0x00, 0xf1, 0xe2, 0xbf, 0x7d, 0x84, 0x19, 0x32, 0x8b };
|
|
||||||
mock_simulate_hci_event(&rand4_data_event[0], sizeof(rand4_data_event));
|
|
||||||
|
|
||||||
// expect le encrypt command
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_16);
|
|
||||||
|
|
||||||
aes128_report_result();
|
|
||||||
|
|
||||||
// expect le encrypt command
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_17);
|
|
||||||
|
|
||||||
aes128_report_result();
|
|
||||||
|
|
||||||
// expect le encrypt command
|
|
||||||
CHECK_HCI_COMMAND(test_command_packet_18);
|
|
||||||
|
|
||||||
aes128_report_result();
|
|
||||||
|
|
||||||
//
|
|
||||||
uint8_t num_completed_packets_event[] = { 0x13, 0x05, 0x01, 0x4a, 0x00, 0x01, 00 };
|
|
||||||
|
|
||||||
// expect send LE SMP Encryption Information Command
|
|
||||||
CHECK_ACL_PACKET(test_acl_packet_18);
|
|
||||||
|
|
||||||
mock_simulate_hci_event(&num_completed_packets_event[0], sizeof(num_completed_packets_event));
|
|
||||||
|
|
||||||
// expect send LE SMP Master Identification Command
|
|
||||||
CHECK_ACL_PACKET(test_acl_packet_19);
|
|
||||||
|
|
||||||
mock_simulate_hci_event(&num_completed_packets_event[0], sizeof(num_completed_packets_event));
|
|
||||||
|
|
||||||
// expect send LE SMP Identity Information Command
|
|
||||||
CHECK_ACL_PACKET(test_acl_packet_20);
|
|
||||||
|
|
||||||
mock_simulate_hci_event(&num_completed_packets_event[0], sizeof(num_completed_packets_event));
|
|
||||||
|
|
||||||
// expect send LE SMP Identity Address Information Command
|
|
||||||
CHECK_ACL_PACKET(test_acl_packet_21);
|
|
||||||
|
|
||||||
mock_simulate_hci_event(&num_completed_packets_event[0], sizeof(num_completed_packets_event));
|
|
||||||
|
|
||||||
// expect send LE SMP Code Signing Information Command
|
|
||||||
CHECK_ACL_PACKET(test_acl_packet_22);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(GATTClient, TestScanning){
|
TEST(SecurityManager, MainTest){
|
||||||
|
|
||||||
|
mock_simulate_hci_state_working();
|
||||||
|
|
||||||
|
printf("0\n");
|
||||||
|
|
||||||
|
// expect le encrypt commmand
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_01);
|
||||||
|
|
||||||
|
aes128_report_result();
|
||||||
|
|
||||||
|
// expect le encrypt commmand
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_02);
|
||||||
|
|
||||||
|
aes128_report_result();
|
||||||
|
|
||||||
|
printf("1\n");
|
||||||
|
|
||||||
|
mock_simulate_connected();
|
||||||
|
|
||||||
|
uint8_t test_pairing_request_command[] = { 0x01, 0x04, 0x00, 0x01, 0x10, 0x07, 0x07 };
|
||||||
|
mock_simulate_sm_data_packet(&test_pairing_request_command[0], sizeof(test_pairing_request_command));
|
||||||
|
|
||||||
|
printf("2\n");
|
||||||
|
|
||||||
|
// expect send pairing response command
|
||||||
|
CHECK_ACL_PACKET(test_acl_packet_03);
|
||||||
|
|
||||||
|
printf("3\n");
|
||||||
|
|
||||||
|
uint8_t test_pairing_confirm_command[] = { 0x03, 0x84, 0x5a, 0x87, 0x9a, 0x0f, 0xa9, 0x42, 0xba, 0x48, 0xc5, 0x79, 0xa0, 0x70, 0x70, 0xa9, 0xc8 };
|
||||||
|
mock_simulate_sm_data_packet(&test_pairing_confirm_command[0], sizeof(test_pairing_confirm_command));
|
||||||
|
|
||||||
|
printf("4\n");
|
||||||
|
|
||||||
|
// expect le random command
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_04);
|
||||||
|
|
||||||
|
uint8_t rand1_data_event[] = { 0x0e, 0x0c, 0x01, 0x18, 0x20, 0x00, 0x2f, 0x04, 0x82, 0x84, 0x72, 0x46, 0x9c, 0x93 };
|
||||||
|
mock_simulate_hci_event(&rand1_data_event[0], sizeof(rand1_data_event));
|
||||||
|
|
||||||
|
// expect le random command
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_05);
|
||||||
|
|
||||||
|
uint8_t rand2_data_event[] = { 0x0e, 0x0c,0x01, 0x18,0x20, 0x00,0x48, 0x3f,0x27, 0x0e,0xeb, 0xd5,0x05, 0x7a };
|
||||||
|
mock_simulate_hci_event(&rand2_data_event[0], sizeof(rand2_data_event));
|
||||||
|
|
||||||
|
// expect le encrypt command
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_06);
|
||||||
|
|
||||||
|
aes128_report_result();
|
||||||
|
|
||||||
|
// expect le encrypt command
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_07);
|
||||||
|
|
||||||
|
aes128_report_result();
|
||||||
|
|
||||||
|
// expect send paring confirm command
|
||||||
|
CHECK_ACL_PACKET(test_acl_packet_08);
|
||||||
|
|
||||||
|
uint8_t test_pairing_random_command[] ={0x04, 0xfd, 0xd4, 0x06, 0x45, 0x0f, 0x1e, 0xdc, 0x84, 0xd5, 0x43, 0xac, 0xf7, 0x5e, 0xc0, 0x36, 0x29};
|
||||||
|
mock_simulate_sm_data_packet(&test_pairing_random_command[0], sizeof(test_pairing_random_command));
|
||||||
|
|
||||||
|
// expect le encrypt command
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_09);
|
||||||
|
|
||||||
|
aes128_report_result();
|
||||||
|
|
||||||
|
// expect le encrypt command
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_10);
|
||||||
|
|
||||||
|
aes128_report_result();
|
||||||
|
|
||||||
|
// expect send pairing random command
|
||||||
|
CHECK_ACL_PACKET(test_acl_packet_11);
|
||||||
|
|
||||||
|
// NOTE: SM also triggered for wrong handle
|
||||||
|
|
||||||
|
uint8_t test_le_ltk_request[] = { 0x3e, 0x0d, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00 };
|
||||||
|
mock_simulate_hci_event(&test_le_ltk_request[0], sizeof(test_le_ltk_request));
|
||||||
|
|
||||||
|
// expect le encrypt command
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_12);
|
||||||
|
|
||||||
|
aes128_report_result();
|
||||||
|
|
||||||
|
// expect le ltk reply
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_13);
|
||||||
|
|
||||||
|
uint8_t test_ecnryption_change_event[] = { 0x08, 0x04, 0x00, 0x40, 0x00, 0x01 };
|
||||||
|
mock_simulate_hci_event(&test_ecnryption_change_event[0], sizeof(test_ecnryption_change_event));
|
||||||
|
|
||||||
|
// expect le random command
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_14);
|
||||||
|
|
||||||
|
uint8_t rand3_data_event[] = { 0x0e, 0x0c, 0x01, 0x18, 0x20, 0x00, 0xc0, 0x10, 0x70, 0x5f, 0x3c, 0x2d, 0xe3, 0xb3 };
|
||||||
|
mock_simulate_hci_event(&rand3_data_event[0], sizeof(rand3_data_event));
|
||||||
|
|
||||||
|
// expect le random command
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_15);
|
||||||
|
|
||||||
|
uint8_t rand4_data_event[] = { 0x0e, 0x0c, 0x01, 0x18, 0x20, 0x00, 0xf1, 0xe2, 0xbf, 0x7d, 0x84, 0x19, 0x32, 0x8b };
|
||||||
|
mock_simulate_hci_event(&rand4_data_event[0], sizeof(rand4_data_event));
|
||||||
|
|
||||||
|
// expect le encrypt command
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_16);
|
||||||
|
|
||||||
|
aes128_report_result();
|
||||||
|
|
||||||
|
// expect le encrypt command
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_17);
|
||||||
|
|
||||||
|
aes128_report_result();
|
||||||
|
|
||||||
|
// expect le encrypt command
|
||||||
|
CHECK_HCI_COMMAND(test_command_packet_18);
|
||||||
|
|
||||||
|
aes128_report_result();
|
||||||
|
|
||||||
|
//
|
||||||
|
uint8_t num_completed_packets_event[] = { 0x13, 0x05, 0x01, 0x4a, 0x00, 0x01, 00 };
|
||||||
|
|
||||||
|
// expect send LE SMP Encryption Information Command
|
||||||
|
CHECK_ACL_PACKET(test_acl_packet_18);
|
||||||
|
|
||||||
|
mock_simulate_hci_event(&num_completed_packets_event[0], sizeof(num_completed_packets_event));
|
||||||
|
|
||||||
|
// expect send LE SMP Master Identification Command
|
||||||
|
CHECK_ACL_PACKET(test_acl_packet_19);
|
||||||
|
|
||||||
|
mock_simulate_hci_event(&num_completed_packets_event[0], sizeof(num_completed_packets_event));
|
||||||
|
|
||||||
|
// expect send LE SMP Identity Information Command
|
||||||
|
CHECK_ACL_PACKET(test_acl_packet_20);
|
||||||
|
|
||||||
|
mock_simulate_hci_event(&num_completed_packets_event[0], sizeof(num_completed_packets_event));
|
||||||
|
|
||||||
|
// expect send LE SMP Identity Address Information Command
|
||||||
|
CHECK_ACL_PACKET(test_acl_packet_21);
|
||||||
|
|
||||||
|
mock_simulate_hci_event(&num_completed_packets_event[0], sizeof(num_completed_packets_event));
|
||||||
|
|
||||||
|
// expect send LE SMP Code Signing Information Command
|
||||||
|
CHECK_ACL_PACKET(test_acl_packet_22);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, const char * argv[]){
|
int main (int argc, const char * argv[]){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user