Signed-off-by: Antonio Ospite <osp...@studenti.unina.it>
---
I am committing this, posted here just as a recap.

Changes since v1:
 - Fix a typo s/se/we/
 - instanciate StateBasedAtParser as function argument
 - get dlci lines from config file
 - use Thread.usleep() in place of Posix.sleep()

Regards,
   Antonio

 fsogsmd/conf/Makefile.am                           |    1 +
 fsogsmd/conf/motorola_ezx/Makefile.am              |   12 ++
 fsogsmd/conf/motorola_ezx/fsogsmd.conf             |   45 ++++++
 fsogsmd/configure.ac                               |    2 +
 fsogsmd/src/plugins/Makefile.am                    |    1 +
 .../plugins/modem_freescale_neptune/Makefile.am    |   65 ++++++++
 .../plugins/modem_freescale_neptune/commands.vala  |   48 ++++++
 .../plugins/modem_freescale_neptune/mediators.vala |  159 ++++++++++++++++++++
 .../plugins/modem_freescale_neptune/plugin.vala    |  157 +++++++++++++++++++
 .../modem_freescale_neptune/unsolicited.vala       |  121 +++++++++++++++
 10 files changed, 611 insertions(+), 0 deletions(-)
 create mode 100644 fsogsmd/conf/motorola_ezx/Makefile.am
 create mode 100644 fsogsmd/conf/motorola_ezx/fsogsmd.conf
 create mode 100644 fsogsmd/src/plugins/modem_freescale_neptune/Makefile.am
 create mode 100644 fsogsmd/src/plugins/modem_freescale_neptune/commands.vala
 create mode 100644 fsogsmd/src/plugins/modem_freescale_neptune/mediators.vala
 create mode 100644 fsogsmd/src/plugins/modem_freescale_neptune/plugin.vala
 create mode 100644 fsogsmd/src/plugins/modem_freescale_neptune/unsolicited.vala

diff --git a/fsogsmd/conf/Makefile.am b/fsogsmd/conf/Makefile.am
index 2d3eede..fb0b1cb 100644
--- a/fsogsmd/conf/Makefile.am
+++ b/fsogsmd/conf/Makefile.am
@@ -6,6 +6,7 @@ SUBDIRS = \
        default \
        htc_qualcomm_dream \
        htc_qualcomm_msm \
+       motorola_ezx \
        openmoko_gta \
        palm_pre \
        $(NULL)
