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.3 2002/04/03 00:08:04 short
19 Found in "gnokii-working" directory, some November-patches version
21 Revision 1.3 2001/02/21 19:57:00 chris
22 More fiddling with the directory layout
24 Revision 1.2 2001/02/17 22:40:51 chris
30 #define __data_datapump_c
41 #include <sys/types.h>
48 #include "gsm-common.h"
50 #include "data/at-emulator.h"
51 #include "data/virtmodem.h"
52 #include "data/datapump.h"
53 #include "data/rlp-common.h"
55 /* Global variables */
56 extern bool CommandMode;
59 int PtyRDFD; /* File descriptor for reading and writing to/from */
60 int PtyWRFD; /* pty interface - only different in debug mode. */
65 bool DP_Initialise(int read_fd, int write_fd)
71 RLP_Initialise(GSM->SendRLPFrame, DP_CallBack);
72 RLP_SetUserRequest(Attach_Req,true);
79 int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length)
85 if (CommandMode==false) write(PtyWRFD, buffer, length);
88 if (CommandMode==false) ATEM_ModemResult(MR_CARRIER);
89 RLP_SetUserRequest(Conn_Req,true);
94 if (CommandMode==false) ATEM_ModemResult(MR_CONNECT);
98 if (CommandMode==false) ATEM_ModemResult(MR_NOCARRIER);
100 /* Set the call passup back to the at emulator */
101 GSM->DialData(NULL,-1,&ATEM_CallPassup);
105 RLP_SetUserRequest(Reset_Resp,true);
108 if (poll(&ufds,1,0)) {
110 /* Check if the program has closed */
111 /* Return to command mode */
112 /* Note that the call will still be in progress, */
113 /* as with a normal modem (I think) */
115 if (ufds.revents!=POLLIN) {
117 /* Set the call passup back to the at emulator */
118 GSM->DialData(NULL,-1,&ATEM_CallPassup);
122 temp = read(PtyRDFD, buffer, length);
124 if (temp<0) return 0; /* FIXME - what do we do now? */
126 /* This will only check +++ and the beginning of a read */
127 /* But there should be a pause before it anyway */
129 if (buffer[0]=='+') {
132 if (buffer[1]=='+') pluscount++;
135 if (buffer[2]=='+') pluscount++;
137 if (temp>3) pluscount=0;
144 /* Set the call passup back to the at emulator */
145 GSM->DialData(NULL,-1,&ATEM_CallPassup);
146 ATEM_ModemResult(MR_OK);
161 void DP_CallPassup(char c)
165 if (CommandMode==false) ATEM_ModemResult(MR_CARRIER);
166 RLP_SetUserRequest(Conn_Req,true);
171 /* Set the call passup back to the at emulator */
172 GSM->DialData(NULL,-1,&ATEM_CallPassup);
173 ATEM_ModemResult(MR_NOCARRIER);
174 RLP_SetUserRequest(Disc_Req, true);