#define INDICATOR_UPDATE_INTERVAL 1
#define INDICATOR_PROCFILE "/proc/net/dev"
#define INDICATOR_BUFF_SIZE 4096
-#define DATABASE_PATH "/opt/dbspace/.dnet.db"
#define NO_RX_PKT_TIMEOUT 30
//enum
+
+typedef enum _cellular_state {
+ CELLULAR_OFF = 0x00,
+ CELLULAR_NORMAL_CONNECTED = 0x01,
+ CELLULAR_SECURE_CONNECTED = 0x02,
+ CELLULAR_USING = 0x03,
+} cellular_state;
+
typedef enum _indicator_state {
- INDICATOR_OFF = 0x00,
- INDICATOR_ON = 0x01,
- INDICATOR_ONLINE = 0x03,
+ INDICATOR_NORMAL = 0x00,
+ INDICATOR_RX = 0x01,
+ INDICATOR_TX = 0x02,
+ INDICATOR_RXTX = 0x03,
} indicator_state;
-typedef enum _ps_call_state {
- PS_CALL_STATE_RESULT_OK = 0x00,
- PS_CALL_STATE_RESULT_CONNECT = 0x01,
- PS_CALL_STATE_RESULT_NO_CARRIER = 0x03,
-} ps_call_state;
-
struct indicator_device_state {
gchar *devname;
gboolean active;
if (!vconf_handle)
err("fail to create vconf db_handle");
- tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_SERVICE_STATE, INDICATOR_ON);
+ tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_SERVICE_STATE, CELLULAR_NORMAL_CONNECTED);
+ tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_INDICATOR_STATE, INDICATOR_NORMAL);
if(src != 0)
return FALSE;
if (!vconf_handle)
err("fail to create vconf db_handle");
- tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_SERVICE_STATE, INDICATOR_OFF);
+ tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_SERVICE_STATE, CELLULAR_OFF);
+ tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_INDICATOR_STATE, INDICATOR_NORMAL);
t_rx = tcore_storage_get_int(strg_vconf, STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV);
t_tx = tcore_storage_get_int(strg_vconf, STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT);
{
FILE *pf = NULL;
gint proc_ver = 0;
+ char *res;
gchar buff[INDICATOR_BUFF_SIZE];
- gchar *rv = NULL;
pf = fopen(INDICATOR_PROCFILE, "r");
if (pf == NULL) {
return FALSE;
}
- rv = fgets(buff, sizeof(buff), pf);
- rv = fgets(buff, sizeof(buff), pf);
+ res = fgets(buff, sizeof(buff), pf);
+ if (res == NULL)
+ err("fegts fails");
+ res = fgets(buff, sizeof(buff), pf);
+ if (res == NULL)
+ err("fegts fails");
proc_ver = _indicator_get_proc_ver(buff);
while (fgets(buff, sizeof(buff), pf)) {
static gboolean _indicator_update(Server *s)
{
- gint pkt_state = 0;
+ guint64 rx_changes = 0;
+ guint64 tx_changes = 0;
Storage *strg_vconf;
gpointer vconf_handle;
if (!vconf_handle)
err("fail to create vconf db_handle");
- pkt_state = tcore_storage_get_int(strg_vconf, STORAGE_KEY_PACKET_SERVICE_STATE);
-
if(!indicator_info.active) return FALSE;
- if ((indicator_info.curr_rx > indicator_info.prev_rx)
- || (indicator_info.curr_tx > indicator_info.prev_tx)) {
- if(pkt_state != INDICATOR_ONLINE)
- tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_SERVICE_STATE, INDICATOR_ONLINE);
- }
- else{ //rx, tx are the same as before
- if(pkt_state != INDICATOR_ON)
- tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_SERVICE_STATE, INDICATOR_ON);
- }
+ rx_changes = indicator_info.curr_rx - indicator_info.prev_rx;
+ tx_changes = indicator_info.curr_tx - indicator_info.prev_tx;
+
+ if (rx_changes != 0 || tx_changes != 0)
+ tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_SERVICE_STATE, CELLULAR_USING);
+ else
+ tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_SERVICE_STATE, CELLULAR_NORMAL_CONNECTED);
+
+ if (rx_changes > 0 && tx_changes > 0)
+ tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_INDICATOR_STATE, INDICATOR_RXTX);
+ else if (rx_changes > 0 && tx_changes == 0)
+ tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_INDICATOR_STATE, INDICATOR_RX);
+ else if (rx_changes == 0 && tx_changes > 0)
+ tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_INDICATOR_STATE, INDICATOR_TX);
+ else
+ tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_INDICATOR_STATE, INDICATOR_NORMAL);
return TRUE;
}
enum tcore_notification_command command, unsigned int data_len, void *data,
void *user_data)
{
- int con_id = 0;
+ unsigned int con_id = 0;
CoreObject *co_ps = NULL, *co_context = NULL;
struct tnoti_ps_call_status *cstatus = NULL;
dbg("context(%p) con_id(%d)", co_context, con_id);
cstatus = (struct tnoti_ps_call_status *) data;
- dbg("call status event cid(%d) state(%d) reason(%d)", cstatus->context_id, cstatus->state, cstatus->result);
+ dbg("call status event cid(%d) state(%d)", cstatus->context_id, cstatus->state);
if(con_id != cstatus->context_id)
return TCORE_HOOK_RETURN_CONTINUE;
- if (cstatus->state == PS_CALL_STATE_RESULT_OK) {
+ if (cstatus->state == PS_DATA_CALL_CTX_DEFINED) {
/* do nothing. */
dbg("Just noti for PDP define complete, do nothing.");
return TCORE_HOOK_RETURN_CONTINUE;
}
- else if (cstatus->state == PS_CALL_STATE_RESULT_CONNECT) {
+ else if (cstatus->state == PS_DATA_CALL_CONNECTED) {
indicator_info.active = TRUE;
indicator_info.devname = tcore_context_get_ipv4_devname(co_context);
_indicator_start_updater(s);