7 A Linux/Unix toolset and driver for Nokia mobile phones.
9 Copyright 2001 Pavel Machek <pavel@ucw.cz>
11 Released under the terms of the GNU GPL, see file COPYING for more details.
13 This file provides functions specific to the dancall 2711.
14 See README for more details on supported mobile phones.
17 Revision 1.1.1.1 2001/11/25 21:59:11 short
18 :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
20 Revision 1.5 2001/07/27 00:02:21 pkot
21 Generic AT support for the new structure (Manfred Jonsson)
23 Revision 1.4 2001/04/25 12:53:07 machek
24 Added error handling to SMS receive function.
26 Revision 1.3 2001/03/23 13:40:23 chris
27 Pavel's patch and a few fixes.
29 Revision 1.2 2001/03/13 01:24:03 pkot
30 Code cleanup - no warnings during compilation
32 Revision 1.1 2001/03/11 11:26:15 machek
33 Dancall support, now actually works enough to get sms messages.
43 #include "gsm-common.h"
44 #include "phones/generic.h"
45 #include "links/cbus.h"
47 /* Mobile phone information */
50 static GSM_IncomingFunctionType D2711_IncomingFunctions[];
54 "dancall|2711|2713", /* Supported models */ \
55 7, /* Max RF Level */ \
56 0, /* Min RF Level */ \
57 GRF_Percentage, /* RF level units */ \
58 7, /* Max Battery Level */ \
59 0, /* Min Battery Level */ \
60 GBU_Percentage, /* Battery level units */ \
61 0, /* Have date/time support */ \
62 0, /* Alarm supports time only */ \
63 1, /* Alarms available - FIXME */ \
64 60, 96, /* Startup logo size - 7110 is fixed at init*/ \
65 21, 78, /* Op logo size */ \
66 14, 72 /* Caller logo size */ \
69 GSM_Information D2711_Information = INFO;
72 static GSM_Phone phone = {
73 D2711_IncomingFunctions,
78 /* LinkOK is always true for now... */
79 bool D2711_LinkOK = true;
80 char reply_buf[10240];
82 static void Terminate()
87 /* ----------------------------------------------------------------------------------- */
89 static GSM_Error Reply(int messagetype, unsigned char *buffer, int length, GSM_Data *data)
96 extern char reply_buf[];
98 static char *Request(char *c)
100 link.SendMessage(strlen(c), 0, c);
106 /* ----------------------------------- SMS stuff ------------------------------------- */
109 GSM_Error ATGSM_GetSMSMessage(GSM_SMSMessage * m)
111 GSM_Error test = GE_NONE;
116 m->MemoryType = GMT_SM; // Type of memory message is stored in.
118 sprintf(writecmd, "AT+CMGR=%d\r", m->Location);
119 s = Request(writecmd);
122 t = strchr(s, '\n')+1;
123 if (!strncmp(s, "+CMS ERROR: 321", 15))
124 return GE_EMPTYSMSLOCATION;
125 if (!strncmp(s, "+CMS ERROR: ", 11))
126 return GE_INTERNALERROR;
128 printf("Got %s [%s] as reply for cmgr\n", s, t);
138 memset(m->MessageText, 0, 161);
139 strncpy(m->MessageText, (void *) t, 161);
140 m->Length = strlen(t);
141 strcpy(m->MessageCenter.Number, "(unknown)");
142 strcpy(m->MessageCenter.Name, "(unknown)");
143 m->MessageCenter.No = 0;
144 strcpy(m->Sender, "(sender unknown)");
145 m->UDHType = GSM_NoUDH;
151 GSM_Error ATGSM_DeleteSMSMessage(GSM_SMSMessage * message)
155 sprintf(writecmd, "AT+CMGD=%d\r", message->Location);
162 GSM_Error ATGSM_SendSMSMessage(GSM_SMSMessage * SMS, int size)
164 return (GE_NOTIMPLEMENTED);
167 /* ----------------------------------------------------------------------------------- */
169 static GSM_Error Initialise(char *port_device, char *initlength,
170 GSM_ConnectionType connection,
171 void (*rlp_callback)(RLP_F96Frame *frame))
173 /* char model[10]; */
175 strncpy(link.PortDevice, port_device, 20);
176 link.InitLength = atoi(initlength);
177 link.ConnectionType = connection;
179 fprintf(stderr, "Initializing dancall...\n");
180 switch (connection) {
182 CBUS_Initialise(&link, &phone);
185 return GE_NOTSUPPORTED;
188 sendat("AT+CPMS=\"SM\",\"SM\"\r");
189 printf("Waiting spurious...\n");
190 if (strncmp(reply_buf, "+CPMS", 5)) {
191 while (strncmp(reply_buf, "+CPMS", 5))
194 printf("Waiting OKAY\n");
204 GetSMSStatus(GSM_SMSStatus *Status)
207 char *message = Request("AT+CPMS=\"SM\",\"SM\"\r");
208 if (sscanf(message, "+CPMS: \"SM\",%d,%d,\"SM\",%d,%d", &i, &j, &k, &l)!=4)
215 /* Here we initialise model specific functions called by 'gnokii'. */
216 /* This too needs fixing .. perhaps pass the link a 'request' of certain */
217 /* type and the link then searches the phone functions.... */
219 GSM_Functions D2711_Functions = {
222 UNIMPLEMENTED, /* GetMemoryLocation */
223 UNIMPLEMENTED, /* WritePhonebookLocation */
224 UNIMPLEMENTED, /* GetSpeedDial */
225 UNIMPLEMENTED, /* SetSpeedDial */
226 UNIMPLEMENTED, /* GetMemoryStatus */
227 GetSMSStatus, /* GetSMSStatus */
228 UNIMPLEMENTED, /* GetSMSCentre */
229 UNIMPLEMENTED, /* SetSMSCentre */
230 ATGSM_GetSMSMessage, /* GetSMSMessage */
231 ATGSM_DeleteSMSMessage, /* DeleteSMSMessage */
232 ATGSM_SendSMSMessage, /* SendSMSMessage */
233 UNIMPLEMENTED, /* SaveSMSMessage */
234 UNIMPLEMENTED, /* GetRFLevel */
235 UNIMPLEMENTED, /* GetBatteryLevel */
236 UNIMPLEMENTED, /* GetPowerSource */
237 UNIMPLEMENTED, /* GetDisplayStatus */
238 UNIMPLEMENTED, /* EnterSecurityCode */
239 UNIMPLEMENTED, /* GetSecurityCodeStatus */
240 UNIMPLEMENTED, /* GetIMEI */
241 UNIMPLEMENTED, /* GetRevision */
242 UNIMPLEMENTED, /* GetModel */
243 UNIMPLEMENTED, /* GetManufacturer */
244 UNIMPLEMENTED, /* GetDateTime */
245 UNIMPLEMENTED, /* SetDateTime */
246 UNIMPLEMENTED, /* GetAlarm */
247 UNIMPLEMENTED, /* SetAlarm */
248 UNIMPLEMENTED, /* DialVoice */
249 UNIMPLEMENTED, /* DialData */
250 UNIMPLEMENTED, /* GetIncomingCallNr */
251 UNIMPLEMENTED, /* GetNetworkInfo */
252 UNIMPLEMENTED, /* GetCalendarNote */
253 UNIMPLEMENTED, /* WriteCalendarNote */
254 UNIMPLEMENTED, /* DeleteCalendarNote */
255 UNIMPLEMENTED, /* NetMonitor */
256 UNIMPLEMENTED, /* SendDTMF */
257 UNIMPLEMENTED, /* GetBitmap */
258 UNIMPLEMENTED, /* SetBitmap */
259 UNIMPLEMENTED, /* SetRingtone */
260 UNIMPLEMENTED, /* SendRingtone */
261 UNIMPLEMENTED, /* Reset */
262 UNIMPLEMENTED, /* GetProfile */
263 UNIMPLEMENTED, /* SetProfile */
264 UNIMPLEMENTED, /* SendRLPFrame */
265 UNIMPLEMENTED, /* CancelCall */
266 UNIMPLEMENTED, /* EnableDisplayOutput */
267 UNIMPLEMENTED, /* DisableDisplayOutput */
268 UNIMPLEMENTED, /* EnableCellBroadcast */
269 UNIMPLEMENTED, /* DisableCellBroadcast */
270 UNIMPLEMENTED /* ReadCellBroadcast */
273 static GSM_IncomingFunctionType D2711_IncomingFunctions[] = {