r552 - trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src

tony_guan at gta01.hmw-consulting.de tony_guan at gta01.hmw-consulting.de
Mon Jan 15 09:21:13 CET 2007


Author: tony_guan
Date: 2007-01-15 09:20:55 +0100 (Mon, 15 Jan 2007)
New Revision: 552

Added:
   trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/event.c
   trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/event.h
Modified:
   trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/Makefile.am
   trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c
Log:
event.c


Modified: trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/Makefile.am	2007-01-13 23:53:00 UTC (rev 551)
+++ trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/Makefile.am	2007-01-15 08:20:55 UTC (rev 552)
@@ -2,7 +2,10 @@
 
 bin_PROGRAMS = openmoko-panel-gsm
 
-openmoko_panel_gsm_SOURCES = openmoko-panel-gsm.c
+openmoko_panel_gsm_SOURCES = openmoko-panel-gsm.c\
+event.c
 
+
+
 openmoko_panel_gsm_LDADD = @OPENMOKO_LIBS@
 

Added: trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/event.c
===================================================================
--- trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/event.c	2007-01-13 23:53:00 UTC (rev 551)
+++ trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/event.c	2007-01-15 08:20:55 UTC (rev 552)
@@ -0,0 +1,99 @@
+/* libgsmd tool
+ *
+ * (C) 2006-2007 by OpenMoko, Inc.
+ * Written by Harald Welte <laforge at openmoko.org>
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */ 
+
+#include <stdio.h>
+#include <string.h>
+
+#include <common/linux_list.h>
+#include <libgsmd/libgsmd.h>
+#include <libgsmd/event.h>
+static int incall_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+	printf("EVENT: Incoming call type = %u\n", aux->u.call.type);
+
+	return 0;
+}
+
+static int clip_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+	printf("EVENT: Incoming call clip = %s\n", aux->u.clip.addr.number);
+
+	return 0;
+}
+
+static int colp_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+	printf("EVENT: Outgoing call colp = %s\n", aux->u.colp.addr.number);
+
+	return 0;
+}
+
+static int netreg_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+	printf("EVENT: Netreg ");
+
+	switch (aux->u.netreg.state) {
+	case 0:
+		printf("not searching for network ");
+		break;
+	case 1:
+		printf("registered (home network) ");
+		break;
+	case 2:
+		printf("searching for network ");
+		break;
+	case 3:
+		printf("registration denied ");
+		break;
+	case 5:
+		printf("registered (roaming) ");
+		break;
+	}
+
+	if (aux->u.netreg.lac)
+		printf("LocationAreaCode = 0x%04X ", aux->u.netreg.lac);
+	if (aux->u.netreg.ci)
+		printf("CellID = 0x%04X ", aux->u.netreg.ci);
+	
+	printf("\n");
+
+	return 0;
+}
+
+
+static int sigq_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+	printf("EVENT: Signal Quality: %u\n", aux->u.signal.sigq.rssi);
+	return 0;
+}
+
+int event_init(struct lgsm_handle *lh)
+{
+	int rc;
+
+	rc  = lgsm_evt_handler_register(lh, GSMD_EVT_IN_CALL, &incall_handler);
+	rc |= lgsm_evt_handler_register(lh, GSMD_EVT_NETREG, &netreg_handler);
+	rc |= lgsm_evt_handler_register(lh, GSMD_EVT_SIGNAL, &sigq_handler);
+
+	return rc;
+}
+

Added: trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/event.h
===================================================================
--- trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/event.h	2007-01-13 23:53:00 UTC (rev 551)
+++ trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/event.h	2007-01-15 08:20:55 UTC (rev 552)
@@ -0,0 +1,2 @@
+
+extern int event_init(struct lgsm_handle *lh);

Modified: trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c
===================================================================
--- trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c	2007-01-13 23:53:00 UTC (rev 551)
+++ trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c	2007-01-15 08:20:55 UTC (rev 552)
@@ -2,10 +2,14 @@
 #include <X11/Xlib.h>
 #include <string.h>
 #include <sys/types.h>
+#include <sys/time.h>
 #include <unistd.h>
-//#include <libgsmd/libgsmd.h>
-//#include <libgsmd/misc.h>
+#include <libgsmd/libgsmd.h>
 
+#include <libgsmd/misc.h>
+#include <libgsmd/libgsmd.h>
+#include "dialergsm.h"
+
 #define DIR_LONG	256
 #define FONT_POPUP_DESC       "Sans bold 28px"
 #define ADD_IMG "mbadd.png"  //use for test
@@ -30,11 +34,12 @@
 static int screen;
 static int times = 0;
 
-//static struct lgsm_handle *lgsmh;
-/*
+
+	static struct lgsm_handle *lgsmh=0;
 Bool
 gsm_connect_init()
 {
+
 	lgsmh = lgsm_init(LGSMD_DEVICE_GSMD);
 	
 	if (!lgsmh) 
@@ -42,9 +47,14 @@
 		fprintf(stderr, "Can't connect to gsmd\n");
 		return False;
 	}
-	else return True;
+	else 
+	{
+	event_init(lgsmh);
+	return True;
+	}
+	
 }
-*/
+
 /*
 *
 */
@@ -52,8 +62,8 @@
 signal_update(void)
 {
    int sig_quality = 0;
-  // int result = 0;
-  // result = lgsm_get_signal_quality (lgsmh, &sig_quality);
+   int result = 0;
+   //result = lgsm_get_signal_quality (lgsmh, &sig_quality);
 
     if (CurImg<MAX_ID-1) 
     	CurImg++;
@@ -318,9 +328,39 @@
     }
 }
 
+#define STDIN_BUF_SIZE	1024
 void
 timeout_callback ( MBTrayApp *app )
 {
+	printf("timeout_callback\n");
+		fd_set readset;
+		int rc;
+		char buf[STDIN_BUF_SIZE+1];
+		struct timeval t;
+		t.tv_sec=0;
+		t.tv_usec=0;
+		int gsm_fd = lgsm_fd(lgsmh);
+		//FD_SET(0, &readset);
+		FD_SET(gsm_fd, &readset);
+		printf("select>\n");
+		rc = select(gsm_fd+1, &readset, NULL, NULL, &t);
+		printf("select<\n");
+		if (FD_ISSET(gsm_fd, &readset)) 
+		{
+			printf("read>\n");
+			rc = read(gsm_fd, buf, sizeof(buf));
+			printf("read<\n");
+			if (rc <= 0) {
+				printf("ERROR reding from gsm_fd\n");
+				return;
+			}
+			else
+			{
+				printf("data from gsm_fd\n");
+				rc = lgsm_handle_packet(lgsmh, buf, rc);
+			}
+		
+		}
   mb_tray_app_repaint (app);
 }
 
@@ -366,7 +406,9 @@
 
    mb_tray_app_request_offset (app, 1);
 
-//   gsm_connect_init();
+   gsm_connect_init();
+   
+   //gsm_lgsm_start(0);
 
    mb_tray_app_main (app);
    





More information about the commitlog mailing list