diff options
author | Lukasz Rymanowski <lukasz.rymanowski@tieto.com> | 2014-11-20 16:55:12 +0100 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2014-11-24 12:56:39 +0100 |
commit | f357911cc309e57bcd8bbc9c003b5a254d9e09da (patch) | |
tree | 009fdbe4af73423f0d8b1ebc37e7bf89d42f9fec /src | |
parent | 8d4261c86433723e7b7531f81e2e8865b96b13ea (diff) | |
download | bluez-f357911cc309e57bcd8bbc9c003b5a254d9e09da.tar.gz |
shared/hfp: Refactor call_prefix_handler
With this patch call_prefix_handle gets new name handle_at_command and
returns true if correct at command has been handled or false when
provided data does not contain any AT command.
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/hfp.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/shared/hfp.c b/src/shared/hfp.c index 42e4c6b0f..2a0965846 100644 --- a/src/shared/hfp.c +++ b/src/shared/hfp.c @@ -179,7 +179,18 @@ static void skip_whitespace(struct hfp_context *context) context->offset++; } -static bool call_prefix_handler(struct hfp_gw *hfp, const char *data) +static void handle_unknown_at_command(struct hfp_gw *hfp, + const char *data) +{ + if (hfp->command_callback) { + hfp->command_callback(data, hfp->command_data); + hfp->result_pending = true; + } else { + hfp_gw_send_result(hfp, HFP_RESULT_ERROR); + } +} + +static bool handle_at_command(struct hfp_gw *hfp, const char *data) { struct cmd_handler *handler; const char *separators = ";?=\0"; @@ -247,8 +258,10 @@ done: handler = queue_find(hfp->cmd_handlers, match_handler_prefix, lookup_prefix); - if (!handler) - return false; + if (!handler) { + handle_unknown_at_command(hfp, data); + return true; + } handler->callback(&context, type, handler->user_data); @@ -505,14 +518,7 @@ static void process_input(struct hfp_gw *hfp) *ptr = '\0'; } - if (!call_prefix_handler(hfp, str)) { - if (hfp->command_callback) { - hfp->command_callback(str, hfp->command_data); - hfp->result_pending = true; - } else { - hfp_gw_send_result(hfp, HFP_RESULT_ERROR); - } - } + handle_at_command(hfp, str); len = ringbuf_drain(hfp->read_buf, count + 1); |