#ifndef __S_CALL_H__
#define __S_CALL_H__
-gboolean s_call_init(TcorePlugin *p, TcoreHal *h);
-void s_call_exit(TcorePlugin *p);
+gboolean s_call_init(TcorePlugin *cp, CoreObject *co_call);
+void s_call_exit(TcorePlugin *cp, CoreObject *co_call);
#endif
#ifndef __S_COMMON_H__
#define __S_COMMON_H__
-#include <tcore.h>
#include <glib.h>
-#include <user_request.h>
-#define EVENT_SYS_NOTI_MODEM_POWER "system_power"
-#define EVENT_NOTI_MODEM_POWER "modem_power"
-#define EVENT_NOTI_MODEM_PHONE_STATE "modem_phone_state"
-#define EVENT_NOTI_MODEM_PIN_CTRL "ps_pin_control"
-
-#define EVENT_NOTI_CALL_STATUS "call_status"
-#define EVENT_NOTI_CALL_INCOMING "call_incoming"
-#define EVENT_NOTI_CALL_WAITING "call_waiting"
-#define EVENT_NOTI_CALL_SOUND_WBAMR_REPORT "call_sound_wbamr_report"
-#define EVENT_NOTI_CALL_SOUND_TWO_MIC "call_sound_two_mic"
-#define EVENT_NOTI_CALL_SOUND_DHA "call_sound_dha"
-
-#define EVENT_NOTI_SS_INFO "ss_info"
-#define EVENT_NOTI_SS_USSD "ss_ussd"
-
-#define EVENT_NOTI_PS_CALL_STATUS "ps_call_status"
-#define EVENT_NOTI_PS_DATA_COUNTER "ps_data_counter"
-#define EVENT_NOTI_PS_IPCONFIGURATION "ps_ipconfiguration"
-#define EVENT_NOTI_PS_HSDPA_STATUS "ps_hsdpa_status"
-#define EVENT_NOTI_PS_ATTACH_DETACH "ps_attach_detach"
-#define EVENT_NOTI_PS_EXTERNAL_CALL "ps_external_call"
-
-#define EVENT_NOTI_SAP_STATUS "sap_status"
-#define EVENT_NOTI_SAP_DISCONNECT "sap_disconnect"
-
-#define EVENT_NOTI_SIM_PIN_STATUS "sim_pin_status"
-
-#define EVENT_NOTI_SAT_ENVELOPE_RESP "sat_envelope_response"
-#define EVENT_NOTI_SAT_REFRESH_STATUS "sat_refresh_status"
-#define EVENT_NOTI_SAT_PROACTIVE_COMMAND "sat_proactive_command"
-#define EVENT_NOTI_SAT_CONTROL_RESULT "sat_control_result"
-
-#define EVENT_NOTI_NETWORK_REGISTRATION "network_regist"
-#define EVENT_NOTI_NETWORK_ICON_INFO "network_icon_info"
-#define EVENT_NOTI_NETWORK_TIME_INFO "network_time_info"
-#define EVENT_NOTI_NETWORK_IDENTITY "network_identity"
-
-#define EVENT_NOTI_SMS_INCOM_MSG "sms_incom_msg"
-#define EVENT_NOTI_SMS_SEND_ACK "sms_send_ack"
-#define EVENT_NOTI_SMS_MEMORY_STATUS "sms_memory_status"
-#define EVENT_NOTI_SMS_CB_INCOM_MSG "sms_cb_incom_msg"
-#define EVENT_NOTI_SMS_DELETE_MSG_CNF "sms_delete_msg_cnf"
-#define EVENT_NOTI_SMS_WRITE_MSG_CNF "sms_write_msg_cnf"
-#define EVENT_NOTI_SMS_DELIVERY_RPT_CNF "sms_deliver_rpt_cnf"
-#define EVENT_NOTI_SMS_DEVICE_READY "sms_device_ready"
-
-#define EVENT_NOTI_PHONEBOOK_STATUS "phonebook_status"
-#define EVENT_NOTI_PHONEBOOK_FIRST_INDEX "phonebook_first_index"
-
-#define EVENT_NOTI_GPS_ASSIST_DATA "gps_assist_data"
-#define EVENT_IND_GPS_MEASURE_POSITION "gps_measure_position"
-#define EVENT_NOTI_RESET_ASSIST_DATA "gps_reset_assist_data"
-
-enum direction_e {
- RX,
- TX
-};
-
-struct global_data {
- unsigned int msg_auto_id_current;
- unsigned int msg_auto_id_start;
- unsigned int msg_auto_id_end;
-
- TcoreHal *hal;
-};
-
-struct work_queue_data {
- unsigned int id;
- UserRequest *ur;
-};
-
-#define UTIL_ID(hdr) ((hdr).main_cmd << 8 | (hdr).sub_cmd)
-#define UTIL_IDP(hdr) ((hdr)->main_cmd << 8 | (hdr)->sub_cmd)
-
-void hook_hex_dump(enum direction_e d, int size, const void *data);
-unsigned int util_assign_message_sequence_id(TcorePlugin *p);
-gboolean util_add_waiting_job(GQueue *queue, unsigned int id, UserRequest *ur);
-UserRequest* util_pop_waiting_job(GQueue *queue, unsigned int id);
void util_hex_dump(char *pad, int size, const void *data);
unsigned char util_hexCharToInt(char c);
char* util_hexStringToBytes(char *s);
#ifndef __S_GPS_H__
#define __S_GPS_H__
-gboolean s_gps_init(TcorePlugin *p, TcoreHal *h);
-void s_gps_exit(TcorePlugin *p);
+gboolean s_gps_init(TcorePlugin *cp, CoreObject *co_gps);
+void s_gps_exit(TcorePlugin *cp, CoreObject *co_gps);
#endif
#ifndef __S_MODEM_H__
#define __S_MODEM_H__
-gboolean on_event_modem_power(TcoreAT *at, const char *line, TcorePlugin *p);
-gboolean s_modem_init(TcorePlugin *p, TcoreHal *h);
-void s_modem_exit(TcorePlugin *p);
-gboolean s_modem_send_poweron(TcorePlugin *p);
+gboolean s_modem_init(TcorePlugin *cp, CoreObject *co_modem);
+void s_modem_exit(TcorePlugin *cp, CoreObject *co_modem);
+
+gboolean modem_power_on(TcorePlugin *p);
#endif
#ifndef __S_NETWORK_H__
#define __S_NETWORK_H__
-gboolean s_network_init(TcorePlugin *p, TcoreHal *h);
-void s_network_exit(TcorePlugin *p);
+gboolean s_network_init(TcorePlugin *cp, CoreObject *co_network);
+void s_network_exit(TcorePlugin *cp, CoreObject *co_network);
#endif
#ifndef S_PHONEBOOK_H_
#define S_PHONEBOOK_H_
-gboolean s_phonebook_init(TcorePlugin *p, TcoreHal *h);
-void s_phonebook_exit(TcorePlugin *p);
+gboolean s_phonebook_init(TcorePlugin *cp, CoreObject *co_phonebook);
+void s_phonebook_exit(TcorePlugin *cp, CoreObject *co_phonebook);
#endif /* S_PHONEBOOK_H_ */
#ifndef __S_PS_H__
#define __S_PS_H__
-gboolean s_ps_init(TcorePlugin *p, TcoreHal *hal);
-void s_ps_exit(TcorePlugin *p);
+gboolean s_ps_init(TcorePlugin *cp, CoreObject *co_ps);
+void s_ps_exit(TcorePlugin *cp, CoreObject *co_ps);
#endif /*__S_PS_H__*/
#ifndef S_SAP_H_
#define S_SAP_H_
-gboolean s_sap_init(TcorePlugin *p, TcoreHal *h);
-void s_sap_exit(TcorePlugin *p);
+gboolean s_sap_init(TcorePlugin *cp, CoreObject *co_sap);
+void s_sap_exit(TcorePlugin *cp, CoreObject *co_sap);
#endif /* S_SAP_H_ */
#ifndef S_SAT_H_
#define S_SAT_H_
-gboolean s_sat_init(TcorePlugin *p, TcoreHal *h);
-void s_sat_exit(TcorePlugin *p);
+gboolean s_sat_init(TcorePlugin *cp, CoreObject *co_sat);
+void s_sat_exit(TcorePlugin *cp, CoreObject *co_sat);
#endif /* S_SAT_H_ */
#ifndef __S_SIM_H__
#define __S_SIM_H__
-gboolean s_sim_init(TcorePlugin *p, TcoreHal *h);
-void s_sim_exit(TcorePlugin *p);
+gboolean s_sim_init(TcorePlugin *cp, CoreObject *co_sim);
+void s_sim_exit(TcorePlugin *cp, CoreObject *co_sim);
#endif
#ifndef S_SMS_H_
#define S_SMS_H_
-gboolean s_sms_init(TcorePlugin *p, TcoreHal *h);
-void s_sms_exit(TcorePlugin *p);
+gboolean s_sms_init(TcorePlugin *cp, CoreObject *co_sms);
+void s_sms_exit(TcorePlugin *cp, CoreObject *co_sms);
#endif // S_SMS_H_
#ifndef __S_SS_H__
#define __S_SS_H__
-gboolean s_ss_init(TcorePlugin *p, TcoreHal *h);
-void s_ss_exit(TcorePlugin *p);
+gboolean s_ss_init(TcorePlugin *cp, CoreObject *co_ss);
+void s_ss_exit(TcorePlugin *cp, CoreObject *co_ss);
#endif
#include <glib.h>
#include <tcore.h>
#include <plugin.h>
+#include <core_object.h>
#include <hal.h>
-#include <server.h>
#include <at.h>
-#include <core_object.h>
-#include "s_common.h"
#include "s_network.h"
#include "s_modem.h"
#include "s_sim.h"
#include "s_phonebook.h"
#include "s_gps.h"
-static char *cp_name;
-static int cp_count = 0;
-
-#define MAX_CP_QUERY_COUNT 60
-
-static gboolean _query_cp_state(gpointer data)
-{
- gboolean power_state = FALSE;
- TcorePlugin *p = NULL;
- CoreObject* obj = NULL;
- TcoreHal* h = NULL;
-
- p = (TcorePlugin *) data;
-
- if (cp_count > MAX_CP_QUERY_COUNT) {
- dbg("cp query counter exceeds MAX_CP_QUERY_COUNT");
- return FALSE;
- }
- obj = tcore_plugin_ref_core_object(p, "modem");
- h = tcore_object_get_hal(obj);
- power_state = tcore_hal_get_power_state(h);
-
- if (TRUE == power_state) {
- dbg("CP READY");
- s_modem_send_poweron(p);
- return FALSE;
- } else {
- dbg("CP NOT READY, cp_count :%d", cp_count);
- cp_count++;
- return TRUE;
- }
-}
-
-static enum tcore_hook_return on_hal_send(TcoreHal *hal, unsigned int data_len, void *data, void *user_data)
-{
- hook_hex_dump(TX, data_len, data);
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static void on_hal_recv(TcoreHal *hal, unsigned int data_len, const void *data, void *user_data)
-{
- msg("=== RX data DUMP =====");
- util_hex_dump(" ", data_len, data);
- msg("=== RX data DUMP =====");
-}
-
static gboolean on_load()
{
dbg("i'm load!");
return TRUE;
}
-static int _get_cp_name(char **name)
+static void on_confirmation_modem_message_send(TcorePending *p,
+ gboolean result,
+ void *user_data)
{
- struct utsname u;
-
- char *svnet1_models[] = {
- "F1", "S1", "M2", "H2", "H2_SDK",
- "CRESPO", "STEALTHV", "SLP45", "Kessler", "P1P2",
- "U1SLP", "U1HD", "SLP7_C210", "SLP10_C210", NULL
- };
+ dbg("on_confirmation_modem_message_send - msg out from queue.");
- char *svnet2_models[] = { "SMDK4410", "SMDK4212", "TRATS2", "SLP_PQ_LTE", "SLP_NAPLES", "REDWOOD", "TRATS", NULL };
-
- char *tty_models[] = { "QCT MSM8X55 SURF", "QCT MSM7x27a FFA", NULL };
-
- int i = 0;
-
- if (*name) {
- dbg("[ error ] name is not empty");
- return FALSE;
- }
+ dbg("%s", result == FALSE ? "SEND FAIL" : "SEND OK");
+}
- memset(&u, '\0', sizeof(struct utsname));
+static void on_response_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ TcorePlugin *plugin = user_data;
+ const TcoreATResponse *resp = data;
- uname(&u);
+ dbg("entry of on_response_bootup_subscription() - response comes\n");
- dbg("u.nodename : [ %s ]", u.nodename);
+ if (resp->success)
+ dbg("result OK");
- for (i = 0; svnet1_models[i]; i++) {
- if (!strcmp(u.nodename, svnet1_models[i])) {
- *name = g_new0(char, 5);
- strcpy(*name, "6260");
- return 5;
- }
- }
+ dbg("result ERROR");
- for (i = 0; svnet2_models[i]; i++) {
- if (!strcmp(u.nodename, svnet2_models[i])) {
- *name = g_new0(char, 5);
- strcpy(*name, "6262");
- return 5;
- }
- }
+ if (plugin != NULL)
+ modem_power_on(plugin);
+}
- for (i = 0; tty_models[i]; i++) {
- if (!strcmp(u.nodename, tty_models[i])) {
- *name = g_new0(char, 6);
- strcpy(*name, "dpram");
- return 6;
- }
- }
+static void modem_subscribe_events(TcorePlugin *plugin)
+{
+ CoreObject *co_call = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL);
+ CoreObject *co_sim = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SIM);
+ CoreObject *co_sms = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SMS);
+ CoreObject *co_modem = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_MODEM);
+ CoreObject *co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
+ CoreObject *co_ps = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_PS);
+ CoreObject *co_sap = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SAP);
+ CoreObject *co_gps = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_GPS);
+
+ dbg("Entry");
+
+ /* XCALLSTAT subscription */
+ tcore_prepare_and_send_at_request(co_call, "at+xcallstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* XSIMSTATE subscription */
+ tcore_prepare_and_send_at_request(co_sim, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ tcore_prepare_and_send_at_request(co_sms, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+ tcore_prepare_and_send_at_request(co_modem, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* CREG subscription */
+ tcore_prepare_and_send_at_request(co_network, "at+creg=2", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* CGREG subscription */
+ tcore_prepare_and_send_at_request(co_network, "at+cgreg=2", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* Allow automatic time Zone updation via NITZ */
+ tcore_prepare_and_send_at_request(co_network, "at+ctzu=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* TZ, time & daylight changing event reporting subscription */
+ tcore_prepare_and_send_at_request(co_network, "at+ctzr=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* XMER subscription */
+ tcore_prepare_and_send_at_request(co_network, "at+xmer=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* CGEREP subscription */
+ tcore_prepare_and_send_at_request(co_ps, "at+cgerep=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* XDATASTAT subscription */
+ tcore_prepare_and_send_at_request(co_ps, "at+xdatastat=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* CSSN subscription */
+ tcore_prepare_and_send_at_request(co_call, "at+cssn=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* CUSD subscription */
+ tcore_prepare_and_send_at_request(co_call, "at+cusd=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* XDNS subscription */
+ tcore_prepare_and_send_at_request(co_ps, "at+xdns=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* CLIP subscription */
+ tcore_prepare_and_send_at_request(co_call, "at+clip=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /*CMEE subscription for ps*/
+ tcore_prepare_and_send_at_request(co_ps, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /*CMEE subscription for sms*/
+ tcore_prepare_and_send_at_request(co_sms, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /*incoming sms,cb,status report subscription*/
+ tcore_prepare_and_send_at_request(co_sms, "at+cnmi=1,2,2,1,0", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* XBCSTAT subscription */
+ tcore_prepare_and_send_at_request(co_sap, "at+xbcstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+ /* AGPS- assist data and reset assist data subscription */
+ tcore_prepare_and_send_at_request(co_gps, "at+cposr=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ tcore_prepare_and_send_at_request(co_gps, "at+xcposr=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /* text/pdu mode subscription*/
+ tcore_prepare_and_send_at_request(co_sms, "at+cmgf=0", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, plugin,
+ on_confirmation_modem_message_send, NULL);
+
+ dbg("Exit");
+}
- dbg("[ error ] unknown model : (%s)", u.nodename);
+struct object_initializer init_table = {
+ .modem_init = s_modem_init,
+ .sim_init = s_sim_init,
+ .sat_init = s_sat_init,
+ .sap_init = s_sap_init,
+ .network_init = s_network_init,
+ .ps_init = s_ps_init,
+ .call_init = s_call_init,
+ .ss_init = s_ss_init,
+ .sms_init = s_sms_init,
+ .phonebook_init = s_phonebook_init,
+ .gps_init = s_gps_init,
+};
- return 0;
-}
+struct object_deinitializer deinit_table = {
+ .modem_deinit = s_modem_exit,
+ .sim_deinit = s_sim_exit,
+ .sat_deinit = s_sat_exit,
+ .sap_deinit = s_sap_exit,
+ .network_deinit = s_network_exit,
+ .ps_deinit = s_ps_exit,
+ .call_deinit = s_call_exit,
+ .ss_deinit = s_ss_exit,
+ .sms_deinit = s_sms_exit,
+ .phonebook_deinit = s_phonebook_exit,
+ .gps_deinit = s_gps_exit,
+};
static gboolean on_init(TcorePlugin *p)
{
- TcoreHal *h;
- struct global_data *gd;
- // char *cp_name = 0;
- int len = 0;
-
if (!p)
return FALSE;
- gd = calloc(sizeof(struct global_data), 1);
- if (!gd)
- return FALSE;
-
- dbg("i'm init!");
-
- gd->msg_auto_id_current = 0;
- gd->msg_auto_id_start = 1;
- gd->msg_auto_id_end = 255;
-
- len = _get_cp_name(&cp_name);
- if (!len) {
- dbg("[ error ] unsupport cp (name : %s)", cp_name);
- free(gd);
+ if (tcore_object_init_objects(p, &init_table)
+ != TCORE_RETURN_SUCCESS) {
+ err("Failed to initialize Core Objects");
return FALSE;
}
- /* FIXME: HAL will reside in Co-object.
- * This HAL is just used as default before MUX setup.
- * Each HAL has AT pasre functionality.
- */
- h = tcore_server_find_hal(tcore_plugin_ref_server(p), cp_name);
- if (!h) {
- g_free(cp_name);
- free(gd);
- return FALSE;
- }
-
- // set physical hal into plugin's userdata
- gd->hal = h;
-
- tcore_plugin_link_user_data(p, gd);
-
- tcore_hal_add_send_hook(h, on_hal_send, p);
- tcore_hal_add_recv_callback(h, on_hal_recv, p);
-
- s_modem_init(p, h);
- s_sim_init(p, h);
- s_sat_init(p, h);
- s_network_init(p, h);
- s_ps_init(p, h);
- s_call_init(p, h);
- s_ss_init(p, h);
- s_sms_init(p, h);
- s_phonebook_init(p, h);
- s_sap_init(p, h);
- s_gps_init(p, h);
+ dbg("i'm init!");
- g_free(cp_name);
+ modem_subscribe_events(p);
- tcore_hal_set_power(h, TRUE);
- //wait until CP is ready
- g_timeout_add_full(G_PRIORITY_HIGH,500,_query_cp_state, p, 0 );
return TRUE;
}
static void on_unload(TcorePlugin *p)
{
- struct global_data *gd;
-
if (!p)
return;
- dbg("i'm unload");
+ tcore_object_deinit_objects(p, &deinit_table);
- gd = tcore_plugin_ref_user_data(p);
- if (gd) {
- free(gd);
- }
+ dbg("i'm unload");
}
struct tcore_plugin_define_desc plugin_define_desc = {
UserRequest *ur;
dbg("Entry");
- core_obj = tcore_plugin_ref_core_object(p, "call");
+ core_obj = tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_CALL);
dbg("Call ID [%d], Call Status [%d]", tcore_call_object_get_id(co), tcore_call_object_get_status(co));
if (tcore_call_object_get_status(co) != TCORE_CALL_STATUS_IDLE) {
// Send notification to TAPI
tcore_server_send_notification(tcore_plugin_ref_server(p),
- tcore_plugin_ref_core_object(p, "call"),
+ tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_CALL),
TNOTI_CALL_STATUS_DIALING,
sizeof(struct tnoti_call_status_dialing),
(void *) &data);
// Send notification to TAPI
tcore_server_send_notification(tcore_plugin_ref_server(p),
- tcore_plugin_ref_core_object(p, "call"),
+ tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_CALL),
TNOTI_CALL_STATUS_ALERT,
sizeof(struct tnoti_call_status_alert),
(void *) &data);
// Send notification to TAPI
tcore_server_send_notification(tcore_plugin_ref_server(p),
- tcore_plugin_ref_core_object(p, "call"),
+ tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_CALL),
TNOTI_CALL_STATUS_ACTIVE,
sizeof(struct tnoti_call_status_active),
(void *) &data);
// Send notification to TAPI
tcore_server_send_notification(tcore_plugin_ref_server(p),
- tcore_plugin_ref_core_object(p, "call"),
+ tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_CALL),
TNOTI_CALL_STATUS_HELD,
sizeof(struct tnoti_call_status_held),
(void *) &data);
// Send notification to TAPI
tcore_server_send_notification(tcore_plugin_ref_server(p),
- tcore_plugin_ref_core_object(p, "call"),
+ tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_CALL),
TNOTI_CALL_STATUS_INCOMING,
sizeof(struct tnoti_call_status_incoming),
(void *) &data);
.set_sound_noise_reduction = NULL,
};
-static void s_call_info_mo_waiting(CoreObject *o)
+gboolean s_call_init(TcorePlugin *cp, CoreObject *co_call)
{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_current_on_mo_processing(o);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_WAITING,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_mo_forwarded(CoreObject *o)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_current_on_mo_processing(o);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_FORWARDED,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_mo_barred_incoming(CoreObject *o)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_current_on_mo_processing(o);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_BARRED_INCOMING,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_mo_barred_outgoing(CoreObject *o)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_current_on_mo_processing(o);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_BARRED_OUTGOING,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_mo_deflected(CoreObject *o)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_current_on_mo_processing(o);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_DEFLECTED,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_mo_clir_suppression_reject(CoreObject *o)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
dbg("Entry");
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
+ tcore_call_override_ops(co_call, &call_ops, NULL);
- // Call Core object
- co = tcore_call_object_current_on_mo_processing(o);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_CLIR_SUPPRESSION_REJECT,
- sizeof(unsigned int),
- (void *) &id);
+ /* Add Callbacks */
+ tcore_object_override_callback(co_call, "+XCALLSTAT", on_notification_call_info, NULL);
+ tcore_object_override_callback(co_call, "+CLIP", on_notification_call_clip_info, NULL);
dbg("Exit");
- return;
-}
-
-static void s_call_info_mo_cfu(CoreObject *o)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_current_on_mo_processing(o);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_FORWARD_UNCONDITIONAL,
- sizeof(unsigned int),
- (void *) &id);
- dbg("Exit");
- return;
-}
-
-static void s_call_info_mo_cfc(CoreObject *o)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_current_on_mo_processing(o);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_FORWARD_CONDITIONAL,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_mt_cli(CoreObject *o, enum tcore_call_cli_mode mode, char *number)
-{
- CallObject *co = NULL;
-
- dbg("Entry");
-
- // Call Core object
- co = tcore_call_object_current_on_mt_processing(o);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Set CLI information
- tcore_call_object_set_cli_info(co, mode, number);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_mt_cna(CoreObject *o, enum tcore_call_cna_mode mode, char *name, int dcs)
-{
- CallObject *co = NULL;
-
- dbg("Entry");
-
- // Call Core object
- co = tcore_call_object_current_on_mt_processing(o);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Set CNA information
- tcore_call_object_set_cna_info(co, mode, name, dcs);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_mt_forwarded_call(CoreObject *o, char *number)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_find_by_number(o, number);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_FORWARDED_CALL,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_mt_deflected_call(CoreObject *o, char *number)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_find_by_number(o, number);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_DEFLECTED_CALL,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_mt_transfered(CoreObject *o, char *number)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_find_by_number(o, number);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_TRANSFERED_CALL,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_held(CoreObject *o, char *number)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_find_by_number(o, number);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_HELD,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_active(CoreObject *o, char *number)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_find_by_number(o, number);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_ACTIVE,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_joined(CoreObject *o, char *number)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_find_by_number(o, number);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_JOINED,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_released_on_hold(CoreObject *o, char *number)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_find_by_number(o, number);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_RELEASED_ON_HOLD,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_transfer_alert(CoreObject *o, char *number)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_find_by_number(o, number);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_TRANSFER_ALERT,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_transfered(CoreObject *o, char *number)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_find_by_number(o, number);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_TRANSFERED,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-static void s_call_info_cf_check_message(CoreObject *o, char *number)
-{
- TcorePlugin *plugin = NULL;
- CallObject *co = NULL;
- int id = 0;
-
- dbg("Entry");
-
- // Parent plugin
- plugin = tcore_object_ref_plugin(o);
-
- // Call Core object
- co = tcore_call_object_find_by_number(o, number);
- if (!co) {
- err("Failed to find Call Core object!");
- return;
- }
-
- // Call ID
- id = tcore_call_object_get_id(co);
-
- // Send notification to TAPI
- tcore_server_send_notification(tcore_plugin_ref_server(plugin),
- tcore_plugin_ref_core_object(plugin, "call"),
- TNOTI_CALL_INFO_CF_CHECK_MESSAGE,
- sizeof(unsigned int),
- (void *) &id);
-
- dbg("Exit");
- return;
-}
-
-// Call Information Operations
-static struct tcore_call_information_operations call_information_ops = {
- .mo_call_col = 0,
- .mo_call_waiting = s_call_info_mo_waiting,
- .mo_call_cug = 0,
- .mo_call_forwarded = s_call_info_mo_forwarded,
- .mo_call_barred_incoming = s_call_info_mo_barred_incoming,
- .mo_call_barred_outgoing = s_call_info_mo_barred_outgoing,
- .mo_call_deflected = s_call_info_mo_deflected,
- .mo_call_clir_suppression_reject = s_call_info_mo_clir_suppression_reject,
- .mo_call_cfu = s_call_info_mo_cfu,
- .mo_call_cfc = s_call_info_mo_cfc,
- .mt_call_cli = s_call_info_mt_cli,
- .mt_call_cna = s_call_info_mt_cna,
- .mt_call_forwarded_call = s_call_info_mt_forwarded_call,
- .mt_call_cug_call = 0,
- .mt_call_deflected_call = s_call_info_mt_deflected_call,
- .mt_call_transfered = s_call_info_mt_transfered,
- .call_held = s_call_info_held,
- .call_active = s_call_info_active,
- .call_joined = s_call_info_joined,
- .call_released_on_hold = s_call_info_released_on_hold,
- .call_transfer_alert = s_call_info_transfer_alert,
- .call_transfered = s_call_info_transfered,
- .call_cf_check_message = s_call_info_cf_check_message,
-};
-
-gboolean s_call_init(TcorePlugin *p, TcoreHal *h)
-{
- CoreObject *o = NULL;
- struct property_call_info *data = NULL;
-
- dbg("Entry");
-
- // Creating Call COre object
- o = tcore_call_new(p, "call", &call_ops, h);
- if (!o) {
- err("Failed to create Call Core Object");
- return FALSE;
- }
-
- // Set Call Operations
- tcore_call_information_set_operations(o, &call_information_ops);
-
- // Add Callbacks
- tcore_object_add_callback(o, "+XCALLSTAT", on_notification_call_info, NULL);
- tcore_object_add_callback(o, "+CLIP", on_notification_call_clip_info, NULL);
-
- // User Data
- data = calloc(sizeof(struct property_call_info *), 1);
- tcore_plugin_link_property(p, "CALL", data);
-
- dbg("Exit");
return TRUE;
}
-void s_call_exit(TcorePlugin *p)
+void s_call_exit(TcorePlugin *cp, CoreObject *co_call)
{
- CoreObject *o = NULL;
- struct property_network_info *data = NULL;
-
- dbg("Entry");
-
- o = tcore_plugin_ref_core_object(p, "call");
-
- // Free Call Core Object */
- tcore_call_free(o);
-
- // Free 'CALL' property */
- data = tcore_plugin_ref_property(p, "CALL");
- if (data) {
- g_free(data);
- }
-
dbg("Exit");
- return;
}
#include <stdlib.h>
#include <glib.h>
+#include <log.h>
#include "s_common.h"
-#include <plugin.h>
-
#undef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
msg("%s", buf);
}
-void hook_hex_dump(enum direction_e d, int size, const void *data)
-{
- msg("=== TX data DUMP =====");
- util_hex_dump(" ", size, data);
- msg("=== TX data DUMP =====");
-}
-
-unsigned int util_assign_message_sequence_id(TcorePlugin *p)
-{
- struct global_data *gd;
-
- if (!p) {
- dbg("plugin is NULL");
- return -1;
- }
-
- gd = tcore_plugin_ref_user_data(p);
- if (!gd) {
- dbg("global data is NULL");
- return -1;
- }
-
- if (gd->msg_auto_id_current == 0) {
- gd->msg_auto_id_current = gd->msg_auto_id_start;
- dbg("pending_auto_id_current is 0, reset to start");
- } else if (gd->msg_auto_id_current >= gd->msg_auto_id_end) {
- gd->msg_auto_id_current = gd->msg_auto_id_start;
- dbg("pending_auto_id_current is over, reset to start");
- } else {
- gd->msg_auto_id_current++;
- }
-
- dbg("message_sequence_id = %d", gd->msg_auto_id_current);
-
- return gd->msg_auto_id_current;
-}
-
-gboolean util_add_waiting_job(GQueue *queue, unsigned int id, UserRequest *ur)
-{
- struct work_queue_data *wqd;
-
- if (!queue)
- return FALSE;
-
- wqd = calloc(sizeof(struct work_queue_data), 1);
- if (!wqd)
- return FALSE;
-
- wqd->id = id;
- wqd->ur = tcore_user_request_ref(ur);
- g_queue_push_tail(queue, wqd);
-
- dbg("id = %d, ur = 0x%x", wqd->id, wqd->ur);
- return TRUE;
-}
-
-UserRequest* util_pop_waiting_job(GQueue *queue, unsigned int id)
-{
- int i = 0;
- UserRequest *ur;
- struct work_queue_data *wqd;
-
- if (!queue)
- return NULL;
-
-
- dbg("before waiting job count: %d", g_queue_get_length(queue));
-
- do {
- wqd = g_queue_peek_nth(queue, i);
- if (!wqd)
- return NULL;
-
- if (wqd->id == id) {
- wqd = g_queue_pop_nth(queue, i);
- break;
- }
-
- i++;
- } while (wqd != NULL);
-
- dbg("after waiting job count: %d", g_queue_get_length(queue));
-
- if (!wqd)
- return NULL;
-
- ur = wqd->ur;
- free(wqd);
-
- return ur;
-}
-
unsigned char util_hexCharToInt(char c)
{
if (c >= '0' && c <= '9')
rshift = MAX(8 - (pos + len), 0);
if (rshift > 0) {
- result = MASK_AND_SHIFT(len, pos, rshift, *src);
+ result = MASK_AND_SHIFT(len, pos, rshift, (unsigned char)*src);
} else {
- result = MASK(8 - pos, pos, *src);
+ result = MASK(8 - pos, pos, (unsigned char)*src);
src++;
len -= 8 - pos;
.confirm_measure_pos = gps_confirm_measure_pos,
};
-gboolean s_gps_init(TcorePlugin *p, TcoreHal *h)
+gboolean s_gps_init(TcorePlugin *cp, CoreObject *co_gps)
{
- CoreObject *o = NULL;
- GQueue *work_queue = NULL;
+ dbg("Enter");
- dbg("enter");
+ tcore_gps_override_ops(co_gps, &gps_ops);
- o = tcore_gps_new(p, "gps", &gps_ops, h);
- if (!o)
- return FALSE;
+ tcore_object_override_callback(co_gps, "+CPOSR", on_notification_gps_assist_data, NULL);
+ tcore_object_override_callback(co_gps, "+XCPOSR", on_notification_reset_assist_data, NULL);
- work_queue = g_queue_new();
- tcore_object_link_user_data(o, work_queue);
+ dbg("Exit");
- tcore_object_add_callback(o, "+CPOSR", on_notification_gps_assist_data, NULL);
- tcore_object_add_callback(o, "+XCPOSR", on_notification_reset_assist_data, NULL);
- dbg("exit");
return TRUE;
}
-void s_gps_exit(TcorePlugin *p)
+void s_gps_exit(TcorePlugin *cp, CoreObject *co_gps)
{
- CoreObject *o;
- GQueue *work_queue;
-
- o = tcore_plugin_ref_core_object(p, "gps");
- if (!o)
- return;
-
- work_queue = tcore_object_ref_user_data(o);
- if (work_queue)
- g_queue_free(work_queue);
-
- tcore_gps_free(o);
+ dbg("Exit");
}
#include <hal.h>
#include <core_object.h>
#include <plugin.h>
+#include <user_request.h>
#include <queue.h>
#include <co_modem.h>
#include <storage.h>
} TelMiscVersionInformation;
-void prepare_and_send_pending_request(TcorePlugin *plugin, char *co_name, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, TcorePendingResponseCallback callback);
+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_timeout_modem_poweron(TcorePending *p, void *user_data);
static void on_response_enable_proactive_command(TcorePending *p, int data_len, const void *data, void *user_data);
-static void on_timeout_modem_poweron(TcorePending *p, void *user_data)
-{
- unsigned int data_len = 0;
- char data[] = "AT+CPAS";
-
- dbg("TIMEOUT for 1st AT Command !!!!! NO Response for initial AT command. Resending it");
- data_len = sizeof(data);
-
- /* Retransmit 1st AT command directly via HAL, don't disturb pending queue. */
- /* HAL was passed as user_data, re-use it */
- if (user_data) {
- tcore_hal_send_data(user_data, data_len, (void *) data);
- }
-}
-
static void on_confirmation_modem_message_send(TcorePending *p, gboolean result, void *user_data)
{
dbg("on_confirmation_modem_message_send - msg out from queue.\n");
}
}
-void prepare_and_send_pending_request(TcorePlugin *plugin, char *co_name, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, TcorePendingResponseCallback callback)
+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;
TcoreHal *hal = NULL;
- CoreObject *o = NULL;
TcorePending *pending = NULL;
TReturn ret;
- o = tcore_plugin_ref_core_object(plugin, co_name);
- hal = tcore_object_get_hal(o);
+ hal = tcore_object_get_hal(co);
dbg("hal: %p", hal);
- pending = tcore_pending_new(o, 0);
+ pending = tcore_pending_new(co, 0);
if (!pending)
dbg("Pending is NULL");
req = tcore_at_request_new(at_cmd, prefix, at_cmd_type);
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, callback, NULL);
tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
- tcore_pending_link_user_request(pending, NULL); // set user request to NULL - this is intenal request
ret = tcore_hal_send_request(hal, pending);
- return;
-}
-
-void on_response_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data)
-{
- const TcoreATResponse *resp = data;
-
- dbg("entry of on_response_bootup_subscription() - response comes\n");
-
- if (resp->success) {
- dbg("result OK");
- } else {
- dbg("result ERROR");
- }
-}
-
-void on_response_last_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data)
-{
- const TcoreATResponse *resp = data;
-
- dbg("enry of on_response_last_bootup_subscription() - final response comes\n");
- if (resp->success) {
- dbg("SEND OK");
- } else {
- dbg("SEND FAIL");
- }
- dbg("Response for AT+CLIP. Boot-up configration completed for IMC modem. Bring CP to online based on Flightmode status\n");
- on_event_modem_power(NULL, NULL, tcore_pending_ref_plugin(p));
}
static void on_response_power_off(TcorePending *p, int data_len, const void *data, void *user_data)
if (req_data->enable == 0) {
dbg("Flight mode is disabled, trigger COPS to register on network");
/* Trigger Network registration (for the moment automatic) */
- prepare_and_send_pending_request(tcore_object_ref_plugin(o), "modem", "AT+COPS=0", NULL, TCORE_AT_NO_RESULT, NULL);
+ prepare_and_send_pending_request(o, "AT+COPS=0", NULL, TCORE_AT_NO_RESULT, NULL);
}
}
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(tcore_object_ref_plugin(o), "sat", "AT+CFUN=6", NULL, TCORE_AT_NO_RESULT, on_response_enable_proactive_command);
- prepare_and_send_pending_request(tcore_object_ref_plugin(o), "umts_network", "AT+COPS=0", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
+ 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;
}
-gboolean on_event_modem_power(TcoreAT *at, const char *line, TcorePlugin *p)
+gboolean modem_power_on(TcorePlugin *p)
{
- CoreObject *o = NULL;
+ CoreObject *co_modem = NULL;
struct treq_modem_set_flightmode flight_mode_set = {0};
struct tnoti_modem_power modem_power = {0};
TcoreHal *h = NULL;
Storage *strg = NULL;
- o = tcore_plugin_ref_core_object(p, "modem");
+ co_modem = tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_MODEM);
strg = tcore_server_find_storage(tcore_plugin_ref_server(p), "vconf");
flight_mode_set.enable = tcore_storage_get_bool(strg, STORAGE_KEY_FLIGHT_MODE_BOOL);
- h = tcore_object_get_hal(o);
+ h = tcore_object_get_hal(co_modem);
tcore_hal_set_power_state(h, TRUE);
/* Set Flight mode as per AP settings */
if (flight_mode_set.enable) { /* Radio Off */
- prepare_and_send_pending_request(p, "modem", "AT+CFUN=4", NULL, TCORE_AT_NO_RESULT, on_response_set_flight_mode);
- tcore_modem_set_flight_mode_state(o, TRUE);
+ prepare_and_send_pending_request(co_modem, "AT+CFUN=4", NULL, TCORE_AT_NO_RESULT, on_response_set_flight_mode);
+ tcore_modem_set_flight_mode_state(co_modem, TRUE);
} else { /* Radio On */
- prepare_and_send_pending_request(p, "modem", "AT+CFUN=1", NULL, TCORE_AT_NO_RESULT, on_response_set_flight_mode);
- tcore_modem_set_flight_mode_state(o, FALSE);
+ prepare_and_send_pending_request(co_modem, "AT+CFUN=1", NULL, TCORE_AT_NO_RESULT, on_response_set_flight_mode);
+ tcore_modem_set_flight_mode_state(co_modem, FALSE);
}
/* Get IMEI */
- prepare_and_send_pending_request(p, "modem", "AT+CGSN", NULL, TCORE_AT_NUMERIC, on_response_imei);
+ prepare_and_send_pending_request(co_modem, "AT+CGSN", NULL, TCORE_AT_NUMERIC, on_response_imei);
/* Get Version Number */
- prepare_and_send_pending_request(p, "modem", "AT+CGMR", NULL, TCORE_AT_SINGLELINE, on_response_version);
+ prepare_and_send_pending_request(co_modem, "AT+CGMR", NULL, TCORE_AT_SINGLELINE, on_response_version);
- tcore_modem_set_powered(o, TRUE);
+ tcore_modem_set_powered(co_modem, TRUE);
modem_power.state = MODEM_STATE_ONLINE;
- tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_MODEM_POWER,
+ tcore_server_send_notification(tcore_plugin_ref_server(p), co_modem, TNOTI_MODEM_POWER,
sizeof(struct tnoti_modem_power), &modem_power);
return TRUE;
}
-static void _modem_subscribe_events(TcorePlugin *plugin)
-{
- dbg("Entry");
-
- /* XCALLSTAT subscription */
- prepare_and_send_pending_request(plugin, "call", "at+xcallstat=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* XSIMSTATE subscription */
- prepare_and_send_pending_request(plugin, "sim", "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- prepare_and_send_pending_request(plugin, "umts_sms", "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
- prepare_and_send_pending_request(plugin, "modem", "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* CREG subscription */
- prepare_and_send_pending_request(plugin, "umts_network", "at+creg=2", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* CGREG subscription */
- prepare_and_send_pending_request(plugin, "umts_network", "at+cgreg=2", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* Allow automatic time Zone updation via NITZ */
- prepare_and_send_pending_request(plugin, "umts_network", "at+ctzu=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* TZ, time & daylight changing event reporting subscription */
- prepare_and_send_pending_request(plugin, "umts_network", "at+ctzr=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* XMER subscription */
- prepare_and_send_pending_request(plugin, "umts_network", "at+xmer=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* CGEREP subscription */
- prepare_and_send_pending_request(plugin, "umts_ps", "at+cgerep=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* XDATASTAT subscription */
- prepare_and_send_pending_request(plugin, "umts_ps", "at+xdatastat=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* CSSN subscription */
- prepare_and_send_pending_request(plugin, "call", "at+cssn=1,1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* CUSD subscription */
- prepare_and_send_pending_request(plugin, "call", "at+cusd=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* XDNS subscription */
- prepare_and_send_pending_request(plugin, "umts_ps", "at+xdns=1,1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* CLIP subscription */
- prepare_and_send_pending_request(plugin, "call", "at+clip=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /*CMEE subscription for ps*/
- prepare_and_send_pending_request(plugin, "umts_ps", "at+cmee=2", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /*CMEE subscription for sms*/
- prepare_and_send_pending_request(plugin, "umts_sms", "at+cmee=2", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /*incoming sms,cb,status report subscription*/
- prepare_and_send_pending_request(plugin, "umts_sms", "at+cnmi=1,2,2,1,0", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* XBCSTAT subscription */
- prepare_and_send_pending_request(plugin, "sap", "at+xbcstat=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
- /* AGPS- assist data and reset assist data subscription */
- prepare_and_send_pending_request(plugin, "gps", "at+cposr=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- prepare_and_send_pending_request(plugin, "gps", "at+xcposr=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-
- /* text/pdu mode subscription*/
- prepare_and_send_pending_request(plugin, "umts_sms", "at+cmgf=0", NULL, TCORE_AT_NO_RESULT, on_response_last_bootup_subscription);
-
- dbg("Exit");
- return;
-}
-
-
-static void on_response_setupmux(TcorePending *p, int data_len, const void *data, void *user_data)
-{
- TcorePlugin *plugin = NULL;
- TcoreHal *hal = NULL;
- TReturn ret;
-
- dbg("Entry");
-
- /* IMC Plugin dereferenced from pending request */
- plugin = tcore_pending_ref_plugin(p);
-
- /* Actual HAL - like svnet(2) */
- hal = (TcoreHal *) user_data;
-
- /* Initialize CMUX */
- ret = tcore_cmux_init(plugin, hal);
- if (TCORE_RETURN_SUCCESS == ret) {
- dbg("Successfully initialized CMUX");
- } else {
- err("Failed to initialize CMUX");
- }
-
- dbg("Exit");
- return;
-}
-
-
-
-static void setup_mux(CoreObject *o)
-{
- TcoreHal *hal = NULL;
- TcorePending *pending = NULL;
-
- dbg("Entered");
-
- /* HAL has type itself,
- * e.g.) TCORE_HAL_MODE_AT
- */
- hal = tcore_object_get_hal(o);
-
- pending = tcore_at_pending_new(o, "AT+CMUX=0,0,,1509,10,3,30,,", "+CMUX", TCORE_AT_NO_RESULT, on_response_setupmux, hal);
-
- tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
-
- /* Send callback */
- tcore_hal_send_request(hal, pending);
-
- dbg("Exit");
- return;
-}
-
-
-static gboolean on_event_mux_channel_up(CoreObject *o, const void *event_info, void *user_data)
-{
- TcorePlugin *plugin = NULL;
-
- dbg("Entry");
-
- plugin = (TcorePlugin *) user_data;
- _modem_subscribe_events(plugin);
- dbg("Exit");
- return TRUE;
-}
-
-
-static void on_response_enable_logging(TcorePending *p, int data_len, const void *data, void *user_data)
-{
- const TcoreATResponse *resp = data;
- TcorePlugin *plugin = NULL;
-
- plugin = tcore_pending_ref_plugin(p);
-
- /* DELETE ME: only for DEBUG */
- if (!resp)
- dbg("no data");
-
- dbg("response...(result = %d, final_response = '%s')", resp->success, resp->final_response);
-
- if (resp->success) {
- dbg("RESPONSE OK");
- dbg("Enabling CP logging is success !!!\n");
- } else {
- dbg("RESPONSE NOK");
- dbg("Enabling CP logging is failed !!!\n");
- }
-
- dbg("Calling setup_mux");
- setup_mux(tcore_pending_ref_core_object(p));
-
-
- dbg("Exit");
- return;
-}
-
-static void _send_enable_logging_command(CoreObject *o)
-{
- TcoreATRequest *req = NULL;
- TcoreHal *hal = NULL;
- TcorePending *pending = NULL;
- TReturn ret = 0;
-
- /* DLELTE ME */
- dbg("Send Trace enabling command for CP logging. \n");
-
- if (!o) {
- dbg("Co-object is Null !!\n");
- // goto error;
- }
-
- hal = tcore_object_get_hal(o);
- pending = tcore_pending_new(o, 0);
- req = tcore_at_request_new("at+xsystrace=1,\"digrf=1;bb_sw=1;3g_sw=1\",\"digrf=0x84\",\"oct=4\";+xsystrace=11;+trace=1", NULL, TCORE_AT_NO_RESULT);
-
- dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
-
- tcore_pending_set_request_data(pending, 0, req);
- tcore_pending_set_response_callback(pending, on_response_enable_logging, hal);
- tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
-
- ret = tcore_hal_send_request(hal, pending);
- if (ret != TCORE_RETURN_SUCCESS)
- dbg("tcore_hal_send_request fail !!! (hal: 0x%x, pending: 0x%x)\n", hal, pending);
-}
-
-static void on_response_poweron(TcorePending *p, int data_len, const void *data, void *user_data)
-{
- const TcoreATResponse *resp = data;
- GSList *tokens = NULL;
- const char *line = NULL;
- gboolean bpoweron = FALSE;
- int response = 0;
-
- if (resp->success) {
- dbg("RESPONSE OK");
- /* Parse AT Response */
- if (resp->lines) {
- line = (const char *) resp->lines->data;
- tokens = tcore_at_tok_new(line);
- if (g_slist_length(tokens) != 1) {
- dbg("invalid message");
- bpoweron = FALSE;
- goto error;
- }
- }
-
- response = atoi(g_slist_nth_data(tokens, 0));
-
- dbg("CPAS: response %d", response);
-
- switch (response) {
- case CPAS_RES_READY:
- case CPAS_RES_RINGING:
- case CPAS_RES_CALL_PROGRESS:
- case CPAS_RES_ASLEEP:
- bpoweron = TRUE;
- break;
-
- case CPAS_RES_UNAVAIL:
- case CPAS_RES_UNKNOWN:
- default:
- dbg("value is unvail/unknown - but CP responded - proceed poweron");
- // bpoweron = FALSE;
- bpoweron = TRUE;
- break;
- }
- } else {
- dbg("CPAS: RESPONSE NOK");
- bpoweron = FALSE;
- }
-
-error:
- /* DELE ME: AT request & response are freed after AT processing in HAL.
- * ref.) _emit_pending_response (libtcore/src/at.c)
- */
- if (tokens != NULL)
- tcore_at_tok_free(tokens);
-
- if (bpoweron == TRUE) {
- dbg("Power on NOTI received, (pending: 0x%x, co: 0x%x)\n", p, tcore_pending_ref_core_object(p));
-
- _send_enable_logging_command(tcore_pending_ref_core_object(p));
- } else {
- dbg("CP is not ready, let us send CPAS once again");
- s_modem_send_poweron(tcore_object_ref_plugin(tcore_pending_ref_core_object(p)));
- }
- return;
-}
-
static TReturn power_off(CoreObject *o, UserRequest *ur)
{
TcoreHal *hal = NULL;
.dun_pin_ctrl = NULL,
};
-gboolean s_modem_init(TcorePlugin *p, TcoreHal *h)
+gboolean s_modem_init(TcorePlugin *cp, CoreObject *co_modem)
{
- CoreObject *o = NULL;
- GQueue *work_queue = NULL;
- TelMiscVersionInformation *vi_property = NULL;
- TelMiscSNInformation *imei_property = NULL;
- TelMiscSNInformation *sn_property = NULL;
+ TelMiscVersionInformation *vi_property;
+ TelMiscSNInformation *imei_property;
+ TelMiscSNInformation *sn_property;
- o = tcore_modem_new(p, "modem", &modem_ops, h);
- if (!o)
- return FALSE;
-
- work_queue = g_queue_new();
- tcore_object_link_user_data(o, work_queue);
+ dbg("Enter");
- vi_property = calloc(sizeof(TelMiscVersionInformation), 1);
- tcore_plugin_link_property(p, "VERSION", vi_property);
+ tcore_modem_override_ops(co_modem, &modem_ops);
- imei_property = calloc(sizeof(TelMiscSNInformation), 1);
- tcore_plugin_link_property(p, "IMEI", imei_property);
+ vi_property = g_try_new0(TelMiscVersionInformation, 1);
+ tcore_plugin_link_property(cp, "VERSION", vi_property);
- sn_property = calloc(sizeof(TelMiscSNInformation), 1);
- tcore_plugin_link_property(p, "SN", sn_property);
+ imei_property = g_try_new0(TelMiscSNInformation, 1);
+ tcore_plugin_link_property(cp, "IMEI", imei_property);
- dbg("Registerind for CMUX-UP event");
- tcore_object_add_callback(o, "CMUX-UP", on_event_mux_channel_up, p);
+ sn_property = g_try_new0(TelMiscSNInformation, 1);
+ tcore_plugin_link_property(cp, "SN", sn_property);
dbg("Registering for +XSIM event");
- tcore_object_add_callback(o, "+XSIM", on_event_bootup_sim_status, NULL);
-
- return TRUE;
-}
+ tcore_object_override_callback(co_modem, "+XSIM", on_event_bootup_sim_status, NULL);
-void s_modem_exit(TcorePlugin *p)
-{
- CoreObject *o = NULL;
- GQueue *work_queue = NULL;
- TelMiscVersionInformation *vi_property = NULL;
- TelMiscSNInformation *imei_property = NULL;
- TelMiscSNInformation *sn_property = NULL;
-
- if (!p)
- return;
-
- o = tcore_plugin_ref_core_object(p, "modem");
-
- work_queue = tcore_object_ref_user_data(o);
- g_queue_free(work_queue);
-
- vi_property = tcore_plugin_ref_property(p, "VERSION");
- if (vi_property)
- free(vi_property);
-
- imei_property = tcore_plugin_ref_property(p, "IMEI");
- if (imei_property)
- free(imei_property);
-
- sn_property = tcore_plugin_ref_property(p, "SN");
- if (sn_property)
- free(sn_property);
+ dbg("Exit");
- tcore_modem_free(o);
- return;
+ return TRUE;
}
-gboolean s_modem_send_poweron(TcorePlugin *p)
+void s_modem_exit(TcorePlugin *cp, CoreObject *co_modem)
{
- TcoreHal *hal;
- TcoreATRequest *req;
- TcorePending *pending = NULL;
- CoreObject *o;
+ TelMiscVersionInformation *vi_property;
+ TelMiscSNInformation *imei_property;
+ TelMiscSNInformation *sn_property;
+ TcorePlugin *plugin = tcore_object_ref_plugin(co_modem);
- o = tcore_plugin_ref_core_object(p, "modem");
- hal = tcore_object_get_hal(o);
-
- pending = tcore_pending_new(o, 0);
-
- req = tcore_at_request_new("AT+CPAS", "+CPAS", TCORE_AT_SINGLELINE);
-
- dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+ vi_property = tcore_plugin_ref_property(plugin, "VERSION");
+ g_free(vi_property);
- tcore_pending_set_timeout(pending, 10);
- tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
- tcore_pending_set_timeout_callback(pending, on_timeout_modem_poweron, hal);
+ imei_property = tcore_plugin_ref_property(plugin, "IMEI");
+ g_free(imei_property);
- tcore_pending_set_request_data(pending, 0, req);
- tcore_pending_set_response_callback(pending, on_response_poweron, hal);
- tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
-
- tcore_hal_send_request(hal, pending);
+ sn_property = tcore_plugin_ref_property(plugin, "SN");
+ g_free(sn_property);
- return TRUE;
+ dbg("Exit");
}
#include <hal.h>
#include <core_object.h>
#include <plugin.h>
+#include <user_request.h>
#include <queue.h>
#include <co_network.h>
#include <co_ps.h>
}
}
-static void nwk_prepare_and_send_pending_request(TcorePlugin *plugin, char *co_name, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, UserRequest *ur, TcorePendingResponseCallback callback)
+static void nwk_prepare_and_send_pending_request(CoreObject *co, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, UserRequest *ur, TcorePendingResponseCallback callback)
{
TcoreATRequest *req = NULL;
TcoreHal *hal;
- CoreObject *o = NULL;
TcorePending *pending = NULL;
TReturn ret;
- o = tcore_plugin_ref_core_object(plugin, co_name);
- hal = tcore_object_get_hal(o);
+ hal = tcore_object_get_hal(co);
- pending = tcore_pending_new(o, 0);
+ pending = tcore_pending_new(co, 0);
req = tcore_at_request_new(at_cmd, prefix, at_cmd_type);
dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
static void _ps_set(TcorePlugin *p, int status)
{
- GSList *co_list = NULL;
+ CoreObject *co_ps;
- co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_PS);
- do {
- CoreObject *o = NULL;
- o = (CoreObject *) co_list->data;
- if (!o)
- break;
-
- if (status == NETWORK_SERVICE_DOMAIN_STATUS_FULL) {
- tcore_ps_set_online(o, TRUE);
- } else {
- tcore_ps_set_online(o, FALSE);
- }
- } while ((co_list = g_slist_next(co_list)));
+ co_ps = tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_PS);
+ if (co_ps == NULL) {
+ err("No PS Core Object on plugin");
+ return;
+ }
- g_slist_free(co_list);
+ if (status == NETWORK_SERVICE_DOMAIN_STATUS_FULL)
+ tcore_ps_set_online(co_ps, TRUE);
+ else
+ tcore_ps_set_online(co_ps, FALSE);
}
static void on_timeout_search_network(TcorePending *p, void *user_data)
dbg("new pending(AT+XOPS=0/5/6 for Nitz PLMN name)");
/* Get NITZ name and plmn_id via AT+XCOPS = 0/5/6 */
- nwk_prepare_and_send_pending_request(tcore_object_ref_plugin(o), "umts_network", "AT+XCOPS=0;+XCOPS=5;+XCOPS=6", "+XCOPS", TCORE_AT_MULTILINE, ur, on_response_get_nitz_name);
+ nwk_prepare_and_send_pending_request(o, "AT+XCOPS=0;+XCOPS=5;+XCOPS=6", "+XCOPS", TCORE_AT_MULTILINE, ur, on_response_get_nitz_name);
} else {
dbg("line is NULL");
}
dbg("new pending(AT+COPS?)");
- nwk_prepare_and_send_pending_request(tcore_object_ref_plugin(o), "umts_network", "AT+COPS=3,2;+COPS?;+COPS=3,0;+COPS?", "+COPS", TCORE_AT_MULTILINE, ur, on_response_get_serving_network);
+ nwk_prepare_and_send_pending_request(o, "AT+COPS=3,2;+COPS?;+COPS=3,0;+COPS?", "+COPS", TCORE_AT_MULTILINE, ur, on_response_get_serving_network);
return TCORE_RETURN_SUCCESS;
}
.get_serving_network = get_serving_network,
};
-gboolean s_network_init(TcorePlugin *p, TcoreHal *h)
+gboolean s_network_init(TcorePlugin *cp, CoreObject *co_network)
{
- CoreObject *o = NULL;
+ dbg("Enter");
- o = tcore_network_new(p, "umts_network", &network_ops, h);
- if (!o)
- return FALSE;
+ tcore_network_override_ops(co_network, &network_ops);
- tcore_object_add_callback(o, "+CREG", on_event_cs_network_regist, NULL);
- tcore_object_add_callback(o, "+CGREG", on_event_ps_network_regist, NULL);
- tcore_object_add_callback(o, "+XCIEV", on_event_network_icon_info, NULL);
+ tcore_object_override_callback(co_network, "+CREG", on_event_cs_network_regist, NULL);
+ tcore_object_override_callback(co_network, "+CGREG", on_event_ps_network_regist, NULL);
+ tcore_object_override_callback(co_network, "+XCIEV", on_event_network_icon_info, NULL);
/* +CTZV: <tz>,<time> */
- tcore_object_add_callback(o, "+CTZV", on_event_network_ctzv_time_info, NULL);
+ tcore_object_override_callback(co_network, "+CTZV", on_event_network_ctzv_time_info, NULL);
- tcore_server_add_notification_hook(tcore_plugin_ref_server(p), TNOTI_SIM_STATUS, on_hook_sim_init, o);
+ tcore_server_add_notification_hook(tcore_plugin_ref_server(cp), TNOTI_SIM_STATUS, on_hook_sim_init, co_network);
- _insert_mcc_mnc_oper_list(p, o);
+ _insert_mcc_mnc_oper_list(cp, co_network);
+
+ dbg("Exit");
return TRUE;
}
-void s_network_exit(TcorePlugin *p)
+void s_network_exit(TcorePlugin *cp, CoreObject *co_network)
{
- CoreObject *o;
-
- o = tcore_plugin_ref_core_object(p, "umts_network");
-
- tcore_network_free(o);
+ dbg("Exit");
}
.delete_record = s_delete_record,
};
-gboolean s_phonebook_init(TcorePlugin *p, TcoreHal *h)
+gboolean s_phonebook_init(TcorePlugin *cp, CoreObject *co_phonebook)
{
- CoreObject *o = NULL;
-
dbg("Entry");
- o = tcore_phonebook_new(p, "phonebook", &phonebook_ops, h);
- if (!o)
- return FALSE;
- tcore_object_add_callback(o, "+PBREADY", on_event_phonebook_status, NULL);
+ tcore_phonebook_override_ops(co_phonebook, &phonebook_ops);
+
+ tcore_object_override_callback(co_phonebook, "+PBREADY", on_event_phonebook_status, NULL);
+
dbg("Exit");
+
return TRUE;
}
-void s_phonebook_exit(TcorePlugin *p)
+void s_phonebook_exit(TcorePlugin *cp, CoreObject *co_phonebook)
{
- CoreObject *o = NULL;
- o = tcore_plugin_ref_core_object(p, "phonebook");
- if (!o)
- return;
-
- tcore_phonebook_free(o);
+ dbg("Exit");
}
#include "s_common.h"
#include "s_ps.h"
-
-
-#define VNET_CH_PATH_BOOT0 "/dev/umts_boot0"
-#define IOCTL_CG_DATA_SEND _IO('o', 0x37)
-
/*Invalid Session ID*/
#define PS_INVALID_CID 999 /*Need to check */
#define AT_XDNS_ENABLE 1
#define AT_XDNS_DISABLE 0
#define AT_SESSION_DOWN 0
+
static void _ps_free(void *ptr)
{
dbg("Entered");
struct tnoti_ps_call_status data_resp = {0};
dbg("Entered");
data_resp.context_id = tcore_context_get_id(ps_context);
- data_resp.state = AT_SESSION_DOWN; /*check value of state*/
- data_resp.result = 0xFF; /*check error value*/
+ data_resp.state = PS_DATA_CALL_NOT_CONNECTED; /*check value of state*/
tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps,
TNOTI_PS_CALL_STATUS, sizeof(struct tnoti_ps_call_status), &data_resp);
(void) tcore_context_set_state(ps_context, CONTEXT_STATE_DEACTIVATED);
dbg("Exit");
}
-static TReturn _pdp_device_control(unsigned int cid)
-{
- int fd = -1;
- int ret = -1;
- fd = open(VNET_CH_PATH_BOOT0, O_RDWR);
- if (fd < 0) {
- dbg("error : open [ %s ] [ %s ]", VNET_CH_PATH_BOOT0, strerror(errno));
- return -1;
- }
- /*To Do for different Cids*/
- dbg("Send IOCTL: arg 0x05 (0101) HSIC1, cid=%d \n", cid);
- if (cid == 1) {
- ret = ioctl(fd, IOCTL_CG_DATA_SEND, 0x05);
- } else if (cid == 2) {
- ret = ioctl(fd, IOCTL_CG_DATA_SEND, 0xA);
- } else {
- dbg("More Than 2 context are not supported right Now");
- }
- close(fd);
- if (ret < 0) {
- dbg("[ error ] send IOCTL_CG_DATA_SEND (0x%x) fail!! \n", IOCTL_CG_DATA_SEND);
- return TCORE_RETURN_FAILURE;
- } else {
- dbg("[ ok ] send IOCTL_CG_DATA_SEND (0x%x) success!! \n", IOCTL_CG_DATA_SEND);
- return TCORE_RETURN_SUCCESS;
- }
-}
-
-static gboolean on_event_cgev_handle(CoreObject *co_ps, const void *data, void *user_data)
-{
- char *token = NULL;
- GSList *tokens = NULL;
- GSList *lines = NULL;
- const char *line = NULL;
- char *noti_data = NULL;
- int i = 0;
- int value = 20;
- int state = -1;
- struct tnoti_ps_call_status data_resp = {0};
-
- dbg("Entered");
- lines = (GSList *) data;
- line = (const char *) lines->data;
- dbg("Lines->data :-%s", line);
-
- tokens = tcore_at_tok_new(line);
- switch (g_slist_length(tokens)) {
- case 0:
- {
- dbg("No token present: Ignore +CGEV Notifications ");
- return TRUE;
- }
-
- case 1:
- {
- dbg("one Token present");
- noti_data = g_slist_nth_data(tokens, 0);
- dbg("notification data :-%s", noti_data);
- if (0 == strcmp(noti_data, "ME CLASS B")) {
- dbg("ME Class B notification received");
- goto ignore;
- }
- if (0 == strcmp(noti_data, "NW CLASS A")) {
- dbg("NW Class A notification received");
- goto ignore;
- }
- token = strtok(noti_data, " ");
- while (token != NULL) {
- if ((i == 0) && (0 != strcmp(token, "ME"))) {
- break;
- }
- if ((i == 1) && (0 != strcmp(token, "PDN"))) {
- break;
- }
- if ((i == 2) && (0 == strcmp(token, "ACT"))) {
- state = 1;
- }
- if ((i == 2) && (0 == strcmp(token, "DEACT"))) {
- state = 0;
- }
- if (i == 3) {
- value = atoi(token);
- break;
- }
- i++;
- token = strtok(NULL, " ");
- }
- dbg("value:%d ", value);
- i = 0;
- break;
- }
-
- case 3:
- {
- i = 0;
- state = 0;
- value = 0;
- dbg("Three Token present");
- noti_data = g_slist_nth_data(tokens, 0);
- dbg("notification data :-%s", noti_data);
- token = strtok(noti_data, " ");
- while (token != NULL) {
- if ((i == 0) && (0 == strcmp(token, "ME"))) {
- state = 1;
- }
- if ((i == 1) && (0 != strcmp(token, "DEACT"))) {
- break;
- }
- if ((i == 2) && (0 == strcmp(token, "\"IP\"")) && (0 == state)) {
- dbg("MObile Deactiavted the Context");
- value = 10;
- break;
- }
- if ((i == 2) && (0 == strcmp(token, "\"IP\"")) && (1 == state)) {
- dbg("NW Deactiavted the Context");
- value = 10;
- break;
- }
- i++;
- token = strtok(NULL, " ");
- }
- if (value == 10 && state == 0) {
- dbg("Recieved Notification for Context deactivations from network");
- noti_data = g_slist_nth_data(tokens, 1);
- dbg("PDP Address :- %s", noti_data);
- noti_data = g_slist_nth_data(tokens, 2);
- dbg("CID got deactivated :- %d", atoi(noti_data));
- }
- if (value == 10 && state == 1) {
- dbg("Recieved Notification for Context deactivations from Mobile");
- noti_data = g_slist_nth_data(tokens, 1);
- dbg("PDP Address :- %s", noti_data);
- noti_data = g_slist_nth_data(tokens, 2);
- dbg("CID got deactivated :- %d", atoi(noti_data));
- }
- data_resp.context_id = atoi(noti_data);
- data_resp.state = 3; /*check value of state*/
- dbg("State of the service :- %d", data_resp.state);
- data_resp.result = 0xFF; /*check error value*/
- dbg("Sending the notification");
-
- tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps,
- TNOTI_PS_CALL_STATUS, sizeof(struct tnoti_ps_call_status), &data_resp);
-
- state = 100;
- value = 100;
-
- break;
- }
-
- default:
- {
- dbg("Ignore +CGEV Notifications ");
- }
- }
- if (state == 1) {
- dbg("Notification recieved for Activation of CID:-%d", value);
- } else if (state == 0) {
- dbg("Notification recieved for Deactivation of CID:-%d", value);
- } else {
- dbg("ignore");
- }
-ignore:
- tcore_at_tok_free(tokens);
- return TRUE;
-}
static gboolean on_event_dun_call_notification(CoreObject *o, const void *data, void *user_data)
{
return;
}
}
-static void on_response_data_counter_command(TcorePending *p, int data_len, const void *data, void *user_data)
-{
- CoreObject *ps_context = user_data;
- const TcoreATResponse *resp = data;
- CoreObject *co_ps = tcore_pending_ref_core_object(p);
-
- GSList *tokens = NULL;
- GSList *pRespData;
- const char *line = NULL;
- int no_pdp_active = 0;
- unsigned long long Rx;
- unsigned long long Tx;
- int cid = tcore_context_get_id(ps_context);
- dbg("Entered");
-
- if (resp->final_response) {
- dbg("Response OK");
- dbg(" response lines : -%s", resp->lines);
- if (resp->lines) {
- pRespData = (GSList *) resp->lines;
- no_pdp_active = g_slist_length(pRespData);
- dbg("Total Number of Active PS Context :- %d", no_pdp_active);
-
- if (no_pdp_active == 0) {
- return;
- }
- while (pRespData) {
- dbg("Entered the Loop pRespData");
-
- line = (const char *) pRespData->data;
- dbg("Response->lines->data :%s", line);
- tokens = tcore_at_tok_new(line);
- if (cid == atoi(g_slist_nth_data(tokens, 0))) {
- dbg("Found the data for our CID");
- Tx = (unsigned long long) g_ascii_strtoull((g_slist_nth_data(tokens, 1)), NULL, 10);
- dbg("Tx: %d", Tx);
-
- Rx = (unsigned long long) g_ascii_strtoull((g_slist_nth_data(tokens, 2)), NULL, 10);
- dbg("Rx: %d", Rx);
-
- tcore_at_tok_free(tokens);
- tokens = NULL;
- dbg("Exiting the Loop pRespData");
- break;
- }
- tcore_at_tok_free(tokens);
- tokens = NULL;
- pRespData = pRespData->next;
- }
- dbg("Sending Data counter notifications");
-
- tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps,
- TNOTI_PS_CURRENT_SESSION_DATA_COUNTER, 0, NULL);
- return;
- } else {
- dbg("No Active PS Context");
- }
- }
- dbg("Response NOK");
-}
-
-static TReturn send_data_counter_command(CoreObject *co_ps, CoreObject *ps_context)
-{
- TcoreHal *hal = NULL;
- TcorePending *pending = NULL;
- char cmd_str[MAX_AT_CMD_STR_LEN];
-
- dbg("Enetered");
- memset(cmd_str, 0x0, MAX_AT_CMD_STR_LEN);
-
- hal = tcore_object_get_hal(co_ps);
- (void) sprintf(cmd_str, "AT+XGCNTRD");
- pending = tcore_at_pending_new(co_ps, cmd_str, "+XGCNTRD", TCORE_AT_MULTILINE,
- on_response_data_counter_command, ps_context);
- if (TCORE_RETURN_SUCCESS == tcore_hal_send_request(hal, pending)) {
- return TCORE_RETURN_SUCCESS;
- }
- _unable_to_get_pending(co_ps, ps_context);
- return TCORE_RETURN_FAILURE;
-/*Add code if unable to get the data usage*/
-}
-static void on_response_deactivate_ps_context(TcorePending *p, int data_len, const void *data, void *user_data)
+static void on_mount_netif(CoreObject *co_ps, const char *netif_name,
+ void *user_data)
{
- CoreObject *co_ps = tcore_pending_ref_core_object(p);
CoreObject *ps_context = user_data;
- const TcoreATResponse *resp = data;
- int cid;
+ struct tnoti_ps_call_status data_status = {0};
+ Server *server;
- cid = tcore_context_get_id(ps_context);
- if (resp->success) {
- dbg("Response OK");
- /*get the data usage and report it application*/
- (void) send_data_counter_command(co_ps, ps_context);
- /*get the HSDPA status and report it to server*/
- } else {
- dbg("Response NOK");
- send_undefine_context_cmd(co_ps, ps_context);
- }
- return;
-}
+ dbg("Enter");
-static TReturn deactivate_ps_context(CoreObject *co_ps, CoreObject *ps_context, void *user_data)
-{
- TcoreHal *hal = NULL;
- TcorePending *pending = NULL;
- unsigned int cid = PS_INVALID_CID;
- char cmd_str[MAX_AT_CMD_STR_LEN];
+ dbg("devname = [%s]", netif_name);
- dbg("Entered");
- memset(cmd_str, 0x0, MAX_AT_CMD_STR_LEN);
+ tcore_context_set_ipv4_devname(ps_context, netif_name);
+ if (tcore_util_netif(netif_name, TRUE) != TCORE_RETURN_SUCCESS) {
+ dbg("disabling network interface failed");
+ return;
+ }
- /*Getting Context ID from Core Object*/
- cid = tcore_context_get_id(ps_context);
+ server = tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps));
- /* FIXME: Before MUX setup, use PHY HAL directly. */
- hal = tcore_object_get_hal(co_ps);
- if(FALSE == tcore_hal_get_power_state(hal)){
- dbg("cp not ready/n");
- return TCORE_RETURN_ENOSYS;
- }
+ data_status.context_id = tcore_context_get_id(ps_context);
+ data_status.state = PS_DATA_CALL_CONNECTED;
- (void) sprintf(cmd_str, "AT+CGACT=%d,%d", AT_PDP_DEACTIVATE, cid);
- dbg("At commands :- %s", cmd_str);
+ tcore_server_send_notification(server, co_ps,
+ TNOTI_PS_CALL_STATUS,
+ sizeof(struct tnoti_ps_call_status),
+ &data_status);
- pending = tcore_at_pending_new(co_ps, cmd_str, NULL, TCORE_AT_NO_RESULT,
- on_response_deactivate_ps_context, ps_context);
- if (TCORE_RETURN_SUCCESS == tcore_hal_send_request(hal, pending)) {
- (void) tcore_context_set_state(ps_context, CONTEXT_STATE_DEACTIVATING);
- return TCORE_RETURN_SUCCESS;
- }
- _unable_to_get_pending(co_ps, ps_context);
- return TCORE_RETURN_FAILURE;
+ dbg("Exit");
}
static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *data, void *user_data)
{
- struct tnoti_ps_pdp_ipconfiguration noti = {0};
- struct tnoti_ps_call_status data_status = {0};
- char devname[10] = {0, };
- char *dns_prim = NULL;
- char *dns_sec = NULL;
- char *pdp_address = NULL;
- char addr[4] = {0};
GSList *tokens = NULL;
GSList *pRespData;
const char *line = NULL;
+ char *dns_prim = NULL;
+ char *dns_sec = NULL;
char *token_dns = NULL;
- char *token_add = NULL;
-
- char *token_pdp_address = NULL;
int no_pdp_active = 0;
- int index = 0;
-
CoreObject *ps_context = user_data;
const TcoreATResponse *resp = data;
CoreObject *co_ps = tcore_pending_ref_core_object(p);
int cid = tcore_context_get_id(ps_context);
+ TcoreHal *h = tcore_object_get_hal(co_ps);
dbg("Entered");
dns_prim = util_removeQuotes((void *) token_dns);
dbg("Token_dns :%s", token_dns);
dbg("Primary DNS :- %s", dns_prim);
- index = 0;
- token_add = strtok(dns_prim, ".");
- while (token_add != NULL) {
- noti.primary_dns[index++] = atoi(token_add);
- token_add = strtok(NULL, ".");
- }
- _ps_free(dns_prim);
}
{ /* Read Secondary DNS */
- token_add = NULL;
token_dns = g_slist_nth_data(tokens, 2);
dns_sec = util_removeQuotes((void *) token_dns);
dbg("Token_dns :%s", token_dns);
dbg("Secondary DNS :- %s", dns_sec);
- index = 0;
- token_add = strtok(dns_sec, ".");
- while (token_add != NULL) {
- noti.secondary_dns[index++] = atoi(token_add);
- token_add = strtok(NULL, ".");
- }
- _ps_free(dns_sec);
}
+
+ tcore_context_set_ipv4_dns(ps_context, dns_prim, dns_sec);
+ _ps_free(dns_prim);
+ _ps_free(dns_sec);
+
tcore_at_tok_free(tokens);
tokens = NULL;
goto exit_success;
exit_fail:
{
dbg("Adding default DNS");
- dbg("Adding the Primary DNS");
- noti.primary_dns[0] = 8;
- noti.primary_dns[1] = 8;
- noti.primary_dns[2] = 8;
- noti.primary_dns[3] = 8;
- dbg("Adding Secondary DNS");
- noti.secondary_dns[0] = 8;
- noti.secondary_dns[1] = 8;
- noti.secondary_dns[2] = 4;
- noti.secondary_dns[3] = 4;
+
+ tcore_context_set_ipv4_dns(ps_context, "8.8.8.8", "8.8.4.4");
}
exit_success:
{
- dbg("Able to get the DNS from the DNS Query");
- token_pdp_address = tcore_context_get_address(ps_context);
- pdp_address = util_removeQuotes((void *) token_pdp_address);
-
- dbg("PDP address :- %s", pdp_address);
- /* Store IP address in char array, Telephony expected IP address in this format */
- token_add = strtok(pdp_address, ".");
- index = 0;
- while ((token_add != NULL) && (index < 4)) { /* Currently only IPv4 is supported */
- addr[index++] = atoi(token_add);
- token_add = strtok(NULL, ".");
- }
- _ps_free(pdp_address);
- _ps_free((void *) token_pdp_address);
- noti.field_flag = (0x0001 & 0x0002 & 0x0004);
- noti.err = 0;
- noti.context_id = cid;
- memcpy(¬i.ip_address, &addr, 4);
- if (_pdp_device_control(cid) != TCORE_RETURN_SUCCESS) {
- dbg("_pdp_device_control() failed. errno=%d", errno);
- }
- snprintf(devname, 10, "pdp%d", cid - 1);
- memcpy(noti.devname, devname, 10);
- dbg("devname = [%s]", devname);
- if (tcore_util_netif_up(devname) != TCORE_RETURN_SUCCESS) {
- dbg("util_netif_up() failed. errno=%d", errno);
+ /* mount network interface */
+ if (tcore_hal_setup_netif(h, co_ps, on_mount_netif, ps_context, cid, TRUE)
+ != TCORE_RETURN_SUCCESS) {
+ err("Setup network interface failed");
+ return;
}
- dbg("Send Notification upwards of IP address");
- tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps, TNOTI_PS_PDP_IPCONFIGURATION,
- sizeof(struct tnoti_ps_pdp_ipconfiguration), ¬i);
-
- data_status.context_id = cid;
- data_status.state = 1;
- data_status.result = 0;
-
- tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps,
- TNOTI_PS_CALL_STATUS, sizeof(struct tnoti_ps_call_status), &data_status);
dbg("EXIT : Without error");
- return;
}
}
dbg("token_pdp_address :- %s", token_pdp_address);
/* Strip off starting " and ending " from this token to read actual PDP address */
- (void) tcore_context_set_address(ps_context, (const char *) token_pdp_address);
+ (void) tcore_context_set_ipv4_addr(ps_context, (const char *)token_pdp_address);
}
(void) send_get_dns_cmd(co_ps, ps_context);
} else {
dbg("Response NOK");
/*without PDP address we will not be able to start packet service*/
- (void) deactivate_ps_context(co_ps, ps_context, NULL);
+ tcore_ps_deactivate_context(co_ps, ps_context, NULL);
}
error:
tcore_at_tok_free(tokens);
dbg("Response OK");
dbg("DNS address getting is Enabled");
noti.context_id = cid;
- noti.state = 0;
- noti.result = 0;
+ noti.state = PS_DATA_CALL_CTX_DEFINED;
} else {
dbg("Response NOK");
noti.context_id = cid;
- noti.state = 3;
- noti.result = 0;
+ noti.state = PS_DATA_CALL_NOT_CONNECTED;
/*If response to enable the DNS NOK then we will use google DNS for the PDP context*/
}
return;
}
-static TReturn send_define_pdp_context_cmd(CoreObject *co_ps, CoreObject *ps_context)
+static TReturn define_ps_context(CoreObject *co_ps, CoreObject *ps_context, void *user_data)
{
TcoreHal *hal = NULL;
TcorePending *pending = NULL;
return TCORE_RETURN_FAILURE;
}
-static TReturn define_ps_context(CoreObject *co_ps, CoreObject *ps_context, void *user_data)
-{
- dbg("Entered");
-
- if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(co_ps))){
- dbg("cp not ready/n");
- return TCORE_RETURN_ENOSYS;
- }
- return send_define_pdp_context_cmd(co_ps, ps_context);
-}
-
static struct tcore_ps_operations ps_ops = {
.define_context = define_ps_context,
.activate_context = activate_ps_context,
- .deactivate_context = deactivate_ps_context
+ /* Use AT_standard entry point */
+ .deactivate_context = NULL
};
-gboolean s_ps_init(TcorePlugin *p, TcoreHal *hal)
+gboolean s_ps_init(TcorePlugin *cp, CoreObject *co_ps)
{
- CoreObject *o;
- struct context *context_table = NULL;
+ TcorePlugin *plugin = tcore_object_ref_plugin(co_ps);
- dbg("Entered");
- o = tcore_ps_new(p, "umts_ps", &ps_ops, hal);
+ dbg("Enter");
+
+ tcore_ps_override_ops(co_ps, &ps_ops);
+
+ /*
+ * AT_standard handles standard CGEV notifications:
+ * tcore_object_override_callback(co, "+CGEV", on_cgev_notification, NULL);
+ * no need to handle it here.
+ */
- if (!o)
- return FALSE;
- tcore_object_link_user_data(o, (void *) context_table);
+ tcore_object_override_callback(co_ps, "+XNOTIFYDUNSTATUS", on_event_dun_call_notification, plugin);
- tcore_object_add_callback(o, "+CGEV", on_event_cgev_handle, p);
- tcore_object_add_callback(o, "+XNOTIFYDUNSTATUS", on_event_dun_call_notification, p);
+ dbg("Exit");
- dbg("Exiting");
return TRUE;
}
-void s_ps_exit(TcorePlugin *p)
+void s_ps_exit(TcorePlugin *cp, CoreObject *co_ps)
{
- CoreObject *o;
-
- dbg("Entered");
- o = tcore_plugin_ref_core_object(p, "umts_ps");
- if (!o)
- return;
-
- tcore_ps_free(o);
- dbg("Exiting");
+ dbg("Exit");
}
};
-gboolean s_sap_init(TcorePlugin *p, TcoreHal *h)
+gboolean s_sap_init(TcorePlugin *cp, CoreObject *co_sap)
{
- CoreObject *o = NULL;
-
dbg("Entry");
- o = tcore_sap_new(p, "sap", &sap_ops, h);
- if (!o)
- return FALSE;
- tcore_object_add_callback(o,"+XBCSTAT", on_event_sap_status, NULL);
- //tcore_object_add_callback(o, "NULL", on_event_sap_disconnect, NULL); //ToDo - Indication not present
+ tcore_sap_override_ops(co_sap, &sap_ops);
+
+ tcore_object_override_callback(co_sap,"+XBCSTAT", on_event_sap_status, NULL);
+
dbg("Exit");
+
return TRUE;
}
-void s_sap_exit(TcorePlugin *p)
+void s_sap_exit(TcorePlugin *cp, CoreObject *co_sap)
{
- CoreObject *o;
- o = tcore_plugin_ref_core_object(p, "sap");
- if (!o)
- return;
-
- tcore_sap_free(o);
+ dbg("Exit");
}
.terminal_response = s_terminal_response,
};
-gboolean s_sat_init(TcorePlugin *p, TcoreHal *h)
+gboolean s_sat_init(TcorePlugin *cp, CoreObject *co_sat)
{
- CoreObject *o = NULL;
-
dbg("Entry");
- o = tcore_sat_new(p, "sat", &sat_ops, h);
- if (!o) {
- dbg("CoreObject NULL !!");
- return FALSE;
- }
- tcore_object_add_callback(o, "+SATI", on_event_sat_proactive_command, NULL);
- tcore_object_add_callback(o, "+SATN", on_event_sat_proactive_command, NULL);
- tcore_object_add_callback(o, "+SATF", on_response_terminal_response_confirm, NULL);
+ tcore_sat_override_ops(co_sat, &sat_ops);
+
+ tcore_object_override_callback(co_sat, "+SATI", on_event_sat_proactive_command, NULL);
+ tcore_object_override_callback(co_sat, "+SATN", on_event_sat_proactive_command, NULL);
+ tcore_object_override_callback(co_sat, "+SATF", on_response_terminal_response_confirm, NULL);
dbg("Exit");
+
return TRUE;
}
-void s_sat_exit(TcorePlugin *p)
+void s_sat_exit(TcorePlugin *cp, CoreObject *co_sat)
{
- CoreObject *o = NULL;
- o = tcore_plugin_ref_core_object(p, "sat");
- if (!o)
- return;
- tcore_sat_free(o);
+ dbg("Exit");
}
.req_authentication = NULL,
};
-gboolean s_sim_init(TcorePlugin *p, TcoreHal *h)
+gboolean s_sim_init(TcorePlugin *cp, CoreObject *co_sim)
{
- CoreObject *o;
- struct s_sim_property *file_meta = NULL;
- GQueue *work_queue;
-
- dbg("entry");
+ struct s_sim_property *file_meta;
- o = tcore_sim_new(p, "sim", &sim_ops, h);
+ dbg("Entry");
- if (!o)
- return FALSE;
+ tcore_sim_override_ops(co_sim, &sim_ops);
- file_meta = calloc(sizeof(struct s_sim_property), 1);
+ file_meta = g_try_new0(struct s_sim_property, 1);
if (!file_meta)
return FALSE;
- work_queue = g_queue_new();
- tcore_object_link_user_data(o, work_queue);
+ tcore_sim_link_userdata(co_sim, file_meta);
- file_meta->first_recv_status = SIM_STATUS_UNKNOWN;
- tcore_sim_link_userdata(o, file_meta);
+ tcore_object_override_callback(co_sim, "+XLOCK", on_event_facility_lock_status, NULL);
+ tcore_object_override_callback(co_sim, "+XSIM", on_event_pin_status, NULL);
- tcore_object_add_callback(o, "+XLOCK", on_event_facility_lock_status, NULL);
- tcore_object_add_callback(o, "+XSIM", on_event_pin_status, NULL);
+ dbg("Exit");
- dbg("exit");
return TRUE;
}
-void s_sim_exit(TcorePlugin *p)
+void s_sim_exit(TcorePlugin *cp, CoreObject *co_sim)
{
- CoreObject *o;
+ struct s_sim_property *file_meta;
- o = tcore_plugin_ref_core_object(p, "sim");
- if (!o)
- return;
- tcore_sim_free(o);
+ file_meta = tcore_sim_ref_userdata(co_sim);
+ g_free(file_meta);
+
+ dbg("Exit");
}
#include <at.h>
#include <plugin.h>
+#include <util.h>
+
#include "common/TelErr.h"
#include "s_common.h"
#include "s_sms.h"
#define AT_SW1_LEN_RESP 0x9F
#define AT_MAX_RECORD_LEN 256
-#define AT_EF_SMS_RECORD_LEN 176
+ /* SCA 12 bytes long and TDPU is 164 bytes long */
+#define PDU_LEN_MAX 176
+#define HEX_PDU_LEN_MAX ((PDU_LEN_MAX * 2) + 1)
/*=============================================================
String Preprocessor
ptr_data = (unsigned char *)recordData;
- co_sim = tcore_plugin_ref_core_object(tcore_pending_ref_plugin(p), "sim");
+ co_sim = tcore_plugin_ref_core_object(tcore_pending_ref_plugin(p), CORE_OBJECT_TYPE_SIM);
sim_type = tcore_sim_get_type(co_sim);
dbg("sim type is %d",sim_type);
util_byte_to_hex((const char *)&msg_status, (char *)encoded_data, 1);
//Update EF-SMS with just status byte overwritten, rest 175 bytes are same as received in read information
- cmd_str = g_strdup_printf("AT+CRSM=220,28476,%d, 4, %d, \"%s\"", (req_msg_status->index+1), AT_EF_SMS_RECORD_LEN, encoded_data);
+ cmd_str = g_strdup_printf("AT+CRSM=220,28476,%d, 4, %d, \"%s\"", (req_msg_status->index+1), PDU_LEN_MAX, encoded_data);
atreq = tcore_at_request_new((const char *)cmd_str, "+CRSM", TCORE_AT_SINGLELINE);
pending = tcore_pending_new(tcore_pending_ref_core_object(pending), 0);
if (NULL == cmd_str || NULL == atreq || NULL == pending) {
/*=============================================================
Requests
==============================================================*/
-static TReturn send_umts_msg(CoreObject *obj, UserRequest *ur)
+static TReturn send_umts_msg(CoreObject *co_sms, UserRequest *ur)
{
- gchar *cmd_str = NULL;
- TcoreHal *hal = NULL;
- TcoreATRequest *atreq = NULL;
- TcorePending *pending = NULL;
- const struct treq_sms_send_umts_msg *sendUmtsMsg = NULL;
- char buf[2*(SMS_SMSP_ADDRESS_LEN+SMS_SMDATA_SIZE_MAX)+1] = {0};
- int ScLength = 0;
- int pdu_len = 0;
+ const struct treq_sms_send_umts_msg *send_msg;
+ const unsigned char *tpdu_byte_data, *sca_byte_data;
+ int tpdu_byte_len, pdu_byte_len;
+ char buf[HEX_PDU_LEN_MAX];
+ char pdu[PDU_LEN_MAX];
+ char *cmd_str;
+ int pdu_hex_len, mms;
+ TReturn ret;
- dbg("Entry");
+ dbg("Enter");
- sendUmtsMsg = tcore_user_request_ref_data(ur, NULL);
- hal = tcore_object_get_hal(obj);
- if (NULL == sendUmtsMsg || NULL == hal) {
- err("NULL input. Unable to proceed");
- dbg("sendUmtsMsg: [%p], hal: [%p]", sendUmtsMsg, hal);
+ send_msg = tcore_user_request_ref_data(ur, NULL);
- dbg("Exit");
- return TCORE_RETURN_EINVAL;
- }
+ tpdu_byte_data = send_msg->msgDataPackage.tpduData;
+ sca_byte_data = send_msg->msgDataPackage.sca;
- if(FALSE == tcore_hal_get_power_state(hal)){
- dbg("cp not ready/n");
- return TCORE_RETURN_ENOSYS;
- }
- dbg("msgLength: [%d]", sendUmtsMsg->msgDataPackage.msgLength);
- util_hex_dump(" ", (SMS_SMDATA_SIZE_MAX+1), (void *)sendUmtsMsg->msgDataPackage.tpduData);
- util_hex_dump(" ", SMS_SMSP_ADDRESS_LEN, (void *)sendUmtsMsg->msgDataPackage.sca);
+ /* TPDU length is in byte */
+ tpdu_byte_len = send_msg->msgDataPackage.msgLength;
- ScLength = (int)sendUmtsMsg->msgDataPackage.sca[0];
+ /* Use same Radio Resource Channel */
+ mms = send_msg->more;
- dbg("ScLength: [%d]", ScLength);
+ dbg("TDPU length: [%d]", tpdu_byte_len);
+ dbg("SCA semi-octet length: [%d]", sca_byte_data[0]);
- if ((sendUmtsMsg->msgDataPackage.msgLength > 0)
- && (sendUmtsMsg->msgDataPackage.msgLength <= SMS_SMDATA_SIZE_MAX)
- && (ScLength <= SMS_SCADDRESS_LEN_MAX)) {
- if (ScLength == 0) { // ScAddress not specified
- buf[0] = '0';
- buf[1] = '0';
- pdu_len = 2;
- } else {
- dbg("Specifying SCA in TPDU is currently not supported");
+ /* Prepare PDU for hex encoding */
+ pdu_byte_len = tcore_util_pdu_encode(sca_byte_data, tpdu_byte_data,
+ tpdu_byte_len, pdu);
- buf[0] = '0';
- buf[1] = '0';
- pdu_len = 2;
- }
-
- util_byte_to_hex((const char *)sendUmtsMsg->msgDataPackage.tpduData, (char *)&buf[pdu_len], sendUmtsMsg->msgDataPackage.msgLength);
-
- pdu_len = pdu_len + 2*sendUmtsMsg->msgDataPackage.msgLength;
-
- buf[pdu_len] = '\0'; //Ensure termination
+ pdu_hex_len = (int) tcore_util_encode_hex((unsigned char *) pdu,
+ pdu_byte_len, buf);
- dbg("pdu_len: [%d]", pdu_len);
- util_hex_dump(" ", sizeof(buf), (void *)buf);
-
- //AT+CMGS=<length><CR>PDU is given<ctrl-Z/ESC>
- cmd_str = g_strdup_printf("AT+CMGS=%d%s%s\x1A", sendUmtsMsg->msgDataPackage.msgLength,"\r",buf);
- atreq = tcore_at_request_new((const char *)cmd_str, "+CMGS", TCORE_AT_SINGLELINE);
- pending = tcore_pending_new(obj, 0);
+ dbg("PDU hexadecimal length: [%d]", pdu_hex_len);
- if (NULL == cmd_str || NULL == atreq || NULL == pending) {
- err("Out of memory. Unable to proceed");
- dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
-
- //free memory we own
- g_free(cmd_str);
- util_sms_free_memory(atreq);
- util_sms_free_memory(pending);
+ if (mms > 0) {
+ cmd_str = g_strdup_printf("AT+CMMS=%d", mms);
- dbg("Exit");
- return TCORE_RETURN_ENOMEM;
+ ret = tcore_prepare_and_send_at_request(co_sms, cmd_str, NULL,
+ TCORE_AT_NO_RESULT, NULL, NULL, NULL,
+ on_confirmation_sms_message_send,
+ NULL);
+ if (ret != TCORE_RETURN_SUCCESS) {
+ err("Failed to prepare and send AT request");
+ goto error;
}
- util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
+ g_free(cmd_str);
+ }
- tcore_pending_set_request_data(pending, 0, atreq);
- tcore_pending_set_response_callback(pending, on_response_send_umts_msg, NULL);
- tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
- tcore_hal_send_request(hal, pending);
+ cmd_str = g_strdup_printf("AT+CMGS=%d\r%s\x1A", tpdu_byte_len, buf);
- g_free(cmd_str);
+ ret = tcore_prepare_and_send_at_request(co_sms, cmd_str, "+CMGS:",
+ TCORE_AT_SINGLELINE, ur,
+ on_response_send_umts_msg, NULL,
+ on_confirmation_sms_message_send, NULL);
+ if (ret != TCORE_RETURN_SUCCESS)
+ err("Failed to prepare and send AT request");
- dbg("Exit");
- return TCORE_RETURN_SUCCESS;
- }
+error:
+ g_free(cmd_str);
- err("Invalid Data len");
dbg("Exit");
- return TCORE_RETURN_SMS_INVALID_DATA_LEN;
+
+ return ret;
}
static TReturn read_msg(CoreObject *obj, UserRequest *ur)
return TCORE_RETURN_SUCCESS;
}
-static TReturn get_storedMsgCnt(CoreObject *obj, UserRequest *ur)
+static TReturn get_stored_msg_cnt(CoreObject *obj, UserRequest *ur)
{
gchar *cmd_str = NULL;
TcoreHal *hal = NULL;
}
msg_status = tcore_user_request_ref_data(ur, NULL);
- cmd_str = g_strdup_printf("AT+CRSM=178,28476,%d,4,%d", (msg_status->index+1), AT_EF_SMS_RECORD_LEN);
+ cmd_str = g_strdup_printf("AT+CRSM=178,28476,%d,4,%d", (msg_status->index+1), PDU_LEN_MAX);
atreq = tcore_at_request_new((const char *)cmd_str, "+CRSM", TCORE_AT_SINGLELINE);
pending = tcore_pending_new(obj, 0);
if (NULL == cmd_str || NULL == atreq || NULL == pending) {
.read_msg = read_msg,
.save_msg = save_msg,
.delete_msg = delete_msg,
- .get_storedMsgCnt = get_storedMsgCnt,
+ .get_stored_msg_cnt = get_stored_msg_cnt,
.get_sca = get_sca,
.set_sca = set_sca,
.get_cb_config = get_cb_config,
.get_paramcnt = get_paramcnt,
};
-gboolean s_sms_init(TcorePlugin *plugin, TcoreHal *hal)
+gboolean s_sms_init(TcorePlugin *cp, CoreObject *co_sms)
{
- CoreObject *obj = NULL;
- struct property_sms_info *data = NULL;
- GQueue *work_queue = NULL;
- int *smsp_record_len = NULL;
+ int *smsp_record_len;
dbg("Entry");
- dbg("plugin: [%p]", plugin);
- dbg("hal: [%p]", hal);
-
- obj = tcore_sms_new(plugin, "umts_sms", &sms_ops, hal);
-
- data = calloc(sizeof(struct property_sms_info), 1);
-
- if (NULL == obj || NULL == data) {
- err("Unable to initialize. Exiting");
- s_sms_exit(plugin);
-
- dbg("Exit");
- return FALSE;
- }
- work_queue = g_queue_new();
- tcore_object_link_user_data(obj, work_queue);
+ tcore_sms_override_ops(co_sms, &sms_ops);
- //Registering for SMS notifications
- tcore_object_add_callback(obj, "\e+CMTI", on_event_class2_sms_incom_msg, NULL);
- tcore_object_add_callback(obj, "\e+CMT", on_event_sms_incom_msg, NULL);
+ /* Registering for SMS notifications */
+ tcore_object_override_callback(co_sms, "\e+CMTI", on_event_class2_sms_incom_msg, NULL);
+ tcore_object_override_callback(co_sms, "\e+CMT", on_event_sms_incom_msg, NULL);
- tcore_object_add_callback(obj, "\e+CDS", on_event_sms_incom_msg, NULL);
- tcore_object_add_callback(obj, "+XSMSMMSTAT", on_event_sms_memory_status, NULL);
- tcore_object_add_callback(obj, "+CMS", on_event_sms_memory_status, NULL);
+ tcore_object_override_callback(co_sms, "\e+CDS", on_event_sms_incom_msg, NULL);
+ tcore_object_override_callback(co_sms, "+XSMSMMSTAT", on_event_sms_memory_status, NULL);
+ tcore_object_override_callback(co_sms, "+CMS", on_event_sms_memory_status, NULL);
- tcore_object_add_callback(obj, "\e+CBMI", on_event_sms_cb_incom_msg, NULL);
- tcore_object_add_callback(obj, "\e+CBM", on_event_sms_cb_incom_msg, NULL);
- tcore_object_add_callback(obj, "+XSIM", on_event_sms_ready_status, NULL);
+ tcore_object_override_callback(co_sms, "\e+CBMI", on_event_sms_cb_incom_msg, NULL);
+ tcore_object_override_callback(co_sms, "\e+CBM", on_event_sms_cb_incom_msg, NULL);
+ tcore_object_override_callback(co_sms, "+XSIM", on_event_sms_ready_status, NULL);
- tcore_plugin_link_property(plugin, "SMS", data);
+ /* storing smsp record length */
+ smsp_record_len = g_new0(int, 1);
- //storing smsp record length
- smsp_record_len = calloc(sizeof(int), 1);
- tcore_plugin_link_property(plugin, "SMSPRECORDLEN", smsp_record_len);
+ tcore_plugin_link_property(cp, "SMSPRECORDLEN", smsp_record_len);
dbg("Exit");
+
return TRUE;
}
-void s_sms_exit(TcorePlugin *plugin)
+void s_sms_exit(TcorePlugin *cp, CoreObject *co_sms)
{
- CoreObject *obj = NULL;
- struct property_sms_info *data = NULL;
+ int *smsp_record_len;
- dbg("Entry");
- dbg("plugin: [%p]", plugin);
-
- obj = tcore_plugin_ref_core_object(plugin, "umts_sms");
- if (NULL == obj) {
- err("NULL core object. Nothing to do.");
- return;
- }
- tcore_sms_free(obj);
-
- data = tcore_plugin_ref_property(plugin, "SMS");
- util_sms_free_memory(data);
+ smsp_record_len = tcore_plugin_ref_property(cp, "SMSPRECORDLEN");
+ g_free(smsp_record_len);
dbg("Exit");
- return;
}
}
dbg("noti.str - %s", noti.str);
- core_obj = tcore_plugin_ref_core_object(p, "ss");
+ core_obj = tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_SS);
tcore_server_send_notification(tcore_plugin_ref_server(p),
core_obj,
TNOTI_SS_USSD,
dbg("function enter");
plugin = tcore_object_ref_plugin(o);
- co = tcore_plugin_ref_core_object(plugin, "call");
+ co = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL);
if (!co) {
dbg("[ error ] plugin_ref_core_object : call");
return FALSE;
return ret;
}
-gboolean s_ss_init(TcorePlugin *p, TcoreHal *h)
+gboolean s_ss_init(TcorePlugin *cp, CoreObject *co_ss)
{
- CoreObject *so = 0, *co = 0;
- struct property_call_info *data = 0;
+ CoreObject *co_call = NULL;
- so = tcore_ss_new(p, "ss", &ss_ops, h);
- if (!so) {
- dbg("[ error ] ss_new()");
- return FALSE;
- }
+ tcore_ss_override_ops(co_ss, &ss_ops);
- co = tcore_plugin_ref_core_object(p, "call");
- if (!co) {
- dbg("[ error ] plugin_ref_core_object");
+
+ co_call = tcore_plugin_ref_core_object(cp,
+ CORE_OBJECT_TYPE_CALL);
+ if (co_call) {
+ err("Can't find CALL core object");
return FALSE;
}
- tcore_call_control_set_operations(co, &call_ops);
-
- tcore_object_add_callback(so, "+CSSU", on_notification_ss_info, 0);
- tcore_object_add_callback(so, "+CSSI", on_notification_ss_info, 0);
- tcore_object_add_callback(so, "+CUSD", on_notification_ss_ussd, 0);
+ tcore_call_override_ops(co_call, NULL, &call_ops);
- data = calloc(sizeof(struct property_call_info *), 1);
- tcore_plugin_link_property(p, "SS", data);
+ tcore_object_override_callback(co_ss, "+CSSU", on_notification_ss_info, NULL);
+ tcore_object_override_callback(co_ss, "+CSSI", on_notification_ss_info, NULL);
+ tcore_object_override_callback(co_ss, "+CUSD", on_notification_ss_ussd, NULL);
return TRUE;
}
-void s_ss_exit(TcorePlugin *p)
+void s_ss_exit(TcorePlugin *cp, CoreObject *co_ss)
{
- CoreObject *o;
- struct property_network_info *data;
-
- o = tcore_plugin_ref_core_object(p, "ss");
-
- data = tcore_plugin_ref_property(p, "SS");
- if (data)
- free(data);
-
- tcore_ss_free(o);
+ dbg("Exit");
}