4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hayoon Ko <hayoon.ko@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
24 #include <sys/utsname.h>
29 #include <core_object.h>
34 #include "imc_network.h"
35 #include "imc_modem.h"
43 #include "imc_phonebook.h"
46 static void on_confirmation_modem_message_send(TcorePending *p,
50 dbg("msg out from queue");
52 dbg("%s", result == FALSE ? "SEND FAIL" : "SEND OK");
55 static void on_response_bootup_subscription(TcorePending *p,
56 int data_len, const void *data, void *user_data)
58 const TcoreATResponse *resp = data;
61 if (resp->success > 0) {
64 err("RESULT - ERROR");
68 static void on_response_last_bootup_subscription(TcorePending *p,
69 int data_len, const void *data, void *user_data)
71 const TcoreATResponse *resp = data;
72 TcorePlugin *plugin = tcore_pending_ref_plugin(p);
74 dbg("Last Subscription - COMPLETED");
82 dbg("Boot-up configration completed for IMC modem. %s",
83 "Bring CP to ONLINE state based on Flightmode status");
86 ret = modem_power_on(plugin);
87 dbg("Modem Power ON: [%s]", (ret == TRUE ? "SUCCESS" : "FAIL"));
89 /* NVM Registration */
90 dbg("Registering modem for NVM manager");
91 modem_register_nvm(tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_MODEM));
94 static void _modem_subscribe_events(TcorePlugin *plugin)
96 CoreObject *co_call = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL);
97 CoreObject *co_sim = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SIM);
98 CoreObject *co_sms = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SMS);
99 CoreObject *co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
100 CoreObject *co_ps = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_PS);
101 CoreObject *co_sap = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SAP);
102 CoreObject *co_gps = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_GPS);
106 /* URC Subscriptions per Module */
108 /****** SIM subscriptions ******/
110 tcore_prepare_and_send_at_request(co_sim, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
111 on_response_bootup_subscription, NULL,
112 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
114 /****** CALL subscriptions ******/
116 tcore_prepare_and_send_at_request(co_call, "at+xcallstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
117 on_response_bootup_subscription, NULL,
118 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
121 tcore_prepare_and_send_at_request(co_call, "at+cssn=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
122 on_response_bootup_subscription, NULL,
123 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
126 tcore_prepare_and_send_at_request(co_call, "at+cusd=1", NULL, TCORE_AT_NO_RESULT, NULL,
127 on_response_bootup_subscription, NULL,
128 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
131 tcore_prepare_and_send_at_request(co_call, "at+clip=1", NULL, TCORE_AT_NO_RESULT, NULL,
132 on_response_bootup_subscription, NULL,
133 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
135 /****** NETWORK subscriptions ******/
137 tcore_prepare_and_send_at_request(co_network, "at+creg=2", NULL, TCORE_AT_NO_RESULT, NULL,
138 on_response_bootup_subscription, NULL,
139 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
142 tcore_prepare_and_send_at_request(co_network, "at+cgreg=2", NULL, TCORE_AT_NO_RESULT, NULL,
143 on_response_bootup_subscription, NULL,
144 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
146 /* Allow Automatic Time Zone updation via NITZ */
147 tcore_prepare_and_send_at_request(co_network, "at+ctzu=1", NULL, TCORE_AT_NO_RESULT, NULL,
148 on_response_bootup_subscription, NULL,
149 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
151 /* TZ, Time & Daylight changing event reporting Subscription */
152 tcore_prepare_and_send_at_request(co_network, "at+ctzr=1", NULL, TCORE_AT_NO_RESULT, NULL,
153 on_response_bootup_subscription, NULL,
154 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
157 tcore_prepare_and_send_at_request(co_network, "at+xmer=1", NULL, TCORE_AT_NO_RESULT, NULL,
158 on_response_bootup_subscription, NULL,
159 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
161 /****** PS subscriptions ******/
163 tcore_prepare_and_send_at_request(co_ps, "at+cgerep=1", NULL, TCORE_AT_NO_RESULT, NULL,
164 on_response_bootup_subscription, NULL,
165 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
168 tcore_prepare_and_send_at_request(co_ps, "at+xdatastat=1", NULL, TCORE_AT_NO_RESULT, NULL,
169 on_response_bootup_subscription, NULL,
170 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
174 tcore_prepare_and_send_at_request(co_ps, "at+xdns=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
175 on_response_bootup_subscription, NULL,
176 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
179 tcore_prepare_and_send_at_request(co_ps, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL,
180 on_response_bootup_subscription, NULL,
181 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
183 /****** SMS subscriptions ******/
185 tcore_prepare_and_send_at_request(co_sms, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL,
186 on_response_bootup_subscription, NULL,
187 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
189 /* Incoming SMS, Cell Broadcast, Status Report Subscription */
190 tcore_prepare_and_send_at_request(co_sms, "at+cnmi=1,2,2,1,0", NULL, TCORE_AT_NO_RESULT, NULL,
191 on_response_bootup_subscription, NULL,
192 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
194 /* Text/PDU mode Subscription */
195 tcore_prepare_and_send_at_request(co_sms, "at+cmgf=0", NULL, TCORE_AT_NO_RESULT, NULL,
196 on_response_bootup_subscription, NULL,
197 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
199 /****** GPS subscriptions ******/
200 /* AGPS- Assist Data and Reset Assist Data Subscription */
201 tcore_prepare_and_send_at_request(co_gps, "at+cposr=1", NULL, TCORE_AT_NO_RESULT, NULL,
202 on_response_bootup_subscription, NULL,
203 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
205 tcore_prepare_and_send_at_request(co_gps, "at+xcposr=1", NULL, TCORE_AT_NO_RESULT, NULL,
206 on_response_bootup_subscription, NULL,
207 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
209 /****** SAP subscriptions ******/
211 tcore_prepare_and_send_at_request(co_sap, "at+xbcstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
212 on_response_last_bootup_subscription, NULL,
213 on_confirmation_modem_message_send, NULL, 0, NULL, NULL);
218 /* Initializer Table */
219 struct object_initializer init_table = {
220 .modem_init = imc_modem_init,
221 .sim_init = imc_sim_init,
222 .sat_init = imc_sat_init,
223 .sap_init = imc_sap_init,
224 .network_init = imc_network_init,
225 .ps_init = imc_ps_init,
226 .call_init = imc_call_init,
227 .ss_init = imc_ss_init,
228 .sms_init = imc_sms_init,
229 .phonebook_init = imc_phonebook_init,
230 .gps_init = imc_gps_init,
233 /* Deinitializer Table */
234 struct object_deinitializer deinit_table = {
235 .modem_deinit = imc_modem_exit,
236 .sim_deinit = imc_sim_exit,
237 .sat_deinit = imc_sat_exit,
238 .sap_deinit = imc_sap_exit,
239 .network_deinit = imc_network_exit,
240 .ps_deinit = imc_ps_exit,
241 .call_deinit = imc_call_exit,
242 .ss_deinit = imc_ss_exit,
243 .sms_deinit = imc_sms_exit,
244 .phonebook_deinit = imc_phonebook_exit,
245 .gps_deinit = imc_gps_exit,
248 static gboolean on_load()
255 static gboolean on_init(TcorePlugin *p)
261 /* Initialize Modules (Core Objects) */
262 if (tcore_object_init_objects(p, &init_table)
263 != TCORE_RETURN_SUCCESS) {
264 err("Failed to initialize Core Objects");
268 /* Subscribe for the Events from CP */
269 _modem_subscribe_events(p);
271 dbg("Init - Successful");
275 static void on_unload(TcorePlugin *p)
282 /* Deinitialize Modules (Core Objects) */
283 tcore_object_deinit_objects(p, &deinit_table);
286 /* IMC - Modem Plug-in Descriptor */
287 struct tcore_plugin_define_desc plugin_define_desc = {
289 .priority = TCORE_PLUGIN_PRIORITY_MID,