1 /*
2 
3   $Id$
4 
5   G N O K I I
6 
7   A Linux/Unix toolset and driver for the mobile phones.
8 
9   This file is part of gnokii.
10 
11   Gnokii is free software; you can redistribute it and/or modify
12   it under the terms of the GNU General Public License as published by
13   the Free Software Foundation; either version 2 of the License, or
14   (at your option) any later version.
15 
16   Gnokii is distributed in the hope that it will be useful,
17   but WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   GNU General Public License for more details.
20 
21   You should have received a copy of the GNU General Public License
22   along with gnokii; if not, write to the Free Software
23   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24 
25   Copyright (C) 2008 Pawel Kot
26 
27   This file provides functions specific to at commands on Sagem phones.
28   See README for more details on supported mobile phones.
29 
30 */
31 
32 #include "config.h"
33 
34 #include <string.h>
35 #include <stdlib.h>
36 #include <ctype.h>
37 
38 #include "compat.h"
39 #include "misc.h"
40 #include "gnokii.h"
41 #include "phones/generic.h"
42 #include "phones/atgen.h"
43 #include "phones/atsag.h"
44 
AT_GetModel(gn_data * data,struct gn_statemachine * state)45 static gn_error AT_GetModel(gn_data *data, struct gn_statemachine *state)
46 {
47 	/* Sagem myW-8 replies to "AT+GMM" with "+CGMM: myW-7 UMTS" and to "AT+CGMM" with "+CGMM: myW-8 UMTS"
48 	   so don't use the first command that gives the wrong answer and isn't correctly
49 	   handled by ReplyIdentify() in atgen.c because of the mismatch AT+GMM / +CGMM
50 	 */
51 
52 	if (sm_message_send(8, GN_OP_Identify, "AT+CGMM\r", state))
53 		return GN_ERR_NOTREADY;
54 	return sm_block_no_retry(GN_OP_Identify, data, state);
55 }
56 
at_sagem_init(char * foundmodel,char * setupmodel,struct gn_statemachine * state)57 void at_sagem_init(char* foundmodel, char* setupmodel, struct gn_statemachine *state)
58 {
59 	AT_DRVINST(state)->lac_swapped = 1;
60 	AT_DRVINST(state)->encode_number = 1;
61 
62 	/* fix for Sagem myW-8 returning the wrong answer to GN_OP_GetModel */
63 	at_insert_send_function(GN_OP_GetModel, AT_GetModel, state);
64 }
65