7 A Linux/Unix toolset and driver for Nokia mobile phones.
9 Copyright (C) 1999, 2000 Hugh Blemings & Pavel JanÃk ml.
11 Released under the terms of the GNU GPL, see file COPYING for more details.
13 This file provides routines to handle processing of data when connected in
14 fax or data mode. Converts data from/to GSM phone to virtual modem
18 Revision 1.1.1.1 2001/11/25 21:59:07 short
19 :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
21 Revision 1.4 2001/11/17 16:41:35 pkot
24 Revision 1.3 2001/02/21 19:57:00 chris
25 More fiddling with the directory layout
27 Revision 1.2 2001/02/17 22:40:51 chris
33 #define __data_datapump_c
44 #include <sys/types.h>
51 #include "gsm-common.h"
53 #include "data/at-emulator.h"
54 #include "data/virtmodem.h"
55 #include "data/datapump.h"
56 #include "data/rlp-common.h"
58 /* Global variables */
59 extern bool CommandMode;
62 int PtyRDFD; /* File descriptor for reading and writing to/from */
63 int PtyWRFD; /* pty interface - only different in debug mode. */
68 bool DP_Initialise(int read_fd, int write_fd)
74 RLP_Initialise(GSM->SendRLPFrame, DP_CallBack);
75 RLP_SetUserRequest(Attach_Req, true);
82 int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length)
88 if (CommandMode == false) write(PtyWRFD, buffer, length);
91 if (CommandMode == false) ATEM_ModemResult(MR_CARRIER);
92 RLP_SetUserRequest(Conn_Req, true);
97 if (CommandMode == false) ATEM_ModemResult(MR_CONNECT);
101 if (CommandMode == false) ATEM_ModemResult(MR_NOCARRIER);
103 /* Set the call passup back to the at emulator */
104 GSM->DialData(NULL, -1, &ATEM_CallPassup);
108 RLP_SetUserRequest(Reset_Resp, true);
111 if (poll(&ufds, 1, 0)) {
113 /* Check if the program has closed */
114 /* Return to command mode */
115 /* Note that the call will still be in progress, */
116 /* as with a normal modem (I think) */
118 if (ufds.revents != POLLIN) {
120 /* Set the call passup back to the at emulator */
121 GSM->DialData(NULL, -1, &ATEM_CallPassup);
125 temp = read(PtyRDFD, buffer, length);
127 if (temp < 0) return 0; /* FIXME - what do we do now? */
129 /* This will only check +++ and the beginning of a read */
130 /* But there should be a pause before it anyway */
132 if (buffer[0] == '+') {
135 if (buffer[1] == '+') pluscount++;
138 if (buffer[2] == '+') pluscount++;
140 if (temp > 3) pluscount = 0;
143 } else pluscount = 0;
145 if (pluscount == 3) {
147 /* Set the call passup back to the at emulator */
148 GSM->DialData(NULL, -1, &ATEM_CallPassup);
149 ATEM_ModemResult(MR_OK);
162 void DP_CallPassup(char c)
166 if (CommandMode == false) ATEM_ModemResult(MR_CARRIER);
167 RLP_SetUserRequest(Conn_Req, true);
172 /* Set the call passup back to the at emulator */
173 GSM->DialData(NULL, -1, &ATEM_CallPassup);
174 ATEM_ModemResult(MR_NOCARRIER);
175 RLP_SetUserRequest(Disc_Req, true);