This commit was generated by cvs2svn to compensate for changes in r164,
[gnokii.git] / include / phones / nk7110.h
1 /*
2
3   $Id$
4
5   G N O K I I
6
7   A Linux/Unix toolset and driver for Nokia mobile phones.
8
9   Copyright (C) 2000 Hugh Blemings & Pavel Janík ml.
10   Copytight (C) 2000 Chris Kemp
11
12   Released under the terms of the GNU GPL, see file COPYING for more details.
13
14   This file provides functions specific to the 7110 series. 
15   See README for more details on supported mobile phones.
16
17   The various routines are called P7110_(whatever).
18
19   $Log$
20   Revision 1.1.1.3  2002/04/03 00:08:21  short
21   Found in "gnokii-working" directory, some November-patches version
22
23   Revision 1.6  2001/11/08 16:47:48  pkot
24   Start fiddling with 7110 and SMS
25
26   Revision 1.5  2001/06/27 23:52:52  pkot
27   7110/6210 updates (Marian Jancar)
28
29   Revision 1.4  2001/05/24 20:47:30  chris
30   More updating of 7110 code and some of xgnokii_lowlevel changed over.
31
32   Revision 1.3  2001/03/23 13:40:25  chris
33   Pavel's patch and a few fixes.
34
35   Revision 1.2  2001/03/21 23:36:08  chris
36   Added the statemachine
37   This will break gnokii --identify and --monitor except for 6210/7110
38
39   Revision 1.1  2001/02/21 19:57:13  chris
40   More fiddling with the directory layout
41
42   Revision 1.1  2001/02/16 14:29:54  chris
43   Restructure of common/.  Fixed a problem in fbus-phonet.c
44   Lots of dprintfs for Marcin
45   Any size xpm can now be loaded (eg for 7110 startup logos)
46   nk7110 code detects 7110/6210 and alters startup logo size to suit
47   Moved Marcin's extended phonebook code into gnokii.c
48
49   Revision 1.4  2001/01/29 17:14:44  chris
50   dprintf now in misc.h (and fiddling with 7110 code)
51
52   Revision 1.3  2001/01/23 15:32:44  chris
53   Pavel's 'break' and 'static' corrections.
54   Work on logos for 7110.
55
56   Revision 1.2  2001/01/17 02:54:56  chris
57   More 7110 work.  Use with care! (eg it is not possible to delete phonebook entries)
58   I can now edit my phonebook in xgnokii but it is 'work in progress'.
59
60   Revision 1.1  2001/01/14 22:47:01  chris
61   Preliminary 7110 support (dlr9 only) and the beginnings of a new structure
62
63
64 */
65
66 #ifndef __phones_nk7110_h
67 #define __phones_nk7110_h
68
69 #include <gsm-common.h>
70 #include "gsm-statemachine.h"
71
72 extern bool P7110_LinkOK;
73
74 /* Message types */
75 #define P7110_MSG_COMMSTATUS    0x01    /* Communication status */
76 #define P7110_MSG_SMS           0x02    /* SMS handling */
77 #define P7110_MSG_PHONEBOOK     0x03    /* Phonebook functions */
78 #define P7110_MSG_NETSTATUS     0x0a    /* Network status */
79 #define P7110_MSG_CALENDAR      0x13    /* Calendar notes */
80 #define P7110_MSG_FOLDER        0x14    /* Folders handling */
81 #define P7110_MSG_BATTERY       0x17    /* Battery info */
82 #define P7110_MSG_CLOCK         0x19    /* Date & alarm */
83 #define P7110_MSG_IDENTITY      0x1b    /* Brief product info */
84 #define P7110_MSG_RINGTONE      0x1f    /* Ringtone handling */
85 #define P7110_MSG_SECURITY      0x40    /* Security */
86 #define P7110_MSG_STLOGO        0x7a    /* Startup logo */
87 #define P7110_MSG_VERREQ        0xd1    /* HW&SW version request */
88 #define P7110_MSG_VERRESP       0xd2    /* HW&SW version response */
89
90 /* SMS handling message subtypes (send) */
91 #define P7110_SUBSMS_SEND_SMS           0x01    /* Send SMS */
92 #define P7110_SUBSMS_SET_CELLBRD        0x20    /* Set cell broadcast */
93 #define P7110_SUBSMS_SET_SMSC           0x30    /* Set SMS center */
94 #define P7110_SUBSMS_GET_SMSC           0x33    /* Get SMS center */
95 /* SMS handling message subtypes (recv) */
96 #define P7110_SUBSMS_SMS_SENT           0x02    /* SMS sent */
97 #define P7110_SUBSMS_SEND_FAIL          0x03    /* SMS send failed */
98 #define P7110_SUBSMS_SMS_RCVD           0x10    /* SMS received */
99 #define P7110_SUBSMS_CELLBRD_OK         0x21    /* Set cell broadcast success*/
100 #define P7110_SUBSMS_CELLBRD_FAIL       0x22    /* Set cell broadcast failure */
101 #define P7110_SUBSMS_READ_CELLBRD       0x23    /* Read cell broadcast */
102 #define P7110_SUBSMS_SMSC_OK            0x31    /* Set SMS center success*/
103 #define P7110_SUBSMS_SMSC_FAIL          0x32    /* Set SMS center failure */
104 #define P7110_SUBSMS_SMSC_RCVD          0x34    /* SMS center received */
105 #define P7110_SUBSMS_SMSC_RCVFAIL       0x35    /* SMS center receive failure */
106
107 /* Clock handling message subtypes (send) */
108 #define P7110_SUBCLO_GET_DATE           0x62    /* Get date & time */
109 #define P7110_SUBCLO_GET_ALARM          0x6D    /* Get alarm */
110 /* Clock handling message subtypes (recv) */
111 #define P7110_SUBCLO_DATE_RCVD          0x63    /* Received date & time */
112 #define P7110_SUBCLO_ALARM_RCVD         0x6E    /* Received alarm */
113 /* Alarm on/off */
114 #define P7110_ALARM_ENABLED             0x02    /* Alarm enabled */
115 #define P7110_ALARM_DISABLED            0x01    /* Alarm disabled */
116
117 /* Calendar handling message subtypes (send) */
118 #define P7110_SUBCAL_ADD_MEETING        0x01    /* Add meeting note */
119 #define P7110_SUBCAL_ADD_CALL           0x03    /* Add call note */
120 #define P7110_SUBCAL_ADD_BIRTHDAY       0x05    /* Add birthday note */
121 #define P7110_SUBCAL_ADD_REMINDER       0x07    /* Add reminder note */
122 #define P7110_SUBCAL_DEL_NOTE           0x0b    /* Delete note */
123 #define P7110_SUBCAL_GET_NOTE           0x19    /* Get note */
124 #define P7110_SUBCAL_GET_FREEPOS        0x31    /* Get first free position */
125 #define P7110_SUBCAL_GET_INFO           0x3a    /* Calendar sumary */
126 /* Calendar handling message subtypes (recv) */
127 #define P7110_SUBCAL_ADD_MEETING_RESP   0x02    /* Add meeting note response */
128 #define P7110_SUBCAL_ADD_CALL_RESP      0x04    /* Add call note response */
129 #define P7110_SUBCAL_ADD_BIRTHDAY_RESP  0x06    /* Add birthday note response */
130 #define P7110_SUBCAL_ADD_REMINDER_RESP  0x08    /* Add reminder note response */
131 #define P7110_SUBCAL_DEL_NOTE_RESP      0x0c    /* Dletete note response */
132 #define P7110_SUBCAL_NOTE_RCVD          0x1a    /* Received note */
133 #define P7110_SUBCAL_FREEPOS_RCVD       0x32    /* Received first free position */
134 #define P7110_SUBCAL_INFO_RCVD          0x3b    /* Received calendar summary*/
135 /* Calendar note types */
136 #define P7110_NOTE_MEETING              0x01    /* Metting */
137 #define P7110_NOTE_CALL                 0x02    /* Call */
138 #define P7110_NOTE_BIRTHDAY             0x04    /* Birthday */
139 #define P7110_NOTE_REMINDER             0x08    /* Reminder */
140
141 /* Phone Memory types */
142 #define P7110_MEMORY_DIALLED    0x01    /* Dialled numbers */
143 #define P7110_MEMORY_MISSED     0x02    /* Missed calls */
144 #define P7110_MEMORY_RECEIVED   0x03    /* Received calls */
145 #define P7110_MEMORY_PHONE      0x05    /* Telephone phonebook */
146 #define P7110_MEMORY_SIM        0x06    /* SIM phonebook */
147 #define P7110_MEMORY_SPEEDDIALS 0x0e    /* Speed dials */
148 #define P7110_MEMORY_GROUPS     0x10    /* Caller groups */
149
150 #define P7110_MEMORY_DC         0x01    /* ME dialled calls list */
151 #define P7110_MEMORY_MC         0x02    /* ME missed (unanswered received) calls list */
152 #define P7110_MEMORY_RC         0x03    /* ME received calls list */
153 #define P7110_MEMORY_FD         0x04    /* ?? SIM fixdialling-phonebook */
154 #define P7110_MEMORY_ME         0x05    /* ME (Mobile Equipment) phonebook */
155 #define P7110_MEMORY_SM         0x06    /* SIM phonebook */
156 #define P7110_MEMORY_ON         0x07    /* ?? SIM (or ME) own numbers list */
157 #define P7110_MEMORY_EN         0x08    /* ?? SIM (or ME) emergency number */
158 #define P7110_MEMORY_MT         0x09    /* ?? combined ME and SIM phonebook */
159 #define P7110_MEMORY_VOICE      0x0b    /* Voice Mailbox */
160
161 /* This is used when the memory type is unknown. */
162 #define P7110_MEMORY_XX 0xff
163
164 /* Entry Types for the enhanced phonebook */
165 #define P7110_ENTRYTYPE_POINTER         0x04    /* Pointer to other memory */
166 #define P7110_ENTRYTYPE_NAME            0x07    /* Name always the only one */
167 #define P7110_ENTRYTYPE_EMAIL           0x08    /* Email Adress (TEXT) */
168 #define P7110_ENTRYTYPE_POSTAL          0x09    /* Postal Address (Text) */
169 #define P7110_ENTRYTYPE_NOTE            0x0a    /* Note (Text) */
170 #define P7110_ENTRYTYPE_NUMBER          0x0b    /* Phonenumber */
171 #define P7110_ENTRYTYPE_RINGTONE        0x0c    /* Ringtone */
172 #define P7110_ENTRYTYPE_DATE            0x13    /* Date for a Called List */
173 #define P7110_ENTRYTYPE_LOGO            0x1b    /* Group logo */
174 #define P7110_ENTRYTYPE_LOGOSWITCH      0x1c    /* Group logo on/off */
175 #define P7110_ENTRYTYPE_GROUP           0x1e    /* Group number for phonebook entry */
176
177 #ifdef __phones_nk7110_c  /* Prototype functions for phone-7110.c only */
178
179 static GSM_Error P7110_Functions(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state);
180 static GSM_Error P7110_Initialise(GSM_Statemachine *state);
181 static GSM_Error P7110_GetModel(GSM_Data *data, GSM_Statemachine *state);
182 static GSM_Error P7110_GetRevision(GSM_Data *data, GSM_Statemachine *state);
183 static GSM_Error P7110_GetIMEI(GSM_Data *data, GSM_Statemachine *state);
184 static GSM_Error P7110_Identify(GSM_Data *data, GSM_Statemachine *state);
185 static GSM_Error P7110_GetBatteryLevel(GSM_Data *data, GSM_Statemachine *state);
186 static GSM_Error P7110_GetRFLevel(GSM_Data *data, GSM_Statemachine *state);
187 static GSM_Error P7110_GetMemoryStatus(GSM_Data *data, GSM_Statemachine *state);
188 static GSM_Error P7110_SetBitmap(GSM_Data *data, GSM_Statemachine *state);
189 static GSM_Error P7110_GetBitmap(GSM_Data *data, GSM_Statemachine *state);
190 static GSM_Error P7110_WritePhonebookLocation(GSM_Data *data, GSM_Statemachine *state);
191 static GSM_Error P7110_ReadPhonebook(GSM_Data *data, GSM_Statemachine *state);
192 static GSM_Error P7110_GetNetworkInfo(GSM_Data *data, GSM_Statemachine *state);
193 static GSM_Error P7110_GetSpeedDial(GSM_Data *data, GSM_Statemachine *state);
194 static GSM_Error P7110_GetSMSCenter(GSM_Data *data, GSM_Statemachine *state);
195 static GSM_Error P7110_GetClock(char req_type, GSM_Data *data, GSM_Statemachine *state);
196 static GSM_Error P7110_GetCalendarNote(GSM_Data *data, GSM_Statemachine *state);
197 static GSM_Error P7110_GetSMS(GSM_Data *data, GSM_Statemachine *state);
198 static GSM_Error P7110_GetSMSFolders(GSM_Data *data, GSM_Statemachine *state);
199 static GSM_Error P7110_GetSMSFolderStatus(GSM_Data *data, GSM_Statemachine *state);
200
201 static GSM_Error P7110_Incoming0x1b(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
202 static GSM_Error P7110_IncomingPhonebook(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
203 static GSM_Error P7110_IncomingNetwork(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
204 static GSM_Error P7110_IncomingBattLevel(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
205 static GSM_Error P7110_IncomingStartup(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
206 static GSM_Error P7110_IncomingSMS(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
207 static GSM_Error P7110_IncomingFolder(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
208 static GSM_Error P7110_IncomingClock(int messagetype, unsigned char *message, int length, GSM_Data *data);
209 static GSM_Error P7110_IncomingCalendar(int messagetype, unsigned char *message, int length, GSM_Data *data);
210
211 static int GetMemoryType(GSM_MemoryType memory_type);
212
213 #if 0
214 static GSM_Error P7110_Initialise(char *port_device, char *initlength,
215                  GSM_ConnectionType connection,
216                  void (*rlp_callback)(RLP_F96Frame *frame));
217 static GSM_Error P7110_GenericCRHandler(int messagetype, unsigned char *buffer, int length);
218 static GSM_Error P7110_IncomingDefault(int messagetype, unsigned char *buffer, int length);
219 static GSM_Error P7110_GetIMEI(char *imei);
220 static GSM_Error P7110_GetRevision(char *revision);
221 static GSM_Error P7110_GetModel(char *model);
222 static GSM_Error P7110_ReadPhonebook(GSM_PhonebookEntry *entry);
223 static GSM_Error P7110_WritePhonebookLocation(GSM_PhonebookEntry *entry);
224 static GSM_Error P7110_GetMemoryStatus(GSM_MemoryStatus *status);
225 static GSM_Error P7110_GetBatteryLevel(GSM_BatteryUnits *units, float *level);
226 static GSM_Error P7110_GetRFLevel(GSM_RFUnits *units, float *level);
227 static GSM_Error P7110_GetBitmap(GSM_Bitmap *bitmap);
228 static GSM_Error P7110_SetBitmap(GSM_Bitmap *bitmap);
229 static GSM_Error P7110_DialVoice(char *Number);
230 static void P7110_Terminate();
231 static bool P7110_SendRLPFrame( RLP_F96Frame *frame, bool out_dtx );
232
233 #endif
234
235
236 #endif  /* #ifdef __phones_nk7110_c */
237
238 #endif  /* #ifndef __phones_nk7110_h */