summaryrefslogtreecommitdiff
path: root/recipes/gpephone/phoneserver/phoneserver-gta01.patch
blob: fc5968ef5aa57a6596693c411a298ba4c4bd704e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
diff -u -r phoneserver-1.0/config.h phoneserver-1.0-mine/config.h
--- phoneserver-1.0/config.h	2007-02-02 13:20:13.000000000 +0100
+++ phoneserver-1.0-mine/config.h	2007-07-10 15:06:28.000000000 +0200
@@ -21,8 +21,7 @@
 
 /* serial port name */
 #ifndef SERIAL_PORT
-//#define SERIAL_PORT "/dev/pts/0"        //ttyS1"
-#define SERIAL_PORT "/dev/ttyS1"        //ttyS1"
+#define SERIAL_PORT "/dev/ttySAC0"        /* NEO1973 */
 #endif                          /*  */
 
 /* serial port baudrate */
@@ -30,6 +29,8 @@
 #define SERIAL_BAUDRATE B115200
 #endif                          /*  */
 
+#define CRTSCTS 1	/* NEO needs RTS/CTS flow control */
+
 /* buffer to hold AT command response */
 #ifndef ATCOMMAND_BUFFER_SIZE
 #define ATCOMMAND_BUFFER_SIZE 10240
diff -u -r phoneserver-1.0/Makefile.am phoneserver-1.0-mine/Makefile.am
--- phoneserver-1.0/Makefile.am	2007-02-02 13:20:13.000000000 +0100
+++ phoneserver-1.0-mine/Makefile.am	2007-07-10 13:14:47.000000000 +0200
@@ -3,7 +3,7 @@
 
 INCLUDES = @DEPS_CFLAGS@ -DPREFIX=\"@prefix@\" -D_GNU_SOURCE -Wall \
            -DDBUS_API_SUBJECT_TO_CHANGE \
-           -DDEBUG -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -DCELLON_PLATFORM 
+           -DDEBUG -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -DT39_PLATFORM -DNEO1973 
 LDADD = @DEPS_LIBS@
 
 
diff -u -r phoneserver-1.0/Makefile.in phoneserver-1.0-mine/Makefile.in
--- phoneserver-1.0/Makefile.in	2007-02-02 13:25:43.000000000 +0100
+++ phoneserver-1.0-mine/Makefile.in	2007-07-10 13:07:16.000000000 +0200
@@ -158,7 +158,7 @@
 target_alias = @target_alias@
 INCLUDES = @DEPS_CFLAGS@ -DPREFIX=\"@prefix@\" -D_GNU_SOURCE -Wall \
            -DDBUS_API_SUBJECT_TO_CHANGE \
-           -DDEBUG -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -DCELLON_PLATFORM 
+           -DDEBUG -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -DT39_PLATFORM 
 
 LDADD = @DEPS_LIBS@
 phoneserver_SOURCES = phoneserver.c phone-server-voc.c phone-server-sms.c phone-server-mul.c phone-server-pbk.c \
diff -u -r phoneserver-1.0/phoneserver.c phoneserver-1.0-mine/phoneserver.c
--- phoneserver-1.0/phoneserver.c	2007-02-02 13:20:13.000000000 +0100
+++ phoneserver-1.0-mine/phoneserver.c	2007-07-10 13:43:57.000000000 +0200
@@ -324,22 +324,31 @@
                             phonebook_update_entry_handler);
 #endif
 
+#ifdef NEO1973
+  system("echo 1 > /sys/devices/platform/gta01-pm-gsm.0/power_on");
+  sleep(1);
+#endif
+
   // tapi begins
   // Initialize
   result = tapi_initialize ();
 
   // Get file descripter
