mirror of https://github.com/ARMmbed/mbed-os.git
AT command fix - hex string shouldn't be quoted on bc95
parent
d147abc3e5
commit
a8982ca06e
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue