Bluetooth: BR: at: add function at_get_string

Add a function at_get_string to get the string from the received AT
result code.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
This commit is contained in:
Lyle Zhu 2024-07-25 14:34:18 +08:00 committed by Benjamin Cabé
commit e6d42cc37e
2 changed files with 33 additions and 0 deletions

View file

@ -535,3 +535,35 @@ void at_register(struct at_client *at, at_resp_cb_t resp, at_finish_cb_t finish)
at->finish = finish;
at->state = AT_STATE_START;
}
char *at_get_string(struct at_client *at)
{
uint8_t pos = at->pos;
char *string;
skip_space(at);
if (at->buf[at->pos] != '"') {
at->pos = pos;
return NULL;
}
at->pos++;
string = &at->buf[at->pos];
while (at->buf[at->pos] != '\0' && at->buf[at->pos] != '"') {
at->pos++;
}
if (at->buf[at->pos] != '"') {
at->pos = pos;
return NULL;
}
at->buf[at->pos] = '\0';
at->pos++;
skip_space(at);
next_list(at);
return string;
}

View file

@ -116,3 +116,4 @@ int at_list_get_string(struct at_client *at, char *name, uint8_t len);
int at_close_list(struct at_client *at);
int at_open_list(struct at_client *at);
int at_has_next_list(struct at_client *at);
char *at_get_string(struct at_client *at);