gnokii-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnokii/common/data at-emulator.c, 1.36, 1.37 datapump.c, 1.22, 1.23 rlp-


From: BORBELY Zoltan <address@hidden>
Subject: gnokii/common/data at-emulator.c, 1.36, 1.37 datapump.c, 1.22, 1.23 rlp-common.c, 1.13, 1.14 virtmodem.c, 1.40, 1.41
Date: Thu, 23 Oct 2003 17:45:43 +0000

Update of /cvsroot/gnokii/gnokii/common/data
In directory subversions:/tmp/cvs-serv21287/common/data

Modified Files:
        at-emulator.c datapump.c rlp-common.c virtmodem.c 
Log Message:
AT emulator improved


Index: at-emulator.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/data/at-emulator.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** at-emulator.c       23 Oct 2003 01:16:26 -0000      1.36
--- at-emulator.c       23 Oct 2003 17:45:41 -0000      1.37
***************
*** 66,92 ****
  #define REG_LF        4
  #define REG_BS        5
! #define S35           6
! #define REG_CTRLZ     7
! #define REG_ESCAPE    8
  
! #define REG_RESP     12
! #define BIT_RESP      1
! #define REG_RESPNUM  12
! #define BIT_RESPNUM   2
! #define REG_ECHO     12
! #define BIT_ECHO      4
! #define REG_DCD      12
! #define BIT_DCD       8
! #define REG_CTS      12
! #define BIT_CTS      16
! #define REG_DTRR     12
! #define BIT_DTRR     32
! #define REG_DSR      12
! #define BIT_DSR      64
! #define REG_CPPP     12
! #define BIT_CPPP    128
  
  
! #define       MAX_MODEM_REGISTERS     20
  
  /* Message format definitions */
--- 66,83 ----
  #define REG_LF        4
  #define REG_BS        5
! #define       S22          22
! #define S35          35
! #define REG_CTRLZ   100
! #define REG_ESCAPE  101
  
! #define REG_QUIET    14
! #define BIT_QUIET     4
! #define REG_VERBOSE  14
! #define BIT_VERBOSE   8
! #define REG_ECHO     14
! #define BIT_ECHO      2
  
  
! #define       MAX_MODEM_REGISTERS     102
  
  /* Message format definitions */
***************
*** 115,120 ****
  static int    CurrentCmdBuffer;
  static int    CurrentCmdBufferIndex;
! static bool   VerboseResponse;        /* Switch betweek numeric (4) and text 
responses (ERROR) */
! static char    IncomingCallNo;
  static int     MessageFormat;          /* Message Format (text or pdu) */
  
--- 106,110 ----
  static int    CurrentCmdBuffer;
  static int    CurrentCmdBufferIndex;
! static int    IncomingCallNo;
  static int     MessageFormat;          /* Message Format (text or pdu) */
  
***************
*** 150,156 ****
        CurrentCmdBufferIndex = 0;
  
-       /* Default to verbose reponses */
-       VerboseResponse = true;
- 
        /* Initialise registers */
        gn_atem_registers_init();
--- 140,143 ----
***************
*** 170,173 ****
--- 157,163 ----
        gn_sm_functions(GN_OP_SetCallNotification, &data, sm);
  
+       /* query model, revision and imei */
+       if (gn_sm_functions(GN_OP_Identify, &data, sm) != GN_ERR_NONE) return 
false;
+ 
        /* We're ready to roll... */
        gn_atem_initialised = true;
