diff --git a/connectivity/cellular/include/cellular/framework/API/ATHandler.h b/connectivity/cellular/include/cellular/framework/API/ATHandler.h index 6ba6562fbe4..da2a6ea124a 100644 --- a/connectivity/cellular/include/cellular/framework/API/ATHandler.h +++ b/connectivity/cellular/include/cellular/framework/API/ATHandler.h @@ -352,8 +352,9 @@ class ATHandler { * * @param str input buffer to be converted to hex ascii * @param size of the input param str + * @param quote_string if true it will add the double-quote character at beginning and end of string */ - void write_hex_string(const char *str, size_t size); + void write_hex_string(const char *str, size_t size, bool quote_string = true); /** Reads as string and converts result to integer. Supports only non-negative integers. * diff --git a/connectivity/cellular/source/framework/device/ATHandler.cpp b/connectivity/cellular/source/framework/device/ATHandler.cpp index a3009e70fcd..034d586a142 100644 --- a/connectivity/cellular/source/framework/device/ATHandler.cpp +++ b/connectivity/cellular/source/framework/device/ATHandler.cpp @@ -1551,21 +1551,25 @@ void ATHandler::set_send_delay(uint16_t send_delay) _at_send_delay = std::chrono::duration(send_delay); } -void ATHandler::write_hex_string(const char *str, size_t size) +void ATHandler::write_hex_string(const char *str, size_t size, bool quote_string) { // do common checks before sending subparameter if (check_cmd_send() == false) { return; } - (void) write("\"", 1); + if (quote_string) { + (void) write("\"", 1); + } char hexbuf[2]; for (size_t i = 0; i < size; i++) { hexbuf[0] = hex_values[((str[i]) >> 4) & 0x0F]; hexbuf[1] = hex_values[(str[i]) & 0x0F]; write(hexbuf, 2); } - (void) write("\"", 1); + if (quote_string) { + (void) write("\"", 1); + } } void ATHandler::set_baud(int baud_rate) diff --git a/connectivity/drivers/cellular/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp b/connectivity/drivers/cellular/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp index 1c92fe36e86..12499a6b0d2 100644 --- a/connectivity/drivers/cellular/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp +++ b/connectivity/drivers/cellular/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp @@ -211,7 +211,7 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_sendto_impl(CellularSoc return NSAPI_ERROR_PARAMETER; } - _at.write_hex_string((char *)data, size); + _at.write_hex_string((char *)data, size, false); _at.cmd_stop(); _at.resp_start(); // skip socket id