2 * Copyright (C) 2009-2012 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
3 * Copyright (C) 2014 Sebastian Krzyszkowiak <dos@dosowisko.net>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 * @class CinterionPS8.Modem
28 * This modem plugin supports Cinterion PS8 modem family (PHS8, PLS8, PXS8)
31 class CinterionPS8
.Modem
: FsoGsm
.AbstractModem
33 private const string CHANNEL_NAME
= "main"; // "Modem" (when using two channels) or "Application" (when using only one)
34 private const string URC_CHANNEL_NAME
= "urc"; // "Application" (optionally)
36 public override string repr()
41 public override void configureData()
43 assert( modem_data
!= null );
45 modem_data
.simHasReadySignal
= true; // ^SSIM READY (enabled by ^SSET=1) or +CIEV: simstatus,5 (enabled by ^SIND="simstatus",1)
46 modem_data
.simReadyTimeout
= 30; // seconds
47 modem_data
.atCommandRejectIncoming
= "^SHUP=21,%d"; // release cause "call rejected"
48 modem_data
.atCommandRejectIncomingWithId
= true;
49 modem_data
.atCommandCancelOutgoing
= "^SHUP=16,%d"; // release cause "normal call clearing"
50 modem_data
.atCommandCancelOutgoingWithId
= true;
51 modem_data
.atCommandReleaseAllActive
= "+CHUP";
52 modem_data
.atCommandReleaseAllHeld
= "+CHUP";
54 registerAtCommandSequence( "MODEM", "init", new
AtCommandSequence( {
56 """+CMEE=1""", // report mobile equipment errors = numerical format
57 """^SLED=2""", // enable STATUS LED (non-persistent)
58 """+CFUN=4""", // power up the SIM card
59 """^SSET=1""", // enable SIM ready indication
60 """^SIND="nitz
",1""", // enable Network Identity and Time Zone indication (for now to tests)
61 """^SCFG="MEopMode
/RingOnData
","on
"""", // set RingOnData - for some reason this one seems to be volatile?
62 """^SCFG="MEopMode
/PowerMgmt
/LCI
","enabled
"""" // enable Low Current Indicator (aka SLEEP LED), it's volatile as well
65 registerAtCommandSequence( "main", "unlocked", new
AtCommandSequence( {
66 "+CRC=1", // extended cellular result codes = enable
67 "+CLIP=0", // calling line id present = disable
68 "+CLIR=0", // calling line id restrict = disable
69 "+COLP=0", // connected line id present = disable
70 "+CCWA=0" // call waiting = disable
73 registerAtCommandSequence( "main", "suspend", new
AtCommandSequence( {
74 """+CREG=0""", // disable network status updates
75 """^SIND="nitz
",0""" // disable Network Identity and Time Zone indication
78 registerAtCommandSequence( "main", "resume", new
AtCommandSequence( {
79 """+CREG=2""", // enable network status updates
80 """^SIND="nitz
",1""" // enable Network Identity and Time Zone indication
83 registerAtCommandSequence( "MODEM", "shutdown", new
AtCommandSequence( {
84 """+CFUN=0""", // put the modem into airplane mode
88 protected override void createChannels()
90 var transport
= modem_transport_spec
.create();
91 var parser
= new FsoGsm
.StateBasedAtParser();
93 new
AtChannel( this
, CHANNEL_NAME
, transport
, parser
);
95 // we can optionally use second channel to read all URCs
96 var modem_urc_access
= FsoFramework
.theConfig
.stringValue( "fsogsm.modem_cinterion_ps8", "modem_urc_access", "" );
97 if ( modem_urc_access
.length
> 0 )
99 transport
= FsoFramework
.TransportSpec
.parse( modem_urc_access
).create();
100 parser
= new FsoGsm
.StateBasedAtParser();
101 new
AtChannel( this
, URC_CHANNEL_NAME
, transport
, parser
, true );
105 protected override FsoGsm
.UnsolicitedResponseHandler
createUnsolicitedHandler()
107 return new CinterionPS8
.UnsolicitedResponseHandler( this
);
110 protected override void registerCustomMediators( HashMap
<Type
,Type
> mediators
)
112 CinterionPS8
.registerCustomMediators( mediators
);
115 protected override void registerCustomAtCommands( HashMap
<string,FsoGsm
.AtCommand
> commands
)
117 CinterionPS8
.registerCustomAtCommands( commands
);
120 protected override FsoGsm
.Channel
channelForCommand( FsoGsm
.AtCommand command
, string query
)
122 // we use only one channel for sending all AT commands
123 return channels
[ CHANNEL_NAME
];
128 * This function gets called on plugin initialization time.
129 * @return the name of your plugin here
130 * @note that it needs to be a name in the format <subsystem>.<plugin>
131 * else your module will be unloaded immediately.
133 public static string fso_factory_function( FsoFramework
.Subsystem subsystem
) throws Error
135 FsoFramework
.theLogger
.debug( "fsogsm.cinterion_ps8 fso_factory_function" );
136 return "fsogsmd.modem_cinterion_ps8";
140 public static void fso_register_function( TypeModule module
)
142 // do not remove this function
146 * This function gets called on plugin load time.
147 * @return false, if the plugin operating conditions are present.
148 * @note Some versions of glib contain a bug that leads to a SIGSEGV
149 * in g_module_open, if you return true here.
151 /*public static bool g_module_check_init( void* m )
153 var ok = FsoFramework.FileHandling.isPresent( Kernel26.SYS_CLASS_LEDS );
158 // vim:ts=4:sw=4:expandtab