***************
*** 179,185 ****
  void  gn_atem_registers_init(void)
  {
  
        ModemRegisters[REG_RINGATA] = 0;
!       ModemRegisters[REG_RINGCNT] = 2;
        ModemRegisters[REG_ESC] = '+';
        ModemRegisters[REG_CR] = 10;
--- 169,176 ----
  void  gn_atem_registers_init(void)
  {
+       memset(ModemRegisters, 0, sizeof(ModemRegisters));
  
        ModemRegisters[REG_RINGATA] = 0;
!       ModemRegisters[REG_RINGCNT] = 0;
        ModemRegisters[REG_ESC] = '+';
        ModemRegisters[REG_CR] = 10;
***************
*** 187,191 ****
        ModemRegisters[REG_BS] = 8;
        ModemRegisters[S35]=7;
!       ModemRegisters[REG_ECHO] = BIT_ECHO;
        ModemRegisters[REG_CTRLZ] = 26;
        ModemRegisters[REG_ESCAPE] = 27;
--- 178,183 ----
        ModemRegisters[REG_BS] = 8;
        ModemRegisters[S35]=7;
!       ModemRegisters[REG_ECHO] |= BIT_ECHO;
!       ModemRegisters[REG_VERBOSE] |= BIT_VERBOSE;
        ModemRegisters[REG_CTRLZ] = 26;
        ModemRegisters[REG_ESCAPE] = 27;
***************
*** 193,196 ****
--- 185,215 ----
  
  
+ static void  gn_atem_hangup_phone(void)
+ {
+       if (IncomingCallNo > 0) {
+               rlp_user_request_set(Disc_Req, true);
+               gn_sm_loop(10, sm);
+       }
+       if (IncomingCallNo > 0) {
+               data.call_info->call_id = IncomingCallNo;
+               gn_sm_functions(GN_OP_CancelCall, &data, sm);
+               IncomingCallNo = -1;
+       }
+       dp_Initialise(PtyRDFD, PtyWRFD);
+ }
+ 
+ 
+ static void  gn_atem_answer_phone(void)
+ {
+       /* For now we'll also initialise the datapump + rlp code again */
+       dp_Initialise(PtyRDFD, PtyWRFD);
+       data.call_notification = dp_CallPassup;
+       gn_sm_functions(GN_OP_SetCallNotification, &data, sm);
+       data.call_info->call_id = IncomingCallNo;
+       gn_sm_functions(GN_OP_AnswerCall, &data, sm);
+       CommandMode = false;
+ }
+ 
+ 
  /* This gets called to indicate an incoming call */
  void gn_atem_call_passup(gn_call_status CallStatus, gn_call_info *CallInfo, 
struct gn_statemachine *state)
***************
*** 198,204 ****
        dprintf("gn_atem_call_passup called with %d\n", CallStatus);
  
!       if (CallStatus == GN_CALL_Incoming) {
                gn_atem_modem_result(MR_RING);
                IncomingCallNo = CallInfo->call_id;
        }
  }
--- 217,233 ----
        dprintf("gn_atem_call_passup called with %d\n", CallStatus);
  
!       switch (CallStatus) {
!       case GN_CALL_Incoming:
                gn_atem_modem_result(MR_RING);
                IncomingCallNo = CallInfo->call_id;
+               ModemRegisters[REG_RINGCNT]++;
+               if (ModemRegisters[REG_RINGATA] != 0) gn_atem_answer_phone();
+               break;
+       case GN_CALL_LocalHangup:
+       case GN_CALL_RemoteHangup:
+               IncomingCallNo = -1;
+               break;
+       default:
+               break;
        }
  }
