From 17f6f1c0e3f15ed60ab4381dc3384ec25917b194 Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Wed, 14 Aug 2019 12:15:43 +0200 Subject: [PATCH 1/2] Make AT_CellularSMS support index 0 in SMS inbox When AT+CGML is used to retrieve list of SMS stored in modem inbox, every message has an associated index. ETSI TS 127 005 v7.0.0 does not specify what is the allowed range of such indices - all it says is "integer type; value in the range of location numbers supported by the associated memory". Usually, AT modems use positive indexes (starting at 1). Quectel BG96 modem takes a different approach, indexing messages starting at 0. Current implementation of `AT_CellularSMS::list_messages()` considers index 0 invalid and ignores such message, effectively making it impossible to access using mbed-os API. This commit changes the behavior so that value of 0 is handled as any other positive message index. --- features/cellular/framework/AT/AT_CellularSMS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/cellular/framework/AT/AT_CellularSMS.cpp b/features/cellular/framework/AT/AT_CellularSMS.cpp index b0b01879828..e4d51d6d24c 100644 --- a/features/cellular/framework/AT/AT_CellularSMS.cpp +++ b/features/cellular/framework/AT/AT_CellularSMS.cpp @@ -1037,7 +1037,7 @@ nsapi_error_t AT_CellularSMS::list_messages() (void)_at.consume_to_stop_tag(); // consume until } - if (index > 0) { + if (index >= 0) { add_info(info, index, part_number); } else { delete info; From ce0bb7f56802651d3f8636f5d8e6e6ba3d390938 Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Fri, 16 Aug 2019 11:53:02 +0200 Subject: [PATCH 2/2] Update test_AT_CellularSMS_get_sms 0 is now a valid value --- .../cellular/framework/AT/at_cellularsms/at_cellularsmstest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UNITTESTS/features/cellular/framework/AT/at_cellularsms/at_cellularsmstest.cpp b/UNITTESTS/features/cellular/framework/AT/at_cellularsms/at_cellularsmstest.cpp index 8589a7e9fe1..1a8ffc7ae66 100644 --- a/UNITTESTS/features/cellular/framework/AT/at_cellularsms/at_cellularsmstest.cpp +++ b/UNITTESTS/features/cellular/framework/AT/at_cellularsms/at_cellularsmstest.cpp @@ -137,7 +137,7 @@ TEST_F(TestAT_CellularSMS, test_AT_CellularSMS_get_sms) EXPECT_TRUE(NSAPI_ERROR_PARAMETER == sms.get_sms(NULL, 16, phone, 21, stamp, 21, &size)); ATHandler_stub::resp_info_true_counter = 1; - ATHandler_stub::int_value = 0; + ATHandler_stub::int_value = -1; EXPECT_TRUE(-1 == sms.get_sms(buf, 16, phone, 21, stamp, 21, &size)); //In below we are expecting the stub ATHandler info_resp() to respond