diff --git a/fsogsmd/conf/motorola_ezx/Makefile.am 
b/fsogsmd/conf/motorola_ezx/Makefile.am
new file mode 100644
index 0000000..6efcd40
--- /dev/null
+++ b/fsogsmd/conf/motorola_ezx/Makefile.am
@@ -0,0 +1,12 @@
+include $(top_srcdir)/Makefile.decl
+
+NULL=
+
+THISDIR = `basename $$PWD`
+
+confdir = $(sysconfdir)/freesmartphone/conf/$(THISDIR)
+dist_conf_DATA = \
+       fsogsmd.conf \
+       $(NULL)
+
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/fsogsmd/conf/motorola_ezx/fsogsmd.conf 
b/fsogsmd/conf/motorola_ezx/fsogsmd.conf
new file mode 100644
index 0000000..ad7d27a
--- /dev/null
+++ b/fsogsmd/conf/motorola_ezx/fsogsmd.conf
@@ -0,0 +1,45 @@
+#######################################################################################
+# FSO GSM Daemon Configuration File -- for SYSTEM INTEGRATORS only
+########################################################################################
+[logging]
+# Log level: DEBUG, INFO (default), WARNING, ERROR
+# Override via environment as FSO_LOG_LEVEL
+log_level = INFO
+# Where to log to: none (default), stderr, stderr:colors, file, syslog
+# Override via environment as FSO_LOG_TO
+log_to = file
+# Log Destination (valid only for log_to = file)
+# Override via environment as FSO_LOG_DESTINATION
+log_destination = /var/log/fsogsmd.log
+
+[libfsotransport]
+log_level = INFO
+log_to = file
+log_destination = /var/log/fsogsmd.log
+
+[fsogsm]
+modem_type = freescale_neptune
+sim_buffers_sms = true
+pdp_type = ppp
+
+# Global modem init sequence; this is the first sequence that gets sent to the 
modem after power cycling
+modem_init = E0V1;+CMEE=1;+CRC=1;+CSCS="UCS2"
+
+# Where to store SMS: <path> (default=/tmp/fsogsmd/sms/)
+sms_storage_dir = /tmp/fsogsmd/sms/
+
+[fsogsm.modem_freescale_neptune]
+muxnode_prefix = /dev/mux
+dlci_main = 1
+dlci_sms  = 3
+dlci_sim  = 4
+dlci_misc = 5
+
+[fsogsm.lowlevel_motorola_ezx]
+# No settings yet
+
+[fsogsm.pdp_ppp]
+# No settings yet
+
+[fsogsm.dbus_service]
+# No settings yet
diff --git a/fsogsmd/configure.ac b/fsogsmd/configure.ac
index 7596689..2455669 100644
--- a/fsogsmd/configure.ac
+++ b/fsogsmd/configure.ac
@@ -174,6 +174,7 @@ AC_CONFIG_FILES([
   conf/default/Makefile
   conf/htc_qualcomm_dream/Makefile
   conf/htc_qualcomm_msm/Makefile
+  conf/motorola_ezx/Makefile
   conf/openmoko_gta/Makefile
   conf/palm_pre/Makefile
   data/Makefile
@@ -187,6 +188,7 @@ AC_CONFIG_FILES([
   src/plugins/lowlevel_palmpre/Makefile
   src/plugins/modem_cinterion_mc75/Makefile
   src/plugins/modem_dummy/Makefile
+  src/plugins/modem_freescale_neptune/Makefile
   src/plugins/modem_singleline/Makefile
   src/plugins/modem_ti_calypso/Makefile
   src/plugins/modem_qualcomm_htc/Makefile
diff --git a/fsogsmd/src/plugins/Makefile.am b/fsogsmd/src/plugins/Makefile.am
index 2e7a65a..a537bdd 100644
--- a/fsogsmd/src/plugins/Makefile.am
+++ b/fsogsmd/src/plugins/Makefile.am
@@ -13,6 +13,7 @@ SUBDIRS = \
        modem_dummy \
        modem_singleline \
        modem_qualcomm_htc \
+       modem_freescale_neptune \
        \
        pdp_qmi \
        $(NULL)
diff --git a/fsogsmd/src/plugins/modem_freescale_neptune/Makefile.am 
b/fsogsmd/src/plugins/modem_freescale_neptune/Makefile.am
new file mode 100644
index 0000000..3aeffb1
--- /dev/null
+++ b/fsogsmd/src/plugins/modem_freescale_neptune/Makefile.am
@@ -0,0 +1,65 @@
+include $(top_srcdir)/Makefile.decl
+
+NULL =
+
+AM_CFLAGS = \
+       -I$(top_srcdir)/src/lib \
+       -I$(top_srcdir)/src/3rdparty \
+       $(PALM_CFLAGS) \
+       $(FSO_CFLAGS) \
+       $(GLIB_CFLAGS) \
+       $(GEE_CFLAGS) \
+       $(DBUS_CFLAGS) \
+       $(NULL)
+
+noinst_PROGRAMS = $(TEST_PROGS)
+
+progs_ldadd = \
+       $(PALM_LIBS) \
+       $(FSO_LIBS) \
+       $(GLIB_LIBS) \
+       $(GEE_LIBS) \
+       $(DBUS_LIBS) \
+       $(top_srcdir)/src/lib/libfsogsm.la
+
+VALAC_ARGS = \
+       --basedir $(top_srcdir) \
+       --vapidir ../../lib \
+       --pkg posix \
+       --pkg glib-2.0 \
+       --pkg gee-1.0 \
+       --pkg dbus-glib-1 \
+       --pkg fso-glib-1.0 \
+       --pkg fsoframework-2.0 \
+       --pkg fsotransport-2.0 \
+       --pkg fsogsm-2.0
+
+if WANT_DEBUG
+VALAC_ARGS += -g -D DEBUG
+AM_CFLAGS += -ggdb -O0
+endif
+
+#
+# plugin
+#
+modlibexecdir = $(libdir)/cornucopia/modules/fsogsm
+modlibexec_LTLIBRARIES = modem_freescale_neptune.la
+modem_freescale_neptune_la_SOURCES = plugin.c commands.c mediators.c 
unsolicited.c
+modem_freescale_neptune_la_VALASOURCES = plugin.vala commands.vala 
mediators.vala unsolicited.vala
+$(modem_freescale_neptune_la_SOURCES): 
$(modem_freescale_neptune_la_VALASOURCES)
+       $(VALAC) -C $(VALAC_ARGS) $^
+       touch $@
+modem_freescale_neptune_la_LIBADD = $(progs_ldadd)
+modem_freescale_neptune_la_LDFLAGS = -no-undefined -module -avoid-version
+modem_freescale_neptune_la_LIBTOOLFLAGS = --tag=disable-static
+
+CLEANFILES = \
+    *.c \
+    *.h \
+    *.la \
+    *.lo \
+    $(NULL)
+
+MAINTAINERCLEANFILES = \
+  Makefile.in \
+  $(NULL)
diff --git a/fsogsmd/src/plugins/modem_freescale_neptune/commands.vala 
b/fsogsmd/src/plugins/modem_freescale_neptune/commands.vala
new file mode 100644
index 0000000..6a19f5b
--- /dev/null
+++ b/fsogsmd/src/plugins/modem_freescale_neptune/commands.vala
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010  Antonio Ospite <osp...@studenti.unina.it>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+ *
+ */
+
+using FsoGsm;
+using Gee;
+
+namespace FreescaleNeptune
+{
+
+/**
+ * Modem violating GSM 07.07 here.
+ *
+ * Format seems to be +CPIN=<number>,"<PIN>", where 1 is PIN1, 2 may be PIN2 
or PUK1
+ **/
+public class NeptunePlusCPIN : PlusCPIN
+{
+    public new string issue( int pin_type, string pin)
+    {
+        return "+CPIN=%d,\"%s\"".printf( pin_type, pin );
+    }
+}
+
+
+/**
+ * Register all custom commands
+ **/
+public void registerCustomAtCommands( HashMap<string,AtCommand> table )
+{
+    table[ "+CPIN" ]              = new NeptunePlusCPIN();
+}
+
+} /* namespace FreescaleNeptune */
diff --git a/fsogsmd/src/plugins/modem_freescale_neptune/mediators.vala 
b/fsogsmd/src/plugins/modem_freescale_neptune/mediators.vala
new file mode 100644
index 0000000..1615862
--- /dev/null
+++ b/fsogsmd/src/plugins/modem_freescale_neptune/mediators.vala
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2010  Antonio Ospite <osp...@studenti.unina.it>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+ *
+ */
+
+using FsoGsm;
+using Gee;
+
+namespace FreescaleNeptune {
+
+/**
+ * Debug mediators
+ **/
+
+/**
+ * Modem not implementing any of +CGMR;+CGMM;+CGMI -- only +CGSN is supported
+ **/
+public class NeptuneDeviceGetInformation : DeviceGetInformation
+{
+    public override async void run() throws FreeSmartphone.GSM.Error, 
FreeSmartphone.Error
+    {
+        /*
+        var channel = theModem.channel( "main" ) as AtChannel;
+        */
+        info = new GLib.HashTable<string,Value?>( str_hash, str_equal );
+
+        info.insert( "manufacturer", "Motorola" );
+        info.insert( "model", "Neptune Freescale Modem" );
+
+        /* FIXME: Use information from the +EBPV URC we get on modem init */
+        info.insert( "revision", "unknown" );
+
+        /* "+CGSN" */
+        var cgsn = theModem.createAtCommand<PlusCGSN>( "+CGSN" );
+        var response = yield theModem.processAtCommandAsync( cgsn, 
cgsn.query() );
+        checkResponseValid( cgsn, response );
+        info.insert( "imei", cgsn.value );
+    }
+}
+
+
+/**
+ * SIM Mediators
+ **/
+
+/**
+ * Modem violating GSM 07.07 here.
+ *
+ * Format seems to be +CPIN=<number>,"<PIN>", where 1 is PIN1, 2 may be PIN2 
or PUK1
+ **/
+public class NeptuneSimSendAuthCode : SimSendAuthCode
+{
+    public override async void run( string pin ) throws 
FreeSmartphone.GSM.Error, FreeSmartphone.Error
+    {
+        var cmd = theModem.createAtCommand<NeptunePlusCPIN>( "+CPIN" );
+        var response = yield theModem.processAtCommandAsync( cmd, cmd.issue( 
1, pin ) );
+        var code = checkResponseExpected( cmd, response,
+            { Constants.AtResponse.OK, 
Constants.AtResponse.CME_ERROR_016_INCORRECT_PASSWORD } );
+
+        if ( code == Constants.AtResponse.CME_ERROR_016_INCORRECT_PASSWORD )
+        {
+            throw new FreeSmartphone.GSM.Error.SIM_AUTH_FAILED( @"PIN $pin not 
accepted" );
+        }
+
+        gatherSimStatusAndUpdate();
+    }
+}
+
+
+/**
+ * SMS Mediators
+ **/
+
+/**
+ * Network Mediators
+ **/
+
+public class NeptuneNetworkRegister : NetworkRegister
+{
+    public override async void run() throws FreeSmartphone.GSM.Error, 
FreeSmartphone.Error
+    {
+        // FIXME: find a better way to make NetworkRegister reliable,
+        // avoid sleeping if possible.
+        Thread.usleep(4000 * 1000);
+        var cmd = theModem.createAtCommand<PlusCOPS>( "+COPS" );
+        var response = yield theModem.processAtCommandAsync( cmd, cmd.issue( 
PlusCOPS.Action.REGISTER_WITH_BEST_PROVIDER ) );
+        checkResponseOk( cmd, response );
+    }
+}
+
+public class NeptuneNetworkUnregister : NetworkUnregister
+{
+    public override async void run() throws FreeSmartphone.GSM.Error, 
FreeSmartphone.Error
+    {
+        var cmd = theModem.createAtCommand<PlusCOPS>( "+COPS" );
+        var response = yield theModem.processAtCommandAsync( cmd, cmd.issue( 
PlusCOPS.Action.UNREGISTER ) );
+        // FIXME: find a better way to make NetworkRegister reliable,
+        // avoid sleeping if possible.
+        Thread.usleep(4000 * 1000);
+        checkResponseOk( cmd, response );
+    }
+}
+
+/**
+ * Call Mediators
+ **/
+
+/**
+ * Neptune replies to +CLCC? but not to +CLCC
+ * So we use cmd.query() here instead of cmd.execute()
+ **/
+public class NeptuneCallListCalls : CallListCalls
+{
+    public override async void run() throws FreeSmartphone.GSM.Error, 
FreeSmartphone.Error
+    {
+        var cmd = theModem.createAtCommand<PlusCLCC>( "+CLCC" );
+        var response = yield theModem.processAtCommandAsync( cmd, cmd.query() 
);
+        checkMultiResponseValid( cmd, response );
+        calls = cmd.calls;
+    }
+}
+
+/**
+ * PDP Mediators
+ **/
+
+/**
+ * Register all mediators
+ **/
+public void registerNeptuneMediators( HashMap<Type,Type> table )
+{
+    /*
+    table[ typeof(DebugPing) ]                    = typeof( NeptuneDebugPing );
+    */
+
+    table[ typeof(DeviceGetInformation) ]         = typeof( 
NeptuneDeviceGetInformation );
+    table[ typeof(SimSendAuthCode) ]              = typeof( 
NeptuneSimSendAuthCode );
+
+    table[ typeof(NetworkRegister) ]              = typeof( 
NeptuneNetworkRegister );
+    table[ typeof(NetworkUnregister) ]            = typeof( 
NeptuneNetworkUnregister );
+
+    table[ typeof(CallListCalls) ]                = typeof( 
NeptuneCallListCalls );
+}
+
+} /* FreescaleNeptune */
diff --git a/fsogsmd/src/plugins/modem_freescale_neptune/plugin.vala 
b/fsogsmd/src/plugins/modem_freescale_neptune/plugin.vala
new file mode 100644
index 0000000..d191adf
--- /dev/null
+++ b/fsogsmd/src/plugins/modem_freescale_neptune/plugin.vala
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2010  Antonio Ospite <osp...@studenti.unina.it>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+ *
+ */
+
+using GLib;
+using Gee;
+using FsoGsm;
+
+namespace FreescaleNeptune
+{
+    const string MODULE_NAME = "fsogsm.modem_freescale_neptune";
+    // FIXME: rename main to call ??
+    const string CHANNEL_NAMES[] = { "main", "sms", "sim", "misc" };
+}
+
+/**
+ * @class FreescaleNeptune.Modem
+ *
+ * This modem plugin supports the Freescale neptune chipset used on Motorola 
EzX
+ * phones.
+ **/
+class FreescaleNeptune.Modem : FsoGsm.AbstractModem
+{
+    construct
+    {
+        /* Init the modem */
+        logger.info("Called FreescaleNeptune.Modem construct");
+    }
+
+    public override string repr()
+    {
+        return @"<$(channels.size)C>";
+    }
+
+    public override void configureData()
+    {
+        /* XXX: we could send these here too, but right now doing something
+         * like in 
http://git.ao2.it/fso-scripts.git/?a=blob;f=fso-auth.py;h=0fc26f98f7f31a414c46dbfc8e6d27ba3e3f8a77
+         * would fail because +CPIN? is sent before +EPOM completes...
+            """+EPOM=1,0""",
+            """+EAPF=12,1,0""",
+         *   so we put these commands in the lowlevel plugin
+         */
+
+        // sequence for initializing the channel
+        registerAtCommandSequence( "main", "init", new AtCommandSequence( {
+            // GSM unsolicited
+            """+CRC=1""",
+            """+CLIP=1""",
+            """+COLP=1""",
+            """+CCWA=1""",
+            """+CSSN=1,1""",
+            """+CTZU=1""",
+            """+CTZR=1""",
+            """+CREG=2""",
+            """+CAOC=2""",
+            // GPRS unsolicited
+            """+CGEREP=2,1""",
+            """+CGREG=2"""
+        } ) );
+
+        // sequence for initializing the channel
+        registerAtCommandSequence( "sms", "unlocked", new AtCommandSequence( {
+            """+CRRM""",
+            //FIXME if this returns an error, we might have no SIM inserted
+            """+EPMS?""",
+            """+EMGL=4"""
+        } ) );
+
+        // sequence for initializing the channel
+        registerAtCommandSequence( "misc", "init", new AtCommandSequence( {
+            """+USBSTAT=255,1"""
+        } ) );
+    }
+
+    protected override void createChannels()
+    {
+        logger.info("Create Freescale Neptune channels");
+
+        var muxnode_prefix = config.stringValue( MODULE_NAME, 
"muxnode_prefix");
+
+        for ( int i = 0; i < CHANNEL_NAMES.length; ++i ) {
+            var channel = CHANNEL_NAMES[i];
+            var dlci = config.stringValue( MODULE_NAME, @"dlci_$(channel)" );
+            if ( dlci != "" ) {
+                var muxnode = @"$(muxnode_prefix)$(dlci)";
+                var transport = FsoFramework.Transport.create("serial", 
muxnode, 115200);
+                new AtChannel( channel, transport, new 
FsoGsm.StateBasedAtParser() );
+            } else {
+                logger.warning( @"No dlci for channel \"$(channel)\"" );
+            }
+        }
+    }
+
+    protected override void registerCustomMediators( HashMap<Type,Type> 
mediators )
+    {
+        logger.info("Register Neptune mediators");
+        FreescaleNeptune.registerNeptuneMediators( mediators );
+    }
+
+    protected override FsoGsm.UnsolicitedResponseHandler 
createUnsolicitedHandler()
+    {
+        return new FreescaleNeptune.UnsolicitedResponseHandler();
+    }
+
+    protected override FsoGsm.Channel channelForCommand( FsoGsm.AtCommand 
command, string query )
+    {
+        // FIXME: check what commands are to be sent to each channel
+        return channels[ "main" ];
+    }
+}
+
+/**
+ * This function gets called on plugin initialization time.
+ * @return the name of your plugin here
+ * @note that it needs to be a name in the format <subsystem>.<plugin>
+ * else your module will be unloaded immediately.
+ **/
+public static string fso_factory_function( FsoFramework.Subsystem subsystem ) 
throws Error
+{
+    FsoFramework.theLogger.debug( "fsogsm.freescale_neptune 
fso_factory_function" );
+    return FreescaleNeptune.MODULE_NAME;
+}
+
+[ModuleInit]
+public static void fso_register_function( TypeModule module )
+{
+    // do not remove this function
+}
+
+/**
+ * This function gets called on plugin load time.
+ * @return false, if the plugin operating conditions are present.
+ * @note Some versions of glib contain a bug that leads to a SIGSEGV
+ * in g_module_open, if you return true here.
+ **/
+/*public static bool g_module_check_init( void* m )
+{
+    var ok = FsoFramework.FileHandling.isPresent( Kernel26.SYS_CLASS_LEDS );
+    return (!ok);
+}
+*/
diff --git a/fsogsmd/src/plugins/modem_freescale_neptune/unsolicited.vala 
b/fsogsmd/src/plugins/modem_freescale_neptune/unsolicited.vala
new file mode 100644
index 0000000..c08696e
--- /dev/null
+++ b/fsogsmd/src/plugins/modem_freescale_neptune/unsolicited.vala
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2010  Antonio Ospite <osp...@studenti.unina.it>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+ *
+ */
+
+using Gee;
+using FsoGsm;
+
+public class FreescaleNeptune.UnsolicitedResponseHandler : 
FsoGsm.AtUnsolicitedResponseHandler
+{
+    public UnsolicitedResponseHandler()
+    {
+        registerUrc( "+MBAN", channelReady );
+        registerUrc( "+CIEV", plusCIEV );
+        registerUrc( "+CLIN", plusCLIN );
+        registerUrc( "+CLIP", plusCLIP );
+        registerUrc( "+EBAD", dummy );
+        registerUrc( "+EFLEX", dummy );
+        registerUrc( "+EBPV", dummy );
+    }
+
+    public virtual void channelReady( string prefix, string rhs )
+    {
+        assert( theModem.logger.debug( "Congratulations Madam, it's a 
channel!" ) );
+    }
+
+    /**
+     * Indicator Event Reporting. Based on 3GPP TS 07.07, Chapter 8.9, but 
slightly extended.
+     *
+     * As +CIND=? gives us a hint (one of the few test commands EZX exposes), 
we conclude:
+     *
+     *  0: battery charge level (0-5)
+     *  1: signal level (0-5)
+     *  2: service availability (0-1)
+     *  3: call active? (0-1)
+     *  4: voice mail (message) (0-1)
+     *  5: transmit activated by voice activity (0-1)
+     *  6: call progress (0-3) [0:no more in progress, 1:incoming, 2:outgoing, 
3:ringing]
+     *  7: roaming (0-2)
+     *  8: sms storage full (0-1)
+     * 11: ???
+     * 20: ??? (SIM not inserted?)
+     **/
+    public override void plusCIEV( string prefix, string rhs )
+    {
+        int indicator = rhs.split(",")[0].to_int();
+        int value = rhs.split(",")[1].to_int();
+
+        switch (indicator) {
+        case 1:
+            theModem.logger.debug( @"plusCIEV: $indicator,$value NOT 
implemented" );
+            break;
+        case 2:
+            theModem.logger.debug( @"plusCIEV: $indicator,$value NOT 
implemented" );
+            break;
+        case 3:
+            theModem.logger.debug( @"plusCIEV: $indicator,$value NOT 
implemented" );
+            break;
+        case 4:
+            theModem.logger.debug( @"plusCIEV: $indicator,$value NOT 
implemented" );
+            break;
+        case 5:
+            theModem.logger.debug( @"plusCIEV: $indicator,$value NOT 
implemented" );
+            break;
+        case 6:
+            theModem.logger.debug( @"plusCIEV: $indicator,$value NOT 
implemented" );
+            break;
+        case 7:
+            theModem.logger.debug( @"plusCIEV: $indicator,$value NOT 
implemented" );
+            break;
+        case 8:
+            theModem.logger.debug( @"plusCIEV: $indicator,$value NOT 
implemented" );
+            break;
+        case 11:
+            theModem.logger.debug( @"plusCIEV: $indicator,$value NOT 
implemented" );
+            break;
+        case 20:
+            theModem.logger.debug( @"plusCIEV: $indicator,$value NOT 
implemented" );
+            break;
+        default:
+            theModem.logger.warning( @"plusCIEV: $indicator,$value UNKNOWN" );
+            break;
+        }
+    }
+
+    /**
+     * When an incoming call arrives we get the URC:
+     * +CLIN: 0
+     **/
+    public void plusCLIN( string prefix, string rhs )
+    {
+            theModem.callhandler.handleIncomingCall("VOICE");
+    }
+
+    /**
+     * +CLIP: "+4969123456789",145
+     **/
+    public override void plusCLIP( string prefix, string rhs )
+    {
+        assert( theModem.logger.debug( @"plusCLIP: not implemented on Neptune" 
) );
+    }
+
+    public virtual void dummy( string prefix, string rhs )
+    {
+        assert( theModem.logger.debug( @"URC: $prefix not implemented on 
Neptune" ) );
+    }
+}
-- 
1.7.1


_______________________________________________
Smartphones-userland mailing list
Smartphones-userland@linuxtogo.org
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/smartphones-userland

Reply via email to