Skip to content

Commit 2bb1539

Browse files
authored
Merge pull request #14922 from ARMmbed/at-handler-fix
Cellular: AT command fix - hex string shouldn't be quoted on bc95
2 parents c923417 + a8982ca commit 2bb1539

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

connectivity/cellular/include/cellular/framework/API/ATHandler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,9 @@ class ATHandler {
352352
*
353353
* @param str input buffer to be converted to hex ascii
354354
* @param size of the input param str
355+
* @param quote_string if true it will add the double-quote character at beginning and end of string
355356
*/
356-
void write_hex_string(const char *str, size_t size);
357+
void write_hex_string(const char *str, size_t size, bool quote_string = true);
357358

358359
/** Reads as string and converts result to integer. Supports only non-negative integers.
359360
*

connectivity/cellular/source/framework/device/ATHandler.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,21 +1551,25 @@ void ATHandler::set_send_delay(uint16_t send_delay)
15511551
_at_send_delay = std::chrono::duration<uint16_t, std::milli>(send_delay);
15521552
}
15531553

1554-
void ATHandler::write_hex_string(const char *str, size_t size)
1554+
void ATHandler::write_hex_string(const char *str, size_t size, bool quote_string)
15551555
{
15561556
// do common checks before sending subparameter
15571557
if (check_cmd_send() == false) {
15581558
return;
15591559
}
15601560

1561-
(void) write("\"", 1);
1561+
if (quote_string) {
1562+
(void) write("\"", 1);
1563+
}
15621564
char hexbuf[2];
15631565
for (size_t i = 0; i < size; i++) {
15641566
hexbuf[0] = hex_values[((str[i]) >> 4) & 0x0F];
15651567
hexbuf[1] = hex_values[(str[i]) & 0x0F];
15661568
write(hexbuf, 2);
15671569
}
1568-
(void) write("\"", 1);
1570+
if (quote_string) {
1571+
(void) write("\"", 1);
1572+
}
15691573
}
15701574

15711575
void ATHandler::set_baud(int baud_rate)

connectivity/drivers/cellular/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_sendto_impl(CellularSoc
211211
return NSAPI_ERROR_PARAMETER;
212212
}
213213

214-
_at.write_hex_string((char *)data, size);
214+
_at.write_hex_string((char *)data, size, false);
215215
_at.cmd_stop();
216216
_at.resp_start();
217217
// skip socket id

0 commit comments

Comments
 (0)