7 A Linux/Unix toolset and driver for Nokia mobile phones.
9 Released under the terms of the GNU GPL, see file COPYING for more details.
11 This file provides routines to handle processing of data when connected in
12 fax or data mode. Converts data from/to GSM phone to virtual modem
17 #define __data_datapump_c
28 #include <sys/types.h>
35 #include "gsm-common.h"
37 #include "data/at-emulator.h"
38 #include "data/virtmodem.h"
39 #include "data/datapump.h"
40 #include "data/rlp-common.h"
42 /* Global variables */
43 extern bool CommandMode;
46 int PtyRDFD; /* File descriptor for reading and writing to/from */
47 int PtyWRFD; /* pty interface - only different in debug mode. */
52 bool DP_Initialise(int read_fd, int write_fd)
58 RLP_Initialise(GSM->SendRLPFrame, DP_CallBack);
59 RLP_SetUserRequest(Attach_Req,true);
66 int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length)
72 if (CommandMode==false) write(PtyWRFD, buffer, length);
75 if (CommandMode==false) ATEM_ModemResult(MR_CARRIER);
76 RLP_SetUserRequest(Conn_Req,true);
81 if (CommandMode==false) ATEM_ModemResult(MR_CONNECT);
85 if (CommandMode==false) ATEM_ModemResult(MR_NOCARRIER);
87 /* Set the call passup back to the at emulator */
88 GSM->DialData(NULL,-1,&ATEM_CallPassup);
92 RLP_SetUserRequest(Reset_Resp,true);
95 if (poll(&ufds,1,0)) {
97 /* Check if the program has closed */
98 /* Return to command mode */
99 /* Note that the call will still be in progress, */
100 /* as with a normal modem (I think) */
102 if (ufds.revents!=POLLIN) {
104 /* Set the call passup back to the at emulator */
105 GSM->DialData(NULL,-1,&ATEM_CallPassup);
109 temp = read(PtyRDFD, buffer, length);
111 if (temp<0) return 0; /* FIXME - what do we do now? */
113 /* This will only check +++ and the beginning of a read */
114 /* But there should be a pause before it anyway */
116 if (buffer[0]=='+') {
119 if (buffer[1]=='+') pluscount++;
122 if (buffer[2]=='+') pluscount++;
124 if (temp>3) pluscount=0;
131 /* Set the call passup back to the at emulator */
132 GSM->DialData(NULL,-1,&ATEM_CallPassup);
133 ATEM_ModemResult(MR_OK);
148 void DP_CallPassup(char c)
152 if (CommandMode==false) ATEM_ModemResult(MR_CARRIER);
153 RLP_SetUserRequest(Conn_Req,true);
158 /* Set the call passup back to the at emulator */
159 GSM->DialData(NULL,-1,&ATEM_CallPassup);
160 ATEM_ModemResult(MR_NOCARRIER);
161 RLP_SetUserRequest(Disc_Req, true);