Skip to content

Cellular: AT command fix - hex string shouldn't be quoted on bc95 #14922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
10 changes: 7 additions & 3 deletions connectivity/cellular/source/framework/device/ATHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down