+++ /dev/null
-From c524695eda823d025f5d2f64b8a84e1b478caa9a Mon Sep 17 00:00:00 2001
-From: Nicolas Bertrand <nicolas.bertrand@linux.intel.com>
-Date: Thu, 4 Oct 2012 10:23:16 +0200
-Subject: [PATCH 01/10] hal: Add set_sound_path function
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- include/hal.h | 2 ++
- src/hal.c | 10 ++++++++++
- src/mux.c | 8 ++++++++
- 3 files changed, 20 insertions(+)
-
-diff --git a/include/hal.h b/include/hal.h
-index d93795a..55b4762 100644
---- a/include/hal.h
-+++ b/include/hal.h
-@@ -43,6 +43,7 @@ enum tcore_hal_mode {
- struct tcore_hal_operations {
- TReturn (*power)(TcoreHal *hal, gboolean flag);
- TReturn (*send)(TcoreHal *hal, unsigned int data_len, void *data);
-+ TReturn (*set_sound_path)(TcoreHal *hal, int device);
- };
-
- TcoreHal* tcore_hal_new(TcorePlugin *plugin, const char *name,
-@@ -58,6 +59,7 @@ enum tcore_hal_mode tcore_hal_get_mode(TcoreHal *hal);
- TReturn tcore_hal_set_mode(TcoreHal *hal, enum tcore_hal_mode mode);
-
- TReturn tcore_hal_set_power(TcoreHal *hal, gboolean flag);
-+TReturn tcore_hal_set_sound_path(TcoreHal *hal, int device);
-
- TReturn tcore_hal_link_user_data(TcoreHal *hal, void *user_data);
- void* tcore_hal_ref_user_data(TcoreHal *hal);
-diff --git a/src/hal.c b/src/hal.c
-index 178cecd..59ba41f 100644
---- a/src/hal.c
-+++ b/src/hal.c
-@@ -508,3 +508,13 @@ TReturn tcore_hal_set_power(TcoreHal *hal, gboolean flag)
-
- return hal->ops->power(hal, flag);
- }
-+
-+TReturn tcore_hal_set_sound_path(TcoreHal *hal, int device)
-+{
-+ dbg("start");
-+
-+ if (!hal || !hal->ops || !hal->ops->set_sound_path)
-+ return TCORE_RETURN_EINVAL;
-+
-+ return hal->ops->set_sound_path(hal, device);
-+}
-diff --git a/src/mux.c b/src/mux.c
-index 46cafce..7456762 100644
---- a/src/mux.c
-+++ b/src/mux.c
-@@ -283,10 +283,18 @@ static TReturn tcore_cmux_hal_send(TcoreHal *h, unsigned int data_len, void *dat
- return TCORE_RETURN_SUCCESS;
- }
-
-+static TReturn tcore_cmux_hal_set_sound_path(TcoreHal *hal, int device)
-+{
-+ dbg("Entry");
-+
-+ return tcore_hal_set_sound_path(g_mux_obj_ptr->phy_hal, device);
-+}
-+
- /* CMUX supported HAL (Logical HAL) operations */
- static struct tcore_hal_operations mux_hops = {
- .power = tcore_cmux_hal_power,
- .send = tcore_cmux_hal_send,
-+ .set_sound_path = tcore_cmux_hal_set_sound_path,
- };
-
- static TReturn tcore_cmux_send_data(int data_len, unsigned char *data)
---
-1.7.10.4
-
+++ /dev/null
-From 69ef003199bc6848d39d75b12bd6ccb84383abad Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Wed, 3 Oct 2012 10:14:40 +0200
-Subject: [PATCH 02/10] hal: Add new entry points and method declarations
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-Create callback for HAL power operation.
-
-mux_init-->initialize multiplexer through HAL
-lin_object_channel--> link core object to HAL channel
----
- include/hal.h | 10 ++++++++--
- 1 file changed, 8 insertions(+), 2 deletions(-)
-
-diff --git a/include/hal.h b/include/hal.h
-index 55b4762..bed6684 100644
---- a/include/hal.h
-+++ b/include/hal.h
-@@ -25,6 +25,7 @@ __BEGIN_DECLS
-
- typedef void (*TcoreHalReceiveCallback)(TcoreHal *hal, unsigned int data_len, const void *data, void *user_data);
- typedef enum tcore_hook_return (*TcoreHalSendHook)(TcoreHal *hal, unsigned int data_len, void *data, void *user_data);
-+typedef void (*TcoreHalPowerCallBack)(TcoreHal *hal, void *user_data);
-
- enum tcore_hal_recv_data_type {
- TCORE_HAL_RECV_INDICATION,
-@@ -41,9 +42,11 @@ enum tcore_hal_mode {
- };
-
- struct tcore_hal_operations {
-- TReturn (*power)(TcoreHal *hal, gboolean flag);
-+ TReturn (*power)(TcoreHal *hal, gboolean flag,
-+ TcoreHalPowerCallBack func, void *user_data);
- TReturn (*send)(TcoreHal *hal, unsigned int data_len, void *data);
- TReturn (*set_sound_path)(TcoreHal *hal, int device);
-+ TReturn (*link_object_channel)(CoreObject *object);
- };
-
- TcoreHal* tcore_hal_new(TcorePlugin *plugin, const char *name,
-@@ -58,11 +61,14 @@ TcoreAT* tcore_hal_get_at(TcoreHal *hal);
- enum tcore_hal_mode tcore_hal_get_mode(TcoreHal *hal);
- TReturn tcore_hal_set_mode(TcoreHal *hal, enum tcore_hal_mode mode);
-
--TReturn tcore_hal_set_power(TcoreHal *hal, gboolean flag);
-+TReturn tcore_hal_set_power(TcoreHal *hal, gboolean flag,
-+ TcoreHalPowerCallBack func,
-+ void *user_data);
- TReturn tcore_hal_set_sound_path(TcoreHal *hal, int device);
-
- TReturn tcore_hal_link_user_data(TcoreHal *hal, void *user_data);
- void* tcore_hal_ref_user_data(TcoreHal *hal);
-+TReturn tcore_hal_link_object(TcoreHal *hal, CoreObject *co);
-
- TReturn tcore_hal_send_data(TcoreHal *hal, unsigned int data_len, void *data);
- TReturn tcore_hal_send_request(TcoreHal *hal, TcorePending *pending);
---
-1.7.10.4
-
+++ /dev/null
-From a7806ad9a86716bcdc9acba58575015e6224af91 Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Wed, 3 Oct 2012 10:16:53 +0200
-Subject: [PATCH 03/10] hal: Add new method definitions
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/hal.c | 14 ++++++++++++--
- 1 file changed, 12 insertions(+), 2 deletions(-)
-
-diff --git a/src/hal.c b/src/hal.c
-index 59ba41f..9ade963 100644
---- a/src/hal.c
-+++ b/src/hal.c
-@@ -241,6 +241,14 @@ TReturn tcore_hal_link_user_data(TcoreHal *hal, void *user_data)
- return TCORE_RETURN_SUCCESS;
- }
-
-+TReturn tcore_hal_link_object(TcoreHal *hal, CoreObject *co)
-+{
-+ if (!hal)
-+ return TCORE_RETURN_EINVAL;
-+
-+ return hal->ops->link_object_channel(co);
-+}
-+
- void *tcore_hal_ref_user_data(TcoreHal *hal)
- {
- if (!hal)
-@@ -501,12 +509,14 @@ gboolean tcore_hal_get_power_state(TcoreHal *hal)
- return hal->power_state;
- }
-
--TReturn tcore_hal_set_power(TcoreHal *hal, gboolean flag)
-+TReturn tcore_hal_set_power(TcoreHal *hal, gboolean flag,
-+ TcoreHalPowerCallBack func,
-+ void *user_data)
- {
- if (!hal || !hal->ops || !hal->ops->power)
- return TCORE_RETURN_EINVAL;
-
-- return hal->ops->power(hal, flag);
-+ return hal->ops->power(hal, flag, func, user_data);
- }
-
- TReturn tcore_hal_set_sound_path(TcoreHal *hal, int device)
---
-1.7.10.4
-
+++ /dev/null
-From 77346145fe1c5e9332b509ab489f087d29321c25 Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Wed, 3 Oct 2012 10:18:00 +0200
-Subject: [PATCH 04/10] mux: Declare new public API for HAL plugin
- manipulations
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-Add new callback to notify when MUX is ready.
----
- include/mux.h | 13 ++++++++++---
- 1 file changed, 10 insertions(+), 3 deletions(-)
-
-diff --git a/include/mux.h b/include/mux.h
-index 1b11776..342244f 100644
---- a/include/mux.h
-+++ b/include/mux.h
-@@ -21,8 +21,15 @@
- #ifndef __MUX_H__
- #define __MUX_H__
-
--TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal);
--void tcore_cmux_close(void);
--int tcore_cmux_rcv_from_hal(unsigned char *data, size_t length);
-+#include "hal.h"
-+
-+typedef void (*CMuxInitCallBack)(void *user_data);
-+
-+TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal,
-+ CMuxInitCallBack cb, void *user_data,
-+ int channel_num);
-+TcoreHal *tcore_cmux_get_hal_channel(int channel_idx);
-+void tcore_cmux_close(void);
-+int tcore_cmux_rcv_from_hal(unsigned char *data, size_t length);
-
- #endif /* __MUX_H__ */
---
-1.7.10.4
-
+++ /dev/null
-From a8facc64fbebfe779218931b22f7062d75f9820a Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Wed, 3 Oct 2012 10:26:41 +0200
-Subject: [PATCH 05/10] mux: Remove plateform dependencies from core
- multiplexer
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-Remove struct cmux_channel_object.
-Remove hardcoded channel indexes and channel limitations.
-Remove core object list from mux object.
-Only allocate multiplexer channel during cmux_init and
-open channels on HAL plugin demand.
-Let telephony plugin set physical HAL back to each of its
-core object.
----
- src/mux.c | 321 +++++++++++++++++--------------------------------------------
- 1 file changed, 88 insertions(+), 233 deletions(-)
-
-diff --git a/src/mux.c b/src/mux.c
-index 7456762..3794685 100644
---- a/src/mux.c
-+++ b/src/mux.c
-@@ -27,16 +27,12 @@
-
- #include "tcore.h"
-
--#include "hal.h"
- #include "plugin.h"
- #include "user_request.h"
- #include "server.h"
- #include "mux.h"
- #include "core_object.h"
-
--/* Maximum Core objects per Logical HAL (indirectly per Channel) */
--#define MAX_CMUX_CORE_OBJECTS 3
--
- /* Max CMUX Buffer size */
- #define MAX_CMUX_BUFFER_SIZE 4096
-
-@@ -57,16 +53,6 @@
- #define CMUX_COMMAND_MSC 0xE3 // Modem Status Command
- #define CMUX_COMMAND_CLD 0xC3 // Multiplexer close down
-
--/* CMUX Channels [0-7] -
-- * Channel 0 - Control Channel for CMUX
-- * Channel 1 - CALL
-- * Channel 2 - SIM
-- * Channel 3 - SAT
-- * Channel 4 - SMS
-- * Channel 5 - SS
-- * Channel 6 - NETWORK
-- * Channel 7 - MODEM & PS
-- */
- typedef enum CMUX_Channels {
- CMUX_CHANNEL_0,
- CMUX_CHANNEL_1,
-@@ -135,30 +121,28 @@ const unsigned char crc_table[256] = { // reversed, 8-bit, poly=0x07
-
- /* CMUX Channel */
- typedef struct cmux_channel {
-- GSList *co;
- TcoreHal *hal;
- MuxChannelState state;
- CMUX_Channels channel_id;
-+ char *channel_id_name;
- int frame_type;
- unsigned char ext_bit;
- unsigned char cr_bit;
- unsigned char poll_final_bit;
- } CHANNEL;
-
--/* CMUX callback prototype */
--typedef gboolean (*mux_cb_func)(CHANNEL *channel_ptr);
--
- /* CMUX structure */
- typedef struct cmux {
- MuxState state;
- CHANNEL *channel_info[MAX_CMUX_CHANNELS_SUPPORTED];
-+ int channel_num;
- int is_waiting;
- int msg_len;
- int cur_main_buf_len;
- TcorePlugin *plugin;
- TcoreHal *phy_hal;
-- CoreObject *modem_co;
-- mux_cb_func cb_func;
-+ CMuxInitCallBack cb_init;
-+ void *cb_data;
- int info_field_len;
- unsigned char *info_field;
- } MUX;
-@@ -169,69 +153,26 @@ MUX *g_mux_obj_ptr = NULL;
- /* CMUX mode of operation */
- int g_mux_mode = 0; /* BASIC mode */
-
--struct cmux_channel_object {
-- char *channel_id_name;
-- char *core_object_name[MAX_CMUX_CORE_OBJECTS];
--};
--
--/* Core Object names need to be verified, define a MACRO globally */
--struct cmux_channel_object cmux_channel_core_object[] = {
-- {"channel_0", {"control", NULL, NULL}},
-- {"channel_1", {"call", NULL, NULL}},
-- {"channel_2", {"sim", NULL, NULL}},
-- {"channel_3", {"sat", NULL, NULL}},
-- {"channel_4", {"umts_sms", NULL, NULL}},
-- {"channel_5", {"ss", NULL, NULL}},
-- {"channel_6", {"umts_network", NULL, NULL}},
-- {"channel_7", {"modem", "umts_ps", NULL}},
--};
--
- /* All the local functions declared below */
- static unsigned char calc_crc(unsigned char *header, int length);
- static int rcv_crc_check(unsigned char *data, unsigned char len, unsigned char rcv_FCS);
--MUX* tcore_cmux_new(void);
-+static MUX* tcore_cmux_new(int channel_num);
- static void tcore_cmux_free(void);
--void tcore_cmux_link_core_object_hal(CMUX_Channels channel_id, TcorePlugin *plugin);
- static gboolean tcore_cmux_recv_mux_data(CHANNEL *channel_ptr);
- static void tcore_cmux_process_rcv_frame(unsigned char *data, int len);
- static void tcore_cmux_process_channel_data(CHANNEL *channel_info_ptr);
- static void tcore_cmux_control_channel_handle(void);
- static void tcore_cmux_flush_channel_data(void);
- static void tcore_cmux_channel_init(CMUX_Channels channel_id);
--static void tcore_cmux_close_channel(int channel_id);
- static unsigned char* tcore_encode_cmux_frame(unsigned char *data, int length, int channel_id, int frame_type, unsigned char EA_bit, unsigned char CR_bit, unsigned char PF_bit, int *out_data_len);
-+static void tcore_cmux_close_channel(int channel_idx);
- static TReturn tcore_cmux_send_data(int data_len, unsigned char *data);
-
--static TReturn tcore_cmux_hal_power(TcoreHal *h, gboolean flag)
--{
-- TcorePlugin *p = NULL;
-- struct custom_data *user_data = NULL;
--
-- dbg("Entry");
--
-- p = tcore_hal_ref_plugin(h);
-- if (!p) {
-- err("Plugin is undefined");
-- return TCORE_RETURN_FAILURE;
-- }
--
-- user_data = tcore_hal_ref_user_data(h);
-- if (!user_data) {
-- err("User data is undefined");
-- return TCORE_RETURN_FAILURE;
-- }
--
-- tcore_hal_set_power_state(h, TRUE);
--
-- dbg("Exit");
-- return TCORE_RETURN_SUCCESS;
--}
--
- static TReturn tcore_cmux_hal_send(TcoreHal *h, unsigned int data_len, void *data)
- {
- unsigned char *send_data = NULL;
-- char *channel_name = NULL;
-- int channel_id = MAX_CMUX_CHANNELS_SUPPORTED;
-+ char *channel_id_name = NULL;
-+ int channel_id = g_mux_obj_ptr->channel_num;
- int len = 0;
- int i = 0;
- int ret;
-@@ -244,16 +185,15 @@ static TReturn tcore_cmux_hal_send(TcoreHal *h, unsigned int data_len, void *dat
- return TCORE_RETURN_FAILURE;
- }
-
-- channel_name = tcore_hal_get_name(h);
-- dbg("HAL name: %s", channel_name)
-- if (channel_name) {
-- while (i < MAX_CMUX_CHANNELS_SUPPORTED) {
-- if (0 == strcmp((char *) cmux_channel_core_object[i].channel_id_name, (char *) channel_name)) {
-+ channel_id_name = tcore_hal_get_name(h);
-+ if (channel_id_name) {
-+ while (i < g_mux_obj_ptr->channel_num) {
-+ if (strcmp((char *) g_mux_obj_ptr->channel_info[i]->channel_id_name, (char *) channel_id_name) == 0) {
- channel_id = i;
- dbg("Found Channel ID: %d", channel_id);
-
- /* Free memory */
-- free(channel_name);
-+ free(channel_id_name);
- break;
- }
- i++;
-@@ -263,7 +203,7 @@ static TReturn tcore_cmux_hal_send(TcoreHal *h, unsigned int data_len, void *dat
- return TCORE_RETURN_FAILURE;
- }
-
-- if (channel_id > MAX_CMUX_CHANNELS_SUPPORTED) {
-+ if (channel_id > g_mux_obj_ptr->channel_num) {
- err("Failed to find Channel ID");
- return TCORE_RETURN_FAILURE;
- }
-@@ -292,9 +232,10 @@ static TReturn tcore_cmux_hal_set_sound_path(TcoreHal *hal, int device)
-
- /* CMUX supported HAL (Logical HAL) operations */
- static struct tcore_hal_operations mux_hops = {
-- .power = tcore_cmux_hal_power,
-+ .power = NULL,
- .send = tcore_cmux_hal_send,
- .set_sound_path = tcore_cmux_hal_set_sound_path,
-+ .link_object_channel = NULL,
- };
-
- static TReturn tcore_cmux_send_data(int data_len, unsigned char *data)
-@@ -323,76 +264,41 @@ static gboolean tcore_cmux_recv_mux_data(CHANNEL *channel_ptr)
- /* Dereferencing HAL from Channel Pointer */
- hal = channel_ptr->hal;
-
-- dbg("Dispatching to logical HAL - hal: %x", (unsigned int)hal);
-+ dbg("Dispatching to logical HAL - hal: %x", hal);
- tcore_hal_dispatch_response_data(hal, 0, g_mux_obj_ptr->info_field_len, g_mux_obj_ptr->info_field);
-
- dbg("Exit");
- return TRUE;
- }
-
--void tcore_cmux_link_core_object_hal(CMUX_Channels channel_id, TcorePlugin *plugin)
-+TcoreHal *tcore_cmux_get_hal_channel(int channel_idx)
- {
-- TcoreHal *hal = NULL;
-- CoreObject *co = NULL;
-- int index;
--
- dbg("Entry");
-
-- if (CMUX_CHANNEL_0 != channel_id) {
-- dbg("Normal channel [%d]", channel_id);
--
-- /* Creating Logical HAL for Core Object - Mode - 'AT mode' */
-- hal = tcore_hal_new(plugin, cmux_channel_core_object[channel_id].channel_id_name, &mux_hops, TCORE_HAL_MODE_AT);
-- dbg("hal: %p", hal);
--
-- /* Update Logical HAL of CMUX Channel */
-- g_mux_obj_ptr->channel_info[channel_id]->hal = hal;
--
-- index = 0;
-- while (NULL != cmux_channel_core_object[channel_id].core_object_name[index]) {
-- /* Retrieving Core Object */
-- dbg("Core Object: '%s'", cmux_channel_core_object[channel_id].core_object_name[index]);
-- co = tcore_plugin_ref_core_object(plugin, cmux_channel_core_object[channel_id].core_object_name[index]);
-- dbg("co: %p", co);
--
-- if (0 == strcmp((const char *) cmux_channel_core_object[channel_id].core_object_name[index], "modem")) {
-- g_mux_obj_ptr->modem_co = co;
-- dbg("'modem' Core object reference is stored");
-- }
--
-- /* Set Logical HAL to Core objects */
-- tcore_object_set_hal(co, hal);
--
-- /* Update Core Object list of CMUX Channel */
-- g_mux_obj_ptr->channel_info[channel_id]->co = g_slist_append(g_mux_obj_ptr->channel_info[channel_id]->co, co);
--
-- /* Next Core Object of the channel */
-- index++;
-- }
-- } else {
-- /* Control Channel */
-- dbg("Control channel");
--
-- /* Creating Logical HAL for Core Object - Mode - 'AT mode' */
-- hal = tcore_hal_new(plugin, cmux_channel_core_object[channel_id].channel_id_name, &mux_hops, TCORE_HAL_MODE_AT);
-- dbg("hal: %p", hal);
--
-- /* Update Logical HAL of CMUX Channel */
-- g_mux_obj_ptr->channel_info[channel_id]->hal = hal;
-+ if (g_mux_obj_ptr == NULL) {
-+ err("No multiplexer available");
-+ return NULL;
- }
-
-- /* Set Logical HAL Power State to TRUE */
-- tcore_hal_set_power_state(hal, TRUE);
-- dbg("HAL Power is SET");
-+ if (channel_idx >= g_mux_obj_ptr->channel_num) {
-+ err("Channel ID out of range");
-+ return NULL;
-+ }
-
- dbg("Exit");
-- return;
-+
-+ return g_mux_obj_ptr->channel_info[channel_idx]->hal;
- }
-
--MUX* tcore_cmux_new(void)
-+static MUX* tcore_cmux_new(int channel_num)
- {
- MUX *mux = NULL;
-- int i = 0;
-+ int i;
-+
-+ if (channel_num > MAX_CMUX_CHANNELS_SUPPORTED) {
-+ err("Exceed number of supported channels");
-+ return NULL;
-+ }
-
- /* Allocating memory for mux */
- mux = (MUX *) calloc(sizeof(MUX), 1);
-@@ -401,6 +307,8 @@ MUX* tcore_cmux_new(void)
- return NULL;
- }
-
-+ mux->channel_num = channel_num;
-+
- /* Allocating memory for info_field */
- mux->info_field = (unsigned char *) calloc(MAX_CMUX_BUFFER_SIZE, 1);
- if (!mux->info_field) {
-@@ -411,10 +319,8 @@ MUX* tcore_cmux_new(void)
- /* MUX State initialize to MUX_NOT_INITIALIZED */
- mux->state = MUX_NOT_INITIALIZED;
-
-- /* Allocating memory for channel_info */
-- for (i = 0; i < MAX_CMUX_CHANNELS_SUPPORTED; i++) {
-+ for (i = 0; i < channel_num; i ++) {
- mux->channel_info[i] = (CHANNEL *) calloc(sizeof(CHANNEL), 1);
-- /* Check for Memory allocation failure */
- if (!mux->channel_info[i]) {
- err("Failed to allocate memory for channel_info of channel: %d", i);
- goto ERROR;
-@@ -430,7 +336,7 @@ ERROR:
- free(mux->info_field);
- }
-
-- for (i = 0; i < MAX_CMUX_CHANNELS_SUPPORTED; i++) {
-+ for (i = 0; i < channel_num; i++) {
- if (mux->channel_info[i]) {
- free(mux->channel_info[i]);
- }
-@@ -495,11 +401,11 @@ static unsigned char* tcore_encode_cmux_frame(unsigned char *data,
-
- /* DLCI: Data Link Connection Identifier */
- /* Check if the channel is within range */
-- if (channel_id < MAX_CMUX_CHANNELS_SUPPORTED && channel_id >= 0) {
-+ if (channel_id < g_mux_obj_ptr->channel_num && channel_id >= 0) {
- dbg("Channel ID: %d", channel_id);
- g_mux_obj_ptr->info_field[frame_length] = g_mux_obj_ptr->info_field[frame_length] | ((unsigned char) channel_id << 2);
- } else {
-- err("Channel is out of range[0-8]");
-+ err("Channel is out of range[0-%d]", g_mux_obj_ptr->channel_num);
- return NULL;
- }
- frame_length++;
-@@ -694,21 +600,10 @@ static void tcore_cmux_process_channel_data(CHANNEL *channel_info_ptr)
-
- count++;
- dbg("Count: %d", count);
-- if (MAX_CMUX_CHANNELS_SUPPORTED == count) {
-- /* Indicate to CoreObject */
-- CoreObject *co = NULL;
--
-- /* 'modem' Core Object */
-- co = g_mux_obj_ptr->modem_co;
-- if (NULL == co) {
-- err("'modem' Core object is not present");
-- return;
-- }
--
-- /* Emit callback */
-- dbg("Emit Core object callback");
-- tcore_object_emit_callback(co, "CMUX-UP", NULL);
-- dbg("Emitted Core object callback");
-+ if (g_mux_obj_ptr->channel_num == count) {
-+
-+ /* Call init callback to notify mux is ready */
-+ g_mux_obj_ptr->cb_init(g_mux_obj_ptr->cb_data);
-
- /* Reset 'count' */
- count = 0;
-@@ -840,7 +735,7 @@ static void tcore_cmux_process_rcv_frame(unsigned char *data, int len)
- /* Get the Channel ID : 1st byte will be flag (F9)..Flag checking is already done.*/
- channel_id = (*++frame_process_ptr >> 2) & 0x3F;
-
-- if (channel_id < MAX_CMUX_CHANNELS_SUPPORTED) { // max channel is 8
-+ if (channel_id < g_mux_obj_ptr->channel_num) { // max channel is 8
- ch = g_mux_obj_ptr->channel_info[channel_id];
-
- ch->channel_id = channel_id;
-@@ -1029,9 +924,9 @@ static void tcore_cmux_channel_init(CMUX_Channels channel_id)
- memset(ch, 0x0, sizeof(CHANNEL));
-
- ch->channel_id = channel_id;
-+ ch->channel_id_name = g_strdup_printf("channel_%d", channel_id);
- ch->state = MUX_CHANNEL_SABM_SEND_WAITING_FOR_UA;
-
-- ch->co = NULL;
- ch->hal = NULL;
-
- /* TODO - Check if required */
-@@ -1045,7 +940,7 @@ static void tcore_cmux_channel_init(CMUX_Channels channel_id)
- return;
- }
-
--static void tcore_cmux_close_channel(int channel_id)
-+static void tcore_cmux_close_channel(int channel_idx)
- {
- CHANNEL *ch = NULL;
- unsigned char *send_data = NULL;
-@@ -1053,7 +948,13 @@ static void tcore_cmux_close_channel(int channel_id)
-
- dbg("Entry");
-
-- ch = g_mux_obj_ptr->channel_info[channel_id];
-+ ch = g_mux_obj_ptr->channel_info[channel_idx];
-+
-+ if (ch == NULL)
-+ return;
-+
-+ g_free(ch->channel_id_name);
-+ ch->channel_id_name = NULL;
-
- if (ch->state != MUX_CHANNEL_CLOSED) {
- ch->frame_type = CMUX_COMMAND_DISC;
-@@ -1063,26 +964,24 @@ static void tcore_cmux_close_channel(int channel_id)
-
- /* Send DSC command */
- /* Encoding frame */
-- send_data = tcore_encode_cmux_frame(NULL, 0, channel_id, CMUX_COMMAND_DISC, 0x01, 0x01, 0x01, &len);
-- if (0 != len) {
-+ send_data = tcore_encode_cmux_frame(NULL, 0, channel_idx, CMUX_COMMAND_DISC, 0x01, 0x01, 0x01, &len);
-+ if (0 > len)
- /* Send CMUX data */
- ret = tcore_cmux_send_data(len, send_data);
-- } else {
-+ else
- err("Failed to encode");
-- }
-- } else {
-+ } else
- /* Channel is already closed */
- err("Channel is already closed");
-- }
-+
-+ free(g_mux_obj_ptr->channel_info[channel_idx]);
-+ g_mux_obj_ptr->channel_info[channel_idx] = NULL;
-
- dbg("Exit");
-- return;
- }
-
- static void tcore_cmux_free(void)
- {
-- int channel;
--
- dbg("Entry");
-
- if (g_mux_obj_ptr) {
-@@ -1092,14 +991,6 @@ static void tcore_cmux_free(void)
- g_mux_obj_ptr->info_field = NULL;
- }
-
-- for (channel = 0; channel < MAX_CMUX_CHANNELS_SUPPORTED; channel++) {
-- /* Free Channel Information */
-- if (g_mux_obj_ptr->channel_info[channel]) {
-- free(g_mux_obj_ptr->channel_info[channel]);
-- g_mux_obj_ptr->channel_info[channel] = NULL;
-- }
-- }
--
- /* Free MUX Object */
- free(g_mux_obj_ptr);
- g_mux_obj_ptr = NULL;
-@@ -1111,21 +1002,21 @@ static void tcore_cmux_free(void)
- return;
- }
-
--TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal)
-+TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal,
-+ CMuxInitCallBack cb, void *user_data,
-+ int channel_num)
- {
-+ TReturn ret = TCORE_RETURN_SUCCESS;
- unsigned char *data = NULL;
- int data_len = 0;
--
- int index;
-
-- TReturn ret = TCORE_RETURN_SUCCESS;
--
- dbg("Entry");
-
-- dbg("Physical HAL: %x", (unsigned int)hal);
-+ dbg("Physical HAL: %x", hal);
-
- /* Creat new CMUX Object */
-- g_mux_obj_ptr = tcore_cmux_new();
-+ g_mux_obj_ptr = tcore_cmux_new(channel_num);
- if (NULL == g_mux_obj_ptr) {
- err("Failed to create MUX object");
-
-@@ -1139,18 +1030,11 @@ TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal)
- /* Save Physical HAL */
- g_mux_obj_ptr->phy_hal = hal;
-
-- /* Setting Receive callback function for data received from Physical HAL */
-- g_mux_obj_ptr->cb_func = tcore_cmux_recv_mux_data;
-+ /* Set init callback function and data */
-+ g_mux_obj_ptr->cb_init = cb;
-+ g_mux_obj_ptr->cb_data = user_data;
-
-- /* After MUX setup, AT parse functionality of PHY HAL should be disabled,
-- * here we change the mode of PHYSICAL HAL to Transparent.
-- */
-- tcore_hal_set_mode(g_mux_obj_ptr->phy_hal, TCORE_HAL_MODE_TRANSPARENT);
-- dbg("Physical HAL mode changed to Transparent");
--
-- /* Initialize all the Channels */
-- /* Open all Channels */
-- for (index = 0; index < MAX_CMUX_CHANNELS_SUPPORTED; index++) {
-+ for (index = 0; index < channel_num; index ++) {
- dbg("Initialize the Channel %d", index);
- tcore_cmux_channel_init((CMUX_Channels) index);
-
-@@ -1169,10 +1053,22 @@ TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal)
- tcore_cmux_send_data(data_len, data);
- dbg("CMUX Control Request sent to CP");
-
-- /* Set Core object and HAL */
-- tcore_cmux_link_core_object_hal((CMUX_Channels) index, plugin);
-+ hal = tcore_hal_new(plugin, g_mux_obj_ptr->channel_info[index]->channel_id_name, &mux_hops, TCORE_HAL_MODE_AT);
-+
-+ /* Update Logical HAL of CMUX Channel */
-+ g_mux_obj_ptr->channel_info[index]->hal = hal;
-+
-+ /* Set Logical HAL Power State to TRUE */
-+ tcore_hal_set_power_state(hal, TRUE);
- }
-
-+ /*
-+ * After MUX setup, AT parse functionality of PHY HAL should be disabled,
-+ * here we change the mode of PHYSICAL HAL to Transparent.
-+ */
-+ tcore_hal_set_mode(g_mux_obj_ptr->phy_hal, TCORE_HAL_MODE_TRANSPARENT);
-+ dbg("Physical HAL mode changed to Transparent");
-+
- dbg("Exit");
- return ret;
-
-@@ -1187,68 +1083,27 @@ ERROR:
- void tcore_cmux_close(void)
- {
- int channel = 0;
-- int index = 0;
-- CoreObject *co = NULL;
-- GSList *co_list = NULL;
-
- dbg("Entry");
-
-- for (channel = 0; channel < MAX_CMUX_CHANNELS_SUPPORTED; channel++) {
-+ for (channel = 0; channel < g_mux_obj_ptr->channel_num; channel++) {
- dbg("Channel ID: %d", channel);
-- index = 0;
-
- /* Close Channel - Send DSC command */
- tcore_cmux_close_channel(channel);
-
-- /* Revert Physical HAL as HAL of each Core Object associated to this Channel */
-- while (NULL != cmux_channel_core_object[channel].core_object_name[index]) {
-- co = NULL;
--
-- /* Core Objects list */
-- co_list = g_mux_obj_ptr->channel_info[channel]->co;
-- dbg("Core Objects list : %p", co_list);
--
-- /* Core Object list may contain multiple Core Objects.
-- * Revert to Physical HAL for each of the Core Objects associated
-- * with this Channel
-- */
-- while (NULL != co_list) {
-- if (NULL != co_list->data) {
-- if (!strcmp((const char *) cmux_channel_core_object[channel].core_object_name[index], (const char *) tcore_object_ref_name((CoreObject *) co_list->data))) {
-- co = (CoreObject *) co_list->data;
-- dbg("Core Object found ");
-- break;
-- }
-- }
--
-- /* To next Core Object in the list */
-- co_list = co_list->next;
-- }
--
-- /* Set the previous Physical HAL as HAL for Core Object */
-- if (NULL != co) {
-- tcore_object_set_hal(co, g_mux_obj_ptr->phy_hal);
-- } else {
-- /* Proceed to next Channel */
-- err("No more Core Objects present in this Channel");
-- break;
-- }
--
-- /* To next Core Object */
-- index++;
-- }
--
- /* Free Logical HAL for Channel */
- tcore_hal_free(g_mux_obj_ptr->channel_info[channel]->hal);
- g_mux_obj_ptr->channel_info[channel]->hal = NULL;
- }
-
-- /* Change the mode of PHYSICAL HAL to Custom */
-+ /* Change the mode of PHYSICAL HAL to AT */
- tcore_hal_set_mode(g_mux_obj_ptr->phy_hal, TCORE_HAL_MODE_AT);
-
- /* Free all the allocated memory */
- tcore_cmux_free();
-
- dbg("Exit");
-+
- return;
- }
---
-1.7.10.4
-
+++ /dev/null
-From 00565c321fc84175fbc3aa599b074d30f798e4ec Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Mon, 8 Oct 2012 11:32:11 +0200
-Subject: [PATCH 06/10] notification: Add new notifcation type
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- include/type/notification.h | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/include/type/notification.h b/include/type/notification.h
-index 3fa9520..a196226 100644
---- a/include/type/notification.h
-+++ b/include/type/notification.h
-@@ -84,6 +84,7 @@ enum tcore_notification_command {
- TNOTI_SS_RELEASE_COMPLETE,
-
- TNOTI_MODEM = TCORE_NOTIFICATION | TCORE_TYPE_MODEM,
-+ TNOTI_MODEM_ADDED,
- TNOTI_MODEM_POWER,
- TNOTI_MODEM_FLIGHT_MODE,
- TNOTI_MODEM_DUN_PIN_CONTROL,
---
-1.7.10.4
-
+++ /dev/null
-From 5f313b36343eae686e0f630d1dc037513b4aac1e Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Thu, 4 Oct 2012 14:59:15 +0200
-Subject: [PATCH 07/10] at: Add Connect to success responses
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/at.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/src/at.c b/src/at.c
-index 00e40f9..c13d830 100644
---- a/src/at.c
-+++ b/src/at.c
-@@ -75,6 +75,7 @@ struct _notification {
- */
- static const char *list_final_responses_success[] = {
- "OK",
-+ "CONNECT",
- };
-
- /**
---
-1.7.10.4
-
+++ /dev/null
-From aef0af1166e2f7b6b3d53992774135891e379deb Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Thu, 4 Oct 2012 15:00:41 +0200
-Subject: [PATCH 08/10] hal: Add new setup_pdp entry point declaration and
- DATA mode
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- include/hal.h | 13 ++++++++++++-
- 1 file changed, 12 insertions(+), 1 deletion(-)
-
-diff --git a/include/hal.h b/include/hal.h
-index bed6684..1e8a072 100644
---- a/include/hal.h
-+++ b/include/hal.h
-@@ -26,6 +26,7 @@ __BEGIN_DECLS
- typedef void (*TcoreHalReceiveCallback)(TcoreHal *hal, unsigned int data_len, const void *data, void *user_data);
- typedef enum tcore_hook_return (*TcoreHalSendHook)(TcoreHal *hal, unsigned int data_len, void *data, void *user_data);
- typedef void (*TcoreHalPowerCallBack)(TcoreHal *hal, void *user_data);
-+typedef void (*TcoreHalSetupPDPCallBack)(CoreObject *co, const char *iname, void *user_data);
-
- enum tcore_hal_recv_data_type {
- TCORE_HAL_RECV_INDICATION,
-@@ -38,7 +39,8 @@ enum tcore_hal_mode {
- TCORE_HAL_MODE_UNKNOWN,
- TCORE_HAL_MODE_AT,
- TCORE_HAL_MODE_CUSTOM,
-- TCORE_HAL_MODE_TRANSPARENT
-+ TCORE_HAL_MODE_TRANSPARENT,
-+ TCORE_HAL_MODE_DATA,
- };
-
- struct tcore_hal_operations {
-@@ -47,6 +49,10 @@ struct tcore_hal_operations {
- TReturn (*send)(TcoreHal *hal, unsigned int data_len, void *data);
- TReturn (*set_sound_path)(TcoreHal *hal, int device);
- TReturn (*link_object_channel)(CoreObject *object);
-+ TReturn (*setup_pdp)(CoreObject *object,
-+ TcoreHalSetupPDPCallBack func,
-+ void *user_data,
-+ unsigned int cid);
- };
-
- TcoreHal* tcore_hal_new(TcorePlugin *plugin, const char *name,
-@@ -68,7 +74,12 @@ TReturn tcore_hal_set_sound_path(TcoreHal *hal, int device);
-
- TReturn tcore_hal_link_user_data(TcoreHal *hal, void *user_data);
- void* tcore_hal_ref_user_data(TcoreHal *hal);
-+
- TReturn tcore_hal_link_object(TcoreHal *hal, CoreObject *co);
-+TReturn tcore_hal_setup_pdp(TcoreHal *hal, CoreObject *co,
-+ TcoreHalSetupPDPCallBack func,
-+ void *user_data,
-+ unsigned int cid);
-
- TReturn tcore_hal_send_data(TcoreHal *hal, unsigned int data_len, void *data);
- TReturn tcore_hal_send_request(TcoreHal *hal, TcorePending *pending);
---
-1.7.10.4
-
+++ /dev/null
-From ef579dee232a6fdddaf08c537c548cfa2e9d0240 Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Thu, 4 Oct 2012 15:01:27 +0200
-Subject: [PATCH 09/10] hal: Add tcore_hal_setup_pdp definition and mana DATA
- mode
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/hal.c | 16 ++++++++++++++++
- 1 file changed, 16 insertions(+)
-
-diff --git a/src/hal.c b/src/hal.c
-index 9ade963..579d765 100644
---- a/src/hal.c
-+++ b/src/hal.c
-@@ -249,6 +249,16 @@ TReturn tcore_hal_link_object(TcoreHal *hal, CoreObject *co)
- return hal->ops->link_object_channel(co);
- }
-
-+TReturn tcore_hal_setup_pdp(TcoreHal *hal, CoreObject *co,
-+ TcoreHalSetupPDPCallBack func,
-+ void *user_data,
-+ unsigned int cid)
-+{
-+ if (!hal)
-+ return TCORE_RETURN_EINVAL;
-+
-+ return hal->ops->setup_pdp(co, func, user_data, cid);
-+}
- void *tcore_hal_ref_user_data(TcoreHal *hal)
- {
- if (!hal)
-@@ -356,6 +366,12 @@ TReturn tcore_hal_dispatch_response_data(TcoreHal *hal, int id,
-
- /* Invoke CMUX receive API for decoding */
- tcore_cmux_rcv_from_hal((unsigned char *)data, data_len);
-+ } else if (hal->mode == TCORE_HAL_MODE_DATA) {
-+ dbg("TCORE_HAL_MODE_DATA");
-+
-+ tcore_hal_emit_recv_callback(hal, data_len, data);
-+
-+ return TCORE_RETURN_SUCCESS;
- }
- /* Send next request in queue */
- g_idle_add_full(IDLE_SEND_PRIORITY, _hal_idle_send, hal, NULL );
---
-1.7.10.4
-
+++ /dev/null
-From 9c702353c5a38d8c0b45dfc6fe579644d5016479 Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Thu, 4 Oct 2012 15:01:59 +0200
-Subject: [PATCH 10/10] mux: Initialize setup_pdp entry point
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/mux.c | 9 +++++++++
- 1 file changed, 9 insertions(+)
-
-diff --git a/src/mux.c b/src/mux.c
-index 3794685..4cdaa67 100644
---- a/src/mux.c
-+++ b/src/mux.c
-@@ -230,12 +230,21 @@ static TReturn tcore_cmux_hal_set_sound_path(TcoreHal *hal, int device)
- return tcore_hal_set_sound_path(g_mux_obj_ptr->phy_hal, device);
- }
-
-+static TReturn hal_setup_pdp(CoreObject *co, TcoreHalSetupPDPCallBack func,
-+ void *user_data, unsigned int cid)
-+{
-+ /* Redirect request to physical HAL */
-+ return tcore_hal_setup_pdp(g_mux_obj_ptr->phy_hal, co, func,
-+ user_data, cid);
-+}
-+
- /* CMUX supported HAL (Logical HAL) operations */
- static struct tcore_hal_operations mux_hops = {
- .power = NULL,
- .send = tcore_cmux_hal_send,
- .set_sound_path = tcore_cmux_hal_set_sound_path,
- .link_object_channel = NULL,
-+ .setup_pdp = hal_setup_pdp,
- };
-
- static TReturn tcore_cmux_send_data(int data_len, unsigned char *data)
---
-1.7.10.4
-
#sbs-git:slp/pkgs/l/libtcore
Name: libtcore
Summary: Telephony-core library
-Version: 0.1.114
+Version: 0.1.212
Release: 1
Group: System/Libraries
License: Apache
Source0: libtcore-%{version}.tar.gz
-%ifarch %ix86
-%if "%{simulator}" != "1"
-patch0: 0001-hal-Add-set_sound_path-function.patch
-patch1: 0002-hal-Add-new-entry-points-and-method-declarations.patch
-patch2: 0003-hal-Add-new-method-definitions.patch
-patch3: 0004-mux-Declare-new-public-API-for-HAL-plugin-manipulati.patch
-patch4: 0005-mux-Remove-plateform-dependencies-from-core-multiple.patch
-patch5: 0006-notification-Add-new-notifcation-type.patch
-patch6: 0007-at-Add-Connect-to-success-responses.patch
-patch7: 0008-hal-Add-new-setup_pdp-entry-point-declaration-and-DA.patch
-patch8: 0009-hal-Add-tcore_hal_setup_pdp-definition-and-mana-DATA.patch
-patch9: 0010-mux-Initialize-setup_pdp-entry-point.patch
-%endif
-%endif
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: cmake
%prep
%setup -q
-%ifarch %ix86
-%if "%{simulator}" != "1"
-%patch0 -p1
-%patch1 -p1
-%patch2 -p1
-%patch3 -p1
-%patch4 -p1
-%patch5 -p1
-%patch6 -p1
-%patch7 -p1
-%patch8 -p1
-%patch9 -p1
-%endif
-%endif
%build
cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DVERSION=%{version}
#include "user_request.h"
#include "at.h"
-#define NUM_ELEMS(x) (sizeof(x)/sizeof(x[0]))
+#define NUM_ELEMS(x) (sizeof(x) / sizeof(x[0]))
#define CR '\r'
#define LF '\n'
#define MAX_AT_RESPONSE 255 // for testing
-//#define MAX_AT_RESPONSE 8191
+// #define MAX_AT_RESPONSE 8191
struct tcore_at_type {
TcoreHal *hal;
* See 27.007 annex B
*/
static const char *list_final_responses_success[] = {
- "OK",
+ "OK",
};
/**
* See 27.007 annex B
*/
static const char *list_final_responses_error[] = {
- "ERROR",
- "+CMS ERROR:",
- "+CME ERROR:",
- "NO ANSWER",
- "NO DIALTONE",
+ "ERROR",
+ "+CMS ERROR:",
+ "+CME ERROR:",
+ "NO ANSWER",
+ "NO DIALTONE",
};
static int _check_final_response(const char *line)
}
-static char *_find_next_EOL(char *cur)
+static char* _find_next_EOL(char *cur)
{
if (cur[0] == '>' && cur[1] == ' ' && cur[2] == '\0') {
/* SMS prompt character...not \r terminated */
}
// Find next newline
- while (*cur != '\0' && *cur != CR)
+ while (*cur != '\0' && !((*cur == CR) && (*(cur + 1) == LF))) // avoid issue when AT response is having <CR> in between before end of line( <CR> <LF>) or '/0'
cur++;
return *cur == '\0' ? NULL : cur;
static void _response_add(struct tcore_at_response *resp,
- const char *line)
+ const char *line)
{
if (!resp || !line)
return;
}
data = g_slist_append(NULL, g_strdup(line));
- }
- else {
+ } else {
noti = at->pdu_noti;
at->pdu_status = FALSE;
at->pdu_noti = NULL;
if (g_slist_length(noti->callbacks) == 0) {
g_hash_table_remove(at->unsolicited_table, key);
}
-
}
static void _free_noti_list(void *data)
static void _msgat(const char *prefix, const char *str)
{
unsigned int i;
- char buf[8192] = {0,};
+ char buf[8192] = {0, };
char *pos;
if (!str) {
if (str[i] == '\r') {
strncpy(pos, "<CR>", 4);
pos += 4;
- }
- else if (str[i] == '\n') {
+ } else if (str[i] == '\n') {
strncpy(pos, "<LF>", 4);
pos += 4;
- }
- else {
+ } else {
*pos = str[i];
pos++;
}
-
}
msg("%s[%s]", prefix, buf);
}
#endif
-TcoreAT *tcore_at_new(TcoreHal *hal)
+TcoreAT* tcore_at_new(TcoreHal *hal)
{
TcoreAT *at;
at->buf_read_pos = at->buf;
at->buf_write_pos = at->buf;
- at->unsolicited_table = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, _free_noti_list );
-
+ at->unsolicited_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _free_noti_list);
return at;
}
free(at);
}
-TReturn tcore_at_remove_notification_full(TcoreAT *at, const char *prefix,
- TcoreATNotificationCallback callback, void *user_data)
+TReturn tcore_at_remove_notification_full(TcoreAT *at, const char *prefix, TcoreATNotificationCallback callback, void *user_data)
{
struct _notification *noti;
struct _notification_callback *item;
return TCORE_RETURN_SUCCESS;
p = noti->callbacks;
- for(; p; p = p->next) {
+ for (; p; p = p->next) {
item = p->data;
if (!item)
continue;
}
-TReturn tcore_at_remove_notification(TcoreAT *at, const char *prefix,
- TcoreATNotificationCallback callback)
+TReturn tcore_at_remove_notification(TcoreAT *at, const char *prefix, TcoreATNotificationCallback callback)
{
return tcore_at_remove_notification_full(at, prefix, callback, NULL);
}
TReturn tcore_at_add_notification(TcoreAT *at, const char *prefix,
- gboolean pdu, TcoreATNotificationCallback callback,
- void *user_data)
+ gboolean pdu, TcoreATNotificationCallback callback,
+ void *user_data)
{
struct _notification *noti;
struct _notification_callback *item;
at->req->next_send_pos = end + 1;
dbg("next data = [%s]", at->req->next_send_pos);
- *(end+1) = '\0';
+ *(end + 1) = '\0';
ret = tcore_hal_send_data(at->hal, strlen(req->cmd), req->cmd);
- *(end+1) = next;
+ *(end + 1) = next;
return ret;
}
-TcoreATRequest *tcore_at_get_request(TcoreAT *at)
+TcoreATRequest* tcore_at_get_request(TcoreAT *at)
{
if (!at)
return NULL;
}
-TcoreATResponse *tcore_at_get_response(TcoreAT *at)
+TcoreATResponse* tcore_at_get_response(TcoreAT *at)
{
if (!at)
return NULL;
at->buf_read_pos = at->buf;
at->buf_write_pos = at->buf + write_pos - read_pos;
dbg("after read_pos=buf+%d, write_pos=buf+%d",
- at->buf_read_pos - at->buf,
- at->buf_write_pos - at->buf);
+ at->buf_read_pos - at->buf,
+ at->buf_write_pos - at->buf);
memset(at->buf_write_pos, 0, at->buf_size - (at->buf_write_pos - at->buf));
}
pos = at->buf_read_pos;
while (1) {
-
while (*pos == CR || *pos == LF)
pos++;
if (pos != next_pos)
*next_pos = '\0';
- //dbg("complete line found.");
+ // dbg("complete line found.");
dbg("line = [%s]", pos);
-
// check request
if (!at->req) {
_emit_unsolicited_message(at, pos);
- }
- else {
-
+ } else {
if (g_strcmp0(pos, "> ") == 0) {
if (at->req->next_send_pos) {
dbg("send next: [%s]", at->req->next_send_pos);
_emit_pending_response(at);
at->buf_read_pos = next_pos + 1;
return TRUE;
- }
- else {
+ } else {
switch (at->req->type) {
- case TCORE_AT_NO_RESULT:
- _emit_unsolicited_message(at, pos);
- break;
+ case TCORE_AT_NO_RESULT:
+ _emit_unsolicited_message(at, pos);
+ break;
- case TCORE_AT_NUMERIC:
- if (at->resp->lines == NULL && isdigit(pos[0])) {
- _response_add(at->resp, pos);
- }
- else {
- _emit_unsolicited_message(at, pos);
- }
+ case TCORE_AT_NUMERIC:
+ if (at->resp->lines == NULL && isdigit(pos[0])) {
+ _response_add(at->resp, pos);
+ } else {
+ _emit_unsolicited_message(at, pos);
+ }
- break;
-
- case TCORE_AT_SINGLELINE:
- if (at->resp->lines == NULL) {
- if (at->req->prefix) {
- if (g_str_has_prefix(pos, at->req->prefix)) {
- _response_add(at->resp, pos);
- }
- else {
- _emit_unsolicited_message(at, pos);
- }
- }
- else {
- _response_add(at->resp, pos);
- }
- }
- else {
- _emit_unsolicited_message(at, pos);
- }
- break;
+ break;
- case TCORE_AT_MULTILINE:
+ case TCORE_AT_SINGLELINE:
+ if (at->resp->lines == NULL) {
if (at->req->prefix) {
if (g_str_has_prefix(pos, at->req->prefix)) {
_response_add(at->resp, pos);
- }
- else {
+ } else {
_emit_unsolicited_message(at, pos);
}
+ } else {
+ _response_add(at->resp, pos);
}
- else {
+ } else {
+ _emit_unsolicited_message(at, pos);
+ }
+ break;
+
+ case TCORE_AT_MULTILINE:
+ if (at->req->prefix) {
+ if (g_str_has_prefix(pos, at->req->prefix)) {
_response_add(at->resp, pos);
+ } else {
+ _emit_unsolicited_message(at, pos);
}
- break;
+ } else {
+ _response_add(at->resp, pos);
+ }
+ break;
- case TCORE_AT_PDU:
- if (at->req->prefix) {
- if (g_str_has_prefix(pos, at->req->prefix)) {
+ case TCORE_AT_PDU:
+ if (at->req->prefix) {
+ if (g_str_has_prefix(pos, at->req->prefix)) {
+ _response_add(at->resp, pos);
+ } else {
+ if (at->resp->lines != NULL) {
_response_add(at->resp, pos);
+ } else {
+ _emit_unsolicited_message(at, pos);
}
- else {
- if (at->resp->lines != NULL) {
- _response_add(at->resp, pos);
- }
- else {
- _emit_unsolicited_message(at, pos);
- }
- }
- }
- else {
- _response_add(at->resp, pos);
}
- break;
+ } else {
+ _response_add(at->resp, pos);
+ }
+ break;
- default:
- dbg("unknown");
- _emit_unsolicited_message(at, pos);
- break;
+ default:
+ dbg("unknown");
+ _emit_unsolicited_message(at, pos);
+ break;
}
}
}
return FALSE;
}
-TcorePending *tcore_at_pending_new(CoreObject *co, const char *cmd, const char *prefix, enum tcore_at_command_type type, TcorePendingResponseCallback func, void *user_data)
+TcorePending* tcore_at_pending_new(CoreObject *co, const char *cmd, const char *prefix, enum tcore_at_command_type type, TcorePendingResponseCallback func, void *user_data)
{
TcorePending *p;
TcoreATRequest *req;
return p;
}
-#define TYPE_NONE 0
-#define TYPE_RAW 1
-#define TYPE_STR 2
-#define TYPE_STR_FIN 3
-#define TYPE_PAREN 4
-#define TYPE_PAREN_FIN 5
+#define TYPE_NONE 0
+#define TYPE_RAW 1
+#define TYPE_STR 2
+#define TYPE_STR_FIN 3
+#define TYPE_PAREN 4
+#define TYPE_PAREN_FIN 5
-GSList *tcore_at_tok_new(const char *line)
+GSList* tcore_at_tok_new(const char *line)
{
char *begin;
char *pos;
if (line[0] == '(') {
/* list token container */
- pos = (char *)line;
- if (line[strlen(line)-1] == ')')
- mark_end = (char *)line + strlen(line) - 1;
- }
- else {
+ pos = (char *) line;
+ if (line[strlen(line) - 1] == ')')
+ mark_end = (char *) line + strlen(line) - 1;
+ } else {
/* normal at message */
pos = strchr(line, ':');
if (!pos) {
case TYPE_NONE:
if (*pos == '"') {
type = TYPE_STR;
- }
- else if (*pos == ',') {
+ } else if (*pos == ',') {
tokens = g_slist_append(tokens, strdup(""));
- }
- else if (*pos == ' ') {
+ } else if (*pos == ' ') {
// skip
- }
- else if (*pos == '(') {
+ } else if (*pos == '(') {
type = TYPE_PAREN;
- }
- else {
+ } else {
type = TYPE_RAW;
}
begin = pos;
g_slist_free_full(tokens, g_free);
}
-char *tcore_at_tok_extract(const char *src)
+char* tcore_at_tok_extract(const char *src)
{
char *dest = NULL;
char *last = NULL;
if (strlen(src) < 2)
return g_strdup(src);
- last = (char *)src + strlen(src) - 1;
+ last = (char *) src + strlen(src) - 1;
switch (*src) {
- case '(':
- if (*last == ')') {
- dest = g_strdup(src + 1);
- dest[strlen(dest) - 1] = '\0';
- }
- break;
+ case '(':
+ if (*last == ')') {
+ dest = g_strdup(src + 1);
+ dest[strlen(dest) - 1] = '\0';
+ }
+ break;
- case '"':
- if (*last == '"') {
- dest = g_strdup(src + 1);
- dest[strlen(dest) - 1] = '\0';
- }
- break;
+ case '"':
+ if (*last == '"') {
+ dest = g_strdup(src + 1);
+ dest[strlen(dest) - 1] = '\0';
+ }
+ break;
- default:
- return g_strdup(src);
- break;
+ default:
+ return g_strdup(src);
+ break;
}
return dest;
}
-char *tcore_at_tok_nth(GSList *tokens, unsigned int token_index)
+char* tcore_at_tok_nth(GSList *tokens, unsigned int token_index)
{
if (!tokens)
return NULL;
if (token_index > g_slist_length(tokens))
return NULL;
- return (char *)g_slist_nth_data(tokens, token_index);
+ return (char *) g_slist_nth_data(tokens, token_index);
}
if (ps_context == s_context) {
dbg("find contexts(%p) in cid(%d)",
- ps_context, idx_cid);
+ ps_context, idx_cid);
return TRUE;
}
}
if (!po)
return TCORE_RETURN_EINVAL;
- if (!po->online) {
+ if (!po->online) {
dbg("ps network is not online !");
return TCORE_RETURN_PS_NETWORK_NOT_READY;
}
rv = _ps_is_duplicated_apn(o, ps_context);
if (rv) {
- dbg("context activation is already requested for the same apn(%s)",
+ dbg("context activation is already requested for the same apn(%s)",
tcore_context_get_apn(ps_context));
return TCORE_RETURN_SUCCESS;
}
TReturn tcore_ps_deactivate_contexts(CoreObject *o)
{
+ GSList *contexts = NULL;
+ CoreObject *context = NULL;
int index = 0;
struct private_object_data *po = NULL;
for (index = 0; index < PS_MAX_CID; index++) {
if (po->cid[index].cid != 0) {
- GSList *contexts = NULL;
contexts = po->cid[index].contexts;
if (contexts == NULL)
continue;
for (; contexts != NULL; contexts = g_slist_next(contexts)) {
- CoreObject *context = NULL;
context = contexts->data;
if (context == NULL)
continue;
}
co->hal = hal;
- if (!hal)
+ if (hal == NULL)
return TCORE_RETURN_SUCCESS;
// register unsolicited callbacks
struct cmux_channel_object cmux_channel_core_object[] = {
{"channel_0", {"control", NULL, NULL}},
{"channel_1", {"call", NULL, NULL}},
- {"channel_2", {"sim", NULL, NULL}},
- {"channel_3", {"sat", NULL, NULL}},
+ {"channel_2", {"sim", "phonebook", NULL}},
+ {"channel_3", {"sat", "sap", NULL}},
{"channel_4", {"umts_sms", NULL, NULL}},
{"channel_5", {"ss", NULL, NULL}},
- {"channel_6", {"umts_network", NULL, NULL}},
+ {"channel_6", {"umts_network", "gps", NULL}},
{"channel_7", {"modem", "umts_ps", NULL}},
};
tmp = g_hash_table_lookup(strg->callback, key_gen);
if (tmp != NULL) {
- GSList *cb_data = (GSList *) tmp;
+ GSList *cb_data = (GSList *)tmp;
- for (; cb_data != NULL; cb_data = g_slist_next(cb_data)) {
+ do {
tmp_cb = cb_data->data;
tmp_cb->cb_fn(key, value, tmp_cb->user_data);
cb_data = g_slist_next(cb_data);
- }
+ } while (cb_data != NULL);
}
g_free(key_gen);