Fix log init.
Change-Id: I471b8ed1aa990eac54f3cbbd0bdd0c6eaf0da5c1
diff --git a/mbtk/include/mbtk/mbtk_info_api.h b/mbtk/include/mbtk/mbtk_info_api.h
index fef67fd..154a574 100755
--- a/mbtk/include/mbtk/mbtk_info_api.h
+++ b/mbtk/include/mbtk/mbtk_info_api.h
@@ -685,6 +685,47 @@
int8 gain;
} mbtk_ecall_gain_info_t;
+typedef enum {
+ MBTK_ECALL_URC_ID_ALACK = 0, // AL-ACK signal received (refer to : urc_data)
+ MBTK_ECALL_URC_ID_SYNC_LOST, // eIM lost synchronization with PSAP
+ // (A resynch occurs after the synchronization is lost.)
+ MBTK_ECALL_URC_ID_NACK, // NACK signal received
+ MBTK_ECALL_URC_ID_RESERVED_3,
+ MBTK_ECALL_URC_ID_RESERVED_4,
+ MBTK_ECALL_URC_ID_RESERVED_5, // 5
+ MBTK_ECALL_URC_ID_3GPP_FATAL, // eIM is terminated: fatal error (3GPP Abort function)
+ MBTK_ECALL_URC_ID_CALL_DROP, // eIM is terminated: call drop
+ MBTK_ECALL_URC_ID_GENERIC, // Generic error
+ MBTK_ECALL_URC_ID_MSD_REQ, // PSAP request MSD (Only for PULL modem)
+ MBTK_ECALL_URC_ID_MSD_SEND_START, // 10 : eIM starts sending MSD
+ MBTK_ECALL_URC_ID_INITIATION, // The eIM starts sending the Initiation signal (Only for PUSH modem).
+ // It also indicates that the call setup is completed.
+ MBTK_ECALL_URC_ID_SEND_MSD, // PUSH: SEND_MSD -> MSD_SEND_START
+ // PULL: SEND_MSD -> MSD_REQ -> MSD_SEND_START
+ MBTK_ECALL_URC_ID_SEND_MSD_FULL,// SEND MSD signal received too often, PSAP sync failure assumed
+ MBTK_ECALL_URC_ID_SYNCED_PSAP, // IVS eIM is synced with PSAP
+ MBTK_ECALL_URC_ID_SYNCED_PSAP_EIM, // 15: IVS eIM is synced with PSAP eIM
+ MBTK_ECALL_URC_ID_LLACK, // Link layer ACK received
+ MBTK_ECALL_URC_ID_HLACK, // Higher Layer ACK received (similar to AL-ACK (#0) but without data)
+ MBTK_ECALL_URC_ID_EIM_RESET, // The eIM transmitter idles after a full reset. The eIM transmitter is reset after sync loss
+ // (for example, because of the end of PSAP transmission).
+ MBTK_ECALL_URC_ID_EIM_IDLES, // The eIM transmitter idles after the transmission of the Initiation signal (push mode)
+ MBTK_ECALL_URC_ID_MSD_UPDATE, // 20 : MSD update request is received.
+ MBTK_ECALL_URC_ID_MSD_UPDATE_DONE, // MSD update is done.
+ MBTK_ECALL_URC_ID_MSD_UPDATE_ERR, // MSD update request cannot be processed.
+ MBTK_ECALL_URC_ID_T3_EXPIRED, // T3 expired
+ MBTK_ECALL_URC_ID_T5_EXPIRED, // T5 expired
+ MBTK_ECALL_URC_ID_T6_EXPIRED, // 25 : T6 expired
+ MBTK_ECALL_URC_ID_T7_EXPIRED, // T7 expired
+ MBTK_ECALL_URC_ID_TH_EXPIRED, // TH expired
+ MBTK_ECALL_URC_ID_RESERVED_28,
+ MBTK_ECALL_URC_ID_RESERVED_29,
+ MBTK_ECALL_URC_ID_RESERVED_30, // 30
+ MBTK_ECALL_URC_ID_IVS_EVENT_TIMEOUT,
+ MBTK_ECALL_URC_ID_PSAP_REQ, // Only for ERA
+ MBTK_ECALL_URC_ID_MSD_SEND_FAIL_FOR_NG // NG-eCall fail to transfer MSD
+} mbtk_ecall_urc_id_enum;
+
int ipv6_2_str(const void *ipv6, void *ipv6_str);
diff --git a/mbtk/libmbtk_lib/common/mbtk_log.c b/mbtk/libmbtk_lib/common/mbtk_log.c
index 3ffca33..ab599b4 100755
--- a/mbtk/libmbtk_lib/common/mbtk_log.c
+++ b/mbtk/libmbtk_lib/common/mbtk_log.c
@@ -21,6 +21,8 @@
#include "mbtk_log.h"
#include "mbtk_str.h"
+// extern char *__progname;
+
typedef enum {
LOG_ID_MAIN = 0,
LOG_ID_RADIO = 1,
@@ -40,6 +42,8 @@
static bool log_level_printed = FALSE;
+static bool log_init = FALSE;
+
/**
* @brief mbtk_log_init
*
@@ -60,6 +64,12 @@
*/
void mbtk_log_init(char* path, char* tag)
{
+ if(log_init) {
+ return;
+ } else {
+ log_init = TRUE;
+ }
+
if (str_empty(path)) {
tlog_fd = STDOUT_FILENO;
} else if (0 == memcmp(path, "syslog", 6)) {
@@ -90,6 +100,30 @@
int length = 0;
int ret = 0;
+ if(!log_init) {
+ char filename[64] = {0};
+ int fd = open("/proc/self/comm", O_RDONLY);
+ if(fd > 0) {
+ if(read(fd, filename, sizeof(filename)) > 0) {
+ // Delete last '\r' / '\n' / ' '
+ char *ptr = filename + strlen(filename) - 1;
+ while(ptr >= filename && (*ptr == '\r' || *ptr == '\n' || *ptr == ' '))
+ {
+ *ptr-- = '\0';
+ }
+
+ mbtk_log_init("radio", filename);
+ } else {
+ mbtk_log_init("radio", "MBTK");
+ }
+ close(fd);
+ } else {
+ mbtk_log_init("radio", "MBTK");
+ }
+
+ //mbtk_log_init("radio", __progname);
+ }
+
va_start(ap, format);
length = vsnprintf(buf, sizeof(buf), format, ap);
if (length < 0 || 0 == length) {
diff --git a/mbtk/mbtk_rild/src/ril_ecall.c b/mbtk/mbtk_rild/src/ril_ecall.c
index 7e3a03e..3c3d308 100755
--- a/mbtk/mbtk_rild/src/ril_ecall.c
+++ b/mbtk/mbtk_rild/src/ril_ecall.c
@@ -647,6 +647,7 @@
}
if(cfg_info->type & MBTK_ECALL_CFG_T3) {
+ LOGD("MBTK_ECALL_CFG_T3");
if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T3, cfg_info->data[MBTK_ECALL_CFG_ITEM_T3], cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON)
{
@@ -655,6 +656,7 @@
}
if(cfg_info->type & MBTK_ECALL_CFG_T5) {
+ LOGD("MBTK_ECALL_CFG_T5");
if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T5, cfg_info->data[MBTK_ECALL_CFG_ITEM_T5], cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON)
{
@@ -663,6 +665,7 @@
}
if(cfg_info->type & MBTK_ECALL_CFG_T6) {
+ LOGD("MBTK_ECALL_CFG_T6");
if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T6, cfg_info->data[MBTK_ECALL_CFG_ITEM_T6], cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON)
{
@@ -671,6 +674,7 @@
}
if(cfg_info->type & MBTK_ECALL_CFG_T7) {
+ LOGD("MBTK_ECALL_CFG_T7");
if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T7, cfg_info->data[MBTK_ECALL_CFG_ITEM_T7], cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON)
{
@@ -679,6 +683,7 @@
}
if(cfg_info->type & MBTK_ECALL_CFG_TH) {
+ LOGD("MBTK_ECALL_CFG_TH");
if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_TH, cfg_info->data[MBTK_ECALL_CFG_ITEM_TH], cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON)
{
@@ -688,6 +693,7 @@
if(cfg_info->type & MBTK_ECALL_CFG_TIMER_CALLBACK)
{
+ LOGD("MBTK_ECALL_CFG_TIMER_CALLBACK");
if(cfg_ecalltimer_set("callback", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK] / 1000, cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON) {
goto exit;
@@ -695,55 +701,63 @@
}
if(cfg_info->type & MBTK_ECALL_CFG_TIMER_CLEARDOWN)
{
+ LOGD("MBTK_ECALL_CFG_TIMER_CLEARDOWN");
if(cfg_ecalltimer_set("cleardown", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] / 1000, cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON) {
goto exit;
}
}
- if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_DEREG)
+ if(cfg_info->type & MBTK_ECALL_CFG_TIMER_DEREG)
{
+ LOGD("MBTK_ECALL_CFG_ITEM_TIMER_DEREG");
if(cfg_ecalltimer_set("dereg", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DEREG] / 1000, cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON) {
goto exit;
}
}
- if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_DIAL)
+ if(cfg_info->type & MBTK_ECALL_CFG_TIMER_DIAL)
{
+ LOGD("MBTK_ECALL_CFG_ITEM_TIMER_DIAL");
if(cfg_ecalltimer_set("dial", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] / 1000, cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON) {
goto exit;
}
}
- if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_REDIAL)
+ if(cfg_info->type & MBTK_ECALL_CFG_TIMER_REDIAL)
{
+ LOGD("MBTK_ECALL_CFG_ITEM_TIMER_REDIAL");
if(cfg_ecalltimer_set("redialtmr", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_REDIAL] / 1000, cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON) {
goto exit;
}
}
- if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_SMS)
+ if(cfg_info->type & MBTK_ECALL_CFG_TIMER_SMS)
{
+ LOGD("MBTK_ECALL_CFG_ITEM_TIMER_SMS");
if(cfg_ecalltimer_set("sms", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_SMS] / 1000, cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON) {
goto exit;
}
}
- if(cfg_info->type & MBTK_ECALL_CFG_ITEM_REDIALCNT)
+ if(cfg_info->type & MBTK_ECALL_CFG_REDIALCNT)
{
+ LOGD("MBTK_ECALL_CFG_ITEM_REDIALCNT");
if(cfg_ecalltimer_set("redialcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_REDIALCNT], cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON) {
goto exit;
}
}
- if(cfg_info->type & MBTK_ECALL_CFG_ITEM_SMSPROCESS)
+ if(cfg_info->type & MBTK_ECALL_CFG_SMSPROCESS)
{
+ LOGD("MBTK_ECALL_CFG_ITEM_SMSPROCESS");
if(cfg_ecalltimer_set("smsprocess", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSPROCESS], cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON) {
goto exit;
}
}
- if(cfg_info->type & MBTK_ECALL_CFG_ITEM_SMSMSDCNT)
+ if(cfg_info->type & MBTK_ECALL_CFG_SMSMSDCNT)
{
+ LOGD("MBTK_ECALL_CFG_ITEM_SMSMSDCNT");
if(cfg_ecalltimer_set("smsmsdcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSMSDCNT], cme_err)
|| *cme_err != MBTK_INFO_ERR_CME_NON) {
goto exit;