Update: orig2001_12_04_22_45 -> orig2001_12_14_20_46
[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 */
20
21 #ifndef __phones_nk7110_h
22 #define __phones_nk7110_h
23
24 #include <gsm-common.h>
25 #include "gsm-statemachine.h"
26
27 extern bool P7110_LinkOK;
28
29 /* Message types */
30 #define P7110_MSG_COMMSTATUS    0x01    /* Communication status */
31 #define P7110_MSG_SMS           0x02    /* SMS handling */
32 #define P7110_MSG_PHONEBOOK     0x03    /* Phonebook functions */
33 #define P7110_MSG_DIVERT        0x06    /* Call Divert */
34 #define P7110_MSG_NETSTATUS     0x0a    /* Network status */
35 #define P7110_MSG_CALENDAR      0x13    /* Calendar notes */
36 #define P7110_MSG_FOLDER        0x14    /* Folders handling */
37 #define P7110_MSG_BATTERY       0x17    /* Battery info */
38 #define P7110_MSG_CLOCK         0x19    /* Date & alarm */
39 #define P7110_MSG_IDENTITY      0x1b    /* Brief product info */
40 #define P7110_MSG_RINGTONE      0x1f    /* Ringtone handling */
41 #define P7110_MSG_SECURITY      0x40    /* Security */
42 #define P7110_MSG_STLOGO        0x7a    /* Startup logo */
43 #define P7110_MSG_VERREQ        0xd1    /* HW&SW version request */
44 #define P7110_MSG_VERRESP       0xd2    /* HW&SW version response */
45
46 /* SMS handling message subtypes (send) */
47 #define P7110_SUBSMS_SEND_SMS           0x01    /* Send SMS */
48 #define P7110_SUBSMS_SET_CELLBRD        0x20    /* Set cell broadcast */
49 #define P7110_SUBSMS_SET_SMSC           0x30    /* Set SMS center */
50 #define P7110_SUBSMS_GET_SMSC           0x33    /* Get SMS center */
51 /* SMS handling message subtypes (recv) */
52 #define P7110_SUBSMS_SMS_SENT           0x02    /* SMS sent */
53 #define P7110_SUBSMS_SEND_FAIL          0x03    /* SMS send failed */
54 #define P7110_SUBSMS_SMS_RCVD           0x10    /* SMS received */
55 #define P7110_SUBSMS_CELLBRD_OK         0x21    /* Set cell broadcast success*/
56 #define P7110_SUBSMS_CELLBRD_FAIL       0x22    /* Set cell broadcast failure */
57 #define P7110_SUBSMS_READ_CELLBRD       0x23    /* Read cell broadcast */
58 #define P7110_SUBSMS_SMSC_OK            0x31    /* Set SMS center success*/
59 #define P7110_SUBSMS_SMSC_FAIL          0x32    /* Set SMS center failure */
60 #define P7110_SUBSMS_SMSC_RCVD          0x34    /* SMS center received */
61 #define P7110_SUBSMS_SMSC_RCVFAIL       0x35    /* SMS center receive failure */
62
63 /* Clock handling message subtypes (send) */
64 #define P7110_SUBCLO_GET_DATE           0x62    /* Get date & time */
65 #define P7110_SUBCLO_GET_ALARM          0x6D    /* Get alarm */
66 /* Clock handling message subtypes (recv) */
67 #define P7110_SUBCLO_DATE_RCVD          0x63    /* Received date & time */
68 #define P7110_SUBCLO_ALARM_RCVD         0x6E    /* Received alarm */
69 /* Alarm on/off */
70 #define P7110_ALARM_ENABLED             0x02    /* Alarm enabled */
71 #define P7110_ALARM_DISABLED            0x01    /* Alarm disabled */
72
73 /* Calendar handling message subtypes (send) */
74 #define P7110_SUBCAL_ADD_MEETING        0x01    /* Add meeting note */
75 #define P7110_SUBCAL_ADD_CALL           0x03    /* Add call note */
76 #define P7110_SUBCAL_ADD_BIRTHDAY       0x05    /* Add birthday note */
77 #define P7110_SUBCAL_ADD_REMINDER       0x07    /* Add reminder note */
78 #define P7110_SUBCAL_DEL_NOTE           0x0b    /* Delete note */
79 #define P7110_SUBCAL_GET_NOTE           0x19    /* Get note */
80 #define P7110_SUBCAL_GET_FREEPOS        0x31    /* Get first free position */
81 #define P7110_SUBCAL_GET_INFO           0x3a    /* Calendar sumary */
82 /* Calendar handling message subtypes (recv) */
83 #define P7110_SUBCAL_ADD_MEETING_RESP   0x02    /* Add meeting note response */
84 #define P7110_SUBCAL_ADD_CALL_RESP      0x04    /* Add call note response */
85 #define P7110_SUBCAL_ADD_BIRTHDAY_RESP  0x06    /* Add birthday note response */
86 #define P7110_SUBCAL_ADD_REMINDER_RESP  0x08    /* Add reminder note response */
87 #define P7110_SUBCAL_DEL_NOTE_RESP      0x0c    /* Dletete note response */
88 #define P7110_SUBCAL_NOTE_RCVD          0x1a    /* Received note */
89 #define P7110_SUBCAL_FREEPOS_RCVD       0x32    /* Received first free position */
90 #define P7110_SUBCAL_INFO_RCVD          0x3b    /* Received calendar summary*/
91 /* Calendar note types */
92 #define P7110_NOTE_MEETING              0x01    /* Metting */
93 #define P7110_NOTE_CALL                 0x02    /* Call */
94 #define P7110_NOTE_BIRTHDAY             0x04    /* Birthday */
95 #define P7110_NOTE_REMINDER             0x08    /* Reminder */
96
97 /* Phone Memory types */
98 #define P7110_MEMORY_DIALLED    0x01    /* Dialled numbers */
99 #define P7110_MEMORY_MISSED     0x02    /* Missed calls */
100 #define P7110_MEMORY_RECEIVED   0x03    /* Received calls */
101 #define P7110_MEMORY_PHONE      0x05    /* Telephone phonebook */
102 #define P7110_MEMORY_SIM        0x06    /* SIM phonebook */
103 #define P7110_MEMORY_SPEEDDIALS 0x0e    /* Speed dials */
104 #define P7110_MEMORY_GROUPS     0x10    /* Caller groups */
105
106 #define P7110_MEMORY_DC         0x01    /* ME dialled calls list */
107 #define P7110_MEMORY_MC         0x02    /* ME missed (unanswered received) calls list */
108 #define P7110_MEMORY_RC         0x03    /* ME received calls list */
109 #define P7110_MEMORY_FD         0x04    /* ?? SIM fixdialling-phonebook */
110 #define P7110_MEMORY_ME         0x05    /* ME (Mobile Equipment) phonebook */
111 #define P7110_MEMORY_SM         0x06    /* SIM phonebook */
112 #define P7110_MEMORY_ON         0x07    /* ?? SIM (or ME) own numbers list */
113 #define P7110_MEMORY_EN         0x08    /* ?? SIM (or ME) emergency number */
114 #define P7110_MEMORY_MT         0x09    /* ?? combined ME and SIM phonebook */
115 #define P7110_MEMORY_VOICE      0x0b    /* Voice Mailbox */
116
117 /* This is used when the memory type is unknown. */
118 #define P7110_MEMORY_XX 0xff
119
120 /* Entry Types for the enhanced phonebook */
121 #define P7110_ENTRYTYPE_POINTER         0x04    /* Pointer to other memory */
122 #define P7110_ENTRYTYPE_NAME            0x07    /* Name always the only one */
123 #define P7110_ENTRYTYPE_EMAIL           0x08    /* Email Adress (TEXT) */
124 #define P7110_ENTRYTYPE_POSTAL          0x09    /* Postal Address (Text) */
125 #define P7110_ENTRYTYPE_NOTE            0x0a    /* Note (Text) */
126 #define P7110_ENTRYTYPE_NUMBER          0x0b    /* Phonenumber */
127 #define P7110_ENTRYTYPE_RINGTONE        0x0c    /* Ringtone */
128 #define P7110_ENTRYTYPE_DATE            0x13    /* Date for a Called List */
129 #define P7110_ENTRYTYPE_LOGO            0x1b    /* Group logo */
130 #define P7110_ENTRYTYPE_LOGOSWITCH      0x1c    /* Group logo on/off */
131 #define P7110_ENTRYTYPE_GROUP           0x1e    /* Group number for phonebook entry */
132
133 #ifdef __phones_nk7110_c  /* Prototype functions for phone-7110.c only */
134
135 static GSM_Error P7110_Functions(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state);
136 static GSM_Error P7110_Initialise(GSM_Statemachine *state);
137 static GSM_Error P7110_GetModel(GSM_Data *data, GSM_Statemachine *state);
138 static GSM_Error P7110_GetRevision(GSM_Data *data, GSM_Statemachine *state);
139 static GSM_Error P7110_GetIMEI(GSM_Data *data, GSM_Statemachine *state);
140 static GSM_Error P7110_Identify(GSM_Data *data, GSM_Statemachine *state);
141 static GSM_Error P7110_GetBatteryLevel(GSM_Data *data, GSM_Statemachine *state);
142 static GSM_Error P7110_GetRFLevel(GSM_Data *data, GSM_Statemachine *state);
143 static GSM_Error P7110_GetMemoryStatus(GSM_Data *data, GSM_Statemachine *state);
144 static GSM_Error P7110_SetBitmap(GSM_Data *data, GSM_Statemachine *state);
145 static GSM_Error P7110_GetBitmap(GSM_Data *data, GSM_Statemachine *state);
146 static GSM_Error P7110_WritePhonebookLocation(GSM_Data *data, GSM_Statemachine *state);
147 static GSM_Error P7110_ReadPhonebook(GSM_Data *data, GSM_Statemachine *state);
148 static GSM_Error P7110_GetNetworkInfo(GSM_Data *data, GSM_Statemachine *state);
149 static GSM_Error P7110_GetSpeedDial(GSM_Data *data, GSM_Statemachine *state);
150 static GSM_Error P7110_GetSMSCenter(GSM_Data *data, GSM_Statemachine *state);
151 static GSM_Error P7110_GetClock(char req_type, GSM_Data *data, GSM_Statemachine *state);
152 static GSM_Error P7110_GetCalendarNote(GSM_Data *data, GSM_Statemachine *state);
153 static GSM_Error P7110_GetSMS(GSM_Data *data, GSM_Statemachine *state);
154 static GSM_Error P7110_SendSMS(GSM_Data *data, GSM_Statemachine *state);
155 static GSM_Error P7110_GetSMSFolders(GSM_Data *data, GSM_Statemachine *state);
156 static GSM_Error P7110_GetSMSFolderStatus(GSM_Data *data, GSM_Statemachine *state);
157 static GSM_Error P7110_CallDivert(GSM_Data *data, GSM_Statemachine *state);
158
159 static GSM_Error P7110_Incoming0x1b(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
160 static GSM_Error P7110_IncomingPhonebook(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
161 static GSM_Error P7110_IncomingNetwork(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
162 static GSM_Error P7110_IncomingBattLevel(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
163 static GSM_Error P7110_IncomingStartup(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
164 static GSM_Error P7110_IncomingSMS(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
165 static GSM_Error P7110_IncomingFolder(int messagetype, unsigned char *buffer, int length, GSM_Data *data);
166 static GSM_Error P7110_IncomingClock(int messagetype, unsigned char *message, int length, GSM_Data *data);
167 static GSM_Error P7110_IncomingCalendar(int messagetype, unsigned char *message, int length, GSM_Data *data);
168 static GSM_Error P7110_IncomingCallDivert(int messagetype, unsigned char *message, int length, GSM_Data *data);
169
170 static int GetMemoryType(GSM_MemoryType memory_type);
171
172 #if 0
173 static GSM_Error P7110_Initialise(char *port_device, char *initlength,
174                  GSM_ConnectionType connection,
175                  void (*rlp_callback)(RLP_F96Frame *frame));
176 static GSM_Error P7110_GenericCRHandler(int messagetype, unsigned char *buffer, int length);
177 static GSM_Error P7110_IncomingDefault(int messagetype, unsigned char *buffer, int length);
178 static GSM_Error P7110_GetIMEI(char *imei);
179 static GSM_Error P7110_GetRevision(char *revision);
180 static GSM_Error P7110_GetModel(char *model);
181 static GSM_Error P7110_ReadPhonebook(GSM_PhonebookEntry *entry);
182 static GSM_Error P7110_WritePhonebookLocation(GSM_PhonebookEntry *entry);
183 static GSM_Error P7110_GetMemoryStatus(GSM_MemoryStatus *status);
184 static GSM_Error P7110_GetBatteryLevel(GSM_BatteryUnits *units, float *level);
185 static GSM_Error P7110_GetRFLevel(GSM_RFUnits *units, float *level);
186 static GSM_Error P7110_GetBitmap(GSM_Bitmap *bitmap);
187 static GSM_Error P7110_SetBitmap(GSM_Bitmap *bitmap);
188 static GSM_Error P7110_DialVoice(char *Number);
189 static void P7110_Terminate();
190 static bool P7110_SendRLPFrame( RLP_F96Frame *frame, bool out_dtx );
191
192 #endif
193
194
195 #endif  /* #ifdef __phones_nk7110_c */
196
197 #endif  /* #ifndef __phones_nk7110_h */