1 From 658e94ca29da1e7fc52b036a4dc231db1500f3ff Mon Sep 17 00:00:00 2001
2 From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
3 Date: Mon, 8 Oct 2012 15:42:12 +0200
4 Subject: [PATCH 15/23] Change the way imc plugin is initialized
5 Content-Type: text/plain; charset="utf-8"
6 Content-Transfer-Encoding: 8bit
12 src/desc.c | 90 ++++++++++++++++++---------------------------------------
13 src/s_modem.c | 69 +------------------------------------------
14 2 files changed, 29 insertions(+), 130 deletions(-)
16 diff --git a/src/desc.c b/src/desc.c
17 index 7a5ef93..0cf4542 100644
24 -static int cp_count = 0;
26 -#define MAX_CP_QUERY_COUNT 60
28 -static gboolean _query_cp_state(gpointer data)
30 - gboolean power_state = FALSE;
31 - TcorePlugin *p = NULL;
32 - CoreObject* obj = NULL;
35 - p = (TcorePlugin*)data;
37 - if(cp_count > MAX_CP_QUERY_COUNT){
38 - dbg("cp query counter exceeds MAX_CP_QUERY_COUNT");
41 - obj = tcore_plugin_ref_core_object(p, "modem");
42 - h = tcore_object_get_hal(obj);
43 - power_state = tcore_hal_get_power_state(h);
45 - if(TRUE == power_state){
47 - s_modem_send_poweron(p);
51 - dbg("CP NOT READY, cp_count :%d", cp_count);
57 -static enum tcore_hook_return on_hal_send(TcoreHal *hal, unsigned int data_len, void *data, void *user_data)
59 - hook_hex_dump(TX, data_len, data);
60 - return TCORE_HOOK_RETURN_CONTINUE;
63 -static void on_hal_recv(TcoreHal *hal, unsigned int data_len, const void *data, void *user_data)
65 - msg("=== RX data DUMP =====");
66 - util_hex_dump(" ", data_len, data);
67 - msg("=== RX data DUMP =====");
70 static gboolean on_load()
72 @@ -126,7 +81,7 @@ static int _get_cp_name(char **name)
73 dbg("u.__domainname : [ %s ]", u.__domainname);
74 dbg("u.machine : [ %s ]", u.machine);
75 dbg("u.release : [ %s ]", u.release);
76 - dbg("u.sysname : [ %s ]", u.sysname);S
77 + dbg("u.sysname : [ %s ]", u.sysname);
78 dbg("u.version : [ %s ]", u.version);
80 /* By default, SUNRISE IMC modem is returned */
81 @@ -165,11 +120,35 @@ static int _get_cp_name(char **name)
85 +static void on_hal_set_power(TcoreHal *hal, void *user_data)
87 + TcorePlugin *p = user_data;
92 + s_modem_init(p, hal);
95 + s_network_init(p, hal);
97 + s_call_init(p, hal);
100 + s_gps_init(p, hal);
102 + o = tcore_plugin_ref_core_object(p, "modem");
103 + tcore_server_send_notification(tcore_plugin_ref_server(p), o, TNOTI_MODEM_ADDED, 0, NULL);
105 + s_modem_send_poweron(p);
110 static gboolean on_init(TcorePlugin *p)
113 struct global_data *gd;
114 - // char *cp_name = 0;
118 @@ -208,25 +187,12 @@ static gboolean on_init(TcorePlugin *p)
120 tcore_plugin_link_user_data(p, gd);
122 - tcore_hal_add_send_hook(h, on_hal_send, p);
123 - tcore_hal_add_recv_callback(h, on_hal_recv, p);
126 - s_modem_init(p, h);
129 - s_network_init(p, h);
134 - s_phonebook_init(p, h);
136 + tcore_hal_set_power(h, TRUE, on_hal_set_power, p);
140 - tcore_hal_set_power(h, TRUE);
141 - //wait until CP is ready
142 - g_timeout_add_full(G_PRIORITY_HIGH,500,_query_cp_state, p, 0 );
146 diff --git a/src/s_modem.c b/src/s_modem.c
147 index 6212467..47c6c63 100644
150 @@ -616,69 +616,6 @@ static void _modem_subscribe_events(TcorePlugin *plugin)
155 -static void on_response_setupmux(TcorePending *p, int data_len, const void *data, void *user_data)
157 - TcorePlugin *plugin = NULL;
158 - TcoreHal *hal = NULL;
162 - /* IMC Plugin dereferenced from pending request */
163 - plugin = tcore_pending_ref_plugin(p);
165 - /* Actual HAL - like svnet(2) */
166 - hal = (TcoreHal *) user_data;
168 - /* Initialize CMUX */
169 - ret = tcore_cmux_init(plugin, hal);
170 - if (TCORE_RETURN_SUCCESS == ret) {
171 - dbg("Successfully initialized CMUX");
173 - err("Failed to initialize CMUX");
182 -static void setup_mux(CoreObject *o)
184 - TcoreHal *hal = NULL;
185 - TcorePending *pending = NULL;
188 - /* HAL has type itself,
189 - * e.g.) TCORE_HAL_MODE_AT
191 - hal = tcore_object_get_hal(o);
193 - pending = tcore_at_pending_new(o, "AT+CMUX=0,0,,1509,10,3,30,,", "+CMUX", TCORE_AT_NO_RESULT, on_response_setupmux, hal);
195 - tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
197 - /* Send callback */
198 - tcore_hal_send_request(hal, pending);
205 -static gboolean on_event_mux_channel_up(CoreObject *o, const void *event_info, void *user_data)
207 - TcorePlugin *plugin = NULL;
210 - plugin = (TcorePlugin *) user_data;
211 - _modem_subscribe_events(plugin);
217 static void on_response_enable_logging(TcorePending *p, int data_len, const void *data, void *user_data)
219 const TcoreATResponse *resp = data;
220 @@ -700,8 +637,7 @@ static void on_response_enable_logging(TcorePending *p, int data_len, const void
221 dbg("Enabling CP logging is failed !!!\n");
224 - dbg("Calling setup_mux");
225 - setup_mux(tcore_pending_ref_core_object(p));
226 + _modem_subscribe_events(plugin);
228 /* sets the powersaving-mode */
229 prepare_and_send_pending_request(plugin, "modem", "at+xpow=0,0,0", NULL, TCORE_AT_NO_RESULT, NULL);
230 @@ -961,9 +897,6 @@ gboolean s_modem_init(TcorePlugin *p, TcoreHal *h)
231 sn_property = calloc(sizeof(TelMiscSNInformation), 1);
232 tcore_plugin_link_property(p, "SN", sn_property);
234 - dbg("Registerind for CMUX-UP event");
235 - tcore_object_add_callback(o, "CMUX-UP", on_event_mux_channel_up, p);
237 dbg("Registering for +XSIM event");
238 tcore_object_add_callback(o, "+XSIM", on_event_bootup_sim_status, NULL);