7 A Linux/Unix toolset and driver for Nokia mobile phones.
9 Copyright (C) 1999, 2000 Hugh Blemings & Pavel JanÃk ml.
11 Released under the terms of the GNU GPL, see file COPYING for more details.
13 Provides a generic API for accessing functions on the phone, wherever
14 possible hiding the model specific details.
16 The underlying code should run in it's own thread to allow communications to
17 the phone to be run independantly of mailing code that calls these API
20 Unless otherwise noted, all functions herein block until they complete. The
21 functions themselves are defined in a structure in gsm-common.h.
24 Revision 1.1.1.1 2001/11/25 21:59:04 short
25 :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
27 Revision 1.32 2001/11/14 11:26:18 pkot
28 Getting SMS in 6210/7110 does finally work in some cases :)
30 Revision 1.31 2001/11/08 16:45:58 pkot
31 Obsolete old structure, kill treads where possible and make shared library
33 Revision 1.30 2001/08/09 11:51:38 pkot
34 Generic AT support updates and cleanup (Manfred Jonsson)
36 Revision 1.29 2001/07/27 00:02:20 pkot
37 Generic AT support for the new structure (Manfred Jonsson)
39 Revision 1.28 2001/06/06 09:05:56 machek
40 Convert Grab/Release display to new structure.
42 Revision 1.27 2001/05/07 14:13:06 machek
43 nokia-2110 module converted to suit new API better. --identify now works.
45 Revision 1.26 2001/04/25 12:54:47 machek
46 Partly converted nokia 2110 to "new" form, and moved it to phone
49 Revision 1.25 2001/03/26 23:39:21 pkot
51 - Windows INLINE patch (Manfred Jonsson)
52 - patch to configure.in to compile under FreeBSD (Panagiotis Astithas)
62 #include "gsm-common.h"
63 #include "data/rlp-common.h"
64 #include "gsm-statemachine.h"
65 #include "phones/nk7110.h"
66 #include "phones/nk6100.h"
67 #include "phones/nk3110.h"
68 #include "phones/nk2110.h"
70 GSM_Statemachine GSM_SM;
71 GSM_Error (*GSM_F)(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state);
74 /* GSM_LinkOK is set to true once normal communications with the phone have
78 bool LinkAlwaysOK = true;
80 /* Define pointer to the GSM_Functions structure used by external code to call
81 relevant API functions. This structure is defined in gsm-common.h. */
85 /* Define pointer to the GSM_Information structure used by external code to
86 obtain information that varies from model to model. This structure is also
87 defined in gsm-common.h */
89 GSM_Information *GSM_Info;
91 /* Initialise interface to the phone. Model number should be a string such as
92 3810, 5110, 6110 etc. Device is the serial port to use e.g. /dev/ttyS0, the
93 user must have write permission to the device. */
95 static GSM_Error register_phone(GSM_Phone *phone, char *model, char *setupmodel, GSM_Statemachine *sm)
100 GSM_DataClear(&data);
101 data.Model = setupmodel;
106 if (strstr(phone->Info.Models, model) != NULL)
107 return phone->Functions(GOP_Init, p_data, sm);
108 return GE_UNKNOWNMODEL;
111 #define MODULE(x) { \
112 extern GSM_Functions x##_Functions; \
113 extern GSM_Information x##_Information; \
114 extern bool x##_LinkOK; \
115 if (strstr(x##_Information.Models, model) != NULL) { \
116 GSM = & x##_Functions; \
117 GSM_Info = & x##_Information; \
118 GSM_LinkOK = & x##_LinkOK; \
119 return (GSM->Initialise(device, initlength, connection, rlp_callback)); \
123 #define REGISTER_PHONE(x, y) { \
124 extern GSM_Phone phone_##x; \
125 if ((ret = register_phone(&phone_##x, model, y, sm)) != GE_UNKNOWNMODEL) \
130 GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), GSM_Statemachine *sm)
133 #ifndef WIN32 /* MB21 not supported in win32 */
134 if (strstr("2110", model)) {
135 extern GSM_Phone phone_nokia_2110;
136 memcpy(&(sm->Phone), &phone_nokia_2110, sizeof(GSM_Phone));
137 sm->Phone.Functions(GOP_Init, NULL, sm);
141 GSM_LinkOK = &LinkAlwaysOK;
142 sm->Link.ConnectionType=connection;
143 sm->Link.InitLength=atoi(initlength);
144 strcpy(sm->Link.PortDevice,device);
146 REGISTER_PHONE(nokia_7110, NULL);
147 REGISTER_PHONE(nokia_6100, NULL);
148 REGISTER_PHONE(nokia_3110, NULL);
149 REGISTER_PHONE(at, model);
152 return (GE_UNKNOWNMODEL);