-  if (result == TEL_ERR_NONE)
-  {
+  if (result == TEL_ERR_NONE) {
     result = tel_get_fd (sid, (UInt32 *) & g_fd);
+  } else {
+    /* without modem there is nothing we can do */
+    exit(1);
   }
+
   // Open session
-  if (result == TEL_ERR_NONE)
-  {
+  if (result == TEL_ERR_NONE) {
     result = tel_open_session (&sid);
+  } else {
+    /* without fd we are as well useless */
+    exit(1);
   }
 
-
   if (result == TEL_ERR_NONE)
   {
     /* pbk section */
@@ -357,6 +366,9 @@
     tel_evt_register (sid, TEL_EVENT_MTSMS, sms_incoming_cb, NULL);
     tel_evt_register (sid, TEL_EVENT_STATUS_REPORT, sta_report_cb, NULL);
 
+  } else {
+    /* without session we are also lost */
+    exit(1);
   }
   // tapi ends
 #if 1
diff -u -r phoneserver-1.0/phone-server-voc.c phoneserver-1.0-mine/phone-server-voc.c
--- phoneserver-1.0/phone-server-voc.c	2007-02-02 13:20:13.000000000 +0100
+++ phoneserver-1.0-mine/phone-server-voc.c	2007-07-10 16:38:12.000000000 +0200
@@ -1028,6 +1028,7 @@
     g_print ("$$$$$$$$$$$$$$$$$$$notify VOC about the %s, and call_id = %d\n",
              pmethod, call_id);
 
+#if 0
     //0803
 
     guint index;
@@ -1038,7 +1039,7 @@
       ("###The held call which is going to be hungup is equal to: %d, index=%d,cid=%d",
        call_id, index, cid_dbus);
     //0803
-
+#endif
 
     if (!strcmp (pmethod, "accept"))
     {
diff -u -r phoneserver-1.0/serial.c phoneserver-1.0-mine/serial.c
--- phoneserver-1.0/serial.c	2007-02-02 13:20:13.000000000 +0100
+++ phoneserver-1.0-mine/serial.c	2007-07-10 15:07:14.000000000 +0200
@@ -124,7 +124,7 @@
 
 
 /* Open a device with standard options.
- *Use value (-1) for "with_hw_handshake" if its specification is required from the user.
+ * Use value (-1) for "with_hw_handshake" if its specification is required from the user.
  */
 int
 serial_opendevice (const Int8 *file, Int32 with_odd_parity, Int32 with_async)
@@ -148,8 +148,7 @@
 
   /* Set port settings for canonical input processing */
   tp.c_cflag = B0 | CS8 | CLOCAL | CREAD | HUPCL;
-  if (with_odd_parity)
-  {
+  if (with_odd_parity) {
     tp.c_cflag |= (PARENB | PARODD);
     tp.c_iflag = 0;
   }
@@ -157,35 +156,36 @@
     tp.c_iflag = IGNPAR;
 
 #ifdef CRTSCTS
+  tp.c_cflag |= CRTSCTS;
+#else
   tp.c_cflag &= ~CRTSCTS;
-
-#endif /*  */
+#endif
   tp.c_oflag = 0;
   tp.c_lflag = 0;
   tp.c_cc[VMIN] = 1;
   tp.c_cc[VTIME] = 0;
+
   retcode = tcflush (fd, TCIFLUSH);
-  if (retcode == -1)
-  {
+  if (retcode == -1) {
     perror ("Gnokii serial_opendevice: tcflush");
     serial_close (fd);
     return -1;
   }
+
   retcode = tcsetattr (fd, TCSANOW, &tp);
-  if (retcode == -1)
-  {
+  if (retcode == -1) {
     perror ("Gnokii serial_opendevice: tcsetattr");
     serial_close (fd);
     return -1;
   }
+
   serial_changespeed (fd, 115200);
 
   /* We need to turn off O_NONBLOCK now (we have CLOCAL set so it is safe).
    *When we run some device script it really doesn't expect NONBLOCK!
    */
   retcode = fcntl (fd, F_SETFL, 0);
-  if (retcode == -1)
-  {
+  if (retcode == -1) {
     perror ("Gnokii serial_opendevice: fnctl(F_SETFL)");
     serial_close (fd);
     return -1;
@@ -195,8 +195,7 @@
 
 #if !(__unices__)
   retcode = fcntl (fd, F_SETOWN, getpid ());
-  if (retcode == -1)
-  {
+  if (retcode == -1) {
     perror ("Gnokii serial_opendevice: fnctl(F_SETOWN)");
     serial_close (fd);
     return -1;
@@ -223,12 +222,12 @@
 
 #  endif
 #endif /*  */
-  if (retcode == -1)
-  {
+  if (retcode == -1) {
     perror ("Gnokii serial_opendevice: fnctl(F_SETFL)");
     serial_close (fd);
     return -1;
   }
+
   return fd;
 }
 
@@ -240,15 +239,16 @@
   unsigned int flags;
 
   flags = TIOCM_DTR;
+
   if (dtr)
     ioctl (fd, TIOCMBIS, &flags);
-
   else
     ioctl (fd, TIOCMBIC, &flags);
+
   flags = TIOCM_RTS;
+
   if (rts)
     ioctl (fd, TIOCMBIS, &flags);
-
   else
     ioctl (fd, TIOCMBIC, &flags);
 }
@@ -262,6 +262,7 @@
   FD_SET (fd, &readfds);
   return select (fd + 1, &readfds, NULL, NULL, timeout);
 }
+
 static int
 serial_wselect (int fd, struct timeval *timeout)
 {
@@ -361,12 +362,9 @@
   {
     bs = n;
     got = write (fd, buf + r, bs);
-    if (got == 0)
-    {
-      g_print ("Serial write: oops, zero byte has written!\n");
-    }
-    else if (got < 0)
-    {
+    if (got == 0) {
+      g_print ("Serial write: oops, zero byte written!\n");
+    } else if (got < 0) {
       if (errno == EINTR)
         continue;
       if (errno != EAGAIN)
diff -u -r phoneserver-1.0/tapi.c phoneserver-1.0-mine/tapi.c
--- phoneserver-1.0/tapi.c	2007-02-02 13:20:13.000000000 +0100
+++ phoneserver-1.0-mine/tapi.c	2007-07-10 16:51:22.000000000 +0200
@@ -112,6 +112,7 @@
 /************************************************************************/
 /* Initialization Function Block                                        */
 /************************************************************************/
+tel_err_t tapi_Init_PowerOn ();
 tel_err_t tapi_Init_SoftReset ();
 tel_err_t tapi_Init_SetNoEcho ();
 tel_err_t tapi_Init_SetCharset ();
@@ -287,6 +288,7 @@
   
  ****************/
 static init_function init_func_table[] = {
+  tapi_Init_PowerOn,
   tapi_Init_SoftReset,
   tapi_Init_SetNoEcho,
   tapi_Init_SetCharset,
@@ -477,6 +479,18 @@
 
 
 tel_err_t
+tapi_Init_PowerOn ()
+{
+  tel_err_t result;
+  Int8 *CommandStr;
+
+  /* AT+CFUN=1 */
+  CommandStr = AT_Builder_ExeCmd ((Int8 *) CMD_CFUN, (Int8 *) "=1", (Int8 *) NULL);
+  result = tapi_init_general (CommandStr);
+  return result;
+}
+
+tel_err_t
 tapi_Init_SoftReset ()
 {
   tel_err_t result;
@@ -516,7 +530,7 @@
   //TODO: This phone does not support "HEX", we should set it to HEX
 #ifdef T39_PLATFORM
   CommandStr =
-    AT_Builder_SetCmd ((Int8 *) CMD_CSCS, (Int8 *) "\"UTF-8\"", (Int8 *) NULL);
+    AT_Builder_SetCmd ((Int8 *) CMD_CSCS, (Int8 *) "\"8859-1\"", (Int8 *) NULL);
 #endif
 #ifdef CELLON_PLATFORM
   CommandStr =
@@ -689,8 +703,8 @@
                        (Int8 *) "0", (Int8 *) "1", (Int8 *) "0", (Int8 *) NULL);
 #else
   CommandStr =
-    AT_Builder_SetCmd ((Int8 *) CMD_CNMI, (Int8 *) "3", (Int8 *) "1",
-                       (Int8 *) "0", (Int8 *) "0", (Int8 *) "0", (Int8 *) NULL);
+    AT_Builder_SetCmd ((Int8 *) CMD_CNMI, (Int8 *) "2", (Int8 *) "1",
+                       (Int8 *) "0", (Int8 *) "1", (Int8 *) "0", (Int8 *) NULL);
 #endif
   result = tapi_init_general (CommandStr);
   return result;
@@ -1737,7 +1751,7 @@
   (*evt)->evt_data.async_data.cb = tel_ctx.cur_async_evt.cb;
   (*evt)->evt_data.async_data.user_data = tel_ctx.cur_async_evt.user_data;
 #ifdef DEBUG
-  //g_print("sms data is --> %s\n", data->user_data[0].text);
+  g_print("sms data is --> %s\n", data->user_data[0].text);
 #endif
   return TEL_ERR_NONE;
 }
@@ -1979,14 +1993,14 @@
     sscanf (param_str, "%d", &index);
     entry->index = index;
 #ifdef DEBUG
-    //g_print("index -> %d\n", index);
+    g_print("index -> %d\n", index);
 #endif
     /* number */
     param_str = (Int8 *) g_ptr_array_index (param, 1);
     //exclude the quotation
     memcpy (entry->number.number, param_str + 1, strlen (param_str) - 2);
 #ifdef DEBUG
-    //g_print("number -> %s\n", entry->number.number);
+    g_print("number -> %s\n", entry->number.number);
 #endif
     /* type */
     param_str = (Int8 *) g_ptr_array_index (param, 2);
@@ -1994,7 +2008,7 @@
     entry->number.npi = index & 0xF;
     entry->number.ton = (index & 0x70) >> 4;
 #ifdef DEBUG
-    //g_print("type -> %s\n", param_str);
+    g_print("type -> %s\n", param_str);
 #endif
     /* text */
     param_str = (Int8 *) g_ptr_array_index (param, 3);
@@ -2015,7 +2029,7 @@
     char_unicode_decode (entry->text, entry_textbuffer, len);
 #endif
 #ifdef DEBUG
-    //g_print("text -> %s\n", entry->text);
+    g_print("text -> %s\n", entry->text);
 #endif
     AT_Parser_Free (param);
     /* add the entry into array */
@@ -2524,11 +2538,11 @@
   tel_call_info_change_t *call_status = g_new0 (tel_call_info_change_t, 1);
   at_command_buffer_t *cmd_buffer;
 
-  //g_print("AT_UNSO_PPURC_Handler called\n");
-//              cmd_buffer = tapi_get_cmd_buffer(in_buffer, CMD_PPURC, 0, NULL);
+  g_print("AT_UNSO_PPURC_Handler called\n");
+              cmd_buffer = tapi_get_cmd_buffer(in_buffer, CMD_PPURC, 0, NULL);
 #ifdef DEBUG
-  //g_print("====cur parser pos is ---> %d\n", tel_ctx.cur_parser_pos);
-  //g_print("====total parser item is ---> %d\n", tel_ctx.cur_resp.cmd->len);
+  g_print("====cur parser pos is ---> %d\n", tel_ctx.cur_parser_pos);
+  g_print("====total parser item is ---> %d\n", tel_ctx.cur_resp.cmd->len);
 #endif
   cmd_buffer =
     tapi_get_cmd_buffer (in_buffer, CMD_PPURC, tel_ctx.cur_parser_pos - 1,
@@ -3749,8 +3763,10 @@
       break;
     case TEL_HANGUPALL:
       /* +CHUP */
+      //CommandStr =
+      //  AT_Builder_ExeCmd ((Int8 *) CMD_CHUP, (Int8 *) NULL, (Int8 *) NULL);
       CommandStr =
-        AT_Builder_ExeCmd ((Int8 *) CMD_CHUP, (Int8 *) NULL, (Int8 *) NULL);
+        AT_Builder_ExeCmd ((Int8 *) "H", (Int8 *) NULL, (Int8 *) NULL);
       break;
     case TEL_HANGUPACTIVE_ACCEPTOTHER:
       /* +CHLD=1 */
@@ -3859,7 +3875,8 @@
         break;
       case TEL_HANGUPALL:
         /* +CHUP */
-        AT_Builder_AppendCmd ((Int8 *) CMD_CHUP, (Int8 *) NULL, (Int8 *) NULL);
+        //AT_Builder_AppendCmd ((Int8 *) CMD_CHUP, (Int8 *) NULL, (Int8 *) NULL);
+        AT_Builder_AppendCmd ((Int8 *) "H", (Int8 *) NULL, (Int8 *) NULL);
         break;
       case TEL_HANGUPACTIVE_ACCEPTOTHER:
         /* +CHLD=1 */