Merge pull request #14922 from ARMmbed/at-handler-fix

Cellular: AT command fix - hex string shouldn't be quoted on bc95
pull/14941/head
Martin Kojtal 2021-07-20 10:04:02 +02:00 committed by GitHub
commit 2bb1539ec4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View File

@ -352,8 +352,9 @@ public:
*
* @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.
*

View File

@ -1551,21 +1551,25 @@ void ATHandler::set_send_delay(uint16_t send_delay)
_at_send_delay = std::chrono::duration<uint16_t, std::milli>(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)

View File

@ -211,7 +211,7 @@ retry_send:
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