Implemented connection type "tcp" (GCT_TCP), use <hostname>:<port> as "port"
[gnokii.git] / include / fbus-6110.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) 1999, 2000 Hugh Blemings & Pavel Janík ml.
10
11   Released under the terms of the GNU GPL, see file COPYING for more details.
12
13   Header file for the various functions, definitions etc. used to implement
14   the handset interface.  See fbus-6110.c for more details.
15
16   $Log$
17   Revision 1.1.1.2  2002/04/03 00:08:17  short
18   Found in "gnokii-working" directory, some November-patches version
19
20   Revision 1.58  2001/06/28 00:28:45  pkot
21   Small docs updates (Pawel Kot)
22
23
24 */
25
26 #ifndef __fbus_6110_h
27 #define __fbus_6110_h
28
29 #ifndef __gsm_common_h
30 #include "gsm-common.h"
31 #endif
32
33 #define FB61_MAX_TRANSMIT_LENGTH (256)
34 #define FB61_MAX_RECEIVE_LENGTH  (512)
35 #define FB61_MAX_CONTENT_LENGTH  (120)
36
37 /* Nokia 6110 supports phonebook entries of max. 16 characters and numbers of
38    max. 30 digits */
39
40 #define FB61_MAX_PHONEBOOK_NAME_LENGTH   (16)
41 #define FB61_MAX_PHONEBOOK_NUMBER_LENGTH (30)
42
43 /* Alternate defines for memory types.  Two letter codes follow GSM 07.07
44    release 6.2.0, AT+CPBS "Select Phonebook Memory Storage" */
45
46 #define FB61_MEMORY_MT 0x01 /* combined ME and SIM phonebook */
47 #define FB61_MEMORY_ME 0x02 /* ME (Mobile Equipment) phonebook */
48 #define FB61_MEMORY_SM 0x03 /* SIM phonebook */
49 #define FB61_MEMORY_FD 0x04 /* SIM fixdialling-phonebook */
50 #define FB61_MEMORY_ON 0x05 /* SIM (or ME) own numbers list */
51 #define FB61_MEMORY_EN 0x06 /* SIM (or ME) emergency number */
52 #define FB61_MEMORY_DC 0x07 /* ME dialled calls list */
53 #define FB61_MEMORY_RC 0x08 /* ME received calls list */
54 #define FB61_MEMORY_MC 0x09 /* ME missed (unanswered received) calls list */
55
56 /* This is still unknown, it can also be unimplemented in CDS. */
57
58 // #define FB61_MEMORY_LD 0x?? /* SIM last-dialling-phonebook */
59
60 /* TA is not applicable (TA == computer) but it's here for 'completeness' */
61
62 // #define FB61_MEMORY_TA 0x?? /* TA (Terminal Adaptor) phonebook */
63
64 /* This is used when the memory type is unknown. */
65
66 #define FB61_MEMORY_XX 0xff
67
68 /* Limits for IMEI, Revision and Model string storage. */
69
70 #define FB61_MAX_IMEI_LENGTH     (20)
71 #define FB61_MAX_REVISION_LENGTH (20)
72 #define FB61_MAX_SW_LENGTH       (9)
73 #define FB61_MAX_MODEL_LENGTH    (6)
74
75 /* This byte is used to synchronize FBUS channel over cable or IR. */
76
77 #define FB61_SYNC_BYTE 0x55
78
79 /* This byte is at the beginning of all GSM Frames sent over FBUS to Nokia
80    6110 phones. */
81
82 #define FB61_FRAME_ID 0x1e
83
84 /* Every (well, almost every) frame from the computer starts with this
85    sequence. */
86
87 #define FB61_FRAME_HEADER 0x00, 0x01, 0x00
88
89 /* The FBUS interface is 115200 */
90
91 #define FB61_BAUDRATE (B115200)
92
93 /* The next two macros define the source and destination addresses used for
94    specifying the device connected on the cable. */
95
96 /* Nokia mobile phone. */
97 #define FB61_DEVICE_PHONE 0x00
98
99 /* Our PC. */
100 #define FB61_DEVICE_PC 0x0c
101
102 /* These macros are used to specify the type of the frame. Only few types are
103    known yet - if you can cast some light on these, please let us known. */
104
105 /* Acknowledge of the received frame. */
106 #define FB61_FRTYPE_ACK 0x7f
107
108 /* Macros for infrared communication */
109
110 /* This byte is at the beginning of all GSM Frames sent over IR to Nokia 6110
111    phones. */
112
113 #define FB61_IR_FRAME_ID 0x1c
114
115 /* Infrared communication starts on 9600 bps. */
116
117 #define FB61_IR_INIT_SPEED (B9600)
118
119 /* This byte is send after all FB61_SYNC_BYTE bytes. */
120
121 #define FB61_IR_END_INIT_BYTE  0xc1
122
123 /* Global variables */
124
125 extern bool            FB61_LinkOK;
126 extern GSM_Functions   FB61_Functions;
127 extern GSM_Information FB61_Information;
128
129
130 /* Prototypes for the functions designed to be used externally. */
131
132 GSM_Error FB61_Initialise(char *port_device, char *initlength,
133                           GSM_ConnectionType connection,
134                           void (*rlp_callback)(RLP_F96Frame *frame));
135
136 bool      FB61_OpenSerial(void);
137 bool      FB61_Open_Ir_Serial(void);
138 void      FB61_Terminate(void);
139 void      FB61_ThreadLoop(void);
140 void      FB61_SigHandler(int status);
141 void      FB61_RX_StateMachine(char rx_byte);
142 enum FB61_RX_States FB61_RX_DispatchMessage(void);
143 enum FB61_RX_States FB61_RX_HandleRLPMessage(void);
144 void      FB61_RX_DisplayMessage(void);
145
146 int       FB61_TX_SendMessage(u16 message_length, u8 message_type, u8 *buffer);
147 int       FB61_TX_SendAck(u8 message_type, u8 message_seq);
148 int       FB61_TX_SendFrame(u8 message_length, u8 message_type, u8 *buffer); 
149
150 int       FB61_GetMemoryType(GSM_MemoryType memory_type);
151 int       SemiOctetPack(char *Number, unsigned char *Output);
152
153 GSM_Error FB61_GetMemoryLocation(GSM_PhonebookEntry *entry);
154 GSM_Error FB61_WritePhonebookLocation(GSM_PhonebookEntry *entry);
155
156 GSM_Error FB61_GetSpeedDial(GSM_SpeedDial *entry);
157 GSM_Error FB61_SetSpeedDial(GSM_SpeedDial *entry);
158
159 GSM_Error FB61_GetMemoryStatus(GSM_MemoryStatus *Status);
160 GSM_Error FB61_GetSMSStatus(GSM_SMSStatus *Status);
161 GSM_Error FB61_GetSMSCenter(GSM_MessageCenter *MessageCenter);
162   
163 GSM_Error FB61_GetSMSMessage(GSM_SMSMessage *Message);
164 GSM_Error FB61_DeleteSMSMessage(GSM_SMSMessage *Message);
165 GSM_Error FB61_SendSMSMessage(GSM_SMSMessage *Message);
166 GSM_Error FB61_SaveSMSMessage(GSM_SMSMessage *Message);
167
168 GSM_Error FB61_GetRFLevel(GSM_RFUnits *units, float *level);
169 GSM_Error FB61_GetBatteryLevel(GSM_BatteryUnits *units, float *level);
170 GSM_Error FB61_GetPowerSource(GSM_PowerSource *source);
171 GSM_Error FB61_GetDisplayStatus(int *Status);
172
173 GSM_Error FB61_EnterSecurityCode(GSM_SecurityCode SecurityCode);
174 GSM_Error FB61_GetSecurityCodeStatus(int *Status);
175
176 GSM_Error FB61_GetSMSCenter(GSM_MessageCenter *MessageCenter);
177 GSM_Error FB61_SetSMSCenter(GSM_MessageCenter *MessageCenter);
178
179 GSM_Error FB61_GetIMEI(char *imei);
180 GSM_Error FB61_GetRevision(char *revision);
181 GSM_Error FB61_GetModel(char *model);
182
183 GSM_Error FB61_GetDateTime(GSM_DateTime *date_time);
184 GSM_Error FB61_SetDateTime(GSM_DateTime *date_time);
185
186 GSM_Error FB61_GetAlarm(int alarm_number, GSM_DateTime *date_time);
187 GSM_Error FB61_SetAlarm(int alarm_number, GSM_DateTime *date_time);
188
189 GSM_Error FB61_DialVoice(char *Number);
190 GSM_Error FB61_DialData(char *Number, char type,  void (* callpassup)(char c));
191
192 GSM_Error FB61_GetIncomingCallNr(char *Number);
193
194 GSM_Error FB61_SendBitmap(char *NetworkCode, int width, int height,
195                           unsigned char *bitmap);
196 GSM_Error FB61_GetNetworkInfo(GSM_NetworkInfo *NetworkInfo);
197
198 GSM_Error FB61_GetCalendarNote(GSM_CalendarNote *CalendarNote);
199 GSM_Error FB61_WriteCalendarNote(GSM_CalendarNote *CalendarNote);
200 GSM_Error FB61_DeleteCalendarNote(GSM_CalendarNote *CalendarNote);
201
202 GSM_Error FB61_NetMonitor(unsigned char mode, char *Screen);
203
204 GSM_Error FB61_SetBitmap( GSM_Bitmap *Bitmap );
205 GSM_Error FB61_GetBitmap( GSM_Bitmap *Bitmap );
206
207 GSM_Error FB61_SetRingTone(GSM_Ringtone *ringtone);
208
209 GSM_Error FB61_EnableDisplayOutput();
210 GSM_Error FB61_DisableDisplayOutput();
211
212 GSM_Error FB61_EnableCellBroadcast ();
213 GSM_Error FB61_DisableCellBroadcast(void);
214 GSM_Error FB61_ReadCellBroadcast (GSM_CBMessage *Message);
215
216 GSM_Error FB61_SendDTMF(char *String);
217
218 GSM_Error FB61_Reset(unsigned char type);
219
220 GSM_Error FB61_GetProfile(GSM_Profile *Profile);
221 GSM_Error FB61_SetProfile(GSM_Profile *Profile);
222 bool      FB61_SendRLPFrame(RLP_F96Frame *frame, bool out_dtx);
223
224 GSM_Error FB61_CancelCall(void);
225 GSM_Error FB61_AnswerCall(char s);
226
227 /* States for receive code. */
228
229 enum FB61_RX_States {
230   FB61_RX_Sync,
231   FB61_RX_Discarding,
232   FB61_RX_GetDestination,
233   FB61_RX_GetSource,
234   FB61_RX_GetType,
235   FB61_RX_GetUnknown,
236   FB61_RX_GetLength,
237   FB61_RX_GetMessage
238 };
239
240 GSM_Error FB61_TX_SendStatusRequest(void);
241
242 #endif /* __fbus_6110_h */