From f535142100fe29a50b80c7538a900834f742e2fa Mon Sep 17 00:00:00 2001 From: Anga Santhosh Date: Thu, 10 Apr 2014 20:27:49 +0530 Subject: [PATCH] Provide separate APIs for set_request and send_data Change-Id: Ic67eb667baccac52ac7db5b63b510d203f1db1e4 --- include/at.h | 4 +++- src/at.c | 26 ++++++++++++++++++++------ src/hal.c | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) mode change 100644 => 100755 include/at.h diff --git a/include/at.h b/include/at.h old mode 100644 new mode 100755 index e5d365e..8adcc0f --- a/include/at.h +++ b/include/at.h @@ -62,7 +62,9 @@ void tcore_at_free(TcoreAT *at); TelReturn tcore_at_buf_write(TcoreAT *at, guint data_len, const gchar *data); -TelReturn tcore_at_set_request(TcoreAT *at, TcoreAtRequest *req, gboolean send); +TelReturn tcore_at_set_request(TcoreAT *at, TcoreAtRequest *req); +TelReturn tcore_at_send_data(TcoreAT *at, TcoreAtRequest *req, gboolean send); + TcoreAtRequest *tcore_at_get_request(TcoreAT *at); TcoreAtResponse *tcore_at_get_response(TcoreAT *at); diff --git a/src/at.c b/src/at.c index 1c4c42b..b3ba72a 100644 --- a/src/at.c +++ b/src/at.c @@ -436,7 +436,6 @@ TelReturn tcore_at_remove_notification_full(TcoreAT *at, const gchar *prefix, return TEL_RETURN_SUCCESS; } - TelReturn tcore_at_remove_notification(TcoreAT *at, const gchar *prefix, TcoreAtNotificationCallback callback) { @@ -479,22 +478,37 @@ TelReturn tcore_at_add_notification(TcoreAT *at, const gchar *prefix, return TEL_RETURN_SUCCESS; } -TelReturn tcore_at_set_request(TcoreAT *at, TcoreAtRequest *req, gboolean send) +TelReturn tcore_at_set_request(TcoreAT *at, TcoreAtRequest *req) { - TelReturn ret; - gchar *end; - gchar next; - if (at == NULL) { err("AT-Command is NULL"); return TEL_RETURN_INVALID_PARAMETER; } + at->req = req; if (req) { dbg("AT Request - Command: [%s] Pre-fix: [%s] Type: [%d])", at->req->cmd, at->req->prefix, at->req->type); } + return TEL_RETURN_SUCCESS; +} + +TelReturn tcore_at_send_data(TcoreAT *at, TcoreAtRequest *req, gboolean send) +{ + TelReturn ret; + gchar *end; + gchar next; + + if (at == NULL) { + err("AT-Command is NULL"); + return TEL_RETURN_INVALID_PARAMETER; + } + + if ((ret = tcore_at_set_request(at, req)) != TEL_RETURN_SUCCESS) { + err("Failed to set AT request"); + return ret; + } if (send == FALSE) return TEL_RETURN_SUCCESS; diff --git a/src/hal.c b/src/hal.c index 6d5ea18..4a247d0 100644 --- a/src/hal.c +++ b/src/hal.c @@ -96,7 +96,7 @@ static gboolean __hal_idle_send(void *user_data) (guint)pending, tcore_pending_get_id(pending), data_len); if (hal->mode == TCORE_HAL_MODE_AT) - ret = tcore_at_set_request(hal->at, data, TRUE); + ret = tcore_at_send_data(hal->at, data, TRUE); else ret = tcore_hal_send_data(hal, data_len, data); -- 2.7.4