From 701a407d5ea2bd427d5e13259fa435d9fb4dee7a Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 12 Apr 2017 17:56:28 +0700 Subject: [PATCH] close #29 --- .../Bluefruit52Lib/examples/Peripheral/ancs/ancs.ino | 6 +++--- libraries/Bluefruit52Lib/src/clients/BLEAncs.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/ancs/ancs.ino b/libraries/Bluefruit52Lib/examples/Peripheral/ancs/ancs.ino index 5b13dc6a..7c384696 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/ancs/ancs.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/ancs/ancs.ino @@ -106,7 +106,7 @@ void ancs_notification_callback(AncsNotification_t* notif) // Get Application Name ( not work yet) memset(buffer, 0, sizeof(buffer)); n = bleancs.getAppAttribute(app_id, ANCS_APP_ATTR_DISPLAY_NAME, buffer, sizeof(buffer)); - Serial.printf("%-15 | ", buffer); + Serial.printf("%-15s | ", buffer); Serial.println(); @@ -136,8 +136,8 @@ void connect_callback(void) Serial.println(); bleancs.enableNotification(); - Serial.println("| Event | Category (count) | Title | Message | App ID | App Name |"); - Serial.println("-------------------------------------------------------------------------------------------------------------"); + Serial.println("| Event | Category (count) | Title | Message | App ID | App Name |"); + Serial.println("---------------------------------------------------------------------------------------------------------------"); } } } diff --git a/libraries/Bluefruit52Lib/src/clients/BLEAncs.cpp b/libraries/Bluefruit52Lib/src/clients/BLEAncs.cpp index c90abcdd..a4986f83 100644 --- a/libraries/Bluefruit52Lib/src/clients/BLEAncs.cpp +++ b/libraries/Bluefruit52Lib/src/clients/BLEAncs.cpp @@ -201,7 +201,6 @@ uint16_t BLEAncs::getAttribute(uint32_t uid, uint8_t attr, void* buffer, uint16_ _evt_bufsize = bufsize; // Write command using write response - PRINT_BUFFER(&command, cmdlen); VERIFY( cmdlen == _control.write_resp(&command, cmdlen), 0); // wait for 1st response's data arrived to parse attribute length @@ -251,7 +250,12 @@ uint16_t BLEAncs::getAppAttribute(const char* appid, uint8_t attr, void* buffer, // Write command using write response PRINT_BUFFER(command, cmdlen); - (void) _control.write_resp(command, cmdlen); + if ( cmdlen != _control.write_resp(command, cmdlen) ) + { + rtos_free(command); + return 0; + } + rtos_free(command); // Phase 1: Get data until Attribute Length is known