From 2aedd0f7d7fddb03beefb5989043aeb81eb3c40d Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 26 Apr 2018 15:18:33 +0200 Subject: [PATCH] gatt_profiles: pass PTS tests --- test/pts/gatt_profiles.c | 26 ++++++++++++++++++++++++-- test/pts/gatt_profiles.gatt | 5 ++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/test/pts/gatt_profiles.c b/test/pts/gatt_profiles.c index 1c4a64700..dfc05f6d6 100644 --- a/test/pts/gatt_profiles.c +++ b/test/pts/gatt_profiles.c @@ -35,7 +35,7 @@ * */ -#define __BTSTACK_FILE__ "le_counter.c" +#define __BTSTACK_FILE__ "gatt_profiles.c" // ***************************************************************************** /* EXAMPLE_START(le_counter): LE Peripheral - Heartbeat Counter over GATT @@ -52,9 +52,10 @@ #include #include -#include "le_counter.h" +#include "gatt_profiles.h" #include "btstack.h" #include "ble/gatt-service/battery_service_server.h" +#include "ble/gatt-service/device_information_service_server.h" #define HEARTBEAT_PERIOD_MS 1000 @@ -143,6 +144,25 @@ static int att_write_callback(hci_con_handle_t connection_handle, uint16_t att_h } /* LISTING_END */ +static void show_usage(void){ + printf("## BAS\n"); + printf("a - send 50% battery level\n"); +} + +static void stdin_process(char c){ + switch (c){ + case 'a': // accept just works + printf("BAS: Sending 50%% battery level\n"); + battery_service_server_set_battery_value(50); + break; + case 'c': + break; + default: + show_usage(); + break; + } +} + int btstack_main(void); int btstack_main(void) { @@ -178,6 +198,8 @@ int btstack_main(void) gap_advertisements_set_data(adv_data_len, (uint8_t*) adv_data); gap_advertisements_enable(1); + btstack_stdin_setup(stdin_process); + // turn on! hci_power_control(HCI_POWER_ON); diff --git a/test/pts/gatt_profiles.gatt b/test/pts/gatt_profiles.gatt index cd9eae0a4..1b3cd400c 100644 --- a/test/pts/gatt_profiles.gatt +++ b/test/pts/gatt_profiles.gatt @@ -2,7 +2,10 @@ PRIMARY_SERVICE, GAP_SERVICE CHARACTERISTIC, GAP_DEVICE_NAME, READ, "GATT Profiles" // add Battery Service -#import +// Battery Service 180F +PRIMARY_SERVICE, ORG_BLUETOOTH_SERVICE_BATTERY_SERVICE +CHARACTERISTIC, ORG_BLUETOOTH_CHARACTERISTIC_BATTERY_LEVEL, DYNAMIC | READ | NOTIFY, +CHARACTERISTIC_FORMAT, READ, 04, 00, 27AD, 01, 01 // add Device ID Service #import