mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-23 00:39:51 +00:00
test/pts: use ble_central_test as gatt_client_test
This commit is contained in:
parent
7a978a372a
commit
9100fe3435
@ -147,7 +147,7 @@ AVRCP_OBJ = $(AVRCP:.c=.o)
|
||||
HXCMOD_PLAYER_OBJ = ${HXCMOD_PLAYER:.c=.o}
|
||||
SRC_BLE_GATT_SERVICE_FILES_OBJ = ${SRC_BLE_GATT_SERVICE_FILES:.c=.o}
|
||||
|
||||
EXAMPLES = iopt gatt_server_test ble_central_test l2cap_test classic_test bnep_test le_data_channel
|
||||
EXAMPLES = iopt gatt_server_test gatt_client_test l2cap_test classic_test bnep_test le_data_channel
|
||||
EXAMPLES += hsp_ag_test hsp_hs_test sco_loopback hfp_ag_test hfp_hf_test
|
||||
EXAMPLES += avdtp_source_test avdtp_sink_test avrcp_test gatt_profiles hrp_col_test hrp_server_test
|
||||
EXAMPLES += hog_device_test hog_host_test hid_device_test hid_host_test
|
||||
@ -203,14 +203,14 @@ avdtp_source_test: ${CORE_OBJ} ${COMMON_OBJ} ${SM_OBJ} ${SBC_ENCODER_OBJ} ${AVDT
|
||||
gatt_server_test.h: gatt_server_test.gatt
|
||||
python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
|
||||
|
||||
ble_central_test.h: ble_central_test.gatt
|
||||
gatt_client_test.h: gatt_client_test.gatt
|
||||
python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
|
||||
|
||||
gatt_server_test: gatt_server_test.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${SM_OBJ} att_db_util.o gatt_sdp.o gatt_server_test.o
|
||||
${CC} $(filter-out gatt_server_test.h,$^) ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
ble_central_test: ble_central_test.h ${CORE_OBJ} ${COMMON_OBJ} ${SM_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${GATT_CLIENT_OBJ} ad_parser.o ble_central_test.c
|
||||
${CC} $(filter-out ble_central_test.h,$^) ${CFLAGS} ${LDFLAGS} -o $@
|
||||
gatt_client_test: gatt_client_test.h ${CORE_OBJ} ${COMMON_OBJ} ${SM_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${GATT_CLIENT_OBJ} ad_parser.o gatt_client_test.c
|
||||
${CC} $(filter-out gatt_client_test.h,$^) ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
le_data_channel: ${CORE_OBJ} ${COMMON_OBJ} ${SM_OBJ} ${ATT_OBJ} ad_parser.o le_data_channel.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
@ -251,13 +251,15 @@ gatt_profiles: gatt_profiles.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVE
|
||||
myclean:
|
||||
rm -rf *.pyc *.o $(AVDTP_TESTS) *.dSYM *_test *.wav *.sbc ${BTSTACK_ROOT}/port/libusb/*.o ${BTSTACK_ROOT}/src/*.o ${BTSTACK_ROOT}/src/classic/*.o ${BTSTACK_ROOT}/src/ble/*.o
|
||||
rm -rf hog_device_test.h
|
||||
rm -rf ble_central_test.h
|
||||
rm -rf ble_peripheral_test.h
|
||||
rm -rf gatt_client_test.h
|
||||
rm -rf gatt_server_test.h
|
||||
rm -rf csc_server_test.h
|
||||
rm -rf cycling_power_server_test.h
|
||||
rm -rf gatt_profiles.h
|
||||
rm -rf hrp_server_test.h
|
||||
|
||||
rm -f sco_input.msbc
|
||||
rm -f sco_output.msbc
|
||||
|
||||
clean: myclean
|
||||
|
||||
test:
|
||||
|
@ -38,14 +38,13 @@
|
||||
#define BTSTACK_FILE__ "ble_central_test.c"
|
||||
|
||||
/*
|
||||
* ble_central_test.c : Tool for testig BLE central
|
||||
* gatt.c : Tool for testig BLE central
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "btstack_config.h"
|
||||
|
||||
@ -54,10 +53,7 @@
|
||||
#include "ble/att_server.h"
|
||||
#include "ble/le_device_db.h"
|
||||
#include "ble/sm.h"
|
||||
#include "btstack_debug.h"
|
||||
#include "btstack_event.h"
|
||||
#include "btstack_memory.h"
|
||||
#include "btstack_run_loop.h"
|
||||
#include "gap.h"
|
||||
#include "hci.h"
|
||||
#include "hci_dump.h"
|
||||
@ -65,7 +61,7 @@
|
||||
#include "btstack_stdin.h"
|
||||
|
||||
// test profile
|
||||
#include "ble_central_test.h"
|
||||
#include "gatt_client_test.h"
|
||||
|
||||
// Non standard IXIT
|
||||
#define PTS_USES_RECONNECTION_ADDRESS_FOR_ITSELF
|
||||
@ -198,6 +194,7 @@ static gatt_client_service_t service;
|
||||
|
||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||
static btstack_packet_callback_registration_t sm_event_callback_registration;
|
||||
static gatt_client_notification_t gatt_client_notification;
|
||||
|
||||
static void show_usage(void);
|
||||
///
|
||||
@ -316,10 +313,6 @@ static void update_advertisment_params(void){
|
||||
}
|
||||
}
|
||||
|
||||
static void gap_run(void){
|
||||
if (!hci_can_send_command_packet_now()) return;
|
||||
}
|
||||
|
||||
static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
UNUSED(channel);
|
||||
uint16_t aHandle;
|
||||
@ -333,9 +326,12 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
|
||||
case BTSTACK_EVENT_STATE:
|
||||
// bt stack activated, get started
|
||||
if (btstack_event_state_get_state(packet) == HCI_STATE_WORKING){
|
||||
// add bonded device with IRK 0x00112233..FF for gap-conn-prda-bv-2
|
||||
uint8_t pts_irk[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
|
||||
le_device_db_add(public_pts_address_type, public_pts_address, pts_irk);
|
||||
// ready
|
||||
printf("Central test ready\n");
|
||||
show_usage();
|
||||
gap_run();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -401,7 +397,6 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
|
||||
break;
|
||||
}
|
||||
}
|
||||
gap_run();
|
||||
}
|
||||
|
||||
static void use_public_pts_address(void){
|
||||
@ -900,6 +895,7 @@ static void show_usage(void){
|
||||
printf_row("W - signed write on attribute with handle 0x%04x and value 0x12", pts_signed_write_characteristic_handle);
|
||||
printf_row("z - Update L2CAP Connection Parameters");
|
||||
printf_row("---");
|
||||
printf_row("A - Send MTU Exchange");
|
||||
printf_row("e - Discover all Primary Services");
|
||||
printf_row("f/F - Discover Primary Service by UUID16/UUID128");
|
||||
printf_row("g - Discover all characteristics by UUID16");
|
||||
@ -1371,6 +1367,8 @@ static void ui_process_command(char buffer){
|
||||
hci_send_cmd(&hci_le_set_advertise_enable, 1);
|
||||
show_usage();
|
||||
break;
|
||||
case 'A':
|
||||
gatt_client_send_mtu_negotiation(&handle_gatt_client_event, handle);
|
||||
case 'b':
|
||||
sm_request_pairing(handle);
|
||||
break;
|
||||
@ -1622,8 +1620,6 @@ static void stdin_process(char c){
|
||||
}
|
||||
|
||||
ui_process_command(c);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int get_oob_data_callback(uint8_t addres_type, bd_addr_t addr, uint8_t * oob_data){
|
||||
@ -1700,6 +1696,7 @@ int btstack_main(int argc, const char * argv[]){
|
||||
|
||||
// setup GATT Client
|
||||
gatt_client_init();
|
||||
gatt_client_listen_for_characteristic_value_updates(&gatt_client_notification, &handle_gatt_client_event, GATT_CLIENT_ANY_CONNECTION, NULL);
|
||||
|
||||
// Setup ATT/GATT Server
|
||||
att_server_init(profile_data, att_read_callback, NULL);
|
||||
@ -1708,10 +1705,6 @@ int btstack_main(int argc, const char * argv[]){
|
||||
// Setup LE Device DB
|
||||
le_device_db_init();
|
||||
|
||||
// add bonded device with IRK 0x00112233..FF for gap-conn-prda-bv-2
|
||||
uint8_t pts_irk[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
|
||||
le_device_db_add(public_pts_address_type, public_pts_address, pts_irk);
|
||||
|
||||
// set adv params
|
||||
update_advertisment_params();
|
||||
|
@ -1,9 +1,9 @@
|
||||
PRIMARY_SERVICE, GAP_SERVICE
|
||||
CHARACTERISTIC, GAP_DEVICE_NAME, READ, "BTstack"
|
||||
CHARACTERISTIC, GAP_APPEARANCE, READ, 00 00
|
||||
|
||||
PRIMARY_SERVICE, GATT_SERVICE
|
||||
CHARACTERISTIC, GATT_SERVICE_CHANGED, READ,
|
||||
|
||||
PRIMARY_SERVICE, FFF0
|
||||
CHARACTERISTIC, FFF1, READ | WRITE | AUTHENTICATED_SIGNED_WRITE | AUTHENTICATION_REQUIRED, "A"
|
||||
PRIMARY_SERVICE, GAP_SERVICE
|
||||
CHARACTERISTIC, GAP_DEVICE_NAME, READ, "BTstack"
|
||||
CHARACTERISTIC, GAP_APPEARANCE, READ, 00 00
|
||||
|
||||
PRIMARY_SERVICE, GATT_SERVICE
|
||||
CHARACTERISTIC, GATT_SERVICE_CHANGED, READ,
|
||||
|
||||
PRIMARY_SERVICE, FFF0
|
||||
CHARACTERISTIC, FFF1, READ | WRITE | AUTHENTICATED_SIGNED_WRITE | AUTHENTICATION_REQUIRED, "A"
|
Loading…
x
Reference in New Issue
Block a user