static void prepare_and_send_pending_request(CoreObject *co, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, TcorePendingResponseCallback callback);
-static void on_confirmation_modem_message_send(TcorePending *p, gboolean result, void *user_data); // from Kernel
-void on_response_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data);
-void on_response_last_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data);
+static void on_confirmation_modem_message_send(TcorePending *p, gboolean result, void *user_data);
+static void on_response_network_registration(TcorePending *p, int data_len, const void *data, void *user_data);
static void on_response_enable_proactive_command(TcorePending *p, int data_len, const void *data, void *user_data);
static void on_confirmation_modem_message_send(TcorePending *p, gboolean result, void *user_data)
}
}
+static void on_response_network_registration(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ const TcoreATResponse *resp = data;
+
+ if (resp->success > 0) {
+ dbg("registration attempt OK");
+ } else {
+ dbg("registration attempt failed");
+ }
+}
+
void prepare_and_send_pending_request(CoreObject *co, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, TcorePendingResponseCallback callback)
{
TcoreATRequest *req = NULL;
if (resp->lines) {
line = (const char *) resp->lines->data;
tokens = tcore_at_tok_new(line);
- if (g_slist_length(tokens) != 5) {
+ if (g_slist_length(tokens) == 1) {
+ swver = g_slist_nth_data(tokens, 0);
+ dbg("version: sw=[%s]", swver);
+ } else if (g_slist_length(tokens) == 5) {
+ swver = g_slist_nth_data(tokens, 0);
+ hwver = g_slist_nth_data(tokens, 1);
+ caldate = g_slist_nth_data(tokens, 2);
+ pcode = g_slist_nth_data(tokens, 3);
+ id = g_slist_nth_data(tokens, 4);
+
+ dbg("version: sw=[%s], hw=[%s], rf_cal=[%s], product_code=[%s], model_id=[%s]", swver, hwver, caldate, pcode, id);
+ } else {
msg("invalid message");
goto OUT;
}
}
- swver = g_slist_nth_data(tokens, 0);
- hwver = g_slist_nth_data(tokens, 1);
- caldate = g_slist_nth_data(tokens, 2);
- pcode = g_slist_nth_data(tokens, 3);
- id = g_slist_nth_data(tokens, 4);
-
- dbg("version: sw=[%s], hw=[%s], rf_cal=[%s], product_code=[%s], model_id=[%s]", swver, hwver, caldate, pcode, id);
-
vi = calloc(sizeof(TelMiscVersionInformation), 1);
if (NULL != swver)
memcpy(vi->szSwVersion, swver, strlen(swver));
return;
}
-static gboolean on_event_bootup_sim_status(CoreObject *o, const void *event_info, void *user_data)
+static enum tcore_hook_return on_hook_sim_status(Server *s, CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
{
- GSList *tok = NULL;
- GSList *lines = NULL;
- int value = -1;
- char *line = NULL;
-
- lines = (GSList *) event_info;
- if (1 != g_slist_length(lines)) {
- dbg("unsolicited msg but multiple line");
- goto OUT;
+ const struct tnoti_sim_status *sim = data;
+ CoreObject *co_sat;
+ CoreObject *co_network;
+ TcorePlugin *plugin = tcore_object_ref_plugin(source);
+
+ co_sat = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SAT);
+ co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
+
+ if (sim->sim_status == SIM_STATUS_INIT_COMPLETED) {
+ dbg("SIM ready for attach");
+ dbg("Enable STK and Fetching of proactive Commands");
+ prepare_and_send_pending_request(co_sat, "AT+CFUN=6", NULL, TCORE_AT_NO_RESULT, on_response_enable_proactive_command);
+ prepare_and_send_pending_request(co_network, "AT+COPS=0", NULL, TCORE_AT_NO_RESULT, on_response_network_registration);
}
- line = (char *) (lines->data);
- dbg("on_bootup_event_sim_status notification : %s", line);
-
- tok = tcore_at_tok_new(line);
- value = atoi(g_slist_nth_data(tok, 0));
-
- if (7 == value) {
- dbg("SIM ready. request COPS & remove callback");
- dbg("power on done set for proactive command receiving mode");
- prepare_and_send_pending_request(o, "AT+CFUN=6", NULL, TCORE_AT_NO_RESULT, on_response_enable_proactive_command);
- prepare_and_send_pending_request(o, "AT+COPS=0", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
- return FALSE;
- }
-
-OUT:
- if (tok != NULL)
- tcore_at_tok_free(tok);
- return TRUE;
+ return TCORE_HOOK_RETURN_CONTINUE;
}
-
-
gboolean modem_power_on(TcorePlugin *p)
{
CoreObject *co_modem = NULL;
sn_property = g_try_new0(TelMiscSNInformation, 1);
tcore_plugin_link_property(cp, "SN", sn_property);
- dbg("Registering for +XSIM event");
- tcore_object_override_callback(co_modem, "+XSIM", on_event_bootup_sim_status, NULL);
+ tcore_server_add_notification_hook(tcore_plugin_ref_server(cp), TNOTI_SIM_STATUS, on_hook_sim_status, co_modem);
dbg("Exit");