aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Busch <morphis@gravedo.de>2012-06-20 15:24:41 +0200
committerSimon Busch <morphis@gravedo.de>2012-07-16 21:51:58 +0200
commit5fe2c00daa126fc30e41eff0c54553d53747cab0 (patch)
treee8a789821ad842c69b5abec0926e38bb28eef8ea
parent98e29122fb309ef6d80acc5e50af865d8477270e (diff)
downloadcornucopia-morphis/hfp.tar.gz
cornucopia-morphis/hfp.tar.bz2
cornucopia-morphis/hfp.zip
fsogsmd: modem_hfp_hf: update indicator status handlingmorphis/hfp
-rw-r--r--fsogsmd/src/plugins/modem_hfp_hf/indicators.vala26
-rw-r--r--fsogsmd/src/plugins/modem_hfp_hf/modem.vala32
-rw-r--r--fsogsmd/src/plugins/modem_hfp_hf/unsolicited.vala18
3 files changed, 71 insertions, 5 deletions
diff --git a/fsogsmd/src/plugins/modem_hfp_hf/indicators.vala b/fsogsmd/src/plugins/modem_hfp_hf/indicators.vala
index be90e35f..0a2b5dd4 100644
--- a/fsogsmd/src/plugins/modem_hfp_hf/indicators.vala
+++ b/fsogsmd/src/plugins/modem_hfp_hf/indicators.vala
@@ -35,14 +35,38 @@ public class Indicators : FsoFramework.AbstractObject
indexes[type] = index;
}
- public void update( Constants.Indicator type, int value )
+ public int get_value( Constants.Indicator type )
{
+ return values[type];
+ }
+
+ public void update( int index, int value )
+ {
+ var type = Constants.Indicator.UNKNOWN;
+
+ for ( var n = 0; n < indexes.length; n++ )
+ {
+ if ( indexes[n] == index )
+ {
+ type = (Constants.Indicator) n;
+ break;
+ }
+ }
+
+ if ( type == Constants.Indicator.UNKNOWN || type == Constants.Indicator.LAST )
+ return;
+
if ( values[type] != value )
+ {
values[type] = value;
+ indicator_changed( type, values[type] );
+ }
}
public override string repr()
{
return @"<>";
}
+
+ public signal void indicator_changed( Constants.Indicator type, int value );
}
diff --git a/fsogsmd/src/plugins/modem_hfp_hf/modem.vala b/fsogsmd/src/plugins/modem_hfp_hf/modem.vala
index f4f02a95..80b2d996 100644
--- a/fsogsmd/src/plugins/modem_hfp_hf/modem.vala
+++ b/fsogsmd/src/plugins/modem_hfp_hf/modem.vala
@@ -57,6 +57,27 @@ namespace HfpHf
private Indicators _indicators;
//
+ // private
+ //
+
+ private void on_indicator_changed( Constants.Indicator type, int value )
+ {
+ switch ( type )
+ {
+ case Constants.Indicator.SERVICE:
+ break;
+ case Constants.Indicator.SIGNAL:
+ break;
+ case Constants.Indicator.CALL:
+ break;
+ case Constants.Indicator.CALLSETUP:
+ break;
+ case Constants.Indicator.CALLHELD:
+ break;
+ }
+ }
+
+ //
// protected
//
@@ -84,7 +105,7 @@ namespace HfpHf
protected override FsoGsm.UnsolicitedResponseHandler createUnsolicitedHandler()
{
- return new HfpHf.UnsolicitedResponseHandler( this );
+ return new HfpHf.UnsolicitedResponseHandler( this, _indicators );
}
//
@@ -96,6 +117,7 @@ namespace HfpHf
this.device_path = device_path;
this.agent = new DelegateAgent( this );
_indicators = new Indicators();
+ _indicators.indicator_changed.connect( on_indicator_changed );
}
/**
@@ -171,7 +193,7 @@ namespace HfpHf
public async void new_connection( GLib.Socket socket, uint16 version ) throws DBusError, IOError
{
- assert( logger.debug( @"New HFP HF connection" ) );
+ assert( logger.debug( @"Initializing new connection ..." ) );
advanceToState( FsoGsm.Modem.Status.INITIALIZING );
@@ -201,7 +223,11 @@ namespace HfpHf
throw new Bluez.Error.FAILED( "Failed to establish service level connection" );
}
- advanceToState( FsoGsm.Modem.Status.ALIVE_SIM_READY );
+ var next_status = FsoGsm.Modem.Status.ALIVE_SIM_READY;
+ if ( _indicators.get_value( Constants.Indicator.SERVICE ) == 1 )
+ next_status = FsoGsm.Modem.Status.ALIVE_REGISTERED;
+
+ advanceToState( next_status );
}
public async void release() throws DBusError, IOError
diff --git a/fsogsmd/src/plugins/modem_hfp_hf/unsolicited.vala b/fsogsmd/src/plugins/modem_hfp_hf/unsolicited.vala
index 3f017fe5..0b8c5837 100644
--- a/fsogsmd/src/plugins/modem_hfp_hf/unsolicited.vala
+++ b/fsogsmd/src/plugins/modem_hfp_hf/unsolicited.vala
@@ -22,9 +22,25 @@ using FsoGsm;
public class HfpHf.UnsolicitedResponseHandler : FsoGsm.AtUnsolicitedResponseHandler
{
- public UnsolicitedResponseHandler( FsoGsm.Modem modem )
+ private Indicators _indicators;
+
+ public UnsolicitedResponseHandler( FsoGsm.Modem modem, Indicators indicators )
{
base( modem );
+ _indicators = indicators;
+ }
+
+ public virtual void plusCIEV( string prefix, string rhs )
+ {
+ var cmd = modem.createAtCommand<PlusCIEV>( "+CIEV" );
+
+ if ( cmd.validateUrc( @"$prefix: $rhs" ) != Constants.AtResponse.VALID )
+ {
+ logger.warning( @"Received invalid +cmd message $rhs. Please report" );
+ return;
+ }
+
+ _indicators.update( cmd.value1, cmd.value2 );
}
}