***************
*** 221,224 ****
--- 250,259 ----
                    buffer[count] == ModemRegisters[REG_ESCAPE]) {
  
+                       /* Echo character if appropriate. */
+                       if (buffer[count] == ModemRegisters[REG_LF] &&
+                               (ModemRegisters[REG_ECHO] & BIT_ECHO)) {
+                               gn_atem_string_out("\r\n");
+                       }
+ 
                        /* Save CTRL-Z and ESCAPE for the parser */
                        if (buffer[count] == ModemRegisters[REG_CTRLZ] ||
***************
*** 236,239 ****
--- 271,283 ----
                        CurrentCmdBufferIndex = 0;
  
+               } else if (buffer[count] == ModemRegisters[REG_BS]) {
+                       if (CurrentCmdBufferIndex > 0) {
+                               /* Echo character if appropriate. */
+                               if (ModemRegisters[REG_ECHO] & BIT_ECHO) {
+                                       gn_atem_string_out("\b \b");
+                               }
+ 
+                               CurrentCmdBufferIndex--;
+                       }
                } else {
                        /* Echo character if appropriate. */
***************
*** 258,261 ****
--- 302,307 ----
  {
        char *buf;
+       int regno, val;
+       char str[256];
  
        if (strncasecmp (cmd_buffer, "AT", 2) != 0) {
***************
*** 268,284 ****
  
                case 'Z':
                        buf++;
                        break;
                case 'A':
                        buf++;
!                       /* For now we'll also initialise the datapump + rlp 
code again */
!                       dp_Initialise(PtyRDFD, PtyWRFD);
!                       data.call_notification = dp_CallPassup;
!                       gn_sm_functions(GN_OP_SetCallNotification, &data, sm);
!                       data.call_info->call_id = IncomingCallNo;
!                       gn_sm_functions(GN_OP_AnswerCall, &data, sm);
!                       CommandMode = false;
                        return;
                        break;
                case 'D':
                        /* Dial Data :-) */
--- 314,339 ----
  
                case 'Z':
+                       /* Reset modem */
                        buf++;
+                       switch (gn_atem_num_get(&buf)) {
+                       case -1:
+                       case 0: /* reset and load stored profile 0 */
+                       case 1: /* reset and load stored profile 1 */
+                               gn_atem_hangup_phone();
+                               gn_atem_registers_init();
+                               break;
+                       default:
+                               gn_atem_modem_result(MR_ERROR);
+                               return;
+                       }
                        break;
+ 
                case 'A':
+                       /* Answer call */
                        buf++;
!                       gn_atem_answer_phone();
                        return;
                        break;
+ 
                case 'D':
                        /* Dial Data :-) */
***************
*** 287,292 ****
                        dp_Initialise(PtyRDFD, PtyWRFD);
                        buf++;
!                       if (toupper(*buf) == 'T') buf++;
!                       if (*buf == ' ') buf++;
                        data.call_notification = dp_CallPassup;
                        gn_sm_functions(GN_OP_SetCallNotification, &data, sm);
--- 342,347 ----
                        dp_Initialise(PtyRDFD, PtyWRFD);
                        buf++;
!                       if (toupper(*buf) == 'T' || toupper(*buf) == 'P') buf++;
!                       while (*buf == ' ') buf++;
                        data.call_notification = dp_CallPassup;
                        gn_sm_functions(GN_OP_SetCallNotification, &data, sm);
***************
*** 303,329 ****
                        } else {
                                IncomingCallNo = data.call_info->call_id;
                        }
                        return;
                        break;
                case 'H':
                        /* Hang Up */
                        buf++;
!                       rlp_user_request_set(Disc_Req, true);
!                       data.call_info->call_id = IncomingCallNo;
!                       gn_sm_functions(GN_OP_CancelCall, &data, sm);
                        break;
                case 'S':
!                       /* Change registers - only no. 35 for now */
                        buf++;
!                       if (memcmp(buf, "35=", 3) == 0) {
!                               buf += 3;
!                               ModemRegisters[S35] = *buf - '0';
                                buf++;
                        }
                        break;
!                 /* E - Turn Echo on/off */
                case 'E':
                        buf++;
                        switch (gn_atem_num_get(&buf)) {
                        case 0:
                                ModemRegisters[REG_ECHO] &= ~BIT_ECHO;
--- 358,413 ----
                        } else {
                                IncomingCallNo = data.call_info->call_id;
+                               gn_sm_loop(10, sm);
                        }
                        return;
                        break;
+ 
                case 'H':
                        /* Hang Up */
                        buf++;
!                       switch (gn_atem_num_get(&buf)) {
!                       case -1:
!                       case 0: /* hook off the phone */
!                               gn_atem_hangup_phone();
!                               break;
!                       case 1: /* hook on the phone */
!                               break;
!                       default:
!                               gn_atem_modem_result(MR_ERROR);
!                               return;
!                       }
                        break;
+ 
                case 'S':
!                       /* Change registers */
                        buf++;
!                       regno = gn_atem_num_get(&buf);
!                       if (regno < 0 || regno >= MAX_MODEM_REGISTERS) {
!                               gn_atem_modem_result(MR_ERROR);
!                               return;
!                       }
!                       if (*buf == '=') {
                                buf++;
+                               val = gn_atem_num_get(&buf);
+                               if (val < 0 || val > 255) {
+                                       gn_atem_modem_result(MR_ERROR);
+                                       return;
+                               }
+                               ModemRegisters[regno] = val;
+                       } else if (*buf == '?') {
+                               buf++;
+                               snprintf(str, sizeof(str), "%d\r\n", 
ModemRegisters[regno]);
+                               gn_atem_string_out(str);
+                       } else {
+                               gn_atem_modem_result(MR_ERROR);
+                               return;
                        }
                        break;
! 
                case 'E':
+                       /* E - Turn Echo on/off */
                        buf++;
                        switch (gn_atem_num_get(&buf)) {
+                       case -1:
                        case 0:
                                ModemRegisters[REG_ECHO] &= ~BIT_ECHO;
***************
*** 338,341 ****
--- 422,508 ----
                        break;
  
+               case 'Q':
+                       /* Q - Turn Quiet on/off */
+                       buf++;
+                       switch (gn_atem_num_get(&buf)) {
+                       case -1:
+                       case 0:
+                               ModemRegisters[REG_QUIET] &= ~BIT_QUIET;
+                               break;
+                       case 1:
+                               ModemRegisters[REG_QUIET] |= BIT_QUIET;
+                               break;
+                       default:
+                               gn_atem_modem_result(MR_ERROR);
+                               return;
+                       }
+                       break;
+ 
+               case 'V':
+                       /* V - Turn Verbose on/off */
+                       buf++;
+                       switch (gn_atem_num_get(&buf)) {
+                       case -1:
+                       case 0:
+                               ModemRegisters[REG_VERBOSE] &= ~BIT_VERBOSE;
+                               break;
+                       case 1:
+                               ModemRegisters[REG_VERBOSE] |= BIT_VERBOSE;
+                               break;
+                       default:
+                               gn_atem_modem_result(MR_ERROR);
+                               return;
+                       }
+                       break;
+ 
+               case 'X':
+                       /* X - Set verbosity of the result messages */
+                       buf++;
+                       switch (gn_atem_num_get(&buf)) {
+                       case -1:
+                       case 0: val = 0x00; break;
+                       case 1: val = 0x40; break;
+                       case 2: val = 0x50; break;
+                       case 3: val = 0x60; break;
+                       case 4: val = 0x70; break;
+                       case 5: val = 0x10; break;
+                       default:
+                               gn_atem_modem_result(MR_ERROR);
+                               return;
+                       }
+                       ModemRegisters[S22] = (ModemRegisters[S22] & 0x8f) | 
val;
+                       break;
+ 
+               case 'I':
+                       /* I - info */
+                       buf++;
+                       switch (gn_atem_num_get(&buf)) {
+                       case -1:
+                       case 0: /* terminal id */
+                               snprintf(str, sizeof(str), "%d\r\n", 
ModemRegisters[39]);
+                               gn_atem_string_out(str);
+                               break;
+                       case 1: /* serial number (IMEI) */
+                               snprintf(str, sizeof(str), "%s\r\n", imei);
+                               gn_atem_string_out(str);
+                               break;
+                       case 2: /* phone revision */
+                               snprintf(str, sizeof(str), "%s\r\n", revision);
+                               gn_atem_string_out(str);
+                               break;
+                       case 3: /* modem revision */
+                               gn_atem_string_out("gnokiid " VERSION "\r\n");
+                               break;
+                       case 4: /* OEM string */
+                               snprintf(str, sizeof(str), "%s %s\r\n", 
manufacturer, model);
+                               gn_atem_string_out(str);
+                               break;
+                       default:
+                               gn_atem_modem_result(MR_ERROR);
+                               return;
+                       }
+                       ModemRegisters[S22] = (ModemRegisters[S22] & 0x8f) | 
val;
+                       break;
+ 
                  /* Handle AT* commands (Nokia proprietary I think) */
                case '*':
***************
*** 832,858 ****
        char    buffer[16];
  
!       if (VerboseResponse == false) {
!               sprintf(buffer, "\n\r%d\n\r", code);
                gn_atem_string_out(buffer);
        } else {
                switch (code) {
                        case MR_OK:
!                                       gn_atem_string_out("\n\rOK\n\r");
                                        break;
  
                        case MR_ERROR:
!                                       gn_atem_string_out("\n\rERROR\n\r");
                                        break;
  
                        case MR_CARRIER:
!                                       gn_atem_string_out("\n\rCARRIER\n\r");
                                        break;
  
                        case MR_CONNECT:
!                                       gn_atem_string_out("\n\rCONNECT\n\r");
                                        break;
  
                        case MR_NOCARRIER:
!                                       gn_atem_string_out("\n\rNO 
CARRIER\n\r");
                                        break;
                        case MR_RING:
--- 999,1025 ----
        char    buffer[16];
  
!       if (!(ModemRegisters[REG_VERBOSE] & BIT_VERBOSE)) {
!               sprintf(buffer, "%d\n\r", code);
                gn_atem_string_out(buffer);
        } else {
                switch (code) {
                        case MR_OK:
!                                       gn_atem_string_out("OK\n\r");
                                        break;
  
                        case MR_ERROR:
!                                       gn_atem_string_out("ERROR\n\r");
                                        break;
  
                        case MR_CARRIER:
!                                       gn_atem_string_out("CARRIER\n\r");
                                        break;
  
                        case MR_CONNECT:
!                                       gn_atem_string_out("CONNECT\n\r");
                                        break;
  
                        case MR_NOCARRIER:
!                                       gn_atem_string_out("NO CARRIER\n\r");
                                        break;
                        case MR_RING:

Index: datapump.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/data/datapump.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** datapump.c  23 Oct 2003 01:16:26 -0000      1.22
--- datapump.c  23 Oct 2003 17:45:41 -0000      1.23
***************
*** 140,143 ****
--- 140,144 ----
                                data.call_notification = gn_atem_call_passup;
                                gn_sm_functions(GN_OP_SetCallNotification, 
&data, sm);
+                               gn_atem_string_out("\r\n");
                                gn_atem_modem_result(MR_OK);
                                break;
***************
*** 172,175 ****
--- 173,178 ----
                rlp_user_request_set(Disc_Req, true);
                connected = false;
+               /* send the hangup event to the at emulator */
+               gn_atem_call_passup(CallStatus, CallInfo, state);
                break;
        default:

Index: virtmodem.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/data/virtmodem.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** virtmodem.c 21 Jul 2003 20:41:17 -0000      1.40
--- virtmodem.c 23 Oct 2003 17:45:41 -0000      1.41
***************
*** 166,170 ****
        int nfd, devfd;
        int i, n;
!       char buf[256];
  
        devfd = device_getfd(sm);
--- 166,170 ----
        int nfd, devfd;
        int i, n;
!       char buf[256], *d;
  
        devfd = device_getfd(sm);
***************
*** 172,179 ****
  
        while (!GTerminateThread) {
!               if (CommandMode && gn_atem_initialised && queue.n != 0) {
!                       gn_atem_incoming_data_handle(queue.buf + queue.head, 1);
                        queue.head = (queue.head + 1) % sizeof(queue.buf);
                        queue.n--;
                        continue;
                }
--- 172,180 ----
  
        while (!GTerminateThread) {
!               if (CommandMode && gn_atem_initialised && queue.n > 0) {
!                       d = queue.buf + queue.head;
                        queue.head = (queue.head + 1) % sizeof(queue.buf);
                        queue.n--;
+                       gn_atem_incoming_data_handle(d, 1);
                        continue;
                }

Index: rlp-common.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/data/rlp-common.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** rlp-common.c        23 Oct 2003 01:16:26 -0000      1.13
--- rlp-common.c        23 Oct 2003 17:45:41 -0000      1.14
***************
*** 1769,1772 ****
--- 1769,1775 ----
                frame++;
        }
+ 
+       fprintf(stdout, "\n");
+ 
        return;
  }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]