[Goodies-commits] r2560 - xfce4-cellmodem-plugin/trunk/panel-plugin
Alvaro Lopes
alvieboy at xfce.org
Fri Mar 23 10:41:58 CET 2007
Author: alvieboy
Date: 2007-03-23 09:41:58 +0000 (Fri, 23 Mar 2007)
New Revision: 2560
Modified:
xfce4-cellmodem-plugin/trunk/panel-plugin/autodetect.c
xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c
xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver.c
xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver.h
xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c
xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c
xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.h
Log:
Add capabilities and check for pin before network
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/autodetect.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/autodetect.c 2007-03-18 21:41:05 UTC (rev 2559)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/autodetect.c 2007-03-23 09:41:58 UTC (rev 2560)
@@ -28,9 +28,17 @@
#define USB_DEVICE_OPTION_UMTS_CARD 0x5000
#define USB_DEVICE_OPTION_FUSION_CARD 0x6300
+
+/* HUAWEI Technologies */
+
+#define USB_VENDOR_HUAWEI_TECHNOLOGIES 0x12d1
+#define USB_DEVICE_HUAWEI_MOBILE 0x1001
+
+
+
#define NOZOMI_DEVICE "/dev/noz2"
+#define GENERIC_USB_DEVICE "/dev/ttyUSB2"
-
struct device_info *device_info_new()
{
struct device_info *info;
@@ -81,7 +89,10 @@
gboolean serial_detect( struct known_device *dev )
{
- return FALSE;
+
+ dev->info->device = g_strdup( GENERIC_USB_DEVICE );
+
+ return TRUE;
}
@@ -105,6 +116,15 @@
&serial_detect
},
+ {
+ "Huawei E630 HSDPA-Card",
+ "Generic Driver",
+ DEVICE_TYPE_USB,
+ USB_VENDOR_HUAWEI_TECHNOLOGIES,
+ USB_DEVICE_HUAWEI_MOBILE,
+ &serial_detect
+ },
+
{ NULL, NULL, DEVICE_TYPE_NONE, 0, 0, NULL }
};
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c 2007-03-18 21:41:05 UTC (rev 2559)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c 2007-03-23 09:41:58 UTC (rev 2560)
@@ -28,6 +28,7 @@
modem_reply_callback_t callback,
const gchar *command );
static gboolean get_network_info( cellmodem_t *monitor );
+static void cellmodem_t_is_registered( cellmodem_t *monitor );
static void cellmodem_t_identify_network( cellmodem_t *monitor );
static gboolean cellmodem_t_close_modem(cellmodem_t *monitor /*, gboolean failure */);
@@ -194,6 +195,8 @@
*/
if ( strncmp(c,"+CME ERROR",10) == 0 )
return TRUE;
+ if ( strncmp(c,"COMMAND NOT",11) == 0 )
+ return TRUE;
if ( strcmp(c,"NO CARRIER") == 0 )
return TRUE;
if ( strcmp(c,"BUSY") == 0 )
@@ -710,10 +713,11 @@
cellmodem_t_identify_network( monitor );
} else {
+ reschedule_open( monitor );
/* Check for PIN ????? */
- cellmodem_t_get_pin_status( monitor );
+ // cellmodem_t_get_pin_status( monitor );
/*else
- reschedule_open( monitor, FALSE );
+
*/
}
}
@@ -779,9 +783,13 @@
cellmodem_t_switch_network_status( monitor, REGISTRATION_GPRS );
break;
case 2:
- /* Check for HSDPA/UMTS */
- cellmodem_t_get_ohcip_status( monitor );
- return;
+ /* Check for HSDPA/UMTS */
+ if ( monitor->driver->capabilities & MODEM_CAPABILITY_OHCIP ) {
+ cellmodem_t_get_ohcip_status( monitor );
+ } else {
+ cellmodem_t_get_quality( monitor );
+ }
+ return;
default:
cellmodem_t_switch_network_status( monitor, REGISTRATION_UNKNOWN );
}
@@ -833,10 +841,10 @@
cellmodem_t_request_pin( monitor );
return;
}
- if ( strncmp( start, "READY", 2) == 0 )
- {
- /* If we got here, we are registering. Do nothing, just
- reschedule open */
+ if ( strncmp( start, "READY", 5) == 0 )
+ {
+ cellmodem_t_is_registered( monitor );
+ return;
} else {
failure = TRUE;
}
@@ -892,12 +900,13 @@
/* Errors found ?? . */
} else {
- cellmodem_t_switch_to_error_and_restart( monitor, _("Invalid OHCIP reply from modem") );
-
- reschedule_open( monitor );
+ cellmodem_t_switch_to_error_and_restart( monitor, _("Invalid OHCIP reply from modem") );
+ return;
}
- if ( failure )
- cellmodem_t_switch_to_error_and_restart( monitor, _("Unsupportted OHCIP reply from modem") );
+ if ( failure ) {
+ cellmodem_t_switch_to_error_and_restart( monitor, _("Unsupportted OHCIP reply from modem") );
+ return;
+ }
ohcip_out:
cellmodem_t_get_quality( monitor );
}
@@ -1384,8 +1393,8 @@
}
monitor->info_timeout_id = g_timeout_add( OPEN_TIMEOUT,
- (GSourceFunc) get_network_info ,
- monitor );
+ (GSourceFunc) get_network_info ,
+ monitor );
return FALSE; /* Cancel this timer */
}
@@ -1400,9 +1409,10 @@
{
DEBUG("Getting network info");
if ( cellmodem_t_open_modem( monitor ) != FALSE ) {
-
- cellmodem_t_is_registered( monitor );
- return FALSE; /* Dont restart timer. */
+ /* Check PIN first. Some modems reply error in registry check */
+ /* cellmodem_t_is_registered( monitor ); */
+ cellmodem_t_get_pin_status( monitor );
+ return FALSE; /* Dont restart timer. */
}
DEBUG("Cannot open modem");
@@ -1569,7 +1579,6 @@
DEBUG("Calling get network info");
get_network_info(monitor);
-
}
static gboolean
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver.c 2007-03-18 21:41:05 UTC (rev 2559)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver.c 2007-03-23 09:41:58 UTC (rev 2560)
@@ -90,6 +90,7 @@
&modem_driver_generic,
#ifdef HAVE_FAKE_MODEM
&modem_driver_fake,
+ &modem_driver_nohsdpa,
NULL
#endif
};
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver.h
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver.h 2007-03-18 21:41:05 UTC (rev 2559)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver.h 2007-03-23 09:41:58 UTC (rev 2560)
@@ -29,11 +29,17 @@
typedef void * modem_instance_t;
+typedef unsigned long capability_t;
+
+#define MODEM_CAPABILITY_OHCIP 1
+
typedef struct modem_driver_t
{
const gchar *name;
const gchar *description;
+ capability_t capabilities;
+
/* Methods */
modem_instance_t (*create)( );
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c 2007-03-18 21:41:05 UTC (rev 2559)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c 2007-03-23 09:41:58 UTC (rev 2560)
@@ -287,11 +287,12 @@
{
.name = "Testing Driver",
.description = "Simple Driver for Testing Purposes",
+ .capabilities = 0,
.open = &fake_open,
.close = &fake_close,
.writeln = &fake_writeln,
.set_reader = &fake_set_reader,
- .create = &fake_create,
+ .create = &fake_create,
.set_termios = &fake_set_termios,
.destroy = &fake_destroy
};
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c 2007-03-18 21:41:05 UTC (rev 2559)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c 2007-03-23 09:41:58 UTC (rev 2560)
@@ -68,6 +68,17 @@
return TRUE;
}
+static void flush_modem( int fd )
+{
+ fd_set rds;
+ struct timeval tv= { 0, 200000 };
+
+ FD_ZERO(&rds);
+ FD_SET(&rds, fd);
+ while (select(2, &rds, NULL, NULL, &tv) > 0) {
+ }
+}
+
static void generic_close( modem_instance_t instance )
{
struct generic_modem_t *modem = (struct generic_modem_t*)instance;
@@ -215,12 +226,27 @@
struct modem_driver_t modem_driver_generic =
{
.name = "Generic Driver",
- .description = "Generic PCMCIA/PCCARD Driver",
+ .description = "Generic GPRS/UMTS/HSDPA Driver",
+ .capabilities = MODEM_CAPABILITY_OHCIP,
.open = &generic_open,
.close = &generic_close,
.writeln = &generic_writeln,
.set_reader = &generic_set_reader,
- .create = &generic_create,
- .set_termios = &generic_set_termios,
+ .create = &generic_create,
+ .set_termios = &generic_set_termios,
.destroy = &generic_destroy
};
+
+struct modem_driver_t modem_driver_nohsdpa =
+{
+ .name = "Generic Driver",
+ .description = "Generic GPRS/UMTS Driver [no HSDPA]",
+ .capabilities = 0,
+ .open = &generic_open,
+ .close = &generic_close,
+ .writeln = &generic_writeln,
+ .set_reader = &generic_set_reader,
+ .create = &generic_create,
+ .set_termios = &generic_set_termios,
+ .destroy = &generic_destroy
+};
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.h
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.h 2007-03-18 21:41:05 UTC (rev 2559)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.h 2007-03-23 09:41:58 UTC (rev 2560)
@@ -31,5 +31,6 @@
};
extern struct modem_driver_t modem_driver_generic;
+extern struct modem_driver_t modem_driver_nohsdpa;
#endif
More information about the Goodies-commits
mailing list