Bluetooth: shell: Fix adv-data command hex data input
Fix adv-data command when given arbitrary advertising data in hexadecimal format. The data_len field should contain the length of the data which does not include the data type. Instead the AD len field in the data was given. This caused the AD len field to be increased by 1 in the advertising dat. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
1aa3a77130
commit
8672976120
1 changed files with 8 additions and 1 deletions
|
@ -1247,6 +1247,9 @@ static int cmd_adv_data(const struct shell *shell, size_t argc, char *argv[])
|
|||
if (strcmp(arg, "scan-response") &&
|
||||
*data_len == ARRAY_SIZE(ad)) {
|
||||
/* Maximum entries limit reached. */
|
||||
shell_print(shell, "Failed to set advertising data: "
|
||||
"Maximum entries limit reached");
|
||||
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
|
@ -1264,6 +1267,8 @@ static int cmd_adv_data(const struct shell *shell, size_t argc, char *argv[])
|
|||
(*data_len)++;
|
||||
} else if (!strcmp(arg, "scan-response")) {
|
||||
if (data == sd) {
|
||||
shell_print(shell, "Failed to set advertising data: "
|
||||
"duplicate scan-response option");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
|
@ -1276,11 +1281,13 @@ static int cmd_adv_data(const struct shell *shell, size_t argc, char *argv[])
|
|||
sizeof(hex_data) - hex_data_len);
|
||||
|
||||
if (!len || (len - 1) != (hex_data[hex_data_len])) {
|
||||
shell_print(shell, "Failed to set advertising data: "
|
||||
"malformed hex data");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
data[*data_len].type = hex_data[hex_data_len + 1];
|
||||
data[*data_len].data_len = hex_data[hex_data_len];
|
||||
data[*data_len].data_len = len - 2;
|
||||
data[*data_len].data = &hex_data[hex_data_len + 2];
|
||||
(*data_len)++;
|
||||
hex_data_len += len;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue