This commit was generated by cvs2svn to compensate for changes in r161,
[gnokii.git] / common / newmodules / n3110.c
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   This file provides an API for accessing functions on the N3110 and similar
10   phones.
11
12 */
13
14 /* "Turn on" prototypes in n-3110.h */
15
16 #define __n_3110_c 
17
18 /* System header files */
19 #include <stdio.h>
20 #include <string.h>
21 #include <stdlib.h>
22
23 #ifdef WIN32
24   #include "misc_win32.h"
25 #endif
26  
27 /* Various header file */
28 #ifndef VC6
29   #include "config.h"
30 #endif
31
32 #include "misc.h"
33 #include "gsm-api.h"
34 #include "gsm-common.h"
35 #include "files/cfgreader.h"
36 #include "newmodules/n3110.h"
37 #include "newmodules/n6110.h"
38 #include "gsm-networks.h"
39
40 /* Here we initialise model specific functions. */
41
42 GSM_Functions N3110_Functions = {
43   N3110_Initialise,
44   N3110_DispatchMessage,
45   NULL_Terminate,
46   NULL_KeepAlive,
47   NOTSUPPORTED,
48   NOTSUPPORTED,  
49   NOTSUPPORTED,
50   NOTSUPPORTED,
51   NOTSUPPORTED,
52   NOTSUPPORTED,
53   NOTSUPPORTED,
54   NOTSUPPORTED,
55   NOTSUPPORTED,
56   NOTSUPPORTED,
57   NOTSUPPORTED,
58   NOTSUPPORTED,
59   NOTSUPPORTED,
60   NOTSUPPORTED,
61   NOTSUPPORTED,
62   NOTSUPPORTED,
63   NOTSUPPORTED,
64   NOTSUPPORTED,
65   NOTSUPPORTED,
66   NOTSUPPORTED,
67   NOTSUPPORTED,
68   NOTSUPPORTED,
69   NOTSUPPORTED,
70   NOTSUPPORTED,
71   NOTSUPPORTED,
72   NOTSUPPORTED,
73   NOTSUPPORTED,
74   NOTSUPPORTED,
75   NOTSUPPORTED,
76   NOTSUPPORTED,
77   NOTSUPPORTED,
78   NOTSUPPORTED,
79   NOTSUPPORTED,
80   NOTSUPPORTED,
81   NOTSUPPORTED,
82   NOTSUPPORTED,
83   NOTSUPPORTED,
84   NOTSUPPORTED,
85   NOTSUPPORTED,
86   NOTSUPPORTED,
87   NOTSUPPORTED,
88   NOTSUPPORTED,
89   NOTSUPPORTED,
90   NOTSUPPORTED,
91   NOTSUPPORTED,
92   NOTSUPPORTED,
93   NOTSUPPORTED,
94   NOTSUPPORTED,
95   NOTSUPPORTED,
96   NOTSUPPORTED,
97   NOTSUPPORTED,
98   NOTSUPPORTED,
99   NOTSUPPORTED,
100   NOTSUPPORTED,
101   NOTSUPPORTED,
102   NOTSUPPORTED,
103   NOTSUPPORTED,  NOTSUPPORTED,
104   NOTSUPPORTED,
105   NOTSUPPORTED,
106   NOTSUPPORTED,
107   NOTSUPPORTED,
108   NOTSUPPORTED,
109   NOTSUPPORTED,
110   NOTSUPPORTED,
111   NOTSUPPORTED,
112   NOTSUPPORTED
113 };
114
115
116
117 /* for all these Phones we support N3110 */
118
119 GSM_Information N3110_Information = {
120   "", /* Supported models in FBUS */
121   "",/* Supported models in MBUS */
122   "",/* Supported models in FBUS over infrared */
123   "",/* Supported models in FBUS over DLR3 */
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 */
129   0,                     /* Min RF Level */
130   GRF_Arbitrary,         /* RF level units */
131   4,                     /* Max Battery Level */
132   0,                     /* Min Battery Level */
133   GBU_Arbitrary,         /* Battery level units */
134   GDT_None,              /* No date/time support */
135   GDT_None,              /* No alarm support */
136   0                      /* Max alarms = 0 */
137 };
138
139 /* Initialise variables and state machine. */
140 GSM_Error N3110_Initialise(char *port_device, char *initlength,
141                           GSM_ConnectionType connection,
142                           void (*rlp_callback)(RLP_F96Frame *frame))
143 {
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     if (Protocol->Initialise(port_device,initlength,connection,rlp_callback)!=GE_NONE)
154   {
155     return GE_NOTSUPPORTED;
156   }
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);
181   if (error!=GE_NONE) return error;
182
183   CurrentLinkOK = true;                           
184
185   return (GE_NONE);
186 }
187
188
189 void N3110_DispatchMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType)
190 {
191 }