First version, development moved to 5110-connected machine
[gnokii.git] / include / newmodules / n6110.h
1 /*
2
3   G N O K I I
4
5   A Linux/Unix toolset and driver for Nokia mobile phones.
6
7   Released under the terms of the GNU GPL, see file COPYING for more details.
8
9   Header file for the various functions, definitions etc. used to implement
10   the handset interface.  See fbus-6110.c for more details.
11
12 */
13
14 #ifndef __n_6110_h
15 #define __n_6110_h
16
17 #include "gsm-api.h"
18
19 /* Nokia 6110 supports phonebook entries of max. 16 characters and numbers of
20    max. 30 digits */
21 #define N6110_MAX_PHONEBOOK_NAME_LENGTH   (16)
22 #define N6110_MAX_PHONEBOOK_NUMBER_LENGTH (30)
23
24 /* Alternate defines for memory types.  Two letter codes follow GSM 07.07
25    release 6.2.0, AT+CPBS "Select Phonebook Memory Storage" */
26 #define N6110_MEMORY_MT    0x01    /* combined ME and SIM phonebook */
27 #define N6110_MEMORY_ME    0x02    /* ME (Mobile Equipment) phonebook */
28 #define N6110_MEMORY_SM    0x03    /* SIM phonebook */
29 #define N6110_MEMORY_FD    0x04    /* SIM fixdialling-phonebook */
30 #define N6110_MEMORY_ON    0x05    /* SIM (or ME) own numbers list */
31 #define N6110_MEMORY_EN    0x06    /* SIM (or ME) emergency number */
32 #define N6110_MEMORY_DC    0x07    /* ME dialled calls list */
33 #define N6110_MEMORY_RC    0x08    /* ME received calls list */
34 #define N6110_MEMORY_MC    0x09    /* ME missed (unanswered received) calls list */
35 #define N6110_MEMORY_VOICE 0x0b    /* Voice Mailbox */
36 #define N6110_MEMORY_XX    0xff    /* This is used when the memory type is unknown. */
37
38 /* This byte is used to synchronize FBUS channel over cable or IR. */
39 #define N6110_SYNC_BYTE 0x55
40
41 /* This byte is send after all N6110_SYNC_BYTE bytes when init infrared. */
42 #define N6110_IR_END_SYNC_BYTE  0xc1
43
44 /* Every (well, almost every) frame from the computer starts with this
45    sequence. */
46 #define N6110_FRAME_HEADER 0x00, 0x01, 0x00
47
48 /* Global variables */
49 extern bool            N6110_LinkOK;
50 extern GSM_Functions   N6110_Functions;
51 extern GSM_Information N6110_Information;
52
53 /* Prototypes for the functions designed to be used externally. */
54 static GSM_Error N6110_Initialise(char *port_device, char *initlength,
55                           GSM_ConnectionType connection,
56                           void (*rlp_callback)(RLP_F96Frame *frame));
57
58 static void      N6110_DispatchMessage(u16 MessageLength, u8 *MessageBuffer,
59                               u8 MessageType);
60
61 static GSM_Error N6110_SendStatusRequest(void);
62
63 static int       N6110_GetMemoryType(GSM_MemoryType memory_type);
64
65 #ifndef UCLINUX
66 static GSM_Error N6110_GetVoiceMailbox ( GSM_PhonebookEntry *entry);  
67
68 static GSM_Error N6110_GetOperatorName ( GSM_Network *operator);  
69 static GSM_Error N6110_SetOperatorName ( GSM_Network *operator);    
70 #endif /* UCLINUX */
71
72 static GSM_Error N6110_GetMemoryLocation(GSM_PhonebookEntry *entry);
73 static GSM_Error N6110_WritePhonebookLocation(GSM_PhonebookEntry *entry);
74
75 #ifndef UCLINUX
76 static GSM_Error N6110_GetSpeedDial(GSM_SpeedDial *entry);
77 static GSM_Error N6110_SetSpeedDial(GSM_SpeedDial *entry);
78 #endif /* UCLINUX */
79
80 static GSM_Error N6110_GetMemoryStatus(GSM_MemoryStatus *Status);
81 #ifndef UCLINUX
82 static GSM_Error N6110_GetSMSStatus(GSM_SMSStatus *Status);
83 static GSM_Error N6110_GetSMSCenter(GSM_MessageCenter *MessageCenter);
84   
85 static GSM_Error N6110_GetSMSMessage(GSM_SMSMessage *Message);
86 static GSM_Error N6110_DeleteSMSMessage(GSM_SMSMessage *Message);
87 static GSM_Error N6110_SendSMSMessage(GSM_SMSMessage *Message);
88 static GSM_Error N6110_SaveSMSMessage(GSM_SMSMessage *Message);
89 #endif /* UCLINUX */
90
91 static GSM_Error N6110_GetRFLevel(GSM_RFUnits *units, float *level);
92 static GSM_Error N6110_GetBatteryLevel(GSM_BatteryUnits *units, float *level);
93 static GSM_Error N6110_GetPowerSource(GSM_PowerSource *source);
94 #ifndef UCLINUX
95 static GSM_Error N6110_GetDisplayStatus(int *Status);
96
97 static GSM_Error N6110_EnterSecurityCode(GSM_SecurityCode SecurityCode);
98 static GSM_Error N6110_GetSecurityCodeStatus(int *Status);
99 static GSM_Error N6110_GetSecurityCode(GSM_SecurityCode *SecurityCode);
100
101 static GSM_Error N6110_GetSMSCenter(GSM_MessageCenter *MessageCenter);
102 static GSM_Error N6110_SetSMSCenter(GSM_MessageCenter *MessageCenter);
103
104 static GSM_Error N6110_GetIMEI(char *imei);
105 static GSM_Error N6110_GetRevision(char *revision);
106 static GSM_Error N6110_GetModel(char *model);
107 #endif /* UCLINUX */
108 static GSM_Error N6110_GetManufacturer(char *manufacturer);
109
110 #ifndef UCLINUX
111 static GSM_Error N6110_GetDateTime(GSM_DateTime *date_time);
112 static GSM_Error N6110_SetDateTime(GSM_DateTime *date_time);
113
114 static GSM_Error N6110_PrivGetDateTime(GSM_DateTime *date_time, int msgtype);
115 static GSM_Error N6110_PrivSetDateTime(GSM_DateTime *date_time, int msgtype);
116
117 static GSM_Error N6110_GetAlarm(int alarm_number, GSM_DateTime *date_time);
118 static GSM_Error N6110_SetAlarm(int alarm_number, GSM_DateTime *date_time);
119
120 static GSM_Error N6110_PrivGetAlarm(int alarm_number, GSM_DateTime *date_time, int msgtype);
121 static GSM_Error N6110_PrivSetAlarm(int alarm_number, GSM_DateTime *date_time, int msgtype);
122
123 static GSM_Error N6110_DialVoice(char *Number);
124 #endif /* UCLINUX */
125 static GSM_Error N6110_DialData(char *Number, char type,  void (* callpassup)(char c));
126 #ifndef UCLINUX
127 static GSM_Error N6110_AnswerCall(char s);
128
129 static GSM_Error N6110_GetIncomingCallNr(char *Number);
130
131 static GSM_Error N6110_GetNetworkInfo(GSM_NetworkInfo *NetworkInfo);
132
133 static GSM_Error N6110_GetCalendarNote(GSM_CalendarNote *CalendarNote);
134 static GSM_Error N6110_WriteCalendarNote(GSM_CalendarNote *CalendarNote);
135 static GSM_Error N6110_DeleteCalendarNote(GSM_CalendarNote *CalendarNote);
136
137 static GSM_Error N6110_NetMonitor(unsigned char mode, char *Screen);
138
139 static GSM_Error N6110_PlayTone(int Herz, u8 Volume);
140
141 static GSM_Error N6110_SetBitmap( GSM_Bitmap *Bitmap );
142 static GSM_Error N6110_GetBitmap( GSM_Bitmap *Bitmap );
143
144 static GSM_Error N6110_SetRingTone(GSM_Ringtone *ringtone, int *maxlength);
145 static GSM_Error N6110_SetBinRingTone(GSM_BinRingtone *ringtone);
146 static GSM_Error N6110_GetBinRingTone(GSM_BinRingtone *ringtone);
147
148 static GSM_Error N6110_EnableDisplayOutput();
149 static GSM_Error N6110_DisableDisplayOutput();
150
151 static GSM_Error N6110_EnableCellBroadcast ();
152 static GSM_Error N6110_DisableCellBroadcast(void);
153 static GSM_Error N6110_ReadCellBroadcast (GSM_CBMessage *Message);
154
155 static GSM_Error N6110_SendDTMF(char *String);
156 #endif /* UCLINUX */
157
158 static GSM_Error N6110_Reset(unsigned char type);
159
160 #ifndef UCLINUX
161 static GSM_Error N6110_GetProfile(GSM_Profile *Profile);
162 static GSM_Error N6110_SetProfile(GSM_Profile *Profile);
163 static bool      N6110_SendRLPFrame(RLP_F96Frame *frame, bool out_dtx);
164 #endif /* UCLINUX */
165
166 static GSM_Error N6110_CancelCall(void);
167
168 #ifndef UCLINUX
169 static GSM_Error N6110_PressKey(int key, int event);
170
171 static GSM_Error N6110_GetProductProfileSetting (GSM_PPS *PPS);
172 static GSM_Error N6110_SetProductProfileSetting (GSM_PPS *PPS);
173
174 static GSM_Error N6110_CallDivert(GSM_CallDivert *cd);
175 #endif /* UCLINUX */
176
177 static void N6110_RX_HandleRLPMessage(u8 *MessageBuffer);
178
179 static GSM_Error N6110_SendIMEIFrame();
180 static GSM_Error N6110_SendIDFrame();
181 static GSM_Error N6110_SendHWFrame();
182
183 static GSM_Error N6110_EnableExtendedCommands (unsigned char status);
184
185 #ifndef UCLINUX
186 static GSM_Error N6110_Tests();
187
188 static void N6110_DisplayTestsInfo(u8 *MessageBuffer);
189
190 static GSM_Error N6110_SimlockInfo(GSM_AllSimlocks *siml);\r
191 static GSM_Error N6110_GetSMSFolders ( GSM_SMSFolders *folders);
192
193 static GSM_Error N6110_ResetPhoneSettings();
194 #endif /* UCLINUX */
195
196 static void N6110_Dispatch0x01Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
197
198 #ifndef UCLINUX
199 static void N6110_ReplySendSMSMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
200 static void N6110_ReplySetSMSCenter  (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
201 static void N6110_ReplyGetSMSCenter  (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
202 static void N6110_Dispatch0x02Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
203 static void N6110_ReplySetCellBroadcast (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
204 static void N6110_ReplyReadCellBroadcast(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
205
206 static void N6110_ReplyCallDivert    (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
207 static void N6110_Dispatch0x06Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
208 #endif /* UCLINUX */
209
210 #ifndef UCLINUX
211 static void N6110_ReplySetDateTime(u16 MessageLength,u8 *MessageBuffer, u8 MessageType);
212 static void N6110_ReplyGetDateTime(u16 MessageLength,u8 *MessageBuffer, u8 MessageType);
213 static void N6110_ReplySetAlarm   (u16 MessageLength,u8 *MessageBuffer, u8 MessageType);
214 static void N6110_ReplyGetAlarm   (u16 MessageLength,u8 *MessageBuffer, u8 MessageType);
215 #endif /* UCLINUX */
216
217 static void N6110_ReplyEnableExtendedCommands  (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
218 #ifndef UCLINUX
219 static void N6110_ReplyResetPhoneSettings      (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
220 #endif /* UCLINUX */
221 static void N6110_ReplyIMEI                    (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
222 #ifndef UCLINUX
223 static void N6110_ReplyGetProductProfileSetting(u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
224 static void N6110_ReplySetProductProfileSetting(u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
225 static void N6110_ReplyNetmonitor              (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
226 static void N6110_ReplySimlockInfo             (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
227 static void N6110_ReplyPlayTone                (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
228 #endif /* UCLINUX */
229 static void N6110_ReplyHW                      (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
230 static void N6110_Dispatch0x40Message          (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
231
232 static void N6110_DispatchACKMessage (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
233 static void N6110_ReplyID(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
234
235 #ifndef UCLINUX
236 static GSM_Error GSM_EncodeNokiaSMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int *length, SMS_MessageType PDU);
237 static GSM_Error GSM_DecodeNokiaSMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int length);
238
239 static int N6110_MakeCallerGroupFrame (unsigned char *req,GSM_Bitmap Bitmap);
240 static int N6110_MakeOperatorLogoFrame(unsigned char *req,GSM_Bitmap Bitmap);
241 static int N6110_MakeStartupLogoFrame (unsigned char *req,GSM_Bitmap Bitmap);
242 #endif /* UCLINUX */
243
244 #endif /* __n_6110_h */