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 "s_network.h"
43 #include "s_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;
73 dbg("Last Subscription - COMPLETED");
81 dbg("Boot-up configration completed for IMC modem. %s",
82 "Bring CP to ONLINE state based on Flightmode status");
83 ret = modem_power_on(tcore_pending_ref_plugin(p));
84 dbg("Modem Power ON: [%s]", (ret == TRUE ? "SUCCESS" : "FAIL"));
87 static void _modem_subscribe_events(TcorePlugin *plugin)
89 CoreObject *co_call = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL);
90 CoreObject *co_sim = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SIM);
91 CoreObject *co_sms = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SMS);
92 CoreObject *co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
93 CoreObject *co_ps = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_PS);
94 CoreObject *co_sap = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SAP);
95 CoreObject *co_gps = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_GPS);
99 /* URC Subscriptions per Module */
101 /****** SIM subscriptions ******/
103 tcore_prepare_and_send_at_request(co_sim, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
104 on_response_bootup_subscription, NULL,
105 on_confirmation_modem_message_send, NULL);
107 /****** CALL subscriptions ******/
109 tcore_prepare_and_send_at_request(co_call, "at+xcallstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
110 on_response_bootup_subscription, NULL,
111 on_confirmation_modem_message_send, NULL);
114 tcore_prepare_and_send_at_request(co_call, "at+cssn=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
115 on_response_bootup_subscription, NULL,
116 on_confirmation_modem_message_send, NULL);
119 tcore_prepare_and_send_at_request(co_call, "at+cusd=1", NULL, TCORE_AT_NO_RESULT, NULL,
120 on_response_bootup_subscription, NULL,
121 on_confirmation_modem_message_send, NULL);
124 tcore_prepare_and_send_at_request(co_call, "at+clip=1", NULL, TCORE_AT_NO_RESULT, NULL,
125 on_response_bootup_subscription, NULL,
126 on_confirmation_modem_message_send, NULL);
128 /****** NETWORK subscriptions ******/
130 tcore_prepare_and_send_at_request(co_network, "at+creg=2", NULL, TCORE_AT_NO_RESULT, NULL,
131 on_response_bootup_subscription, NULL,
132 on_confirmation_modem_message_send, NULL);
135 tcore_prepare_and_send_at_request(co_network, "at+cgreg=2", NULL, TCORE_AT_NO_RESULT, NULL,
136 on_response_bootup_subscription, NULL,
137 on_confirmation_modem_message_send, NULL);
139 /* Allow Automatic Time Zone updation via NITZ */
140 tcore_prepare_and_send_at_request(co_network, "at+ctzu=1", NULL, TCORE_AT_NO_RESULT, NULL,
141 on_response_bootup_subscription, NULL,
142 on_confirmation_modem_message_send, NULL);
144 /* TZ, Time & Daylight changing event reporting Subscription */
145 tcore_prepare_and_send_at_request(co_network, "at+ctzr=1", NULL, TCORE_AT_NO_RESULT, NULL,
146 on_response_bootup_subscription, NULL,
147 on_confirmation_modem_message_send, NULL);
150 tcore_prepare_and_send_at_request(co_network, "at+xmer=1", NULL, TCORE_AT_NO_RESULT, NULL,
151 on_response_bootup_subscription, NULL,
152 on_confirmation_modem_message_send, NULL);
154 /****** PS subscriptions ******/
156 tcore_prepare_and_send_at_request(co_ps, "at+cgerep=1", NULL, TCORE_AT_NO_RESULT, NULL,
157 on_response_bootup_subscription, NULL,
158 on_confirmation_modem_message_send, NULL);
161 tcore_prepare_and_send_at_request(co_ps, "at+xdatastat=1", NULL, TCORE_AT_NO_RESULT, NULL,
162 on_response_bootup_subscription, NULL,
163 on_confirmation_modem_message_send, NULL);
167 tcore_prepare_and_send_at_request(co_ps, "at+xdns=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
168 on_response_bootup_subscription, NULL,
169 on_confirmation_modem_message_send, NULL);
172 tcore_prepare_and_send_at_request(co_ps, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL,
173 on_response_bootup_subscription, NULL,
174 on_confirmation_modem_message_send, NULL);
176 /****** SMS subscriptions ******/
178 tcore_prepare_and_send_at_request(co_sms, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL,
179 on_response_bootup_subscription, NULL,
180 on_confirmation_modem_message_send, NULL);
182 /* Incoming SMS, Cell Broadcast, Status Report Subscription */
183 tcore_prepare_and_send_at_request(co_sms, "at+cnmi=1,2,2,1,0", NULL, TCORE_AT_NO_RESULT, NULL,
184 on_response_bootup_subscription, NULL,
185 on_confirmation_modem_message_send, NULL);
187 /* Text/PDU mode Subscription */
188 tcore_prepare_and_send_at_request(co_sms, "at+cmgf=0", NULL, TCORE_AT_NO_RESULT, NULL,
189 on_response_bootup_subscription, NULL,
190 on_confirmation_modem_message_send, NULL);
192 /****** GPS subscriptions ******/
193 /* AGPS- Assist Data and Reset Assist Data Subscription */
194 tcore_prepare_and_send_at_request(co_gps, "at+cposr=1", NULL, TCORE_AT_NO_RESULT, NULL,
195 on_response_bootup_subscription, NULL,
196 on_confirmation_modem_message_send, NULL);
198 tcore_prepare_and_send_at_request(co_gps, "at+xcposr=1", NULL, TCORE_AT_NO_RESULT, NULL,
199 on_response_bootup_subscription, NULL,
200 on_confirmation_modem_message_send, NULL);
202 /****** SAP subscriptions ******/
204 tcore_prepare_and_send_at_request(co_sap, "at+xbcstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
205 on_response_last_bootup_subscription, NULL,
206 on_confirmation_modem_message_send, NULL);
211 /* Initializer Table */
212 struct object_initializer init_table = {
213 .modem_init = s_modem_init,
214 .sim_init = s_sim_init,
215 .sat_init = s_sat_init,
216 .sap_init = s_sap_init,
217 .network_init = s_network_init,
218 .ps_init = s_ps_init,
219 .call_init = s_call_init,
220 .ss_init = s_ss_init,
221 .sms_init = s_sms_init,
222 .phonebook_init = s_phonebook_init,
223 .gps_init = s_gps_init,
226 /* Deinitializer Table */
227 struct object_deinitializer deinit_table = {
228 .modem_deinit = s_modem_exit,
229 .sim_deinit = s_sim_exit,
230 .sat_deinit = s_sat_exit,
231 .sap_deinit = s_sap_exit,
232 .network_deinit = s_network_exit,
233 .ps_deinit = s_ps_exit,
234 .call_deinit = s_call_exit,
235 .ss_deinit = s_ss_exit,
236 .sms_deinit = s_sms_exit,
237 .phonebook_deinit = s_phonebook_exit,
238 .gps_deinit = s_gps_exit,
241 static gboolean on_load()
248 static gboolean on_init(TcorePlugin *p)
254 /* Initialize Modules (Core Objects) */
255 if (tcore_object_init_objects(p, &init_table)
256 != TCORE_RETURN_SUCCESS) {
257 err("Failed to initialize Core Objects");
261 /* Subscribe for the Events from CP */
262 _modem_subscribe_events(p);
264 dbg("Init - Successful");
268 static void on_unload(TcorePlugin *p)
275 /* Deinitialize Modules (Core Objects) */
276 tcore_object_deinit_objects(p, &deinit_table);
279 /* IMC - Modem Plug-in Descriptor */
280 struct tcore_plugin_define_desc plugin_define_desc = {
282 .priority = TCORE_PLUGIN_PRIORITY_MID,