http://marcin-wiacek.fkn.pl/english/zips/mygnokii.tar.gz
[gnokii.git] / common / newmodules / n3110.c
1 /*\r
2 \r
3   G N O K I I\r
4 \r
5   A Linux/Unix toolset and driver for Nokia mobile phones.\r
6 \r
7   Released under the terms of the GNU GPL, see file COPYING for more details.\r
8 \r
9   This file provides an API for accessing functions on the N3110 and similar\r
10   phones.\r
11 \r
12 */\r
13 \r
14 /* "Turn on" prototypes in n-3110.h */\r
15 \r
16 #define __n_3110_c \r
17 \r
18 /* System header files */\r
19 #include <stdio.h>\r
20 #include <string.h>\r
21 #include <stdlib.h>\r
22 \r
23 #ifdef WIN32
24   #include "misc_win32.h"
25 #endif
26  
27 /* Various header file */\r
28 #ifndef VC6\r
29   #include "config.h"\r
30 #endif\r
31 \r
32 #include "misc.h"\r
33 #include "gsm-api.h"\r
34 #include "gsm-common.h"\r
35 #include "files/cfgreader.h"\r
36 #include "newmodules/n3110.h"\r
37 #include "newmodules/n6110.h"\r
38 #include "gsm-networks.h"\r
39 \r
40 /* Here we initialise model specific functions. */\r
41 \r
42 GSM_Functions N3110_Functions = {\r
43   N3110_Initialise,\r
44   N3110_DispatchMessage,\r
45   NULL_Terminate,\r
46   NULL_KeepAlive,\r
47   NOTSUPPORTED,\r
48   NOTSUPPORTED,  \r
49   NOTSUPPORTED,\r
50   NOTSUPPORTED,\r
51   NOTSUPPORTED,\r
52   NOTSUPPORTED,\r
53   NOTSUPPORTED,\r
54   NOTSUPPORTED,\r
55   NOTSUPPORTED,\r
56   NOTSUPPORTED,\r
57   NOTSUPPORTED,\r
58   NOTSUPPORTED,\r
59   NOTSUPPORTED,\r
60   NOTSUPPORTED,\r
61   NOTSUPPORTED,\r
62   NOTSUPPORTED,\r
63   NOTSUPPORTED,\r
64   NOTSUPPORTED,\r
65   NOTSUPPORTED,\r
66   NOTSUPPORTED,\r
67   NOTSUPPORTED,\r
68   NOTSUPPORTED,\r
69   NOTSUPPORTED,\r
70   NOTSUPPORTED,\r
71   NOTSUPPORTED,\r
72   NOTSUPPORTED,\r
73   NOTSUPPORTED,\r
74   NOTSUPPORTED,\r
75   NOTSUPPORTED,\r
76   NOTSUPPORTED,\r
77   NOTSUPPORTED,\r
78   NOTSUPPORTED,\r
79   NOTSUPPORTED,\r
80   NOTSUPPORTED,\r
81   NOTSUPPORTED,\r
82   NOTSUPPORTED,\r
83   NOTSUPPORTED,\r
84   NOTSUPPORTED,\r
85   NOTSUPPORTED,\r
86   NOTSUPPORTED,\r
87   NOTSUPPORTED,\r
88   NOTSUPPORTED,\r
89   NOTSUPPORTED,\r
90   NOTSUPPORTED,\r
91   NOTSUPPORTED,\r
92   NOTSUPPORTED,\r
93   NOTSUPPORTED,\r
94   NOTSUPPORTED,\r
95   NOTSUPPORTED,\r
96   NOTSUPPORTED,\r
97   NOTSUPPORTED,\r
98   NOTSUPPORTED,\r
99   NOTSUPPORTED,\r
100   NOTSUPPORTED,\r
101   NOTSUPPORTED,\r
102   NOTSUPPORTED,\r
103   NOTSUPPORTED,\r  NOTSUPPORTED,
104   NOTSUPPORTED,
105   NOTSUPPORTED,
106   NOTSUPPORTED,
107   NOTSUPPORTED,
108   NOTSUPPORTED,
109   NOTSUPPORTED,
110   NOTSUPPORTED,
111   NOTSUPPORTED,
112   NOTSUPPORTED
113 };\r
114 \r
115
116
117 /* for all these Phones we support N3110 */\r
118 \r
119 GSM_Information N3110_Information = {\r
120   "", /* Supported models in FBUS */\r
121   "",/* Supported models in MBUS */\r
122   "",/* Supported models in FBUS over infrared */\r
123   "",/* Supported models in FBUS over DLR3 */\r
124   "",
125   "", /* Supported models in FBUS over Irda sockets */
126   "",
127   "3110|3810|8110|8110i|8148|8148i", /* FBUS version 1 */
128   4,                     /* Max RF Level */\r
129   0,                     /* Min RF Level */\r
130   GRF_Arbitrary,         /* RF level units */\r
131   4,                     /* Max Battery Level */\r
132   0,                     /* Min Battery Level */\r
133   GBU_Arbitrary,         /* Battery level units */\r
134   GDT_None,              /* No date/time support */\r
135   GDT_None,              /* No alarm support */\r
136   0                      /* Max alarms = 0 */\r
137 };\r
138 \r
139 /* Initialise variables and state machine. */\r
140 GSM_Error N3110_Initialise(char *port_device, char *initlength,\r
141                           GSM_ConnectionType connection,\r
142                           void (*rlp_callback)(RLP_F96Frame *frame))\r
143 {\r
144   u8 init[20]={0x02, 0x01, 0x07, 0xa2, 0x88, 0x81, 0x21, 0x55, 0x63, 0xa8,
145                0x00, 0x00, 0x07, 0xa3, 0xb8, 0x81, 0x20, 0x15, 0x63, 0x80};
146
147   unsigned char init_char = N6110_SYNC_BYTE;
148
149   int count;
150   int InitLength;
151
152   GSM_Error error;
153   \r  if (Protocol->Initialise(port_device,initlength,connection,rlp_callback)!=GE_NONE)\r
154   {\r
155     return GE_NOTSUPPORTED;\r
156   }\r
157
158   InitLength = atoi(initlength);
159
160   if ((strcmp(initlength, "default") == 0) || (InitLength == 0)) {
161     InitLength = 250;   /* This is the usual value, lower may work. */
162   }
163
164 #ifdef DEBUG
165   fprintf(stdout,_("Writing init chars...."));
166 #endif
167
168   /* Initialise link with phone or what have you */
169   /* Send init string to phone, this is a bunch of 0x55 characters. Timing is
170      empirical. */
171   for (count = 0; count < InitLength; count ++) {
172     usleep(1000);
173     Protocol->WritePhone(1,&init_char);
174   }
175
176 #ifdef DEBUG
177   fprintf(stdout,_("Done\n"));  
178 #endif
179
180   error=NULL_SendMessageSequence (200, &CurrentGetIMEIError, 20, 0x15, init);\r
181   if (error!=GE_NONE) return error;\r
182 \r
183   CurrentLinkOK = true;                           \r
184 \r
185   return (GE_NONE);\r
186 }\r
187 \r
188
189 void N3110_DispatchMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType)
190 {
191 }