Bluetooth: AT handling error condition
In function at_get_number check for the value if gets computed. If not return error. Also change the end state handling. Change-Id: I193b04fa2880dfb44e7727b30b67c1ec2e051cc7 Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
This commit is contained in:
parent
7e1234b44b
commit
b0d34d83c5
1 changed files with 14 additions and 3 deletions
|
@ -50,12 +50,18 @@ const char *skip_whitespace(const char *buf)
|
||||||
|
|
||||||
int at_get_number(const char *buf, uint32_t *val)
|
int at_get_number(const char *buf, uint32_t *val)
|
||||||
{
|
{
|
||||||
*val = 0;
|
uint32_t i;
|
||||||
|
|
||||||
for (buf = skip_whitespace(buf); isdigit(*buf); buf++) {
|
buf = skip_whitespace(buf);
|
||||||
|
|
||||||
|
for (i = 0, *val = 0; isdigit(*buf); buf++, i++) {
|
||||||
*val = *val * 10 + *buf - '0';
|
*val = *val * 10 + *buf - '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
|
return -ENODATA;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +285,12 @@ static int cmd_get_value(struct at_client *at, struct net_buf *buf,
|
||||||
static int cmd_process_value(struct at_client *at, struct net_buf *buf,
|
static int cmd_process_value(struct at_client *at, struct net_buf *buf,
|
||||||
const char *prefix, parse_val_t func)
|
const char *prefix, parse_val_t func)
|
||||||
{
|
{
|
||||||
return func(at);
|
int ret;
|
||||||
|
|
||||||
|
ret = func(at);
|
||||||
|
at->cmd_state = CMD_STATE_END_LF;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cmd_state_end_lf(struct at_client *at, struct net_buf *buf,
|
static int cmd_state_end_lf(struct at_client *at, struct net_buf *buf,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue