Warning: Can't synchronize with repository "(default)" (No changeset 96d22ec3fa3ef6de3ea8dc0d7d398adc9aa071cf in the repository). Look in the Trac log for more information.

source: fsogsmd/src/plugins/modem_freescale_neptune/mediators.vala @ dd9f4c14

Revision dd9f4c14, 5.0 KB checked in by Klaus Kurzmann <mok@…>, 2 years ago (diff)

fsogsmd: add vim tags for correct indentation with 4 spaces

Signed-off-by: Klaus Kurzmann <mok@…>

  • Property mode set to 100644
Line 
1/*
2 * Copyright (C) 2010  Antonio Ospite <ospite@studenti.unina.it>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17 *
18 */
19
20using FsoGsm;
21using Gee;
22
23namespace FreescaleNeptune {
24
25/**
26 * Debug mediators
27 **/
28
29/**
30 * Modem not implementing any of +CGMR;+CGMM;+CGMI -- only +CGSN is supported
31 **/
32public class NeptuneDeviceGetInformation : DeviceGetInformation
33{
34    public override async void run() throws FreeSmartphone.GSM.Error, FreeSmartphone.Error
35    {
36        var modem = theModem as FreescaleNeptune.Modem;
37        /*
38        var channel = theModem.channel( "main" ) as AtChannel;
39        */
40        info = new GLib.HashTable<string,Variant>( str_hash, str_equal );
41
42        info.insert( "manufacturer", "Motorola" );
43        info.insert( "model", "Neptune Freescale Modem" );
44
45        /* Use information from the +EBPV URC we got on modem init */
46        info.insert( "revision", modem.revision );
47
48        /* "+CGSN" */
49        var cgsn = theModem.createAtCommand<PlusCGSN>( "+CGSN" );
50        var response = yield theModem.processAtCommandAsync( cgsn, cgsn.query() );
51        checkResponseValid( cgsn, response );
52        info.insert( "imei", cgsn.value );
53    }
54}
55
56
57/**
58 * SIM Mediators
59 **/
60
61/**
62 * Modem violating GSM 07.07 here.
63 *
64 * Format seems to be +CPIN=<number>,"<PIN>", where 1 is PIN1, 2 may be PIN2 or PUK1
65 **/
66public class NeptuneSimSendAuthCode : SimSendAuthCode
67{
68    public override async void run( string pin ) throws FreeSmartphone.GSM.Error, FreeSmartphone.Error
69    {
70        var cmd = theModem.createAtCommand<NeptunePlusCPIN>( "+CPIN" );
71        var response = yield theModem.processAtCommandAsync( cmd, cmd.issue( 1, pin ) );
72        var code = checkResponseExpected( cmd, response,
73            { Constants.AtResponse.OK, Constants.AtResponse.CME_ERROR_016_INCORRECT_PASSWORD } );
74
75        if ( code == Constants.AtResponse.CME_ERROR_016_INCORRECT_PASSWORD )
76        {
77            throw new FreeSmartphone.GSM.Error.SIM_AUTH_FAILED( @"PIN $pin not accepted" );
78        }
79
80        gatherSimStatusAndUpdate();
81    }
82}
83
84
85/**
86 * SMS Mediators
87 **/
88
89/**
90 * Network Mediators
91 **/
92
93public class NeptuneNetworkRegister : NetworkRegister
94{
95    public override async void run() throws FreeSmartphone.GSM.Error, FreeSmartphone.Error
96    {
97        // FIXME: find a better way to make NetworkRegister reliable,
98        // avoid sleeping if possible.
99        Thread.usleep(4000 * 1000);
100        var cmd = theModem.createAtCommand<PlusCOPS>( "+COPS" );
101        var response = yield theModem.processAtCommandAsync( cmd, cmd.issue( PlusCOPS.Action.REGISTER_WITH_BEST_PROVIDER ) );
102        checkResponseOk( cmd, response );
103    }
104}
105
106public class NeptuneNetworkUnregister : NetworkUnregister
107{
108    public override async void run() throws FreeSmartphone.GSM.Error, FreeSmartphone.Error
109    {
110        var cmd = theModem.createAtCommand<PlusCOPS>( "+COPS" );
111        var response = yield theModem.processAtCommandAsync( cmd, cmd.issue( PlusCOPS.Action.UNREGISTER ) );
112        // FIXME: find a better way to make NetworkRegister reliable,
113        // avoid sleeping if possible.
114        Thread.usleep(4000 * 1000);
115        checkResponseOk( cmd, response );
116    }
117}
118
119/**
120 * Call Mediators
121 **/
122
123/**
124 * Neptune replies to +CLCC? but not to +CLCC
125 * So we use cmd.query() here instead of cmd.execute()
126 **/
127public class NeptuneCallListCalls : CallListCalls
128{
129    public override async void run() throws FreeSmartphone.GSM.Error, FreeSmartphone.Error
130    {
131        var cmd = theModem.createAtCommand<PlusCLCC>( "+CLCC" );
132        var response = yield theModem.processAtCommandAsync( cmd, cmd.query() );
133        checkMultiResponseValid( cmd, response );
134        calls = cmd.calls;
135    }
136}
137
138/**
139 * PDP Mediators
140 **/
141
142/**
143 * Register all mediators
144 **/
145public void registerNeptuneMediators( HashMap<Type,Type> table )
146{
147    /*
148    table[ typeof(DebugPing) ]                    = typeof( NeptuneDebugPing );
149    */
150
151    table[ typeof(DeviceGetInformation) ]         = typeof( NeptuneDeviceGetInformation );
152    table[ typeof(SimSendAuthCode) ]              = typeof( NeptuneSimSendAuthCode );
153
154    table[ typeof(NetworkRegister) ]              = typeof( NeptuneNetworkRegister );
155    table[ typeof(NetworkUnregister) ]            = typeof( NeptuneNetworkUnregister );
156
157    table[ typeof(CallListCalls) ]                = typeof( NeptuneCallListCalls );
158}
159
160} /* FreescaleNeptune */
161
162// vim:ts=4:sw=4:expandtab
Note: See TracBrowser for help on using the repository browser.