First version, development moved to 5110-connected machine
authorshort <>
Mon, 25 Feb 2002 02:49:24 +0000 (02:49 +0000)
committershort <>
Mon, 25 Feb 2002 02:49:24 +0000 (02:49 +0000)
53 files changed:
Makefile
Makefile.global.in
acconfig.h
bigfunc [new file with mode: 0755]
common/Makefile
common/data/at-emulator.c
common/data/datapump.c
common/data/rlp-common.c
common/data/rlp-crc24.c
common/data/virtmodem.c
common/devices/device.c
common/devices/unixserial.c
common/files/cfgreader.c
common/files/midifile.c
common/gsm-api.c
common/gsm-bitmaps.c
common/gsm-calendar.c
common/gsm-coding.c
common/gsm-datetime.c
common/gsm-networks.c
common/gsm-phonebook.c
common/gsm-sms.c
common/gsm-wap.c
common/misc.c
common/newmodules/n6110.c
common/newmodules/newat.c
common/newmodules/sniff/sniff.c
common/protocol/at.c
common/protocol/fbus.c
common/protocol/fbusirda.c
common/protocol/mbus.c
configure.in
do [new file with mode: 0755]
getopt/getopt.c
getopt/getopt1.c
gnokii/Makefile
gnokii/gnokii.c
gnokii/gnokii.h
include/data/at-emulator.h
include/data/datapump.h
include/data/rlp-common.h
include/data/virtmodem.h
include/devices/device.h
include/devices/unixserial.h
include/files/cfgreader.h
include/gsm-api.h
include/gsm-coding.h
include/gsm-networks.h
include/gsm-sms.h
include/newmodules/n6110.h
include/protocol/fbus.h
include/uccompat.h [new file with mode: 0644]
utils/Makefile

index 1feaf9c..18a138b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,9 +18,9 @@ include ${TOPDIR}/Makefile.global
 BIN_DIRS = gnokii
 
 ifndef WIN32
 BIN_DIRS = gnokii
 
 ifndef WIN32
-BIN_DIRS += gnokiid
-BIN_DIRS += mgnetd
-BIN_DIRS += mgnetd/mg_demo_client
+###BIN_DIRS += gnokiid
+###BIN_DIRS += mgnetd
+###BIN_DIRS += mgnetd/mg_demo_client
 endif
 
 DIRS =  common \
 endif
 
 DIRS =  common \
@@ -38,6 +38,8 @@ endif
 
 GTK_DIRS =  xgnokii \
             xlogos
 
 GTK_DIRS =  xgnokii \
             xlogos
+#uClinux:
+GTK_LIBS=
 
 PO_DIR   =     po
 DOCS_DIR =     Docs
 
 PO_DIR   =     po
 DOCS_DIR =     Docs
index 23fa672..b00c902 100644 (file)
@@ -46,6 +46,7 @@ CFLAGS         = @CFLAGS@
 CPPFLAGS       = @CPPFLAGS@
 LIBS           = @LIBS@
 LEX            = @LEX@
 CPPFLAGS       = @CPPFLAGS@
 LIBS           = @LIBS@
 LEX            = @LEX@
+AR             = @AR@
 
 GTK_CFLAGS     = @GTK_CFLAGS@
 GTK_LIBS       = @GTK_LIBS@
 
 GTK_CFLAGS     = @GTK_CFLAGS@
 GTK_LIBS       = @GTK_LIBS@
index a5dae23..dfd6d99 100644 (file)
 
 */
 
 
 */
 
-/* DO NOT EDIT MANUALLY !!! */
-
 #ifndef __CONFIG_H__
 #define __CONFIG_H__
 
 #ifndef __CONFIG_H__
 #define __CONFIG_H__
 
-#define VERSION    "@VERSION@"
-#define XVERSION   "@XVERSION@"
-#define XGNOKIIDIR "@XGNOKIIDIR@/@XPACKAGE@"
+@TOP@
+
 
 /* Define if you have timersub() */
 #undef HAVE_TIMEOPS
 
 /* Define if you have timersub() */
 #undef HAVE_TIMEOPS
 /* Define if you compile for M$ Windows */
 #undef WIN32
 
 /* Define if you compile for M$ Windows */
 #undef WIN32
 
+/* Missing symbols */
+#undef VERSION
+#undef XVERSION
+#undef DEBUG
+#undef HAVE_CFSETISPEED
+#undef HAVE_CFSETOSPEED
+#undef HAVE_CFSETSPEED
+#undef HAVE_LIBINTL
+#undef HAVE_LIBINTL_H
+#undef HAVE_TERMIOS_CSPEED
+#undef HAVE_TIMEOPS
+#undef HAVE_TM_GMTON
+#undef RLP_DEBUG
+#undef SECURITY
+#undef USE_NLS
+#undef USE_UNIX98PTYS
+#undef WIN32
+#undef XDEBUG
+#undef XPM
+#undef CONFIG_CFG_INITLENGTH
+#undef CONFIG_CFG_MODEL
+#undef CONFIG_CFG_PORT
+
+
+@BOTTOM@
+
+#include "uccompat.h"
+
+
 #endif /* __CONFIG_H__ */
 #endif /* __CONFIG_H__ */
diff --git a/bigfunc b/bigfunc
new file mode 100755 (executable)
index 0000000..231e964
--- /dev/null
+++ b/bigfunc
@@ -0,0 +1,28 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+open NM,"-|",'m68k-pic-coff-nm gnokii/gnokii.coff|sort'
+               or die "nm: $!";
+my(%big,$prevhex,$prevsym,$tot);
+while (<NM>) {
+       chomp;
+       /^([0-9a-f]+) (\w) (.*)$/ or die "parse: $_";
+       my $hex=hex $1;
+       my $type=$2;
+       my $sym=$3;
+       next if $type!~/[tT]/ || $sym=~/^\./ || $sym=~/^L\d+$/ || $sym eq "__gnu_compiled_c" || $sym eq "gcc2_compiled.";
+       if ($prevhex) {
+               warn "dup: $prevsym" if exists $big{$prevsym};
+               $big{$prevsym}=$hex-$prevhex;
+               $tot+=$hex-$prevhex;
+               }
+       $prevhex=$hex;
+       $prevsym=$sym;
+       }
+close NM;
+$big{"_TOTAL"}=$tot;
+for (sort { $big{$b} <=> $big{$a} } keys %big) {
+       printf "%4u %s\n",$big{$_},$_;
+       }
index e396803..570b19a 100644 (file)
@@ -18,30 +18,31 @@ DIRS =              protocol \
                oldmodules \
                newmodules
 
                oldmodules \
                newmodules
 
+#      files/midifile.o \
+#      gsm-ringtones.o \
+#      gsm-wap.o \
+#      gsm-calendar.o \
+#      gsm-bitmaps.o \
+#      protocol/fbusirda.o \
+#      protocol/mbus.o \
+#      protocol/at.o \
+#      newmodules/n7110.o
+#      newmodules/sniff/sniff.o \
+#      newmodules/newat.o \
+
 OBJS = devices/device.o \
        data/rlp-common.o \
        data/rlp-crc24.o \
 OBJS = devices/device.o \
        data/rlp-common.o \
        data/rlp-crc24.o \
-       files/midifile.o \
-       gsm-ringtones.o \
-       gsm-coding.o \
        gsm-datetime.o \
        gsm-datetime.o \
-       gsm-wap.o \
        gsm-api.o \
        gsm-api.o \
+       gsm-sms.o \
+       gsm-coding.o \
        gsm-phonebook.o \
        gsm-phonebook.o \
-       gsm-calendar.o \
        gsm-networks.o \
        gsm-networks.o \
-       gsm-bitmaps.o \
-       gsm-sms.o \
        files/cfgreader.o \
        misc.o \
        protocol/fbus.o \
        files/cfgreader.o \
        misc.o \
        protocol/fbus.o \
-       protocol/fbusirda.o \
-       protocol/mbus.o \
-       protocol/at.o \
-       newmodules/sniff/sniff.o \
-       newmodules/newat.o \
-       newmodules/n6110.o \
-       newmodules/n7110.o
+       newmodules/n6110.o
 
 DATA_OBJS = data/virtmodem.o \
        data/at-emulator.o \
 
 DATA_OBJS = data/virtmodem.o \
        data/at-emulator.o \
@@ -50,22 +51,22 @@ DATA_OBJS = data/virtmodem.o \
 ifdef WIN32
        OBJS += $(TOPDIR)/win32/winserial.o
 else
 ifdef WIN32
        OBJS += $(TOPDIR)/win32/winserial.o
 else
-       OBJS += devices/unixserial.o \
-               devices/unixirda.o \
-               devices/tekram.o
+       OBJS += devices/unixserial.o
+#              devices/unixirda.o \
+#              devices/tekram.o
 endif
 
 ifdef XPM_CFLAGS
     CFLAGS += $(XPM_CFLAGS)
 endif
 
 endif
 
 ifdef XPM_CFLAGS
     CFLAGS += $(XPM_CFLAGS)
 endif
 
-all: COMMON.o DATA.o gsm-filetypes.o
+all: common.a data.a ##gsm-filetypes.o
 
 
-COMMON.o: $(OBJS)
-       $(LD) $(LDREL) $(LDOUT) COMMON.o $(OBJS)
+common.a: $(OBJS)
+       $(AR) rcs $@ $^
 
 
-DATA.o: $(DATA_OBJS)
-       $(LD) $(LDREL) $(LDOUT) DATA.o $(DATA_OBJS)
+data.a: $(DATA_OBJS)
+       $(AR) rcs $@ $^
 
 gsm-filetypes.o: files/gsm-filetypes.c 
        $(CC) $(CFLAGS) -c files/gsm-filetypes.c
 
 gsm-filetypes.o: files/gsm-filetypes.c 
        $(CC) $(CFLAGS) -c files/gsm-filetypes.c
index 41445c8..5f84b0b 100644 (file)
@@ -14,6 +14,8 @@
   
 */
 
   
 */
 
+#include "config.h"
+
 #define                __data_at_emulator_c
 
 
 #define                __data_at_emulator_c
 
 
@@ -50,28 +52,32 @@ bool ATEM_Initialised = false;      /* Set to true once initialised */
 extern bool    CommandMode;
 extern int ConnectCount;
 
 extern bool    CommandMode;
 extern int ConnectCount;
 
-char ModelName[80]; /* This seems to be needed to avoid seg-faults */
-char PortName[80];
+static char ModelName[80]; /* This seems to be needed to avoid seg-faults */
+static char PortName[80];
 
 
        /* Local variables */
 
 
        /* Local variables */
-int    PtyRDFD;        /* File descriptor for reading and writing to/from */
-int    PtyWRFD;        /* pty interface - only different in debug mode. */ 
+extern int     PtyRDFD;        /* File descriptor for reading and writing to/from */
+extern int     PtyWRFD;        /* pty interface - only different in debug mode. */ 
+
+static u8      ModemRegisters[MAX_MODEM_REGISTERS];
+static char    CmdBuffer[MAX_CMD_BUFFERS][CMD_BUFFER_LENGTH];
+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) */
 
 
-u8     ModemRegisters[MAX_MODEM_REGISTERS];
-char   CmdBuffer[MAX_CMD_BUFFERS][CMD_BUFFER_LENGTH];
-int    CurrentCmdBuffer;
-int    CurrentCmdBufferIndex;
-bool   VerboseResponse;        /* Switch betweek numeric (4) and text responses (ERROR) */
-char    IncomingCallNo;
-int     MessageFormat;          /* Message Format (text or pdu) */
+static void    ATEM_ParseAT(char *cmd_buffer);
 
        /* Current command parser */
 
        /* Current command parser */
-void   (*Parser)(char *);
+static void    (*Parser)(char *);
 //void         (*Parser)(char *) = ATEM_ParseAT; /* Current command parser */
 
 //void         (*Parser)(char *) = ATEM_ParseAT; /* Current command parser */
 
-GSM_MemoryType         SMSType;
-int    SMSNumber;
+static GSM_MemoryType  SMSType;
+static int     SMSNumber;
+
+static void    ATEM_InitRegisters(void);
 
        /* If initialised in debug mode, stdin/out is used instead
           of ptys for interface. */
 
        /* If initialised in debug mode, stdin/out is used instead
           of ptys for interface. */
@@ -112,7 +118,7 @@ bool        ATEM_Initialise(int read_fd, int write_fd, char *model, char *port)
 }
 
        /* Initialise the "registers" used by the virtual modem. */
 }
 
        /* Initialise the "registers" used by the virtual modem. */
-void   ATEM_InitRegisters(void) 
+static void    ATEM_InitRegisters(void) 
 {
 
        ModemRegisters[REG_RINGATA] = 0;
 {
 
        ModemRegisters[REG_RINGATA] = 0;
@@ -137,6 +143,7 @@ void ATEM_CallPassup(char c)
        }
 }
 
        }
 }
 
+static void    ATEM_StringOut(char *buffer);
 
     /* Handler called when characters received from serial port.
        calls state machine code to process it. */
 
     /* Handler called when characters received from serial port.
        calls state machine code to process it. */
@@ -177,9 +184,13 @@ void       ATEM_HandleIncomingData(char *buffer, int length)
        }
 }     
 
        }
 }     
 
+static bool    ATEM_CommandPlusC(char **buf);
+static bool    ATEM_CommandPlusG(char **buf);
+static int             ATEM_GetNum(char **p);
+static void    ATEM_ParseSMS(char *cmd_buffer);
 
        /* Parser for standard AT commands.  cmd_buffer must be null terminated. */
 
        /* Parser for standard AT commands.  cmd_buffer must be null terminated. */
-void   ATEM_ParseAT(char *cmd_buffer)
+static void    ATEM_ParseAT(char *cmd_buffer)
 {
        char *buf;
        char number[30];
 {
        char *buf;
        char number[30];
@@ -365,8 +376,10 @@ static void ATEM_HandleSMS()
        return;
 }
 
        return;
 }
 
+static void    ATEM_ParseDIR(char *cmd_buffer);
+
        /* Parser for SMS interactive mode */
        /* Parser for SMS interactive mode */
-void   ATEM_ParseSMS(char *buff)
+static void    ATEM_ParseSMS(char *buff)
 {
        if (!strcasecmp(buff, "HELP")) {
                ATEM_StringOut(_("\n\rThe following commands work...\n\r"));
 {
        if (!strcasecmp(buff, "HELP")) {
                ATEM_StringOut(_("\n\rThe following commands work...\n\r"));
@@ -391,7 +404,7 @@ void        ATEM_ParseSMS(char *buff)
 }
 
        /* Parser for DIR sub mode of SMS interactive mode. */
 }
 
        /* Parser for DIR sub mode of SMS interactive mode. */
-void   ATEM_ParseDIR(char *buff)
+static void    ATEM_ParseDIR(char *buff)
 {
        switch (toupper(*buff)) {
                case 'P':
 {
        switch (toupper(*buff)) {
                case 'P':
@@ -415,7 +428,7 @@ void        ATEM_ParseDIR(char *buff)
  
        /* Handle AT+C commands, this is a quick hack together at this
           stage. */
  
        /* Handle AT+C commands, this is a quick hack together at this
           stage. */
-bool   ATEM_CommandPlusC(char **buf)
+static bool    ATEM_CommandPlusC(char **buf)
 {
        float           rflevel;
        GSM_RFUnits     rfunits = GRF_CSQ;
 {
        float           rflevel;
        GSM_RFUnits     rfunits = GRF_CSQ;
@@ -515,7 +528,7 @@ bool        ATEM_CommandPlusC(char **buf)
                switch (**buf) {
                case '=':
                        buf[0]++;
                switch (**buf) {
                case '=':
                        buf[0]++;
-                       sscanf(*buf, "%d", &index);
+                       index = atoi(*buf);
                        buf[0] += strlen(*buf);
 
                        error = ATEM_ReadSMS(index, SMSType, &message);
                        buf[0] += strlen(*buf);
 
                        error = ATEM_ReadSMS(index, SMSType, &message);
@@ -599,7 +612,7 @@ bool        ATEM_CommandPlusC(char **buf)
 }
 
        /* AT+G commands.  Some of these responses are a bit tongue in cheek... */
 }
 
        /* AT+G commands.  Some of these responses are a bit tongue in cheek... */
-bool   ATEM_CommandPlusG(char **buf)
+static bool    ATEM_CommandPlusG(char **buf)
 {
        char            buffer[MAX_LINE_LENGTH];
 
 {
        char            buffer[MAX_LINE_LENGTH];
 
@@ -685,7 +698,7 @@ void        ATEM_ModemResult(int code)
 
        /* Get integer from char-pointer, set pointer to end of number
           stolen basically verbatim from ISDN code.  */
 
        /* Get integer from char-pointer, set pointer to end of number
           stolen basically verbatim from ISDN code.  */
-int ATEM_GetNum(char **p)
+static int ATEM_GetNum(char **p)
 {
        int v = -1;
 
 {
        int v = -1;
 
@@ -699,7 +712,7 @@ int ATEM_GetNum(char **p)
        /* Write string to virtual modem port, either pty or
           STDOUT as appropriate.  This function is only used during
           command mode - data pump is used when connected.  */
        /* Write string to virtual modem port, either pty or
           STDOUT as appropriate.  This function is only used during
           command mode - data pump is used when connected.  */
-void   ATEM_StringOut(char *buffer)
+static void    ATEM_StringOut(char *buffer)
 {
        int             count = 0;
        char    out_char;
 {
        int             count = 0;
        char    out_char;
index 4eede53..adb201d 100644 (file)
@@ -14,6 +14,8 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 #define                __data_datapump_c
 
 
 #define                __data_datapump_c
 
 
@@ -27,7 +29,9 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef UCLINUX
 #include <sys/poll.h>
 #include <sys/poll.h>
+#endif
 #include <unistd.h>
 
 
 #include <unistd.h>
 
 
 extern bool CommandMode;
 
 /* Local variables */
 extern bool CommandMode;
 
 /* Local variables */
-int            PtyRDFD;        /* File descriptor for reading and writing to/from */
-int            PtyWRFD;        /* pty interface - only different in debug mode. */ 
-struct pollfd ufds;
-u8 pluscount;
-bool connected;
+extern int             PtyRDFD;        /* File descriptor for reading and writing to/from */
+extern int             PtyWRFD;        /* pty interface - only different in debug mode. */ 
+static u8 pluscount;
+static bool connected;
+
+static int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length);
 
 bool DP_Initialise(int read_fd, int write_fd)
 {
        PtyRDFD = read_fd;
        PtyWRFD = write_fd;
 
 bool DP_Initialise(int read_fd, int write_fd)
 {
        PtyRDFD = read_fd;
        PtyWRFD = write_fd;
-       ufds.fd=PtyRDFD;
-       ufds.events=POLLIN;
        RLP_Initialise(GSM->SendRLPFrame, DP_CallBack);
        RLP_SetUserRequest(Attach_Req,true);
        pluscount=0;
        RLP_Initialise(GSM->SendRLPFrame, DP_CallBack);
        RLP_SetUserRequest(Attach_Req,true);
        pluscount=0;
@@ -63,7 +66,7 @@ bool DP_Initialise(int read_fd, int write_fd)
 }
 
 
 }
 
 
-int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length)
+static int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length)
 {
        int temp;
 
 {
        int temp;
 
@@ -91,15 +94,23 @@ int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length)
        case Reset_Ind:
                RLP_SetUserRequest(Reset_Resp,true);
                break;
        case Reset_Ind:
                RLP_SetUserRequest(Reset_Resp,true);
                break;
-       case GetData:
-               if (poll(&ufds,1,0)) {
+       case GetData: {
+               fd_set readfds;
+               struct timeval timeout;
+
+               FD_ZERO(&readfds);
+               FD_SET(PtyRDFD,&readfds);
+               timeout.tv_sec=0;
+               timeout.tv_usec=0;
+
+               if (select(PtyRDFD+1,&readfds,NULL/*writefds*/,NULL/*exceptfds*/,&timeout)) {
 
                        /* Check if the program has closed */
                        /* Return to command mode */
                        /* Note that the call will still be in progress, */
                        /* as with a normal modem (I think) */
 
 
                        /* Check if the program has closed */
                        /* Return to command mode */
                        /* Note that the call will still be in progress, */
                        /* as with a normal modem (I think) */
 
-                       if (ufds.revents!=POLLIN) { 
+                       if (!FD_ISSET(PtyRDFD,&readfds)) { 
                                CommandMode=true;
                                /* Set the call passup back to the at emulator */
                                GSM->DialData(NULL,-1,&ATEM_CallPassup);
                                CommandMode=true;
                                /* Set the call passup back to the at emulator */
                                GSM->DialData(NULL,-1,&ATEM_CallPassup);
@@ -137,7 +148,7 @@ int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length)
                        return temp;
                }
                return 0;
                        return temp;
                }
                return 0;
-               break;
+               break;
 
        default:
 
 
        default:
 
index 9c46e0d..509faa7 100644 (file)
@@ -16,6 +16,8 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 
 /* Our state machine which handles all of nine possible states of RLP
    machine. */
 
 /* Our state machine which handles all of nine possible states of RLP
    machine. */
-void MAIN_STATE_MACHINE(RLP_F96Frame *frame, RLP_F96Header *header);
+static void MAIN_STATE_MACHINE(RLP_F96Frame *frame, RLP_F96Header *header);
 
 /* This is the type we are just handling. */
 
 /* This is the type we are just handling. */
-RLP_FrameTypes CurrentFrameType;
+static RLP_FrameTypes CurrentFrameType;
 
 /* Current state of RLP state machine. */
 
 /* Current state of RLP state machine. */
-RLP_State      CurrentState=RLP_S0; /* We start at ADM and Detached */
+static RLP_State      CurrentState=RLP_S0; /* We start at ADM and Detached */
 
 /* Next state of RLP state machine. */
 
 /* Next state of RLP state machine. */
-RLP_State      NextState;
+static RLP_State      NextState;
 
 /* Pointer to Send function that sends frame to phone. */
 
 /* Pointer to Send function that sends frame to phone. */
-bool      (*RLPSendFunction)(RLP_F96Frame *frame, bool out_dtx);
+static bool      (*RLPSendFunction)(RLP_F96Frame *frame, bool out_dtx);
 
 /* Pointer to Passup function which returns data/inds */
 
 /* Pointer to Passup function which returns data/inds */
-int      (*RLP_Passup)(RLP_UserInds ind, u8 *buffer, int length);
+static int      (*RLP_Passup)(RLP_UserInds ind, u8 *buffer, int length);
 
 
 /* State variables - see GSM 04.22, Annex A, section A.1.2 */
 
 
 
 /* State variables - see GSM 04.22, Annex A, section A.1.2 */
 
-RLP_StateVariable UA_State;
-RLP_StateVariable UI_State;
-RLP_StateVariable Ackn_State;
-RLP_StateVariable Poll_State;
-RLP_StateVariable Poll_xchg;
-RLP_StateVariable SABM_State;
-RLP_StateVariable DISC_State;
-RLP_StateVariable DM_State;  /* FIXME - not handled */
-RLP_StateVariable XI_R_State;
-RLP_StateVariable XID_C_State;
-RLP_StateVariable XID_R_State;
-RLP_StateVariable TEST_R_State;
-
-u8 VR=0;
-u8 VA=0;
-u8 VS=0;
-u8 VD=0;
-u8 DISC_Count;
-
-u8 DTX_VR;
-RLP_FrameTypes DTX_SF;
+static RLP_StateVariable UA_State;
+/*
+static RLP_StateVariable UI_State;
+*/
+static RLP_StateVariable Ackn_State;
+static RLP_StateVariable Poll_State;
+static RLP_StateVariable Poll_xchg;
+static RLP_StateVariable SABM_State;
+static RLP_StateVariable DISC_State;
+static RLP_StateVariable DM_State;  /* FIXME - not handled */
+/*
+static RLP_StateVariable XID_C_State;
+*/
+static RLP_StateVariable XID_R_State;
+/*
+static RLP_StateVariable TEST_R_State;
+*/
+
+static u8 VR=0;
+static u8 VA=0;
+static u8 VS=0;
+static u8 VD=0;
+static u8 DISC_Count;
+
+static u8 DTX_VR;
+static RLP_FrameTypes DTX_SF;
 
 #define RLP_M 62
 
 
 #define RLP_M 62
 
-RLP_Data R[RLP_M];
-RLP_Data S[RLP_M];
+static RLP_Data R[RLP_M];
+static RLP_Data S[RLP_M];
 
 
-RLP_StateVariable SABM_State;
-int SABM_Count;
+static RLP_StateVariable SABM_State;
+static int SABM_Count;
 
 
-RLP_UserRequestStore UserRequests;
+static RLP_UserRequestStore UserRequests;
 
 
-u8 Poll_Count=0;
+static u8 Poll_Count=0;
 
 /* For now timing is done based on a frame reception rate of 20ms */
 /* Serge has measured it as 18.4ms */
 
 /* For now timing is done based on a frame reception rate of 20ms */
 /* Serge has measured it as 18.4ms */
@@ -96,28 +103,28 @@ u8 Poll_Count=0;
 /* To set, timer is loaded with RLP_Timeout1_Limit/RLP_T_Scaling. */
 /* Each received frame (including NULLS / errors) any >0 timer is decrease */
 
 /* To set, timer is loaded with RLP_Timeout1_Limit/RLP_T_Scaling. */
 /* Each received frame (including NULLS / errors) any >0 timer is decrease */
 
-int T;
-int T_RCVS[RLP_M];
+static int T;
+static int T_RCVS[RLP_M];
 
 
-bool UA_FBit=true;
-bool Ackn_FBit=false;
-bool DM_FBit=false;  /* FIXME - not handled */
-bool RRReady=false;
-bool LRReady=true;   /* FIXME - not handled (as if we couldn't keep up with 9600bps :-) */
-bool DISC_PBit=false;
+static bool UA_FBit=true;
+static bool Ackn_FBit=false;
+static bool DM_FBit=false;  /* FIXME - not handled */
+static bool RRReady=false;
+static bool LRReady=true;   /* FIXME - not handled (as if we couldn't keep up with 9600bps :-) */
+static bool DISC_PBit=false;
 
 
-u8 LastStatus=0xff;   /* Last Status byte */
+static u8 LastStatus=0xff;   /* Last Status byte */
 
 
 /* RLP Parameters. FIXME: Reset these - e.g. when entering state 0 */
 
 
 
 /* RLP Parameters. FIXME: Reset these - e.g. when entering state 0 */
 
-u8 RLP_SEND_WS = RLP_M-1;
-u8 RLP_RCV_WS = RLP_M-1;
-u8 RLP_Timeout1_Limit = 55;
-u8 RLP_N2 = 15; /* Maximum number of retransmisions. GSM spec says 6 here, but
-                   Nokia will XID this. */
-u8 RLP_T2=0;
-u8 RLP_VersionNumber=0;
+static u8 RLP_SEND_WS = RLP_M-1;
+static u8 RLP_RCV_WS = RLP_M-1;
+static u8 RLP_Timeout1_Limit = 55;
+static u8 RLP_N2 = 15; /* Maximum number of retransmisions. GSM spec says 6 here, but
+                          Nokia will XID this. */
+static u8 RLP_T2=0;
+static u8 RLP_VersionNumber=0;
 
 
 
 
 
 
@@ -197,7 +204,7 @@ void RLP_SetUserRequest(RLP_UserRequests type, bool value) {
 
 /* Check whether a user event is set */
 
 
 /* Check whether a user event is set */
 
-bool RLP_GetUserRequest(RLP_UserRequests type) {
+static bool RLP_GetUserRequest(RLP_UserRequests type) {
 
        bool result=false, *x;
 
 
        bool result=false, *x;
 
@@ -230,7 +237,7 @@ bool RLP_GetUserRequest(RLP_UserRequests type) {
        return result;
 }
 
        return result;
 }
 
-void RLP_SetTimer(int *timer)
+static void RLP_SetTimer(int *timer)
 {
        *timer=(int)(RLP_Timeout1_Limit/RLP_T_Scaling);
 }
 {
        *timer=(int)(RLP_Timeout1_Limit/RLP_T_Scaling);
 }
@@ -280,7 +287,7 @@ static bool InWindow(u8 val, u8 lower, u8 upper)
        return (val <= upper) || (val >= lower);
 }
 
        return (val <= upper) || (val >= lower);
 }
 
-void RLP_Init_link_vars(void)
+static void RLP_Init_link_vars(void)
 {
        int i;
   
 {
        int i;
   
@@ -305,7 +312,7 @@ void RLP_Init_link_vars(void)
 }
 
 
 }
 
 
-void RLP_AddRingBufferDataToSlots(void)
+static void RLP_AddRingBufferDataToSlots(void)
 {
        u8 buffer[24];
        int size;
 {
        u8 buffer[24];
        int size;
@@ -329,9 +336,11 @@ void RLP_AddRingBufferDataToSlots(void)
 }
 
 
 }
 
 
+#ifndef UCLINUX
+
 /* FIXME: Remove this after finishing. */
 
 /* FIXME: Remove this after finishing. */
 
-void X(RLP_F96Frame *frame) {
+static void X(RLP_F96Frame *frame) {
 
        int i;
 
 
        int i;
 
@@ -340,9 +349,10 @@ void X(RLP_F96Frame *frame) {
    
 }
 
    
 }
 
+#endif /* UCLINUX */
 
  
 
  
-void ResetAllT_RCVS(void)
+static void ResetAllT_RCVS(void)
 {
 
        int i;
 {
 
        int i;
@@ -353,7 +363,7 @@ void ResetAllT_RCVS(void)
 
 /* This function is used for sending RLP frames to the phone. */
 
 
 /* This function is used for sending RLP frames to the phone. */
 
-void RLP_SendF96Frame(RLP_FrameTypes FrameType,
+static void RLP_SendF96Frame(RLP_FrameTypes FrameType,
                       bool OutCR, bool OutPF,
                       u8 OutNR, u8 OutNS,
                       u8 *OutData, u8 OutDTX)
                       bool OutCR, bool OutPF,
                       u8 OutNR, u8 OutNS,
                       u8 *OutData, u8 OutDTX)
@@ -594,6 +604,8 @@ void RLP_SendF96Frame(RLP_FrameTypes FrameType,
 
 }
 
 
 }
 
+static void RLP_DecodeF96Header(RLP_F96Frame *frame, RLP_F96Header *header);
+
 /* Check_input_PDU in Serge's code. */
 
 void RLP_DisplayF96Frame(RLP_F96Frame *frame)
 /* Check_input_PDU in Serge's code. */
 
 void RLP_DisplayF96Frame(RLP_F96Frame *frame)
@@ -930,14 +942,14 @@ void RLP_DisplayF96Frame(RLP_F96Frame *frame)
 
 /* FIXME: real TEST_Handling - we do not handle TEST yet. */
 
 
 /* FIXME: real TEST_Handling - we do not handle TEST yet. */
 
-void TEST_Handling() {
+static void TEST_Handling() {
 }
 
 
 
 /* FIXME: better XID_handling - but this will answer a XID command. */
 
 }
 
 
 
 /* FIXME: better XID_handling - but this will answer a XID command. */
 
-bool XID_Handling (RLP_F96Frame *frame, RLP_F96Header *header) {
+static bool XID_Handling (RLP_F96Frame *frame, RLP_F96Header *header) {
   
        u8 count;
        u8 type;
   
        u8 count;
        u8 type;
@@ -1026,7 +1038,7 @@ bool XID_Handling (RLP_F96Frame *frame, RLP_F96Header *header) {
 }
 
 
 }
 
 
-bool Send_TXU(RLP_F96Frame *frame, RLP_F96Header *header) {
+static bool Send_TXU(RLP_F96Frame *frame, RLP_F96Header *header) {
 
 #ifdef DEBUG
        //    fprintf(stdout, _("Send_TXU()\n"));
 
 #ifdef DEBUG
        //    fprintf(stdout, _("Send_TXU()\n"));
@@ -1070,7 +1082,7 @@ bool Send_TXU(RLP_F96Frame *frame, RLP_F96Header *header) {
 
 /* Deliver data */
 
 
 /* Deliver data */
 
-void RLP_DeliverAllInSeqIF()
+static void RLP_DeliverAllInSeqIF()
 {
        int i,j;
 
 {
        int i,j;
 
@@ -1098,7 +1110,7 @@ void RLP_DeliverAllInSeqIF()
 
 
 /* Mark any missing information frames between VR and Ns*/
 
 
 /* Mark any missing information frames between VR and Ns*/
-void RLP_MarkMissingIF(u8 Ns)
+static void RLP_MarkMissingIF(u8 Ns)
 {
        u8 i;
        for (i=VR; i!=Ns; i=Incr(i)) {
 {
        u8 i;
        for (i=VR; i!=Ns; i=Incr(i)) {
@@ -1109,7 +1121,7 @@ void RLP_MarkMissingIF(u8 Ns)
 
 /* Information frame handler */
 
 
 /* Information frame handler */
 
-bool RLP_I_Handler(RLP_F96Frame *frame, RLP_F96Header *header)
+static bool RLP_I_Handler(RLP_F96Frame *frame, RLP_F96Header *header)
 {
 
        if ((header->CR) && (header->PF))
 {
 
        if ((header->CR) && (header->PF))
@@ -1142,7 +1154,7 @@ bool RLP_I_Handler(RLP_F96Frame *frame, RLP_F96Header *header)
 
 /* Mark acknowledged send frames */
 
 
 /* Mark acknowledged send frames */
 
-void RLP_AdvanceVA(u8 Nr)
+static void RLP_AdvanceVA(u8 Nr)
 {
        while (VA!=Nr) {
                S[VA].State=_idle;
 {
        while (VA!=Nr) {
                S[VA].State=_idle;
@@ -1153,7 +1165,7 @@ void RLP_AdvanceVA(u8 Nr)
 
 /* Decrease VS back down to Nr since these have not been acknowledged */
 
 
 /* Decrease VS back down to Nr since these have not been acknowledged */
 
-void RLP_DecreaseVS(u8 Nr)
+static void RLP_DecreaseVS(u8 Nr)
 {
        while (VS!=Nr) {
                VS=Decr(VS);
 {
        while (VS!=Nr) {
                VS=Decr(VS);
@@ -1163,7 +1175,7 @@ void RLP_DecreaseVS(u8 Nr)
 
 /* Supervisory frame handling */
 
 
 /* Supervisory frame handling */
 
-void RLP_S_Handler(RLP_F96Frame *frame, RLP_F96Header *header)
+static void RLP_S_Handler(RLP_F96Frame *frame, RLP_F96Header *header)
 {
        u8 i;
 
 {
        u8 i;
 
@@ -1219,7 +1231,7 @@ void RLP_S_Handler(RLP_F96Frame *frame, RLP_F96Header *header)
 
 /* Find the first SREJ frame */
 
 
 /* Find the first SREJ frame */
 
-bool RLP_SREJSlot(u8 *x)
+static bool RLP_SREJSlot(u8 *x)
 {
        u8 i;
 
 {
        u8 i;
 
@@ -1235,7 +1247,7 @@ bool RLP_SREJSlot(u8 *x)
 
 /* Check if any SREJ frames need sending, if not send the next in line */
 
 
 /* Check if any SREJ frames need sending, if not send the next in line */
 
-bool RLP_PrepareDataToTransmit(u8 *p)
+static bool RLP_PrepareDataToTransmit(u8 *p)
 {
        u8 i;
 
 {
        u8 i;
 
@@ -1258,7 +1270,7 @@ bool RLP_PrepareDataToTransmit(u8 *p)
 
 /* Send a SREJ command */
 
 
 /* Send a SREJ command */
 
-void RLP_SendSREJ(u8 x)
+static void RLP_SendSREJ(u8 x)
 {
        u8 k;
   
 {
        u8 k;
   
@@ -1298,7 +1310,7 @@ void RLP_SendSREJ(u8 x)
 
 /* Send a command */
 
 
 /* Send a command */
 
-void RLP_Send_XX_Cmd(RLP_FrameTypes type)
+static void RLP_Send_XX_Cmd(RLP_FrameTypes type)
 {
        u8 k;
 
 {
        u8 k;
 
@@ -1336,7 +1348,7 @@ void RLP_Send_XX_Cmd(RLP_FrameTypes type)
 
 /* Send a Response */
 
 
 /* Send a Response */
 
-void RLP_Send_XX_Resp(RLP_FrameTypes type)
+static void RLP_Send_XX_Resp(RLP_FrameTypes type)
 {
        u8 k;
   
 {
        u8 k;
   
@@ -1362,7 +1374,7 @@ void RLP_Send_XX_Resp(RLP_FrameTypes type)
 
 /* Decide which frame to use and send it - currently only used in state 4 */
 
 
 /* Decide which frame to use and send it - currently only used in state 4 */
 
-void RLP_SendData()
+static void RLP_SendData()
 {
        u8 x;
 
 {
        u8 x;
 
@@ -1382,7 +1394,7 @@ void RLP_SendData()
        else RLP_Send_XX_Cmd(RLPFT_S_RNR);
 }
 
        else RLP_Send_XX_Cmd(RLPFT_S_RNR);
 }
 
-void MAIN_STATE_MACHINE(RLP_F96Frame *frame, RLP_F96Header *header) {
+static void MAIN_STATE_MACHINE(RLP_F96Frame *frame, RLP_F96Header *header) {
        int i;
 
        switch (CurrentState) {
        int i;
 
        switch (CurrentState) {
@@ -1743,7 +1755,6 @@ void MAIN_STATE_MACHINE(RLP_F96Frame *frame, RLP_F96Header *header) {
                        if(SABM_State!=_idle) printf("[SABM_State %d]",SABM_State);
                        if(DISC_State!=_idle) printf("[DISC_State %d]",DISC_State);
                        if(DM_State!=_idle) printf("[DM_State %d]",DM_State);
                        if(SABM_State!=_idle) printf("[SABM_State %d]",SABM_State);
                        if(DISC_State!=_idle) printf("[DISC_State %d]",DISC_State);
                        if(DM_State!=_idle) printf("[DM_State %d]",DM_State);
-                       if(XI_R_State!=_idle) printf("[XI_R_State %d]",XI_R_State);
                        if(XID_C_State!=_idle) printf("[XID_C_State %d]",XID_C_State);
                        if(XID_R_State!=_idle) printf("[XID_R_State %d]",XID_R_State);
                        if(TEST_R_State!=_idle) printf("[TEST_R_State %d]",TEST_R_State);
                        if(XID_C_State!=_idle) printf("[XID_C_State %d]",XID_C_State);
                        if(XID_R_State!=_idle) printf("[XID_R_State %d]",XID_R_State);
                        if(TEST_R_State!=_idle) printf("[TEST_R_State %d]",TEST_R_State);
@@ -1925,7 +1936,9 @@ void MAIN_STATE_MACHINE(RLP_F96Frame *frame, RLP_F96Header *header) {
    exact implementation of section 5.2.2.6, Exchange Identification, XID of
    the GSM specification 04.22. */
 
    exact implementation of section 5.2.2.6, Exchange Identification, XID of
    the GSM specification 04.22. */
 
-void RLP_DisplayXID(u8 *frame) 
+#ifdef RLP_DEBUG
+
+static void RLP_DisplayXID(u8 *frame) 
 {
 
        int count = 25;  /* Sanity check */
 {
 
        int count = 25;  /* Sanity check */
@@ -2005,10 +2018,12 @@ void RLP_DisplayXID(u8 *frame)
        return;
 }
 
        return;
 }
 
+#endif /* RLP_DEBUG */
+
 /* Given a pointer to an F9.6 Frame, split data out into component parts of
    header and determine frame type. */
 
 /* Given a pointer to an F9.6 Frame, split data out into component parts of
    header and determine frame type. */
 
-void RLP_DecodeF96Header(RLP_F96Frame *frame, RLP_F96Header *header)
+static void RLP_DecodeF96Header(RLP_F96Frame *frame, RLP_F96Header *header)
 {
 
        /* Poll/Final bit. */
 {
 
        /* Poll/Final bit. */
index cc8af90..7f29c68 100644 (file)
@@ -16,7 +16,7 @@
 
 /* CRC-24 table is used for computation of RLP checksum. */
 
 
 /* CRC-24 table is used for computation of RLP checksum. */
 
-const u32 CRC24_Table[256] = {
+static const u32 CRC24_Table[256] = {
     0x00000000, 0x00D6A776, 0x00F64557, 0x0020E221, 0x00B78115, 0x00612663,
     0x0041C442, 0x00976334, 0x00340991, 0x00E2AEE7, 0x00C24CC6, 0x0014EBB0,
     0x00838884, 0x00552FF2, 0x0075CDD3, 0x00A36AA5, 0x00681322, 0x00BEB454,
     0x00000000, 0x00D6A776, 0x00F64557, 0x0020E221, 0x00B78115, 0x00612663,
     0x0041C442, 0x00976334, 0x00340991, 0x00E2AEE7, 0x00C24CC6, 0x0014EBB0,
     0x00838884, 0x00552FF2, 0x0075CDD3, 0x00A36AA5, 0x00681322, 0x00BEB454,
@@ -62,7 +62,7 @@ const u32 CRC24_Table[256] = {
     0x006D7F0C, 0x00BBD87A, 0x009B3A5B, 0x004D9D2D
 };
 
     0x006D7F0C, 0x00BBD87A, 0x009B3A5B, 0x004D9D2D
 };
 
-void    RLP_CalculateCRC24Polinomial(u8 *data, int length, u32 *polinomial)
+static void    RLP_CalculateCRC24Polinomial(u8 *data, int length, u32 *polinomial)
 {
 
     int     i;
 {
 
     int     i;
index 7c7f4e2..664127f 100644 (file)
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#ifndef UCLINUX
 #include <sys/poll.h>
 #include <pthread.h>
 #include <sys/poll.h>
 #include <pthread.h>
+#endif /* UCLINUX */
 #include <unistd.h>
 
 #include "misc.h"
 #include <unistd.h>
 
 #include "misc.h"
        /* Global variables */
 
 //extern bool TerminateThread;
        /* Global variables */
 
 //extern bool TerminateThread;
-int ConnectCount;
 
        /* Local variables */
 
 int            PtyRDFD;        /* File descriptor for reading and writing to/from */
 int            PtyWRFD;        /* pty interface - only different in debug mode. */ 
 
 
        /* Local variables */
 
 int            PtyRDFD;        /* File descriptor for reading and writing to/from */
 int            PtyWRFD;        /* pty interface - only different in debug mode. */ 
 
-bool   UseSTDIO;       /* Use STDIO for debugging purposes instead of pty */
+static bool    UseSTDIO;       /* Use STDIO for debugging purposes instead of pty */
 bool   CommandMode;
 
 bool   CommandMode;
 
-pthread_t              Thread;
-bool                   RequestTerminate;
-
+static bool    VM_ThreadLoop(void);
+static GSM_Error       VM_GSMInitialise(char *model, char *port, char *initlength, GSM_ConnectionType connection, char *synchronizetime);
+static int             VM_PtySetup(char *bindir);
 
        /* If initialised in debug mode, stdin/out is used instead
           of ptys for interface. */
 
        /* If initialised in debug mode, stdin/out is used instead
           of ptys for interface. */
-bool   VM_Initialise(char *model,char *port, char *initlength, GSM_ConnectionType connection, char *bindir, bool debug_mode, bool GSMInit,char *synchronizetime)
+bool VM_Initialise(char *model,char *port, char *initlength, GSM_ConnectionType connection, char *bindir, bool debug_mode, bool GSMInit,char *synchronizetime)
 {
 {
-       int             rtn;
-
        CommandMode = true;
 
        CommandMode = true;
 
-       RequestTerminate = false;
-
        if (debug_mode == true) {
                UseSTDIO = true;
        }
        if (debug_mode == true) {
                UseSTDIO = true;
        }
@@ -108,34 +105,34 @@ bool      VM_Initialise(char *model,char *port, char *initlength, GSM_ConnectionType
                return (false);
        }
 
                return (false);
        }
 
-               /* Create and start thread, */
-       rtn = pthread_create(&Thread, NULL, (void *) VM_ThreadLoop, (void *)NULL);
-
-    if (rtn == EAGAIN || rtn == EINVAL) {
-        return (false);
-    }
-       return (true);
+       /* Create and start thread, */
+       return VM_ThreadLoop();
 }
 
 }
 
-void   VM_ThreadLoop(void)
+static void    VM_CharHandler(void);
+
+static bool VM_ThreadLoop(void)
 {
        int res;
 {
        int res;
-       struct pollfd ufds;
+       fd_set readfds;
+       struct timeval timeout;
 
                /* Note we can't use signals here as they are already used
                   in the FBUS code.  This may warrant changing the FBUS
                   code around sometime to use select instead to free up
                   the SIGIO handler for mainline code. */
 
 
                /* Note we can't use signals here as they are already used
                   in the FBUS code.  This may warrant changing the FBUS
                   code around sometime to use select instead to free up
                   the SIGIO handler for mainline code. */
 
-       ufds.fd=PtyRDFD;
-       ufds.events=POLLIN;
-
-       while (!RequestTerminate) {
+       for (;;) {
          if (!CommandMode) {
            sleep(1);
          } else {  /* If we are in data mode, leave it to datapump to get the data */
 
          if (!CommandMode) {
            sleep(1);
          } else {  /* If we are in data mode, leave it to datapump to get the data */
 
-               res=poll(&ufds,1,500);
+               FD_ZERO(&readfds);
+               FD_SET(PtyRDFD,&readfds);
+               timeout.tv_sec=0;
+               timeout.tv_usec=500*1000;
+
+               res = select(PtyRDFD+1,&readfds,NULL/*writefds*/,NULL/*exceptfds*/,&timeout);
 
                switch (res) {
                        case 0: /* Timeout */
 
                switch (res) {
                        case 0: /* Timeout */
@@ -143,10 +140,10 @@ void      VM_ThreadLoop(void)
 
                        case -1:
                                perror("VM_ThreadLoop - select");
 
                        case -1:
                                perror("VM_ThreadLoop - select");
-                               exit (-1);
+                               return (false);
 
                        default:
 
                        default:
-                         if (ufds.revents==POLLIN) {
+                         if (FD_ISSET(PtyRDFD,&readfds)) {
                            VM_CharHandler();
                          } else usleep(500); /* Probably the file has been closed */
                          break;
                            VM_CharHandler();
                          } else usleep(500); /* Probably the file has been closed */
                          break;
@@ -160,34 +157,35 @@ void      VM_ThreadLoop(void)
           the virtual modem thread */
 void           VM_Terminate(void)
 {
           the virtual modem thread */
 void           VM_Terminate(void)
 {
-     
-       /* Request termination of thread */
-       RequestTerminate = true;
-
-       /* Now wait for thread to terminate. */
-       pthread_join(Thread, NULL);
-
        if (!UseSTDIO) {
                close (PtyRDFD);
                close (PtyWRFD);
        }
 }
 
        if (!UseSTDIO) {
                close (PtyRDFD);
                close (PtyWRFD);
        }
 }
 
+static int     VM_GetMasterPty(char **name);
+
        /* Open pseudo tty interface and (in due course create a symlink
           to be /dev/gnokii etc. ) */
 
        /* Open pseudo tty interface and (in due course create a symlink
           to be /dev/gnokii etc. ) */
 
-int            VM_PtySetup(char *bindir)
+static int             VM_PtySetup(char *bindir)
 {
        int                     err;
 {
        int                     err;
+#ifndef UCLINUX
        char            mgnokiidev[200];
        char            mgnokiidev[200];
+#endif /* UCLINUX */
        char            *slave_name;
        char            *slave_name;
+#ifndef UCLINUX
        char            cmdline[200];
        char            cmdline[200];
+#endif /* UCLINUX */
 
 
+#ifndef UCLINUX
        if (bindir) {
                strncpy(mgnokiidev, bindir, 200);
                strcat(mgnokiidev, "/");
        }
        strncat(mgnokiidev, "mgnokiidev", 200 - strlen(bindir));
        if (bindir) {
                strncpy(mgnokiidev, bindir, 200);
                strcat(mgnokiidev, "/");
        }
        strncat(mgnokiidev, "mgnokiidev", 200 - strlen(bindir));
+#endif /* UCLINUX */
 
        if (UseSTDIO) {
                PtyRDFD = STDIN_FILENO;
 
        if (UseSTDIO) {
                PtyRDFD = STDIN_FILENO;
@@ -202,22 +200,40 @@ int               VM_PtySetup(char *bindir)
        }
        PtyWRFD = PtyRDFD;
 
        }
        PtyWRFD = PtyRDFD;
 
+#ifndef UCLINUX
                /* Check we haven't been installed setuid root for some reason
                   if so, don't create /dev/gnokii */
        if (getuid() != geteuid()) {
                fprintf(stderr, _("gnokiid should not be installed setuid root!\n"));
                return (0);
        }
                /* Check we haven't been installed setuid root for some reason
                   if so, don't create /dev/gnokii */
        if (getuid() != geteuid()) {
                fprintf(stderr, _("gnokiid should not be installed setuid root!\n"));
                return (0);
        }
+#endif
 
 #ifdef DEBUG
 
 #ifdef DEBUG
-       fprintf (stderr, _("Slave pty is %s, calling %s to create /dev/gnokii.\n"), slave_name, mgnokiidev);
+       fprintf (stderr, _("Slave pty is %s, calling %s to create /dev/gnokii.\n"), slave_name,
+#ifndef UCLINUX
+                       mgnokiidev
+#else /* UCLINUX */
+                       "<uClinux>"
+#endif /* UCLINUX */
+                       );
 #endif /* DEBUG */
 
 #endif /* DEBUG */
 
+#ifndef UCLINUX
                /* Create command line, something line ./mkgnokiidev ttyp0 */
        sprintf(cmdline, "%s %s", mgnokiidev, slave_name);
 
                /* And use system to call it. */        
        err = system (cmdline);
                /* Create command line, something line ./mkgnokiidev ttyp0 */
        sprintf(cmdline, "%s %s", mgnokiidev, slave_name);
 
                /* And use system to call it. */        
        err = system (cmdline);
+#else /* UCLINUX */
+
+       /* Remove symlink in case it already exists. Don't care if it fails.  */
+       unlink ("/dev/gnokii");
+
+       /* Create symlink */
+       err = symlink(slave_name, "/dev/gnokii");
+
+#endif /* UCLINUX */
        
        return (err);
 
        
        return (err);
 
@@ -225,7 +241,7 @@ int         VM_PtySetup(char *bindir)
 
     /* Handler called when characters received from serial port.
        calls state machine code to process it. */
 
     /* Handler called when characters received from serial port.
        calls state machine code to process it. */
-void    VM_CharHandler(void)
+static void    VM_CharHandler(void)
 {
     unsigned char   buffer[255];
     int             res;
 {
     unsigned char   buffer[255];
     int             res;
@@ -250,7 +266,7 @@ void    VM_CharHandler(void)
 }     
 
        /* Initialise GSM interface, returning GSM_Error as appropriate  */
 }     
 
        /* Initialise GSM interface, returning GSM_Error as appropriate  */
-GSM_Error      VM_GSMInitialise(char *model, char *port, char *initlength, GSM_ConnectionType connection, char *synchronizetime)
+static GSM_Error       VM_GSMInitialise(char *model, char *port, char *initlength, GSM_ConnectionType connection, char *synchronizetime)
 {
        int             count=0;
        GSM_Error       error;
 {
        int             count=0;
        GSM_Error       error;
@@ -289,7 +305,7 @@ GSM_Error   VM_GSMInitialise(char *model, char *port, char *initlength, GSM_Conne
    Applications by Troan and Johnson */
 
 
    Applications by Troan and Johnson */
 
 
-int    VM_GetMasterPty(char **name) { 
+static int     VM_GetMasterPty(char **name) { 
 
 #ifdef USE_UNIX98PTYS
        int master, err;
 
 #ifdef USE_UNIX98PTYS
        int master, err;
index 45330c2..eb81b25 100644 (file)
@@ -8,12 +8,11 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 #ifndef WIN32
   #include "devices/unixserial.h"
 #ifndef WIN32
   #include "devices/unixserial.h"
-  #include "devices/unixirda.h"
-  #include "devices/tekram.h"
   #include <sys/ioctl.h>
   #include <sys/ioctl.h>
-  #include <pthread.h>
   #include <termios.h>
   #include <signal.h>
   #include <errno.h>
   #include <termios.h>
   #include <signal.h>
   #include <errno.h>
@@ -32,9 +31,9 @@
   #include "mversion.h"
 #endif
 
   #include "mversion.h"
 #endif
 
-char PortDevice[GSM_MAX_DEVICE_NAME_LENGTH]={0x00};
+static char PortDevice[GSM_MAX_DEVICE_NAME_LENGTH]={0x00};
 
 
-bool duringwrite;
+static bool duringwrite;
 
 #ifndef WIN32
 
 
 #ifndef WIN32
 
@@ -43,26 +42,22 @@ bool duringwrite;
   pthread_t selThread;
 #endif
 
   pthread_t selThread;
 #endif
 
-int device_portfd = -1;
+static int device_portfd = -1;
 
 /*
  * Structure to store the filedescriptor we use.
  *
  */
 
 /*
  * Structure to store the filedescriptor we use.
  *
  */
-int device_getfd(void)
+#ifdef DEBUG
+static int device_getfd(void)
 {
   return device_portfd;
 }
 {
   return device_portfd;
 }
+#endif /* DEBUG */
 
 
-int device_open(__const char *__file, int __with_odd_parity) {
+static int device_open(__const char *__file, int __with_odd_parity) {
 
   switch (CurrentConnectionType) {
 
   switch (CurrentConnectionType) {
-    case GCT_Tekram:
-      device_portfd = tekram_open(__file);
-      break;
-    case GCT_Irda:
-      device_portfd = irda_open();
-      break;
     default:
       device_portfd = serial_opendevice(__file, __with_odd_parity, true, false);
       break;
     default:
       device_portfd = serial_opendevice(__file, __with_odd_parity, true, false);
       break;
@@ -79,23 +74,26 @@ void device_close(void)
   //pthread_join(Thread, NULL);
 
   switch (CurrentConnectionType) {
   //pthread_join(Thread, NULL);
 
   switch (CurrentConnectionType) {
-    case GCT_Tekram: tekram_close(device_portfd); break;
-    case GCT_Irda  :   irda_close(device_portfd); break;
     default        : serial_close(device_portfd); break;
   }
 
   PortDevice[0]=0x00;
 }
 
     default        : serial_close(device_portfd); break;
   }
 
   PortDevice[0]=0x00;
 }
 
+#ifndef UCLINUX
+
 void device_reset(void) {
 }
 
 void device_reset(void) {
 }
 
+#endif /* UCLINUX */
+
+#ifdef DEBUG
+static void device_dumpserial(void);
+#endif /* DEBUG */
+
 void device_setdtrrts(int __dtr, int __rts)
 {
   switch (CurrentConnectionType) {
 void device_setdtrrts(int __dtr, int __rts)
 {
   switch (CurrentConnectionType) {
-    case GCT_Tekram:
-    case GCT_Irda:
-      break;
     default:
       serial_setdtrrts(device_portfd, __dtr, __rts);
 #ifdef DEBUG
     default:
       serial_setdtrrts(device_portfd, __dtr, __rts);
 #ifdef DEBUG
@@ -108,11 +106,6 @@ void device_setdtrrts(int __dtr, int __rts)
 void device_changespeed(int __speed)
 {
   switch (CurrentConnectionType) {
 void device_changespeed(int __speed)
 {
   switch (CurrentConnectionType) {
-    case GCT_Irda:
-      break;
-    case GCT_Tekram:
-      tekram_changespeed(device_portfd, __speed);
-      break;
     default:
       serial_changespeed(device_portfd, __speed);
 #ifdef DEBUG
     default:
       serial_changespeed(device_portfd, __speed);
 #ifdef DEBUG
@@ -122,11 +115,9 @@ void device_changespeed(int __speed)
   }
 }
 
   }
 }
 
-size_t device_read(__ptr_t __buf, size_t __nbytes)
+static size_t device_read(__ptr_t __buf, size_t __nbytes)
 {
   switch (CurrentConnectionType) {
 {
   switch (CurrentConnectionType) {
-    case GCT_Tekram: return (tekram_read(device_portfd, __buf, __nbytes)); break;
-    case GCT_Irda  : return (  irda_read(device_portfd, __buf, __nbytes)); break;
     default        : return (serial_read(device_portfd, __buf, __nbytes)); break;
   }
 }
     default        : return (serial_read(device_portfd, __buf, __nbytes)); break;
   }
 }
@@ -142,8 +133,6 @@ size_t device_write(__const __ptr_t __buf, size_t __n) {
 
   duringwrite=true;
   switch (CurrentConnectionType) {
 
   duringwrite=true;
   switch (CurrentConnectionType) {
-    case GCT_Irda  : mysize =   irda_write(device_portfd, __buf, __n); break;
-    case GCT_Tekram: mysize = tekram_write(device_portfd, __buf, __n); break;      
     default        : mysize = serial_write(device_portfd, __buf, __n); break;
   }
   duringwrite=false;
     default        : mysize = serial_write(device_portfd, __buf, __n); break;
   }
   duringwrite=false;
@@ -151,7 +140,7 @@ size_t device_write(__const __ptr_t __buf, size_t __n) {
 }
 
 #ifdef DEBUG
 }
 
 #ifdef DEBUG
-void device_dumpserial(void)
+static void device_dumpserial(void)
 {
   int PortFD;
   unsigned int Flags=0;
 {
   int PortFD;
   unsigned int Flags=0;
@@ -168,7 +157,7 @@ void device_dumpserial(void)
 }
 #endif /* DEBUG */
 
 }
 #endif /* DEBUG */
 
-void SigHandler(int status)
+static void SigHandler(int status)
 {
 
   unsigned char buffer[2048];
 {
 
   unsigned char buffer[2048];
@@ -223,6 +212,7 @@ bool StartConnection (char *port_device, bool with_odd_parity, GSM_ConnectionTyp
   struct sigaction sig_io;
 #endif
 
   struct sigaction sig_io;
 #endif
 
+#ifndef UCLINUX
 #ifdef DEBUG
       if ((strstr(GSM_Info->IrdaModels,"decode")!=NULL) &&  (CurrentConnectionType == GCT_Irda))
        {
 #ifdef DEBUG
       if ((strstr(GSM_Info->IrdaModels,"decode")!=NULL) &&  (CurrentConnectionType == GCT_Irda))
        {
@@ -230,6 +220,7 @@ bool StartConnection (char *port_device, bool with_odd_parity, GSM_ConnectionTyp
          return true;
        }
 #endif 
          return true;
        }
 #endif 
+#endif /* UCLINUX */
 
   if (PortDevice[0]!=0x00) return true;
 
 
   if (PortDevice[0]!=0x00) return true;
 
@@ -254,13 +245,12 @@ bool StartConnection (char *port_device, bool with_odd_parity, GSM_ConnectionTyp
   strcpy(text,"Connection ");
   switch (con) {
     case GCT_FBUS    :strcpy(text+strlen(text),"FBUS");break;
   strcpy(text,"Connection ");
   switch (con) {
     case GCT_FBUS    :strcpy(text+strlen(text),"FBUS");break;
-    case GCT_Infrared:strcpy(text+strlen(text),"infrared");break;
-    case GCT_Irda    :strcpy(text+strlen(text),"irda sockets");break;
+#ifndef UCLINUX
     case GCT_MBUS    :strcpy(text+strlen(text),"MBUS");break;
     case GCT_DLR3    :strcpy(text+strlen(text),"DLR3");break;
     case GCT_MBUS    :strcpy(text+strlen(text),"MBUS");break;
     case GCT_DLR3    :strcpy(text+strlen(text),"DLR3");break;
-    case GCT_Tekram  :strcpy(text+strlen(text),"Tekram");break;
     case GCT_AT      :strcpy(text+strlen(text),"AT");break;
     default          :strcpy(text+strlen(text),"unknown");break;
     case GCT_AT      :strcpy(text+strlen(text),"AT");break;
     default          :strcpy(text+strlen(text),"unknown");break;
+#endif /* UCLINUX */
   }
   strcpy(text+strlen(text),"\n");
   AppendLogText(text,false);
   }
   strcpy(text+strlen(text),"\n");
   AppendLogText(text,false);
@@ -415,11 +405,8 @@ bool StartConnection (char *port_device, bool with_odd_parity, GSM_ConnectionTyp
   strcpy(text,"Connection ");
   switch (con) {
     case GCT_FBUS    :strcpy(text+strlen(text),"FBUS");break;
   strcpy(text,"Connection ");
   switch (con) {
     case GCT_FBUS    :strcpy(text+strlen(text),"FBUS");break;
-    case GCT_Infrared:strcpy(text+strlen(text),"infrared");break;
-    case GCT_Irda    :strcpy(text+strlen(text),"irda sockets");break;
     case GCT_MBUS    :strcpy(text+strlen(text),"MBUS");break;
     case GCT_DLR3    :strcpy(text+strlen(text),"DLR3");break;
     case GCT_MBUS    :strcpy(text+strlen(text),"MBUS");break;
     case GCT_DLR3    :strcpy(text+strlen(text),"DLR3");break;
-    case GCT_Tekram  :strcpy(text+strlen(text),"Tekram");break;
     case GCT_AT      :strcpy(text+strlen(text),"AT");break;
     default          :strcpy(text+strlen(text),"unknown");break;
   }
     case GCT_AT      :strcpy(text+strlen(text),"AT");break;
     default          :strcpy(text+strlen(text),"unknown");break;
   }
index bc7e37e..ba66941 100644 (file)
 
 /* Structure to backup the setting of the terminal. */
 
 
 /* Structure to backup the setting of the terminal. */
 
-struct termios serial_termios;
+static struct termios serial_termios;
 
 /* Open the serial port and store the settings. */
 
 
 /* Open the serial port and store the settings. */
 
+#ifdef UCLINUX
+static
+#endif /* UCLINUX */
 int serial_open(__const char *__file, int __oflag) {
 
   int __fd;
 int serial_open(__const char *__file, int __oflag) {
 
   int __fd;
@@ -193,6 +196,8 @@ void serial_setdtrrts(int __fd, int __dtr, int __rts) {
 }
 
 
 }
 
 
+#ifndef UCLINUX
+
 int serial_select(int fd, struct timeval *timeout) {
 
   fd_set readfds;
 int serial_select(int fd, struct timeval *timeout) {
 
   fd_set readfds;
@@ -204,6 +209,8 @@ int serial_select(int fd, struct timeval *timeout) {
 
 }
 
 
 }
 
+#endif /* UCLINUX */
+
 
 /* Change the speed of the serial device. */
 
 
 /* Change the speed of the serial device. */
 
@@ -235,7 +242,7 @@ void serial_changespeed(int __fd, int __speed) {
   if (cfsetspeed(&t, speed) == -1)
        fprintf(stdout,_("Serial port speed setting failed\n"));
 #else
   if (cfsetspeed(&t, speed) == -1)
        fprintf(stdout,_("Serial port speed setting failed\n"));
 #else
-  cfsetspeed(&t, speed);
+  (void)cfsetspeed(&t, speed);
 #endif
 
   tcsetattr(__fd, TCSADRAIN, &t);
 #endif
 
   tcsetattr(__fd, TCSADRAIN, &t);
index 9908cc1..ad25708 100644 (file)
 
 #include "files/cfgreader.h"
 
 
 #include "files/cfgreader.h"
 
+#ifndef UCLINUX
+
 /* Read configuration information from a ".INI" style file */
 /* Read configuration information from a ".INI" style file */
-struct CFG_Header *CFG_ReadFile(char *filename)
+static struct CFG_Header *CFG_ReadFile(char *filename)
 {
         FILE *handle;
         char *line;
 {
         FILE *handle;
         char *line;
@@ -169,7 +171,7 @@ struct CFG_Header *CFG_ReadFile(char *filename)
 
 /*  Write configuration information to a config file */
 
 
 /*  Write configuration information to a config file */
 
-int CFG_WriteFile(struct CFG_Header *cfg, char *filename)
+static int CFG_WriteFile(struct CFG_Header *cfg, char *filename)
 {
   /* Not implemented - tricky to do and preserve comments */
 
 {
   /* Not implemented - tricky to do and preserve comments */
 
@@ -209,7 +211,7 @@ char *CFG_Get(struct CFG_Header *cfg, char *section, char *key)
 /*  Set the value of a key in a config file.  Return the new value if
     the section/key can be found, else return NULL.  */
 
 /*  Set the value of a key in a config file.  Return the new value if
     the section/key can be found, else return NULL.  */
 
-char *CFG_Set(struct CFG_Header *cfg, char *section, char *key, 
+static char *CFG_Set(struct CFG_Header *cfg, char *section, char *key, 
                     char *value)
 {
         struct CFG_Header *h;
                     char *value)
 {
         struct CFG_Header *h;
@@ -287,10 +289,21 @@ struct CFG_Header *CFG_FindGnokiirc()
        return cfg_info;
 }
 
        return cfg_info;
 }
 
+#endif /* UCLINUX */
+
 int CFG_ReadConfig(char **model, char **port, char **initlength,
 int CFG_ReadConfig(char **model, char **port, char **initlength,
-               char **connection, char **bindir, char **synchronizetime,
+               char **connection, char **bindir,
               bool isgnokiid)
 {
               bool isgnokiid)
 {
+#ifdef UCLINUX
+
+       *model=strdup(CONFIG_CFG_MODEL);
+       *port=strdup(CONFIG_CFG_PORT);
+       *initlength=strdup(CONFIG_CFG_INITLENGTH);
+       *connection=strdup("fbus");
+       *bindir=NULL;
+
+#else /* UCLINUX */
         struct CFG_Header *cfg_info;
 #ifdef WIN32
         char *DefaultPort            = "com2:";
         struct CFG_Header *cfg_info;
 #ifdef WIN32
         char *DefaultPort            = "com2:";
@@ -300,7 +313,6 @@ int CFG_ReadConfig(char **model, char **port, char **initlength,
         char *DefaultModel           = "auto";
         char *DefaultConnection      = "fbus";
         char *DefaultBindir          = "/usr/local/sbin/";
         char *DefaultModel           = "auto";
         char *DefaultConnection      = "fbus";
         char *DefaultBindir          = "/usr/local/sbin/";
-       char *DefaultSynchronizeTime = "yes";
        char *DefaultInitLength      = "30";
 
        char *section = "global";
        char *DefaultInitLength      = "30";
 
        char *section = "global";
@@ -309,7 +321,6 @@ int CFG_ReadConfig(char **model, char **port, char **initlength,
         (char *)*port = DefaultPort;
         (char *)*connection = DefaultConnection;
         (char *)*bindir = DefaultBindir;
         (char *)*port = DefaultPort;
         (char *)*connection = DefaultConnection;
         (char *)*bindir = DefaultBindir;
-        (char *)*synchronizetime = DefaultSynchronizeTime;
         (char *)*initlength = DefaultInitLength;
        
        cfg_info=CFG_FindGnokiirc();
         (char *)*initlength = DefaultInitLength;
        
        cfg_info=CFG_FindGnokiirc();
@@ -329,11 +340,9 @@ int CFG_ReadConfig(char **model, char **port, char **initlength,
         (char *)*bindir = CFG_Get(cfg_info, section, "bindir");
         if (!*bindir) (char *)*bindir = DefaultBindir;
 
         (char *)*bindir = CFG_Get(cfg_info, section, "bindir");
         if (!*bindir) (char *)*bindir = DefaultBindir;
 
-        (char *)*synchronizetime = CFG_Get(cfg_info, section, "synchronizetime");
-        if (!*synchronizetime) (char *)*synchronizetime = DefaultSynchronizeTime;
-
         (char *)*initlength = CFG_Get(cfg_info, section, "initlength");
         if (!*initlength) (char *)*initlength = "default";
         (char *)*initlength = CFG_Get(cfg_info, section, "initlength");
         if (!*initlength) (char *)*initlength = "default";
+#endif /* UCLINUX */
 
         return 0;
 }
 
         return 0;
 }
index 9e55249..9b3997a 100644 (file)
@@ -2,6 +2,8 @@
 
 /* embedding modified midifile.h and midifile.c into this file */
 
 
 /* embedding modified midifile.h and midifile.c into this file */
 
+#include "config.h"
+
 /***** midifile.h ******/
 
 struct MF {
 /***** midifile.h ******/
 
 struct MF {
index 99b73d7..4546e14 100644 (file)
@@ -18,6 +18,8 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -30,6 +32,7 @@
 
 #include "gsm-api.h"
 
 
 #include "gsm-api.h"
 
+#ifndef UCLINUX
 #include "newmodules/n6110.h"
 #include "newmodules/n7110.h"
 #include "newmodules/newat.h"
 #include "newmodules/n6110.h"
 #include "newmodules/n7110.h"
 #include "newmodules/newat.h"
   #include "newmodules/sniff/sniff.h"
 #endif
 #include "protocol/fbusirda.h"
   #include "newmodules/sniff/sniff.h"
 #endif
 #include "protocol/fbusirda.h"
+#endif /* UCLINUX */
 #include "protocol/fbus.h"
 #include "protocol/fbus.h"
+#ifndef UCLINUX
 #include "protocol/mbus.h"
 #include "protocol/at.h"
 #include "protocol/mbus.h"
 #include "protocol/at.h"
+#endif /* UCLINUX */
 #include "files/cfgreader.h"
 
 #ifndef WIN32
 #include "files/cfgreader.h"
 
 #ifndef WIN32
@@ -81,13 +87,16 @@ GSM_Protocol *Protocol;
 GSM_PhonebookEntry *CurrentPhonebookEntry;
 GSM_Error          CurrentPhonebookError;
 
 GSM_PhonebookEntry *CurrentPhonebookEntry;
 GSM_Error          CurrentPhonebookError;
 
+#ifndef UCLINUX
 GSM_SpeedDial      *CurrentSpeedDialEntry;
 GSM_Error          CurrentSpeedDialError;
 GSM_SpeedDial      *CurrentSpeedDialEntry;
 GSM_Error          CurrentSpeedDialError;
+#endif /* UCLINUX */
 
 unsigned char      Current_IMEI[GSM_MAX_IMEI_LENGTH];
 unsigned char      Current_Revision[GSM_MAX_REVISION_LENGTH];
 unsigned char      Current_Model[GSM_MAX_MODEL_LENGTH];
 
 
 unsigned char      Current_IMEI[GSM_MAX_IMEI_LENGTH];
 unsigned char      Current_Revision[GSM_MAX_REVISION_LENGTH];
 unsigned char      Current_Model[GSM_MAX_MODEL_LENGTH];
 
+#ifndef UCLINUX
 GSM_SMSMessage     *CurrentSMSMessage;
 GSM_Error          CurrentSMSMessageError;
 int                CurrentSMSPointer;
 GSM_SMSMessage     *CurrentSMSMessage;
 GSM_Error          CurrentSMSMessageError;
 int                CurrentSMSPointer;
@@ -99,10 +108,12 @@ int                CurrentSMSFoldersCount;
 GSM_OneSMSFolder   CurrentSMSFolder;
 GSM_Error          CurrentSMSFolderError;
 int                CurrentSMSFolderID;
 GSM_OneSMSFolder   CurrentSMSFolder;
 GSM_Error          CurrentSMSFolderError;
 int                CurrentSMSFolderID;
+#endif /* UCLINUX */
 
 GSM_MemoryStatus   *CurrentMemoryStatus;
 GSM_Error          CurrentMemoryStatusError;
 
 
 GSM_MemoryStatus   *CurrentMemoryStatus;
 GSM_Error          CurrentMemoryStatusError;
 
+#ifndef UCLINUX
 GSM_NetworkInfo    *CurrentNetworkInfo;
 GSM_Error          CurrentNetworkInfoError;
 
 GSM_NetworkInfo    *CurrentNetworkInfo;
 GSM_Error          CurrentNetworkInfoError;
 
@@ -119,6 +130,8 @@ GSM_SecurityCode   *CurrentSecurityCode;
 GSM_DateTime       *CurrentDateTime;
 GSM_Error          CurrentDateTimeError;
 
 GSM_DateTime       *CurrentDateTime;
 GSM_Error          CurrentDateTimeError;
 
+GSM_Error          CurrentResetPhoneSettingsError;
+
 GSM_DateTime       *CurrentAlarm;
 GSM_Error          CurrentAlarmError;
 
 GSM_DateTime       *CurrentAlarm;
 GSM_Error          CurrentAlarmError;
 
@@ -131,17 +144,20 @@ GSM_Error          CurrentCalendarNotesInfoError;
 GSM_Error          CurrentSetDateTimeError;
 GSM_Error          CurrentSetAlarmError;
 
 GSM_Error          CurrentSetDateTimeError;
 GSM_Error          CurrentSetAlarmError;
 
+int                *CurrentFirstCalendarFreePos;
+GSM_Error          CurrentFirstCalendarFreePosError;
+#endif /* UCLINUX */
+
 GSM_Error          CurrentEnableExtendedCommandsError;
 
 int                CurrentRFLevel,
                    CurrentBatteryLevel,
                    CurrentPowerSource;
 
 GSM_Error          CurrentEnableExtendedCommandsError;
 
 int                CurrentRFLevel,
                    CurrentBatteryLevel,
                    CurrentPowerSource;
 
+#ifndef UCLINUX
 int                CurrentDisplayStatus;
 GSM_Error          CurrentDisplayStatusError;
 
 int                CurrentDisplayStatus;
 GSM_Error          CurrentDisplayStatusError;
 
-GSM_Error          CurrentResetPhoneSettingsError;
-
 char               *CurrentNetmonitor;
 GSM_Error          CurrentNetmonitorError;
 
 char               *CurrentNetmonitor;
 GSM_Error          CurrentNetmonitorError;
 
@@ -164,17 +180,21 @@ int                CurrentPressKeyEvent;
 GSM_Error          CurrentPressKeyError;
 
 GSM_Error          CurrentPlayToneError=GE_UNKNOWN;
 GSM_Error          CurrentPressKeyError;
 
 GSM_Error          CurrentPlayToneError=GE_UNKNOWN;
+#endif /* UCLINUX */
 
 GSM_Error          CurrentDialVoiceError;
 
 
 GSM_Error          CurrentDialVoiceError;
 
+#ifndef UCLINUX
 GSM_Error          CurrentGetOperatorNameError;
 GSM_Network        *CurrentGetOperatorNameNetwork;
 GSM_Error          CurrentSetOperatorNameError;
 GSM_Error          CurrentGetOperatorNameError;
 GSM_Network        *CurrentGetOperatorNameNetwork;
 GSM_Error          CurrentSetOperatorNameError;
+#endif /* UCLINUX */
 
 GSM_Error          CurrentGetIMEIError;
 
 GSM_Error          CurrentGetHWError;
 
 
 GSM_Error          CurrentGetIMEIError;
 
 GSM_Error          CurrentGetHWError;
 
+#ifndef UCLINUX
 unsigned char      CurrentPPS[4];
 GSM_Error          CurrentProductProfileSettingsError;
 
 unsigned char      CurrentPPS[4];
 GSM_Error          CurrentProductProfileSettingsError;
 
@@ -184,9 +204,11 @@ GSM_Error          CurrentBinRingtoneError;
 GSM_BinRingtone    *CurrentGetBinRingtone=NULL;
 
 GSM_Error          CurrentRingtoneError;
 GSM_BinRingtone    *CurrentGetBinRingtone=NULL;
 
 GSM_Error          CurrentRingtoneError;
+#endif /* UCLINUX */
 
 GSM_Error          CurrentMagicError;
 
 
 GSM_Error          CurrentMagicError;
 
+#ifndef UCLINUX
 GSM_Error          CurrentSimlockInfoError;
 GSM_AllSimlocks    *CurrentSimLock;
 
 GSM_Error          CurrentSimlockInfoError;
 GSM_AllSimlocks    *CurrentSimLock;
 
@@ -201,6 +223,7 @@ GSM_Error          CurrentCallDivertError;
 GSM_CallDivert    *CurrentCallDivert;
 
 char              *CurrentManufacturer;
 GSM_CallDivert    *CurrentCallDivert;
 
 char              *CurrentManufacturer;
+#endif /* UCLINUX */
 
 /* This is the connection type used in gnokii. */
 GSM_ConnectionType CurrentConnectionType;
 
 /* This is the connection type used in gnokii. */
 GSM_ConnectionType CurrentConnectionType;
@@ -220,8 +243,13 @@ bool CurrentLinkOK;
 
 bool CurrentRequestTerminate;
 
 
 bool CurrentRequestTerminate;
 
+#ifndef UCLINUX
 bool CurrentDisableKeepAlive;
 bool CurrentDisableKeepAlive;
+#endif /* UCLINUX */
 
 
+#ifdef UCLINUX
+static
+#endif /* UCLINUX */
 bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType connection) {
 
   bool found_match=false;
 bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType connection) {
 
   bool found_match=false;
@@ -229,6 +257,7 @@ bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType co
   if (strstr(InfoToCheck.FBUSModels, model) != NULL) {
     if (connection==GCT_FBUS) found_match=true;
   }
   if (strstr(InfoToCheck.FBUSModels, model) != NULL) {
     if (connection==GCT_FBUS) found_match=true;
   }
+#ifndef UCLINUX
   if (strstr(InfoToCheck.MBUSModels, model) != NULL) {
     if (connection==GCT_MBUS) found_match=true;
   }
   if (strstr(InfoToCheck.MBUSModels, model) != NULL) {
     if (connection==GCT_MBUS) found_match=true;
   }
@@ -247,10 +276,13 @@ bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType co
   if (strstr(InfoToCheck.TekramModels, model) != NULL) {
     if (connection==GCT_Tekram) found_match=true;
   }
   if (strstr(InfoToCheck.TekramModels, model) != NULL) {
     if (connection==GCT_Tekram) found_match=true;
   }
+#endif /* UCLINUX */
 
   return found_match;
 }
  
 
   return found_match;
 }
  
+#ifndef UCLINUX
+
 GSM_Error TryNewNokia(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame)) {
   int InitLength;
   int count;
 GSM_Error TryNewNokia(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame)) {
   int InitLength;
   int count;
@@ -298,6 +330,7 @@ GSM_Error TryNewNokia(char *model, char *device, char *initlength, GSM_Connectio
   while (N6110_GetModel(phonemodel) != GE_NONE)
     sleep(1);
 
   while (N6110_GetModel(phonemodel) != GE_NONE)
     sleep(1);
 
+#ifndef UCLINUX
   if (!strcmp(phonemodel,"NPE-3") || !strcmp(phonemodel,"NSE-5"))
   {
     GSM->Terminate();      
   if (!strcmp(phonemodel,"NPE-3") || !strcmp(phonemodel,"NSE-5"))
   {
     GSM->Terminate();      
@@ -308,9 +341,14 @@ GSM_Error TryNewNokia(char *model, char *device, char *initlength, GSM_Connectio
     GSM_LinkOK = &CurrentLinkOK;
     return GE_NONE;
   }
     GSM_LinkOK = &CurrentLinkOK;
     return GE_NONE;
   }
+#endif /* UCLINUX */
 
   return GE_NONE;
 }
 
   return GE_NONE;
 }
+#endif /* UCLINUX */
+
+extern GSM_Information N6110_Information;
+extern GSM_Functions   N6110_Functions;
 
 GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), char* SynchronizeTime)
 {
 
 GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), char* SynchronizeTime)
 {
@@ -318,9 +356,11 @@ GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_Connec
   
   GSM_ConnectionType connection2;
 
   
   GSM_ConnectionType connection2;
 
+#ifndef UCLINUX
   struct tm *now;
   time_t nowh;
   GSM_DateTime Date;
   struct tm *now;
   time_t nowh;
   GSM_DateTime Date;
+#endif /* UCLINUX */
   GSM_Error error;
   
   connection2=connection;
   GSM_Error error;
   
   connection2=connection;
@@ -328,17 +368,22 @@ GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_Connec
   CurrentRLP_RXCallback = rlp_callback;
   CurrentCallPassup=NULL;
   CurrentPhonebookEntry=NULL;
   CurrentRLP_RXCallback = rlp_callback;
   CurrentCallPassup=NULL;
   CurrentPhonebookEntry=NULL;
+#ifndef UCLINUX
   CurrentNetworkInfo = NULL;
   CurrentGetBitmap=NULL;
   CurrentPlayToneError=GE_UNKNOWN;
   strcpy(CurrentIncomingCall," ");
   CurrentGetBinRingtone=NULL;
   CurrentNetworkInfo=NULL;
   CurrentNetworkInfo = NULL;
   CurrentGetBitmap=NULL;
   CurrentPlayToneError=GE_UNKNOWN;
   strcpy(CurrentIncomingCall," ");
   CurrentGetBinRingtone=NULL;
   CurrentNetworkInfo=NULL;
+#endif /* UCLINUX */
   CurrentRequestTerminate=false;
   CurrentRequestTerminate=false;
+#ifndef UCLINUX
   CurrentDisableKeepAlive=false;
   CurrentCalendarNotesInfo.HowMany=2000;
   CurrentDisableKeepAlive=false;
   CurrentCalendarNotesInfo.HowMany=2000;
+#endif /* UCLINUX */
   CurrentMagicError = GE_BUSY;  
   
   CurrentMagicError = GE_BUSY;  
   
+#ifndef UCLINUX
   if (!strcmp(model,"auto")) {
 
     /* For now */
   if (!strcmp(model,"auto")) {
 
     /* For now */
@@ -395,10 +440,13 @@ GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_Connec
       Protocol = &MBUS_Functions;
       CurrentConnectionType=GCT_MBUS;    
       connection2=GCT_MBUS;
       Protocol = &MBUS_Functions;
       CurrentConnectionType=GCT_MBUS;    
       connection2=GCT_MBUS;
+#ifndef UCLINUX
       if (TryNewNokia(model,device,initlength,CurrentConnectionType,rlp_callback)==GE_NONE)
       {
         found_match=true;
       if (TryNewNokia(model,device,initlength,CurrentConnectionType,rlp_callback)==GE_NONE)
       {
         found_match=true;
-      } else {
+      } else
+#endif /* UCLINUX */
+                               {
         GSM->Terminate();      
       }
     }
         GSM->Terminate();      
       }
     }
@@ -407,7 +455,10 @@ GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_Connec
 
     usleep(50);
         
 
     usleep(50);
         
-  } else {
+  } else
+#endif /* UCLINUX */
+               {
+#ifndef UCLINUX
 #ifdef DEBUG
     if (CheckModel (Nsniff_Information, model, connection)) {
       /* Set pointers to relevant addresses */
 #ifdef DEBUG
     if (CheckModel (Nsniff_Information, model, connection)) {
       /* Set pointers to relevant addresses */
@@ -417,6 +468,7 @@ GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_Connec
       found_match=true;
     }
 #endif
       found_match=true;
     }
 #endif
+#endif /* UCLINUX */
 
     if (CheckModel (N6110_Information, model, connection)) {
       /* Set pointers to relevant addresses */
 
     if (CheckModel (N6110_Information, model, connection)) {
       /* Set pointers to relevant addresses */
@@ -425,6 +477,7 @@ GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_Connec
       GSM_LinkOK = &CurrentLinkOK;
       found_match=true;
     }
       GSM_LinkOK = &CurrentLinkOK;
       found_match=true;
     }
+#ifndef UCLINUX
     if (CheckModel (N7110_Information, model, connection)) {
       /* Set pointers to relevant addresses */
       GSM = &N7110_Functions;
     if (CheckModel (N7110_Information, model, connection)) {
       /* Set pointers to relevant addresses */
       GSM = &N7110_Functions;
@@ -439,10 +492,12 @@ GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_Connec
       GSM_LinkOK = &CurrentLinkOK;
       found_match=true;
     }
       GSM_LinkOK = &CurrentLinkOK;
       found_match=true;
     }
+#endif /* UCLINUX */
 
     if (found_match) {
       switch (connection) {
         case GCT_FBUS    : Protocol = &FBUS_Functions;    break;
 
     if (found_match) {
       switch (connection) {
         case GCT_FBUS    : Protocol = &FBUS_Functions;    break;
+#ifndef UCLINUX
         case GCT_Infrared: Protocol = &FBUS_Functions;    break;
         case GCT_Tekram  : Protocol = &FBUS_Functions;    break;
         case GCT_DLR3    : Protocol = &FBUS_Functions;    break;
         case GCT_Infrared: Protocol = &FBUS_Functions;    break;
         case GCT_Tekram  : Protocol = &FBUS_Functions;    break;
         case GCT_DLR3    : Protocol = &FBUS_Functions;    break;
@@ -450,6 +505,7 @@ GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_Connec
         case GCT_Irda    : Protocol = &FBUSIRDA_Functions;break;
         case GCT_AT      : Protocol = &AT_Functions;      break;
         case GCT_Default : Protocol = NULL;               break;
         case GCT_Irda    : Protocol = &FBUSIRDA_Functions;break;
         case GCT_AT      : Protocol = &AT_Functions;      break;
         case GCT_Default : Protocol = NULL;               break;
+#endif /* UCLINUX */
       }
     } else
       return GE_NOTSUPPORTED;
       }
     } else
       return GE_NOTSUPPORTED;
@@ -459,6 +515,7 @@ GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_Connec
   /* Now call model specific initialisation code. */
   error=(GSM->Initialise(device, initlength, connection2, rlp_callback));
 
   /* Now call model specific initialisation code. */
   error=(GSM->Initialise(device, initlength, connection2, rlp_callback));
 
+#ifndef UCLINUX
   /* RTH: FIXME: second try for Irda (6210 only?)*/
   if ( error!=GE_NONE && connection == GCT_Irda)
   {
   /* RTH: FIXME: second try for Irda (6210 only?)*/
   if ( error!=GE_NONE && connection == GCT_Irda)
   {
@@ -468,7 +525,9 @@ GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_Connec
    device_close();
    error=(GSM->Initialise(device, initlength, connection2, rlp_callback));
   }
    device_close();
    error=(GSM->Initialise(device, initlength, connection2, rlp_callback));
   }
+#endif /* UCLINUX */
 
 
+#ifndef UCLINUX
   if (error==GE_NONE && !strcmp(SynchronizeTime,"yes"))
   {
     nowh=time(NULL);
   if (error==GE_NONE && !strcmp(SynchronizeTime,"yes"))
   {
     nowh=time(NULL);
@@ -499,10 +558,13 @@ GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_Connec
     /* FIXME: Error checking should be here. */
     GSM->SetDateTime(&Date);
   }
     /* FIXME: Error checking should be here. */
     GSM->SetDateTime(&Date);
   }
+#endif /* UCLINUX */
 
   return error;
 }
 
 
   return error;
 }
 
+#ifndef UCLINUX
+
 GSM_Error Unimplemented(void)
 {
        return GE_NOTIMPLEMENTED;
 GSM_Error Unimplemented(void)
 {
        return GE_NOTIMPLEMENTED;
@@ -513,6 +575,8 @@ GSM_Error NotSupported(void)
        return GE_NOTSUPPORTED;
 }
 
        return GE_NOTSUPPORTED;
 }
 
+#endif /* UCLINUX */
+
 /* Applications should call N6110_Terminate to shut down the N6110 thread and
    close the serial port. */
 void NULL_Terminate(void)
 /* Applications should call N6110_Terminate to shut down the N6110 thread and
    close the serial port. */
 void NULL_Terminate(void)
@@ -578,12 +642,14 @@ GSM_ConnectionType GetConnectionTypeFromString(char *Connection) {
 
   GSM_ConnectionType connection=GCT_FBUS;
 
 
   GSM_ConnectionType connection=GCT_FBUS;
 
+#ifndef UCLINUX
   if (!strcmp(Connection, "irda"))     connection=GCT_Irda;
   if (!strcmp(Connection, "infrared")) connection=GCT_Infrared;
   if (!strcmp(Connection, "mbus"))     connection=GCT_MBUS;
   if (!strcmp(Connection, "dlr3"))     connection=GCT_DLR3;
   if (!strcmp(Connection, "at"))       connection=GCT_AT;
   if (!strcmp(Connection, "tekram210"))connection=GCT_Tekram;
   if (!strcmp(Connection, "irda"))     connection=GCT_Irda;
   if (!strcmp(Connection, "infrared")) connection=GCT_Infrared;
   if (!strcmp(Connection, "mbus"))     connection=GCT_MBUS;
   if (!strcmp(Connection, "dlr3"))     connection=GCT_DLR3;
   if (!strcmp(Connection, "at"))       connection=GCT_AT;
   if (!strcmp(Connection, "tekram210"))connection=GCT_Tekram;
+#endif /* UCLINUX */
   
   return connection;
 }
   
   return connection;
 }
@@ -694,7 +760,7 @@ static OnePhoneModel allmodels[] = {
 {""    ,""     ,{      0,       0,        0,      0,     0,       0,     0,        0,      0,       0,     0,      0,        0,       0,       0,        0,    0}}
 };
 
 {""    ,""     ,{      0,       0,        0,      0,     0,       0,     0,        0,      0,       0,     0,      0,        0,       0,       0,        0,    0}}
 };
 
-OnePhoneModel *GetPhoneModelData (const char *num)
+static OnePhoneModel *GetPhoneModelData (const char *num)
 {
        register int i = 0;
 
 {
        register int i = 0;
 
@@ -726,6 +792,7 @@ int GetModelFeature (featnum_index num)
   return (GetPhoneModelData(model)->features[num]);
 }
 
   return (GetPhoneModelData(model)->features[num]);
 }
 
+#ifndef UCLINUX
 int LogAvailable=-1; //-1 not checked earlier, 0 not, 1 yes
 char *logfilename;
 
 int LogAvailable=-1; //-1 not checked earlier, 0 not, 1 yes
 char *logfilename;
 
@@ -790,3 +857,4 @@ bool AppendLogText(u8 *buffer,bool format)
 {
   return AppendLog(buffer,strlen(buffer),format);
 }
 {
   return AppendLog(buffer,strlen(buffer),format);
 }
+#endif /* UCLINUX */
index 1e96f8b..3dae76c 100644 (file)
@@ -10,6 +10,8 @@
   
 */
 
   
 */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index eadaff6..7bef750 100644 (file)
@@ -10,6 +10,8 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index 7baaaa9..26c1e67 100644 (file)
@@ -8,6 +8,8 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.h>
 #include <string.h>
 
@@ -24,6 +26,9 @@
 #define NUMBER_OF_7_BIT_ALPHABET_ELEMENTS 128
 
 #ifndef USE_NLS        
 #define NUMBER_OF_7_BIT_ALPHABET_ELEMENTS 128
 
 #ifndef USE_NLS        
+
+#ifndef UCLINUX
+
   static unsigned char GSM_DefaultAlphabet[NUMBER_OF_7_BIT_ALPHABET_ELEMENTS] = {
 
        /* ETSI GSM 03.38, version 6.0.1, section 6.2.1; Default alphabet */
   static unsigned char GSM_DefaultAlphabet[NUMBER_OF_7_BIT_ALPHABET_ELEMENTS] = {
 
        /* ETSI GSM 03.38, version 6.0.1, section 6.2.1; Default alphabet */
        'x',  'y',  'z',  0xe4, 0xf6, 0xf1, 0xfc, 0xe0
   };
 
        'x',  'y',  'z',  0xe4, 0xf6, 0xf1, 0xfc, 0xe0
   };
 
+#endif /* UCLINUX */
+
   #ifndef WIN32
     /*Simple UNICODE decoding and encoding from/to iso-8859-2
     First version prepared by Martin Kacer <M.Kacer@sh.cvut.cz>
 
     Following table contains triplets:
     first unicode byte, second unicode byte, iso-8859-2 character*/
   #ifndef WIN32
     /*Simple UNICODE decoding and encoding from/to iso-8859-2
     First version prepared by Martin Kacer <M.Kacer@sh.cvut.cz>
 
     Following table contains triplets:
     first unicode byte, second unicode byte, iso-8859-2 character*/
-    unsigned char unicode_table[][3] =
+    static unsigned char unicode_table[][3] =
     {
        /* C< D< E< N< R< S< T< Uo Z< */
        {0x01, 0x0C, 0xC8}, {0x01, 0x0E, 0xCF}, {0x01, 0x1A, 0xCC},
     {
        /* C< D< E< N< R< S< T< Uo Z< */
        {0x01, 0x0C, 0xC8}, {0x01, 0x0E, 0xCF}, {0x01, 0x1A, 0xCC},
     };
   #endif
 
     };
   #endif
 
+#ifndef UCLINUX
+
 unsigned char EncodeWithDefaultAlphabet(unsigned char value)
 {
        unsigned char i;
 unsigned char EncodeWithDefaultAlphabet(unsigned char value)
 {
        unsigned char i;
@@ -137,6 +146,11 @@ unsigned char DecodeWithDefaultAlphabet(unsigned char value)
        return GSM_DefaultAlphabet[value];
 }
 
        return GSM_DefaultAlphabet[value];
 }
 
+#endif /* UCLINUX */
+
+#ifdef UCLINUX
+static
+#endif /* UCLINUX */
 wchar_t EncodeWithUnicodeAlphabet(unsigned char value)
 {
        wchar_t retval;
 wchar_t EncodeWithUnicodeAlphabet(unsigned char value)
 {
        wchar_t retval;
@@ -157,6 +171,9 @@ wchar_t EncodeWithUnicodeAlphabet(unsigned char value)
        return retval;
 }
 
        return retval;
 }
 
+#ifdef UCLINUX
+static
+#endif /* UCLINUX */
 unsigned char DecodeWithUnicodeAlphabet(wchar_t value)
 {
        unsigned char retval;
 unsigned char DecodeWithUnicodeAlphabet(wchar_t value)
 {
        unsigned char retval;
@@ -177,6 +194,8 @@ unsigned char DecodeWithUnicodeAlphabet(wchar_t value)
 
 #else
 
 
 #else
 
+#ifndef UCLINUX
+
   /* ETSI GSM 03.38, version 6.0.1, section 6.2.1; Default alphabet */
   unsigned char GSM_DefaultAlphabetUnicode[NUMBER_OF_7_BIT_ALPHABET_ELEMENTS+1][2] =
   {
   /* ETSI GSM 03.38, version 6.0.1, section 6.2.1; Default alphabet */
   unsigned char GSM_DefaultAlphabetUnicode[NUMBER_OF_7_BIT_ALPHABET_ELEMENTS+1][2] =
   {
@@ -259,8 +278,12 @@ unsigned char DecodeWithUnicodeAlphabet(wchar_t value)
        else return retval;
 }
 
        else return retval;
 }
 
+#endif /* UCLINUX */
+
 #endif
 
 #endif
 
+#ifndef UCLINUX
+
 void DecodeDefault (unsigned char* dest, const unsigned char* src, int len)
 {
        int i;
 void DecodeDefault (unsigned char* dest, const unsigned char* src, int len)
 {
        int i;
@@ -279,6 +302,8 @@ void EncodeDefault (unsigned char* dest, const unsigned char* src, int len)
        return;
 }
 
        return;
 }
 
+#endif /* UCLINUX */
+
 void DecodeUnicode (unsigned char* dest, const unsigned char* src, int len)
 {
        int i;
 void DecodeUnicode (unsigned char* dest, const unsigned char* src, int len)
 {
        int i;
@@ -304,6 +329,9 @@ void EncodeUnicode (unsigned char* dest, const unsigned char* src, int len)
        }
 }
 
        }
 }
 
+#ifdef UCLINUX
+static
+#endif /* UCLINUX */
 bool EncodeWithUTF8Alphabet(u8 mychar, u8 *ret1, u8 *ret2)
 {
       u8 mychar1,mychar2,mychar3,mychar4;
 bool EncodeWithUTF8Alphabet(u8 mychar, u8 *ret1, u8 *ret2)
 {
       u8 mychar1,mychar2,mychar3,mychar4;
@@ -334,6 +362,8 @@ bool EncodeWithUTF8Alphabet(u8 mychar, u8 *ret1, u8 *ret2)
       return false;
 }
 
       return false;
 }
 
+#ifndef UCLINUX
+
 void DecodeWithUTF8Alphabet(u8 mychar3, u8 mychar4, u8 *ret)
 {
     u8 mychar1, mychar2;
 void DecodeWithUTF8Alphabet(u8 mychar3, u8 mychar4, u8 *ret)
 {
     u8 mychar1, mychar2;
@@ -356,6 +386,8 @@ void DecodeWithUTF8Alphabet(u8 mychar3, u8 mychar4, u8 *ret)
     j=-1;
 }
 
     j=-1;
 }
 
+#endif /* UCLINUX */
+
 void EncodeUTF8 (unsigned char* dest, const unsigned char* src, int len)
 {
        int i,j=0,z;
 void EncodeUTF8 (unsigned char* dest, const unsigned char* src, int len)
 {
        int i,j=0,z;
@@ -373,6 +405,8 @@ void EncodeUTF8 (unsigned char* dest, const unsigned char* src, int len)
        dest[j++]=0;
 }
 
        dest[j++]=0;
 }
 
+#ifndef UCLINUX
+
 void DecodeUTF8 (unsigned char* dest, const unsigned char* src, int len)
 {
        int i=0,j=0;
 void DecodeUTF8 (unsigned char* dest, const unsigned char* src, int len)
 {
        int i=0,j=0;
@@ -471,13 +505,12 @@ void EncodeBCD (unsigned char* dest, const unsigned char* src, int len, bool fil
 
 unsigned char EncodeWithBCDAlphabet(int value)
 {
 
 unsigned char EncodeWithBCDAlphabet(int value)
 {
-  div_t division;
-
-  division=div(value,10);
-  return ( ( (value-division.quot*10) & 0x0f) << 4) | (division.quot & 0xf);
+  return ((value%10) << 4) | ((value/10) & 0xf);
 }
 
 int DecodeWithBCDAlphabet(unsigned char value)
 {
        return 10*(value & 0x0f)+(value >> 4);
 }
 }
 
 int DecodeWithBCDAlphabet(unsigned char value)
 {
        return 10*(value & 0x0f)+(value >> 4);
 }
+
+#endif /* UCLINUX */
index 589dcb3..13756b0 100644 (file)
@@ -8,14 +8,16 @@
 
 */
 
 
 */
 
-#include <string.h>\r
-#include <time.h>\r
-\r
-#include "misc.h"\r
-#include "gsm-datetime.h"\r
-#include "gsm-common.h"\r
+#include "config.h"
 
 
-char DayOfWeekChar;
+#include <string.h>
+#include <time.h>
+
+#include "misc.h"
+#include "gsm-datetime.h"
+#include "gsm-common.h"
+
+static char DayOfWeekChar;
 
 /* Based on article in Polish PC-Kurier 8/1998 page 104 */
 /* Archive on http://www.pckurier.pl */
 
 /* Based on article in Polish PC-Kurier 8/1998 page 104 */
 /* Archive on http://www.pckurier.pl */
@@ -37,7 +39,9 @@ char *DayOfWeek (int year, int month, int day) {
     case 6: strcpy(&DayOfWeekChar,"Sat"); break;
   }
   return &DayOfWeekChar;
     case 6: strcpy(&DayOfWeekChar,"Sat"); break;
   }
   return &DayOfWeekChar;
-}\r
+}
+
+#ifndef UCLINUX
 
 /* GetMachineDateTime ----------------------------------------------------------
 Purpose:    Gets system date and time.
 
 /* GetMachineDateTime ----------------------------------------------------------
 Purpose:    Gets system date and time.
@@ -47,42 +51,44 @@ Output:   date - System date in the format "aaaa-mm-gg".
           time  - System time in the format "hh:mm:ss".
 Return:  -
 ----------------------------------------------------------------------------- */
           time  - System time in the format "hh:mm:ss".
 Return:  -
 ----------------------------------------------------------------------------- */
-void GetMachineDateTime( char nowdate[], char nowtime[] )\r
-{\r
-  struct tm *now;\r
-  time_t nowh;\r
-\r
-  nowh=time(NULL);\r
-  now=localtime(&nowh);\r
-\r
-  /* I have 100 (for 2000) Year now :-) */\r
-  if (now->tm_year>99 && now->tm_year<1900) {\r
-    now->tm_year=now->tm_year+1900;\r
-  }\r
-\r
+static void GetMachineDateTime( char nowdate[], char nowtime[] )
+{
+  struct tm *now;
+  time_t nowh;
+
+  nowh=time(NULL);
+  now=localtime(&nowh);
+
+  /* I have 100 (for 2000) Year now :-) */
+  if (now->tm_year>99 && now->tm_year<1900) {
+    now->tm_year=now->tm_year+1900;
+  }
+
   sprintf(nowdate,"%04d-%02d-%02d",now->tm_year,now->tm_mon+1,now->tm_mday);
   sprintf(nowdate,"%04d-%02d-%02d",now->tm_year,now->tm_mon+1,now->tm_mday);
-  sprintf(nowtime, "%02d:%02d:%02d",now->tm_hour,now->tm_min,now->tm_sec);\r
-\r
-}\r
-\r
-void EncodeDateTime(unsigned char* buffer, GSM_DateTime *datetime)\r
-{\r
-  buffer[0] = datetime->Year / 256;\r
-  buffer[1] = datetime->Year % 256;\r
-  buffer[2] = datetime->Month;\r
-  buffer[3] = datetime->Day;\r
-\r
-  buffer[4] = datetime->Hour;\r
-  buffer[5] = datetime->Minute;\r
-}\r
-\r
-void DecodeDateTime(unsigned char* buffer, GSM_DateTime *datetime)\r
-{\r
-  datetime->Year = buffer[0] * 256 + buffer[1];\r
-  datetime->Month = buffer[2];\r
-  datetime->Day = buffer[3];\r
-\r
-  datetime->Hour = buffer[4];\r
-  datetime->Minute = buffer[5];\r
-  datetime->Second = buffer[6];\r
-}\r
+  sprintf(nowtime, "%02d:%02d:%02d",now->tm_hour,now->tm_min,now->tm_sec);
+
+}
+
+void EncodeDateTime(unsigned char* buffer, GSM_DateTime *datetime)
+{
+  buffer[0] = datetime->Year / 256;
+  buffer[1] = datetime->Year % 256;
+  buffer[2] = datetime->Month;
+  buffer[3] = datetime->Day;
+
+  buffer[4] = datetime->Hour;
+  buffer[5] = datetime->Minute;
+}
+
+#endif /* UCLINUX */
+
+void DecodeDateTime(unsigned char* buffer, GSM_DateTime *datetime)
+{
+  datetime->Year = buffer[0] * 256 + buffer[1];
+  datetime->Month = buffer[2];
+  datetime->Day = buffer[3];
+
+  datetime->Hour = buffer[4];
+  datetime->Minute = buffer[5];
+  datetime->Second = buffer[6];
+}
index b36bcf5..f0379f5 100644 (file)
 
 */
 
 
 */
 
+#include "config.h"
+
 #include <string.h>
 
 #include "gsm-common.h"
 #include "gsm-networks.h"
 #include "gsm-coding.h"
 
 #include <string.h>
 
 #include "gsm-common.h"
 #include "gsm-networks.h"
 #include "gsm-coding.h"
 
-GSM_Country GSM_Countries[] =
+#ifndef UCLINUX
+
+static GSM_Country GSM_Countries[] =
 {
   { "202", "Greece" },
   { "204", "Netherlands" },
 {
   { "202", "Greece" },
   { "204", "Netherlands" },
@@ -454,7 +458,7 @@ char *GSM_GetCountryName(char *CountryCode)
   return GSM_Countries[index].Name;
 }
 
   return GSM_Countries[index].Name;
 }
 
-char *GSM_GetCountryCode(char *CountryName)
+static char *GSM_GetCountryCode(char *CountryName)
 {
 
   int index=0;
 {
 
   int index=0;
@@ -480,3 +484,5 @@ void DecodeNetworkCode(unsigned char* buffer, unsigned char* output)
     output[4]=output[3];
     output[3]=' ';
 }
     output[4]=output[3];
     output[3]=' ';
 }
+
+#endif /* UCLINUX */
index bf0fdd3..d3be5bc 100644 (file)
@@ -10,6 +10,8 @@
   
 */
 
   
 */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index 5a35034..cfc0061 100644 (file)
@@ -8,6 +8,8 @@
        
 */
 
        
 */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -18,7 +20,7 @@
 #include "gsm-coding.h"
 
 /* User data headers */
 #include "gsm-coding.h"
 
 /* User data headers */
-GSM_UDHHeader UDHHeaders[] = {
+static GSM_UDHHeader UDHHeaders[] = {
   { GSM_ConcatenatedMessages, 0x05, "\x00\x03\x01\x00\x00" },
       /* See GSM 03.40 section 9.2.3.24.1 */
   { GSM_DisableVoice,         0x04, "\x01\x02\x00\x00" },
   { GSM_ConcatenatedMessages, 0x05, "\x00\x03\x01\x00\x00" },
       /* See GSM 03.40 section 9.2.3.24.1 */
   { GSM_DisableVoice,         0x04, "\x01\x02\x00\x00" },
@@ -67,7 +69,8 @@ GSM_UDHHeader UDHHeaders[] = {
 
 #define ByteMask ((1 << Bits) - 1)
 
 
 #define ByteMask ((1 << Bits) - 1)
 
-int GSM_PackSevenBitsToEight(int offset, unsigned char *input, unsigned char *output)
+#ifndef UCLINUX
+static int GSM_PackSevenBitsToEight(int offset, unsigned char *input, unsigned char *output)
 {
         unsigned char *OUT = output; /* Current pointer to the output buffer */
         unsigned char *IN  = input;  /* Current pointer to the input buffer */
 {
         unsigned char *OUT = output; /* Current pointer to the output buffer */
         unsigned char *IN  = input;  /* Current pointer to the input buffer */
@@ -259,7 +262,7 @@ GSM_Error GSM_EncodeSMSDateTime(GSM_DateTime *DT, unsigned char *req)
 }
 
 /* See GSM 03.40 section 9.2.3.11 */
 }
 
 /* See GSM 03.40 section 9.2.3.11 */
-GSM_Error GSM_DecodeSMSDateTime(GSM_DateTime *DT, unsigned char *req)
+static GSM_Error GSM_DecodeSMSDateTime(GSM_DateTime *DT, unsigned char *req)
 {
   DT->Year    = DecodeWithBCDAlphabet(req[0]);
   DT->Month   = DecodeWithBCDAlphabet(req[1]);
 {
   DT->Year    = DecodeWithBCDAlphabet(req[0]);
   DT->Month   = DecodeWithBCDAlphabet(req[1]);
@@ -292,7 +295,7 @@ GSM_Error GSM_DecodeSMSDateTime(GSM_DateTime *DT, unsigned char *req)
   return GE_NONE;
 }
 
   return GE_NONE;
 }
 
-int GSM_EncodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI)
+static int GSM_EncodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI)
 {
   int off,size=0,size2=0,w,i;
 
 {
   int off,size=0,size2=0,w,i;
 
@@ -347,7 +350,7 @@ int GSM_EncodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI)
       ETSI->TPDCS |= 0x08;
 
 #ifdef DEBUG
       ETSI->TPDCS |= 0x08;
 
 #ifdef DEBUG
-      fprintf(stdout,_("SMS Length is %i\n"),strlen(SMS->MessageText));
+      fprintf(stdout,_("SMS Length is %ld\n"),(long)strlen(SMS->MessageText));
 #endif
 
       EncodeUnicode (ETSI->MessageText+off,SMS->MessageText,strlen(SMS->MessageText));
 #endif
 
       EncodeUnicode (ETSI->MessageText+off,SMS->MessageText,strlen(SMS->MessageText));
@@ -821,8 +824,9 @@ GSM_Error GSM_DecodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI)
 
   return GE_NONE;
 }
 
   return GE_NONE;
 }
+#endif /* UCLINUX */
 
 
-void GSM_SetDefaultSMSData (GSM_SMSMessage *SMS)
+static void GSM_SetDefaultSMSData (GSM_SMSMessage *SMS)
 {
   struct tm *now;
   time_t nowh;
 {
   struct tm *now;
   time_t nowh;
@@ -887,6 +891,9 @@ void GSM_SetDefaultSMSData (GSM_SMSMessage *SMS)
    - GSM 03.40 version 6.1.0 Release 1997, section 9.2.3.24
    - Smart Messaging Specification, Revision 1.0.0, September 15, 1997
 */
    - GSM 03.40 version 6.1.0 Release 1997, section 9.2.3.24
    - Smart Messaging Specification, Revision 1.0.0, September 15, 1997
 */
+#ifdef UCLINUX
+static
+#endif /* UCLINUX */
 GSM_Error EncodeUDHHeader(char *text, GSM_UDH UDHType)
 {
        int i=0;
 GSM_Error EncodeUDHHeader(char *text, GSM_UDH UDHType)
 {
        int i=0;
@@ -910,7 +917,7 @@ GSM_Error EncodeUDHHeader(char *text, GSM_UDH UDHType)
        return GE_NONE;
 }
 
        return GE_NONE;
 }
 
-int GSM_MakeSinglePartSMS2(GSM_SMSMessage *SMS,
+static int GSM_MakeSinglePartSMS2(GSM_SMSMessage *SMS,
     unsigned char *MessageBuffer,int cur, GSM_UDH UDHType, GSM_Coding_Type Coding){
 
   int j;
     unsigned char *MessageBuffer,int cur, GSM_UDH UDHType, GSM_Coding_Type Coding){
 
   int j;
index 0ef16cc..fb9d3d5 100644 (file)
@@ -10,6 +10,8 @@
   
 */
 
   
 */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index 34d81b7..b355232 100644 (file)
@@ -8,6 +8,8 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 #include <string.h>\r
 #include <ctype.h>\r
 #include <time.h>\r
 #include <string.h>\r
 #include <ctype.h>\r
 #include <time.h>\r
@@ -57,6 +59,8 @@ int GetLine(FILE *File, char *Line, int count) {
   } else return -1;
 }
 
   } else return -1;
 }
 
+#ifndef UCLINUX
+
 /*
  * like atoi, but of a non-null-terminated string of a specified portion
  */
 /*
  * like atoi, but of a non-null-terminated string of a specified portion
  */
@@ -69,6 +73,8 @@ int mem_to_int(const char str[], int len)
   return( atoi(aux) );
 } 
 
   return( atoi(aux) );
 } 
 
+#endif /* UCLINUX */
+
 /*
  * make hexdump of Message
  */
 /*
  * make hexdump of Message
  */
@@ -156,6 +162,8 @@ void txhexdump(u16 MessageLength, u8 *MessageBuffer)
 
 #ifndef WIN32
 
 
 #ifndef WIN32
 
+#ifndef UCLINUX
+
 #define max_buf_len 128
 #define lock_path "/var/lock/LCK.."
 
 #define max_buf_len 128
 #define lock_path "/var/lock/LCK.."
 
@@ -225,7 +233,7 @@ char *lock_device(const char* port)
 }
 
 /* Removes lock and frees memory */
 }
 
 /* Removes lock and frees memory */
-bool unlock_device(char *lock_file)
+static bool unlock_device(char *lock_file)
 {
        int err;
 
 {
        int err;
 
@@ -237,4 +245,7 @@ bool unlock_device(char *lock_file)
        free(lock_file);
        return (err + 1);
 }
        free(lock_file);
        return (err + 1);
 }
+
+#endif /* UCLINUX */
+
 #endif /* WIN32 */
 #endif /* WIN32 */
index d067fed..481c92e 100644 (file)
-/*\r
-\r
-  G N O K I I\r
-\r
-  A Linux/Unix toolset and driver for Nokia mobile phones.\r
-\r
-  Released under the terms of the GNU GPL, see file COPYING for more details.\r
-\r
-  This file provides an API for accessing functions on the 6110 and similar\r
-  phones.\r
-\r
-*/\r
-\r
-/* "Turn on" prototypes in n-6110.h */\r
-\r
-#define __n_6110_c \r
-\r
-/* System header files */\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-\r
-#ifdef WIN32\r
-  #include "misc_win32.h"\r
-#endif\r
\r
-/* Various header file */\r
-#ifndef VC6\r
-  #include "config.h"\r
-#endif\r
-\r
-#include "gsm-api.h"\r
-#include "gsm-coding.h"\r
-#include "newmodules/n6110.h"\r
-#include "newmodules/n7110.h"\r
-#include "protocol/fbus.h"\r
-#include "devices/device.h"\r
-\r\r/* Global variables used by code in gsm-api.c to expose the functions\r
-   supported by this model of phone. */\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-/* Here we initialise model specific functions. */\r
-GSM_Functions N6110_Functions = {\r
-  N6110_Initialise,\r
-  N6110_DispatchMessage,\r
-  NULL_Terminate,\r
-  NULL_KeepAlive,\r
-  N6110_GetMemoryLocation,\r
-  N6110_WritePhonebookLocation,\r
-  N6110_GetSpeedDial,\r
-  N6110_SetSpeedDial,\r
-  N6110_GetMemoryStatus,\r
-  N6110_GetSMSStatus,\r
-  N6110_GetSMSCenter,\r
-  N6110_SetSMSCenter,\r
-  N6110_GetSMSMessage,\r
-  N6110_DeleteSMSMessage,\r
-  N6110_SendSMSMessage,\r
-  N6110_SaveSMSMessage,\r
-  N6110_GetRFLevel,\r
-  N6110_GetBatteryLevel,\r
-  N6110_GetPowerSource,\r
-  N6110_GetDisplayStatus,\r
-  N6110_EnterSecurityCode,\r
-  N6110_GetSecurityCodeStatus,\r
-  N6110_GetSecurityCode,\r
-  N6110_GetIMEI,\r
-  N6110_GetRevision,\r
-  N6110_GetModel,\r
-  N6110_GetDateTime,\r
-  N6110_SetDateTime,\r
-  N6110_GetAlarm,\r
-  N6110_SetAlarm,\r
-  N6110_DialVoice,\r
-  N6110_DialData,\r
-  N6110_GetIncomingCallNr,\r
-  N6110_GetNetworkInfo,\r
-  N6110_GetCalendarNote,\r
-  N6110_WriteCalendarNote,\r
-  N6110_DeleteCalendarNote,\r
-  N6110_NetMonitor,\r
-  N6110_SendDTMF,\r
-  N6110_GetBitmap,\r
-  N6110_SetBitmap,\r
-  N6110_SetRingTone,\r
-  N6110_SetBinRingTone,\r
-  N6110_GetBinRingTone,\r
-  N6110_Reset,\r
-  N6110_GetProfile,\r
-  N6110_SetProfile,\r
-  N6110_SendRLPFrame,\r
-  N6110_CancelCall,\r
-  N6110_PressKey,\r
-  N6110_EnableDisplayOutput,\r
-  N6110_DisableDisplayOutput,\r
-  N6110_EnableCellBroadcast,\r
-  N6110_DisableCellBroadcast,\r
-  N6110_ReadCellBroadcast,\r
-  N6110_PlayTone,\r
-  N6110_GetProductProfileSetting,\r
-  N6110_SetProductProfileSetting,\r
-  N6110_GetOperatorName,\r
-  N6110_SetOperatorName,\r
-  N6110_GetVoiceMailbox,\r  N6110_Tests,
+/*
+
+  G N O K I I
+
+  A Linux/Unix toolset and driver for Nokia mobile phones.
+
+  Released under the terms of the GNU GPL, see file COPYING for more details.
+
+  This file provides an API for accessing functions on the 6110 and similar
+  phones.
+
+*/
+
+#include "config.h"
+
+/* "Turn on" prototypes in n-6110.h */
+
+#define __n_6110_c 
+
+/* System header files */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#ifdef WIN32
+  #include "misc_win32.h"
+#endif
+/* Various header file */
+#ifndef VC6
+  #include "config.h"
+#endif
+
+#include "gsm-api.h"
+#include "gsm-coding.h"
+#include "newmodules/n6110.h"
+#include "newmodules/n7110.h"
+#include "protocol/fbus.h"
+#include "devices/device.h"
+/* Global variables used by code in gsm-api.c to expose the functions
+   supported by this model of phone. */
+
+
+
+
+
+
+
+/* Here we initialise model specific functions. */
+GSM_Functions N6110_Functions = {
+  N6110_Initialise,
+  N6110_DispatchMessage,
+  NULL_Terminate,
+  NULL_KeepAlive,
+  N6110_GetMemoryLocation,
+  N6110_WritePhonebookLocation,
+#ifndef UCLINUX
+  N6110_GetSpeedDial,
+  N6110_SetSpeedDial,
+#else /* UCLINUX */
+  NULL,
+  NULL,
+#endif /* UCLINUX */
+  N6110_GetMemoryStatus,
+#ifndef UCLINUX
+  N6110_GetSMSStatus,
+  N6110_GetSMSCenter,
+  N6110_SetSMSCenter,
+  N6110_GetSMSMessage,
+  N6110_DeleteSMSMessage,
+  N6110_SendSMSMessage,
+  N6110_SaveSMSMessage,
+#else /* UCLINUX */
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+#endif /* UCLINUX */
+  N6110_GetRFLevel,
+  N6110_GetBatteryLevel,
+  N6110_GetPowerSource,
+#ifndef UCLINUX
+  N6110_GetDisplayStatus,
+  N6110_EnterSecurityCode,
+  N6110_GetSecurityCodeStatus,
+  N6110_GetSecurityCode,
+  N6110_GetIMEI,
+  N6110_GetRevision,
+  N6110_GetModel,
+  N6110_GetDateTime,
+  N6110_SetDateTime,
+  N6110_GetAlarm,
+  N6110_SetAlarm,
+  N6110_DialVoice,
+#else /* UCLINUX */
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+#endif /* UCLINUX */
+  N6110_DialData,
+#ifndef UCLINUX
+  N6110_GetIncomingCallNr,
+  N6110_GetNetworkInfo,
+  N6110_GetCalendarNote,
+  N6110_WriteCalendarNote,
+  N6110_DeleteCalendarNote,
+  N6110_NetMonitor,
+  N6110_SendDTMF,
+  N6110_GetBitmap,
+  N6110_SetBitmap,
+  N6110_SetRingTone,
+  N6110_SetBinRingTone,
+  N6110_GetBinRingTone,
+#else /* UCLINUX */
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+#endif /* UCLINUX */
+  N6110_Reset,
+#ifndef UCLINUX
+  N6110_GetProfile,
+  N6110_SetProfile,
+  N6110_SendRLPFrame,
+#else /* UCLINUX */
+  NULL,
+  NULL,
+  NULL,
+#endif /* UCLINUX */
+  N6110_CancelCall,
+#ifndef UCLINUX
+  N6110_PressKey,
+  N6110_EnableDisplayOutput,
+  N6110_DisableDisplayOutput,
+  N6110_EnableCellBroadcast,
+  N6110_DisableCellBroadcast,
+  N6110_ReadCellBroadcast,
+  N6110_PlayTone,
+  N6110_GetProductProfileSetting,
+  N6110_SetProductProfileSetting,
+  N6110_GetOperatorName,
+  N6110_SetOperatorName,
+  N6110_GetVoiceMailbox,  N6110_Tests,
   N6110_SimlockInfo,
   UNIMPLEMENTED,                 //GetCalendarNotesInfo
   N6110_GetSMSFolders,
   N6110_SimlockInfo,
   UNIMPLEMENTED,                 //GetCalendarNotesInfo
   N6110_GetSMSFolders,
@@ -116,568 +170,612 @@ GSM_Functions N6110_Functions = {
   N7110_GetWAPSettings,
   N6110_CallDivert,
   N6110_AnswerCall,
   N7110_GetWAPSettings,
   N6110_CallDivert,
   N6110_AnswerCall,
+#else /* UCLINUX */
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,  NULL,
+  NULL,
+  NULL,                 //GetCalendarNotesInfo
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+#endif /* UCLINUX */
   N6110_GetManufacturer
   N6110_GetManufacturer
-};\r
-\r
-/* Mobile phone information */\r
-\r
-GSM_Information N6110_Information = {\r
-  "3210|3310|3330|5110|5130|5190|6110|6130|6150|6190|8210|8850",\r
-     /* Supported models in FBUS */\r
-  "3210|3310|3330|5110|5130|5190|6110|6130|6150|6190|8210|8850",\r
-     /* Supported models in MBUS */\r
-  "6110|6130|6150|8210|8850",\r
-     /* Supported models in FBUS over infrared */\r
-  "",\r
-     /* Supported models in FBUS over DLR3 */\r
+};
+
+/* Mobile phone information */
+
+GSM_Information N6110_Information = {
+  "3210|3310|3330|5110|5130|5190|6110|6130|6150|6190|8210|8850",
+     /* Supported models in FBUS */
+  "3210|3310|3330|5110|5130|5190|6110|6130|6150|6190|8210|8850",
+     /* Supported models in MBUS */
+  "6110|6130|6150|8210|8850",
+     /* Supported models in FBUS over infrared */
+  "",
+     /* Supported models in FBUS over DLR3 */
   "",
      /* AT commands */
   "8210|8850",
      /* infrared sockets */
   "6110|6130|6150|8210|8850",
   "",
      /* AT commands */
   "8210|8850",
      /* infrared sockets */
   "6110|6130|6150|8210|8850",
-     /* Supported models in FBUS over infrared with Tekram device */\r  
-  4,                     /* Max RF Level */\r
-  0,                     /* Min RF Level */\r
-  GRF_Arbitrary,         /* RF level units */\r
-  4,                     /* Max Battery Level */\r
-  0,                     /* Min Battery Level */\r
-  GBU_Arbitrary,         /* Battery level units */\r
-  GDT_DateTime,          /* Have date/time support */\r
-  GDT_TimeOnly,                 /* Alarm supports time only */\r
-  1                      /* Only one alarm available */\r
-};\r
-\r
-const char *N6110_MemoryType_String [] = {\r
-  "",  /* 0x00 */\r
-  "MT", /* 0x01 */\r
-  "ME", /* 0x02 */\r
-  "SM", /* 0x03 */\r
-  "FD", /* 0x04 */\r
-  "ON", /* 0x05 */\r
-  "EN", /* 0x06 */\r
-  "DC", /* 0x07 */\r
-  "RC", /* 0x08 */\r
-  "MC", /* 0x09 */\r
-};\r
-\r
-/* Magic bytes from the phone. */\r
-unsigned char MagicBytes[4] = { 0x00, 0x00, 0x00, 0x00 };\r
-\r
-/* For DisplayOutput */\r
-char               PhoneScreen[5+1][27+1];\r
-int                OldX=1000,OldY=0,NewX=0,NewY=0;\r
-\r
-void N6110_ReplyEnableExtendedCommands(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: Answer for EnableExtendedSecurityCommands frame, meaning not known :-(\n"));\r
-#endif /* DEBUG */\r
-\r
-  CurrentEnableExtendedCommandsError=GE_NONE;  \r
-}\r
-\r
-/* If you set make some things (for example,\r
-   change Security Code from phone's menu, disable and enable\r
-   phone), it won't answer for 0x40 frame - you won't be able\r
-   to play tones, get netmonitor, etc.\r
-\r
-   This function do thing called "Enabling extended security commands" -\r
-   it enables 0x40 frame functions.\r
-\r
-   This frame can also some other things - see below */\r
-GSM_Error N6110_EnableExtendedCommands (unsigned char status)\r
-{\r
-  unsigned char req[4] = { 0x00,\r
-                           0x01,0x64, /* Enable extended commands request */\r
-                          0x01 };    /* 0x01 - on, 0x00 - off,\r
-                                        0x03 & 0x04 - soft & hard reset,\r
-                                         0x06 - CONTACT SERVICE */\r
-\r
-  /* 0x06 MAKES CONTACT SERVICE! BE CAREFULL! */\r
+     /* Supported models in FBUS over infrared with Tekram device */  
+  4,                     /* Max RF Level */
+  0,                     /* Min RF Level */
+  GRF_Arbitrary,         /* RF level units */
+  4,                     /* Max Battery Level */
+  0,                     /* Min Battery Level */
+  GBU_Arbitrary,         /* Battery level units */
+  GDT_DateTime,          /* Have date/time support */
+  GDT_TimeOnly,                 /* Alarm supports time only */
+  1                      /* Only one alarm available */
+};
+
+#ifdef DEBUG
+static const char *N6110_MemoryType_String [] = {
+  "",  /* 0x00 */
+  "MT", /* 0x01 */
+  "ME", /* 0x02 */
+  "SM", /* 0x03 */
+  "FD", /* 0x04 */
+  "ON", /* 0x05 */
+  "EN", /* 0x06 */
+  "DC", /* 0x07 */
+  "RC", /* 0x08 */
+  "MC", /* 0x09 */
+};
+#endif /* DEBUG */
+
+/* Magic bytes from the phone. */
+static unsigned char MagicBytes[4] = { 0x00, 0x00, 0x00, 0x00 };
+
+/* For DisplayOutput */
+#ifndef UCLINUX
+static char               PhoneScreen[5+1][27+1];
+static int                OldX=1000,OldY=0,NewX=0,NewY=0;
+#endif /* UCLINUX */
+
+void N6110_ReplyEnableExtendedCommands(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#ifdef DEBUG
+  fprintf(stdout, _("Message: Answer for EnableExtendedSecurityCommands frame, meaning not known :-(\n"));
+#endif /* DEBUG */
+
+  CurrentEnableExtendedCommandsError=GE_NONE;  
+}
+
+/* If you set make some things (for example,
+   change Security Code from phone's menu, disable and enable
+   phone), it won't answer for 0x40 frame - you won't be able
+   to play tones, get netmonitor, etc.
+
+   This function do thing called "Enabling extended security commands" -
+   it enables 0x40 frame functions.
+
+   This frame can also some other things - see below */
+GSM_Error N6110_EnableExtendedCommands (unsigned char status)
+{
+  unsigned char req[4] = { 0x00,
+                           0x01,0x64, /* Enable extended commands request */
+                          0x01 };    /* 0x01 - on, 0x00 - off,
+                                        0x03 & 0x04 - soft & hard reset,
+                                         0x06 - CONTACT SERVICE */
+
+  /* 0x06 MAKES CONTACT SERVICE! BE CAREFULL! */
   /* When use 0x03 and had during session changed time & date
      some phones (like 6150 or 6210) can ask for time & date after reset
      or disable clock on the screen */
   /* When use 0x03 and had during session changed time & date
      some phones (like 6150 or 6210) can ask for time & date after reset
      or disable clock on the screen */
-  if (status!=0x06) req[3] = status;\r
-\r
-  return NULL_SendMessageSequence\r
-    (50, &CurrentEnableExtendedCommandsError, 4, 0x40, req);\r
-}\r
-\r
-void N6110_ReplyIMEI(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#if defined WIN32 || !defined HAVE_SNPRINTF\r
-  sprintf(Current_IMEI, "%s", MessageBuffer+4);\r
-#else\r
-  snprintf(Current_IMEI, GSM_MAX_IMEI_LENGTH, "%s", MessageBuffer+4);\r
-#endif\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: IMEI %s received\n"),Current_IMEI);\r
-#endif\r
-\r
-  CurrentGetIMEIError=GE_NONE;       \r
-}\r
-\r
-GSM_Error N6110_SendIMEIFrame()\r
-{\r
-  unsigned char req[4] = {0x00, 0x01, 0x66, 0x00};  \r
-\r
-  GSM_Error error;\r
-\r
-  error=N6110_EnableExtendedCommands(0x01);\r
-  if (error!=GE_NONE) return error;\r
-  \r
-  return NULL_SendMessageSequence (20, &CurrentGetIMEIError, 4, 0x40, req);\r
-}\r
-\r
-void N6110_ReplyHW(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int i, j;\r
-    \r
-  if (MessageBuffer[3]==0x05) {\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout,_("Message: Hardware version received: "));\r
-#endif\r
-\r
-    j=strlen(Current_Revision);\r
-    Current_Revision[j++]=',';\r
-    Current_Revision[j++]=' ';\r
-    Current_Revision[j++]='H';\r
-    Current_Revision[j++]='W';\r
-            \r
-    for (i=5;i<9;i++) {\r
-#ifdef DEBUG\r
-      fprintf(stdout,_("%c"), MessageBuffer[i]);\r
-#endif\r
-      Current_Revision[j++]=MessageBuffer[i];\r
-    }\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout,_("\n"));\r
-#endif\r
-\r
-    CurrentGetHWError=GE_NONE;\r
-  }\r
-}\r
-\r
-GSM_Error N6110_SendHWFrame()\r
-{\r
-  unsigned char req[4] = {0x00, 0x01, 0xc8, 0x05};  \r
-\r
-  GSM_Error error;\r
-\r
-  error=N6110_EnableExtendedCommands(0x01);\r
-  if (error!=GE_NONE) return error;\r
-  \r
-  return NULL_SendMessageSequence (20, &CurrentGetHWError, 4, 0x40, req);\r
-}\r
-\r
-void N6110_ReplyID(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int i, j;\r
\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: Mobile phone model identification received:\n"));\r
-  fprintf(stdout, _("   Firmware: "));\r
-#endif\r
-\r
-  strcpy(Current_Revision,"SW");\r
-    \r
-  i=6;j=2;\r
-  while (MessageBuffer[i]!=0x0a) {\r
-    Current_Revision[j]=MessageBuffer[i];\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("%c"),MessageBuffer[i]);\r
-#endif\r
-    if (j==GSM_MAX_REVISION_LENGTH-1) {\r
-#ifdef DEBUG\r
-      fprintf(stderr,_("ERROR: increase GSM_MAX_REVISION_LENGTH!\n"));\r
-#endif  \r
-      break;\r
-    }\r
-    j++;\r
-    i++;\r
-  }\r
-  Current_Revision[j+1]=0;\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("\n   Firmware date: "));\r
-#endif\r
-\r
-  i++;\r
-  while (MessageBuffer[i]!=0x0a) {\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("%c"),MessageBuffer[i]);\r
-#endif\r
-    i++;\r
-  }\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("\n   Model: "));\r
-#endif /* DEBUG */\r
-\r
-  i++;j=0;\r
-  while (MessageBuffer[i]!=0x0a) {\r
-    Current_Model[j]=MessageBuffer[i];\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("%c"),MessageBuffer[i]);\r
-#endif\r
-    if (j==GSM_MAX_MODEL_LENGTH-1) {\r
-#ifdef DEBUG\r
-      fprintf(stderr,_("ERROR: increase GSM_MAX_MODEL_LENGTH!\n"));\r
-#endif  \r
-      break;\r
-    }\r
-    j++;\r
-    i++;\r
-  }\r
-  Current_Model[j+1]=0;\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("\n"));\r
-#endif /* DEBUG */\r
-    \r
-  CurrentMagicError=GE_NONE;\r
-}\r
-\r
-GSM_Error N6110_SendIDFrame()\r
-{\r
-  unsigned char req[5] = {N6110_FRAME_HEADER, 0x03, 0x00};  \r
-\r
-  return NULL_SendMessageSequence (50, &CurrentMagicError, 5, 0xd1, req);\r
-}\r
-\r
-/* This function send the status request to the phone. */\r
-/* Seems to be ignored in N3210 */\r
-GSM_Error N6110_SendStatusRequest(void)\r
-{\r
-  unsigned char req[] = {N6110_FRAME_HEADER, 0x01};\r
-\r
-  Protocol->SendMessage(4, 0x04, req);\r
-\r
-  return (GE_NONE);\r
-}\r
-\r
-void N6110_ReplyGetAuthentication(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#if defined WIN32 || !defined HAVE_SNPRINTF\r
-  sprintf(Current_IMEI, "%s", MessageBuffer+9);\r
-  sprintf(Current_Model, "%s", MessageBuffer+25);\r
-  sprintf(Current_Revision, "SW%s, HW%s", MessageBuffer+44, MessageBuffer+39);\r
-#else\r
-  snprintf(Current_IMEI, GSM_MAX_IMEI_LENGTH, "%s", MessageBuffer+9);\r
-  snprintf(Current_Model, GSM_MAX_MODEL_LENGTH, "%s", MessageBuffer+25);\r
-  snprintf(Current_Revision, GSM_MAX_REVISION_LENGTH, "SW%s, HW%s", MessageBuffer+44, MessageBuffer+39);\r
-#endif\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: Mobile phone identification received:\n"));\r
-  fprintf(stdout, _("   IMEI: %s\n"), Current_IMEI);\r
-  fprintf(stdout, _("   Model: %s\n"), Current_Model);\r
-  fprintf(stdout, _("   Production Code: %s\n"), MessageBuffer+31);\r
-  fprintf(stdout, _("   HW: %s\n"), MessageBuffer+39);\r
-  fprintf(stdout, _("   Firmware: %s\n"), MessageBuffer+44);\r
-\r
-  /* These bytes are probably the source of the "Accessory not connected"\r
-     messages on the phone when trying to emulate NCDS... I hope....\r
-     UPDATE: of course, now we have the authentication algorithm. */\r
-  fprintf(stdout, _("   Magic bytes: %02x %02x %02x %02x\n"), MessageBuffer[50], MessageBuffer[51], MessageBuffer[52], MessageBuffer[53]);\r
-#endif /* DEBUG */\r
-\r
-  MagicBytes[0]=MessageBuffer[50];\r
-  MagicBytes[1]=MessageBuffer[51];\r
-  MagicBytes[2]=MessageBuffer[52];\r
-  MagicBytes[3]=MessageBuffer[53];\r
-\r
-  CurrentMagicError=GE_NONE;\r
-}\r
-\r
-/* This function provides Nokia authentication protocol.\r
-\r
-   This code is written specially for gnokii project by Odinokov Serge.\r
-   If you have some special requests for Serge just write him to\r
-   apskaita@post.omnitel.net or serge@takas.lt\r
-\r
-   Reimplemented in C by Pavel Janík ml.\r
-\r
-   Nokia authentication protocol is used in the communication between Nokia\r
-   mobile phones (e.g. Nokia 6110) and Nokia Cellular Data Suite software,\r
-   commercially sold by Nokia Corp.\r
-\r
-   The authentication scheme is based on the token send by the phone to the\r
-   software. The software does it's magic (see the function\r
-   FB61_GetNokiaAuth()) and returns the result back to the phone. If the\r
-   result is correct the phone responds with the message "Accessory\r
-   connected!" displayed on the LCD. Otherwise it will display "Accessory not\r
-   supported" and some functions will not be available for use.\r
-\r
-   The specification of the protocol is not publicly available, no comment. */\r
-void N6110_GetNokiaAuth(unsigned char *Imei, unsigned char *MagicBytes, unsigned char *MagicResponse)\r
-{\r
-\r
-  int i, j, CRC=0;\r
-\r
-  /* This is our temporary working area. */\r
-\r
-  unsigned char Temp[16];\r
-\r
-  /* Here we put FAC (Final Assembly Code) and serial number into our area. */\r
-\r
-  Temp[0]  = Imei[6];\r
-  Temp[1]  = Imei[7];\r
-  Temp[2]  = Imei[8];\r
-  Temp[3]  = Imei[9];\r
-  Temp[4]  = Imei[10];\r
-  Temp[5]  = Imei[11];\r
-  Temp[6]  = Imei[12];\r
-  Temp[7]  = Imei[13];\r
-\r
-  /* And now the TAC (Type Approval Code). */\r
-\r
-  Temp[8]  = Imei[2];\r
-  Temp[9]  = Imei[3];\r
-  Temp[10] = Imei[4];\r
-  Temp[11] = Imei[5];\r
-\r
-  /* And now we pack magic bytes from the phone. */\r
-\r
-  Temp[12] = MagicBytes[0];\r
-  Temp[13] = MagicBytes[1];\r
-  Temp[14] = MagicBytes[2];\r
-  Temp[15] = MagicBytes[3];\r
-\r
-  for (i=0; i<=11; i++)\r
-    if (Temp[i + 1]& 1)\r
-      Temp[i]<<=1;\r
-\r
-  switch (Temp[15] & 0x03) {\r
-\r
-  case 1:\r
-  case 2:\r
-    j = Temp[13] & 0x07;\r
-\r
-    for (i=0; i<=3; i++)\r
-      Temp[i+j] ^= Temp[i+12];\r
-\r
-    break;\r
-\r
-  default:\r
-    j = Temp[14] & 0x07;\r
-\r
-    for (i=0; i<=3; i++)\r
-      Temp[i + j] |= Temp[i + 12];\r
-  }\r
-\r
-  for (i=0; i<=15; i++)\r
-    CRC ^= Temp[i];\r
-\r
-  for (i=0; i<=15; i++) {\r
-\r
-    switch (Temp[15 - i] & 0x06) {\r
-\r
-    case 0:\r
-      j = Temp[i] | CRC;\r
-      break;\r
-\r
-    case 2:\r
-    case 4:\r
-      j = Temp[i] ^ CRC;\r
-      break;\r
-\r
-    case 6:\r
-      j = Temp[i] & CRC;\r
-      break;\r
-    }\r
-  \r
-    if (j == CRC)\r
-      j = 0x2c;\r
-\r
-    if (Temp[i] == 0)\r
-      j = 0;\r
-\r
-    MagicResponse[i] = j;\r
-\r
-  }\r
-}\r
-\r
-GSM_Error N6110_Authentication()\r
-{\r
-  unsigned char connect1[] = {N6110_FRAME_HEADER, 0x0d, 0x00, 0x00, 0x02};\r
-  unsigned char connect2[] = {N6110_FRAME_HEADER, 0x20, 0x02};\r
-  unsigned char connect3[] = {N6110_FRAME_HEADER, 0x0d, 0x01, 0x00, 0x02};\r
-  unsigned char connect4[] = {N6110_FRAME_HEADER, 0x10};\r
-  \r
-  unsigned char magic_connect[] = {N6110_FRAME_HEADER,\r
-  0x12,\r
-\r
-  /* The real magic goes here ... These bytes are filled in with the\r
-     function N6110_GetNokiaAuth(). */\r
-\r
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \r
-\r
-  /* NOKIA&GNOKII Accessory */\r
-\r
-  0x4e, 0x4f, 0x4b, 0x49, 0x41, 0x26, 0x4e, 0x4f, 0x4b, 0x49, 0x41, 0x20,\r
-  0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x79,\r
-  \r
-  0x00, 0x00, 0x00, 0x00};\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout,_("Making authentication!\n"));\r
-#endif\r
-\r
-  usleep(100); Protocol->SendMessage(7, 0x02, connect1);\r
-  usleep(100); Protocol->SendMessage(5, 0x02, connect2);\r
-  usleep(100); Protocol->SendMessage(7, 0x02, connect3);\r
-      \r
-  CurrentMagicError = GE_BUSY;\r
-\r
-  usleep(100); Protocol->SendMessage(4, 0x64, connect4);\r
-  if (NULL_WaitUntil(50,&CurrentMagicError)!=GE_NONE) return GE_TIMEOUT;\r
-\r
-  N6110_GetNokiaAuth(Current_IMEI, MagicBytes, magic_connect+4);\r
-\r
-  Protocol->SendMessage(45, 0x64, magic_connect);\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout,_("End of authentication!\n"));\r
-#endif\r
-\r
-  return GE_NONE;\r
-}\r
-\r
-/* Initialise variables and state machine. */\r
-GSM_Error N6110_Initialise(char *port_device, char *initlength,\r
-                          GSM_ConnectionType connection,\r
-                          void (*rlp_callback)(RLP_F96Frame *frame))\r
-{\r
-  unsigned char init_char = N6110_SYNC_BYTE;\r
-  unsigned char end_init_char = N6110_IR_END_SYNC_BYTE;\r
-\r
-  int count;\r
-  int InitLength;\r
-  \r
-  if (Protocol->Initialise(port_device,initlength,connection,rlp_callback)!=GE_NONE)\r
-  {\r
-    return GE_NOTSUPPORTED;\r
-  }\r
+  if (status!=0x06) req[3] = status;
+
+  return NULL_SendMessageSequence
+    (50, &CurrentEnableExtendedCommandsError, 4, 0x40, req);
+}
+
+void N6110_ReplyIMEI(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#if defined WIN32 || !defined HAVE_SNPRINTF
+  sprintf(Current_IMEI, "%s", MessageBuffer+4);
+#else
+  snprintf(Current_IMEI, GSM_MAX_IMEI_LENGTH, "%s", MessageBuffer+4);
+#endif
+
+#ifdef DEBUG
+  fprintf(stdout, _("Message: IMEI %s received\n"),Current_IMEI);
+#endif
+
+  CurrentGetIMEIError=GE_NONE;       
+}
+
+GSM_Error N6110_SendIMEIFrame()
+{
+  unsigned char req[4] = {0x00, 0x01, 0x66, 0x00};  
+
+  GSM_Error error;
+
+  error=N6110_EnableExtendedCommands(0x01);
+  if (error!=GE_NONE) return error;
+  
+  return NULL_SendMessageSequence (20, &CurrentGetIMEIError, 4, 0x40, req);
+}
+
+void N6110_ReplyHW(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int i, j;
+    
+  if (MessageBuffer[3]==0x05) {
+
+#ifdef DEBUG
+    fprintf(stdout,_("Message: Hardware version received: "));
+#endif
+
+    j=strlen(Current_Revision);
+    Current_Revision[j++]=',';
+    Current_Revision[j++]=' ';
+    Current_Revision[j++]='H';
+    Current_Revision[j++]='W';
+            
+    for (i=5;i<9;i++) {
+#ifdef DEBUG
+      fprintf(stdout,_("%c"), MessageBuffer[i]);
+#endif
+      Current_Revision[j++]=MessageBuffer[i];
+    }
+
+#ifdef DEBUG
+    fprintf(stdout,_("\n"));
+#endif
+
+    CurrentGetHWError=GE_NONE;
+  }
+}
+
+GSM_Error N6110_SendHWFrame()
+{
+  unsigned char req[4] = {0x00, 0x01, 0xc8, 0x05};  
+
+  GSM_Error error;
+
+  error=N6110_EnableExtendedCommands(0x01);
+  if (error!=GE_NONE) return error;
+  
+  return NULL_SendMessageSequence (20, &CurrentGetHWError, 4, 0x40, req);
+}
+
+void N6110_ReplyID(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int i, j;
+#ifdef DEBUG
+  fprintf(stdout, _("Message: Mobile phone model identification received:\n"));
+  fprintf(stdout, _("   Firmware: "));
+#endif
+
+  strcpy(Current_Revision,"SW");
+    
+  i=6;j=2;
+  while (MessageBuffer[i]!=0x0a) {
+    Current_Revision[j]=MessageBuffer[i];
+#ifdef DEBUG
+    fprintf(stdout, _("%c"),MessageBuffer[i]);
+#endif
+    if (j==GSM_MAX_REVISION_LENGTH-1) {
+#ifdef DEBUG
+      fprintf(stderr,_("ERROR: increase GSM_MAX_REVISION_LENGTH!\n"));
+#endif  
+      break;
+    }
+    j++;
+    i++;
+  }
+  Current_Revision[j+1]=0;
+
+#ifdef DEBUG
+  fprintf(stdout, _("\n   Firmware date: "));
+#endif
+
+  i++;
+  while (MessageBuffer[i]!=0x0a) {
+#ifdef DEBUG
+    fprintf(stdout, _("%c"),MessageBuffer[i]);
+#endif
+    i++;
+  }
+
+#ifdef DEBUG
+  fprintf(stdout, _("\n   Model: "));
+#endif /* DEBUG */
+
+  i++;j=0;
+  while (MessageBuffer[i]!=0x0a) {
+    Current_Model[j]=MessageBuffer[i];
+#ifdef DEBUG
+    fprintf(stdout, _("%c"),MessageBuffer[i]);
+#endif
+    if (j==GSM_MAX_MODEL_LENGTH-1) {
+#ifdef DEBUG
+      fprintf(stderr,_("ERROR: increase GSM_MAX_MODEL_LENGTH!\n"));
+#endif  
+      break;
+    }
+    j++;
+    i++;
+  }
+  Current_Model[j+1]=0;
+
+#ifdef DEBUG
+  fprintf(stdout, _("\n"));
+#endif /* DEBUG */
+    
+  CurrentMagicError=GE_NONE;
+}
+
+GSM_Error N6110_SendIDFrame()
+{
+  unsigned char req[5] = {N6110_FRAME_HEADER, 0x03, 0x00};  
+
+  return NULL_SendMessageSequence (50, &CurrentMagicError, 5, 0xd1, req);
+}
+
+/* This function send the status request to the phone. */
+/* Seems to be ignored in N3210 */
+GSM_Error N6110_SendStatusRequest(void)
+{
+  unsigned char req[] = {N6110_FRAME_HEADER, 0x01};
+
+  Protocol->SendMessage(4, 0x04, req);
+
+  return (GE_NONE);
+}
+
+static void N6110_ReplyGetAuthentication(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#if defined WIN32 || !defined HAVE_SNPRINTF
+  sprintf(Current_IMEI, "%s", MessageBuffer+9);
+  sprintf(Current_Model, "%s", MessageBuffer+25);
+  sprintf(Current_Revision, "SW%s, HW%s", MessageBuffer+44, MessageBuffer+39);
+#else
+  snprintf(Current_IMEI, GSM_MAX_IMEI_LENGTH, "%s", MessageBuffer+9);
+  snprintf(Current_Model, GSM_MAX_MODEL_LENGTH, "%s", MessageBuffer+25);
+  snprintf(Current_Revision, GSM_MAX_REVISION_LENGTH, "SW%s, HW%s", MessageBuffer+44, MessageBuffer+39);
+#endif
+
+#ifdef DEBUG
+  fprintf(stdout, _("Message: Mobile phone identification received:\n"));
+  fprintf(stdout, _("   IMEI: %s\n"), Current_IMEI);
+  fprintf(stdout, _("   Model: %s\n"), Current_Model);
+  fprintf(stdout, _("   Production Code: %s\n"), MessageBuffer+31);
+  fprintf(stdout, _("   HW: %s\n"), MessageBuffer+39);
+  fprintf(stdout, _("   Firmware: %s\n"), MessageBuffer+44);
+
+  /* These bytes are probably the source of the "Accessory not connected"
+     messages on the phone when trying to emulate NCDS... I hope....
+     UPDATE: of course, now we have the authentication algorithm. */
+  fprintf(stdout, _("   Magic bytes: %02x %02x %02x %02x\n"), MessageBuffer[50], MessageBuffer[51], MessageBuffer[52], MessageBuffer[53]);
+#endif /* DEBUG */
+
+  MagicBytes[0]=MessageBuffer[50];
+  MagicBytes[1]=MessageBuffer[51];
+  MagicBytes[2]=MessageBuffer[52];
+  MagicBytes[3]=MessageBuffer[53];
+
+  CurrentMagicError=GE_NONE;
+}
+
+/* This function provides Nokia authentication protocol.
+
+   This code is written specially for gnokii project by Odinokov Serge.
+   If you have some special requests for Serge just write him to
+   apskaita@post.omnitel.net or serge@takas.lt
+
+   Reimplemented in C by Pavel Janík ml.
+
+   Nokia authentication protocol is used in the communication between Nokia
+   mobile phones (e.g. Nokia 6110) and Nokia Cellular Data Suite software,
+   commercially sold by Nokia Corp.
+
+   The authentication scheme is based on the token send by the phone to the
+   software. The software does it's magic (see the function
+   FB61_GetNokiaAuth()) and returns the result back to the phone. If the
+   result is correct the phone responds with the message "Accessory
+   connected!" displayed on the LCD. Otherwise it will display "Accessory not
+   supported" and some functions will not be available for use.
+
+   The specification of the protocol is not publicly available, no comment. */
+static void N6110_GetNokiaAuth(unsigned char *Imei, unsigned char *MagicBytes, unsigned char *MagicResponse)
+{
+
+  int i, j, CRC=0;
+
+  /* This is our temporary working area. */
+
+  unsigned char Temp[16];
+
+  /* Here we put FAC (Final Assembly Code) and serial number into our area. */
+
+  Temp[0]  = Imei[6];
+  Temp[1]  = Imei[7];
+  Temp[2]  = Imei[8];
+  Temp[3]  = Imei[9];
+  Temp[4]  = Imei[10];
+  Temp[5]  = Imei[11];
+  Temp[6]  = Imei[12];
+  Temp[7]  = Imei[13];
+
+  /* And now the TAC (Type Approval Code). */
+
+  Temp[8]  = Imei[2];
+  Temp[9]  = Imei[3];
+  Temp[10] = Imei[4];
+  Temp[11] = Imei[5];
+
+  /* And now we pack magic bytes from the phone. */
+
+  Temp[12] = MagicBytes[0];
+  Temp[13] = MagicBytes[1];
+  Temp[14] = MagicBytes[2];
+  Temp[15] = MagicBytes[3];
+
+  for (i=0; i<=11; i++)
+    if (Temp[i + 1]& 1)
+      Temp[i]<<=1;
+
+  switch (Temp[15] & 0x03) {
+
+  case 1:
+  case 2:
+    j = Temp[13] & 0x07;
+
+    for (i=0; i<=3; i++)
+      Temp[i+j] ^= Temp[i+12];
+
+    break;
+
+  default:
+    j = Temp[14] & 0x07;
+
+    for (i=0; i<=3; i++)
+      Temp[i + j] |= Temp[i + 12];
+  }
+
+  for (i=0; i<=15; i++)
+    CRC ^= Temp[i];
+
+  for (i=0; i<=15; i++) {
+
+    switch (Temp[15 - i] & 0x06) {
+
+    case 0:
+      j = Temp[i] | CRC;
+      break;
+
+    case 2:
+    case 4:
+      j = Temp[i] ^ CRC;
+      break;
+
+    case 6:
+      j = Temp[i] & CRC;
+      break;
+    }
+  
+    if (j == CRC)
+      j = 0x2c;
+
+    if (Temp[i] == 0)
+      j = 0;
+
+    MagicResponse[i] = j;
+
+  }
+}
+
+static GSM_Error N6110_Authentication()
+{
+  unsigned char connect1[] = {N6110_FRAME_HEADER, 0x0d, 0x00, 0x00, 0x02};
+  unsigned char connect2[] = {N6110_FRAME_HEADER, 0x20, 0x02};
+  unsigned char connect3[] = {N6110_FRAME_HEADER, 0x0d, 0x01, 0x00, 0x02};
+  unsigned char connect4[] = {N6110_FRAME_HEADER, 0x10};
+  
+  unsigned char magic_connect[] = {N6110_FRAME_HEADER,
+  0x12,
+
+  /* The real magic goes here ... These bytes are filled in with the
+     function N6110_GetNokiaAuth(). */
+
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+
+  /* NOKIA&GNOKII Accessory */
+
+  0x4e, 0x4f, 0x4b, 0x49, 0x41, 0x26, 0x4e, 0x4f, 0x4b, 0x49, 0x41, 0x20,
+  0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x79,
+  
+  0x00, 0x00, 0x00, 0x00};
+
+#ifdef DEBUG
+  fprintf(stdout,_("Making authentication!\n"));
+#endif
+
+  usleep(100); Protocol->SendMessage(7, 0x02, connect1);
+  usleep(100); Protocol->SendMessage(5, 0x02, connect2);
+  usleep(100); Protocol->SendMessage(7, 0x02, connect3);
+      
+  CurrentMagicError = GE_BUSY;
+
+  usleep(100); Protocol->SendMessage(4, 0x64, connect4);
+  if (NULL_WaitUntil(50,&CurrentMagicError)!=GE_NONE) return GE_TIMEOUT;
+
+  N6110_GetNokiaAuth(Current_IMEI, MagicBytes, magic_connect+4);
+
+  Protocol->SendMessage(45, 0x64, magic_connect);
+
+#ifdef DEBUG
+  fprintf(stdout,_("End of authentication!\n"));
+#endif
+
+  return GE_NONE;
+}
+
+/* Initialise variables and state machine. */
+GSM_Error N6110_Initialise(char *port_device, char *initlength,
+                          GSM_ConnectionType connection,
+                          void (*rlp_callback)(RLP_F96Frame *frame))
+{
+  unsigned char init_char = N6110_SYNC_BYTE;
+#ifndef UCLINUX
+  unsigned char end_init_char = N6110_IR_END_SYNC_BYTE;
+#endif /* UCLINUX */
+
+  int count;
+  int InitLength;
+  
+  if (Protocol->Initialise(port_device,initlength,connection,rlp_callback)!=GE_NONE)
+  {
+    return GE_NOTSUPPORTED;
+  }
 
   switch (CurrentConnectionType) {
 
   switch (CurrentConnectionType) {
+#ifndef UCLINUX
     case GCT_Irda:
     case GCT_MBUS:
       /* We don't think about authentication in Irda, because
          AFAIK there are no phones working over sockets
         and having authentication. In MBUS it doesn't work */
     case GCT_Irda:
     case GCT_MBUS:
       /* We don't think about authentication in Irda, because
          AFAIK there are no phones working over sockets
         and having authentication. In MBUS it doesn't work */
-      usleep(100);\r
-\r
-      if (N6110_SendIDFrame()!=GE_NONE) return GE_TIMEOUT;\r
-    \r
-      if (N6110_SendIMEIFrame()!=GE_NONE) return GE_TIMEOUT;    \r
-\r
-      if (N6110_SendHWFrame()!=GE_NONE) return GE_TIMEOUT;    \r
-
-      CurrentLinkOK = true;                           \r      \r
+      usleep(100);
+
+      if (N6110_SendIDFrame()!=GE_NONE) return GE_TIMEOUT;
+    
+      if (N6110_SendIMEIFrame()!=GE_NONE) return GE_TIMEOUT;    
+
+      if (N6110_SendHWFrame()!=GE_NONE) return GE_TIMEOUT;    
+
+      CurrentLinkOK = true;                                 
       break;
       break;
+#endif /* UCLINUX */
       
     case GCT_FBUS:
       
     case GCT_FBUS:
+#ifndef UCLINUX
     case GCT_Infrared:
     case GCT_Tekram:
     case GCT_Infrared:
     case GCT_Tekram:
-      InitLength = atoi(initlength);\r
-\r
-      if ((strcmp(initlength, "default") == 0) || (InitLength == 0)) {\r
-        InitLength = 250;      /* This is the usual value, lower may work. */\r
-      }\r
-\r
+#endif /* UCLINUX */
+      InitLength = atoi(initlength);
+
+      if ((strcmp(initlength, "default") == 0) || (InitLength == 0)) {
+        InitLength = 250;      /* This is the usual value, lower may work. */
+      }
+
+#ifndef UCLINUX
       if (CurrentConnectionType==GCT_Infrared ||
       if (CurrentConnectionType==GCT_Infrared ||
-          CurrentConnectionType==GCT_Tekram) {\r
-#ifdef DEBUG\r
-        fprintf(stdout,_("Setting infrared for FBUS communication...\n"));\r
-#endif\r
-        device_changespeed(9600);\r
-      }\r
-
-#ifdef DEBUG\r
-      fprintf(stdout,_("Writing init chars...."));\r
-#endif\r
-\r
-      /* Initialise link with phone or what have you */\r
-      /* Send init string to phone, this is a bunch of 0x55 characters. Timing is\r
-         empirical. */\r
-      for (count = 0; count < InitLength; count ++) {\r
+          CurrentConnectionType==GCT_Tekram) {
+#ifdef DEBUG
+        fprintf(stdout,_("Setting infrared for FBUS communication...\n"));
+#endif
+        device_changespeed(9600);
+      }
+#endif /* UCLINUX */
+
+#ifdef DEBUG
+      fprintf(stdout,_("Writing init chars...."));
+#endif
+
+      /* Initialise link with phone or what have you */
+      /* Send init string to phone, this is a bunch of 0x55 characters. Timing is
+         empirical. */
+      for (count = 0; count < InitLength; count ++) {
+#ifndef UCLINUX
         if (CurrentConnectionType!=GCT_Infrared &&
         if (CurrentConnectionType!=GCT_Infrared &&
-            CurrentConnectionType!=GCT_Tekram) \r        usleep(100);\r
-        Protocol->WritePhone(1,&init_char);\r
-      }\r
-\r
+            CurrentConnectionType!=GCT_Tekram)
+#endif /* UCLINUX */
+                                       usleep(100);
+        Protocol->WritePhone(1,&init_char);
+      }
+
+#ifndef UCLINUX
       if (CurrentConnectionType==GCT_Infrared ||
       if (CurrentConnectionType==GCT_Infrared ||
-          CurrentConnectionType==GCT_Tekram)\r      {
-        Protocol->WritePhone(1,&end_init_char);\r
+          CurrentConnectionType==GCT_Tekram)      {
+        Protocol->WritePhone(1,&end_init_char);
         usleep(200000);
       }
         usleep(200000);
       }
+#endif /* UCLINUX */
 
 
-#ifdef DEBUG\r
-      fprintf(stdout,_("Done\n"));  \r
-#endif\r
+#ifdef DEBUG
+      fprintf(stdout,_("Done\n"));  
+#endif
 
 
+#ifndef UCLINUX
       if (CurrentConnectionType==GCT_Infrared ||
       if (CurrentConnectionType==GCT_Infrared ||
-          CurrentConnectionType==GCT_Tekram)\r      {
-        device_changespeed(115200);    \r
+          CurrentConnectionType==GCT_Tekram)      {
+        device_changespeed(115200);    
       }
       }
+#endif /* UCLINUX */
+
+      N6110_SendStatusRequest();
+    
+      usleep(100);
+
+      if (N6110_SendIDFrame()!=GE_NONE) return GE_TIMEOUT;
+    
+      /* N51xx/61xx have something called authentication.
+         After making it phone display "Accessory connected"
+         and probably give access to some function (I'm not too sure about it !)
+         Anyway, I make it now for N51xx/61xx */
+      if (GetModelFeature (FN_AUTHENTICATION)!=0) {
+        if (N6110_Authentication()!=GE_NONE) return GE_TIMEOUT;
+      } else {        /* No authentication */
+        if (N6110_SendIMEIFrame()!=GE_NONE) return GE_TIMEOUT;    
 
 
-      N6110_SendStatusRequest();\r
-    \r
-      usleep(100);\r
-\r
-      if (N6110_SendIDFrame()!=GE_NONE) return GE_TIMEOUT;\r
-    \r
-      /* N51xx/61xx have something called authentication.\r
-         After making it phone display "Accessory connected"\r
-         and probably give access to some function (I'm not too sure about it !)\r
-         Anyway, I make it now for N51xx/61xx */\r
-      if (GetModelFeature (FN_AUTHENTICATION)!=0) {\r
-        if (N6110_Authentication()!=GE_NONE) return GE_TIMEOUT;\r
-      } else {\r        /* No authentication */
-        if (N6110_SendIMEIFrame()!=GE_NONE) return GE_TIMEOUT;    \r
-\r
-        if (N6110_SendHWFrame()!=GE_NONE) return GE_TIMEOUT;    \r
-      }\r
+        if (N6110_SendHWFrame()!=GE_NONE) return GE_TIMEOUT;    
+      }
       
       break;
     default:
       
       break;
     default:
-#ifdef DEBUG\r
-      fprintf(stdout,_("Unknown connection type in n6110.c!\n"));\r
-#endif\r
+#ifdef DEBUG
+      fprintf(stdout,_("Unknown connection type in n6110.c!\n"));
+#endif
       break;
   }
 
       break;
   }
 
-  return (GE_NONE);\r
-}\r
-\r
-/* This function translates GMT_MemoryType to N6110_MEMORY_xx */\r
-int N6110_GetMemoryType(GSM_MemoryType memory_type)\r
-{\r
-\r
-  int result;\r
-\r
-  switch (memory_type) {\r
-\r
-     case GMT_MT: result = N6110_MEMORY_MT; break;\r
-     case GMT_ME: result = N6110_MEMORY_ME; break;\r
-     case GMT_SM: result = N6110_MEMORY_SM; break;\r
-     case GMT_FD: result = N6110_MEMORY_FD; break;\r
-     case GMT_ON: result = N6110_MEMORY_ON; break;\r
-     case GMT_EN: result = N6110_MEMORY_EN; break;\r
-     case GMT_DC: result = N6110_MEMORY_DC; break;\r
-     case GMT_RC: result = N6110_MEMORY_RC; break;\r
-     case GMT_MC: result = N6110_MEMORY_MC; break;\r
-     default    : result = N6110_MEMORY_XX;\r
-\r
-   }\r
-\r
-   return (result);\r
-}\r
+  return (GE_NONE);
+}
+
+/* This function translates GMT_MemoryType to N6110_MEMORY_xx */
+int N6110_GetMemoryType(GSM_MemoryType memory_type)
+{
+
+  int result;
+
+  switch (memory_type) {
+
+     case GMT_MT: result = N6110_MEMORY_MT; break;
+     case GMT_ME: result = N6110_MEMORY_ME; break;
+     case GMT_SM: result = N6110_MEMORY_SM; break;
+     case GMT_FD: result = N6110_MEMORY_FD; break;
+     case GMT_ON: result = N6110_MEMORY_ON; break;
+     case GMT_EN: result = N6110_MEMORY_EN; break;
+     case GMT_DC: result = N6110_MEMORY_DC; break;
+     case GMT_RC: result = N6110_MEMORY_RC; break;
+     case GMT_MC: result = N6110_MEMORY_MC; break;
+     default    : result = N6110_MEMORY_XX;
+
+   }
+
+   return (result);
+}
+
+#ifndef UCLINUX
 
 void N6110_ReplyCallDivert(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
 
 
 void N6110_ReplyCallDivert(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
 
@@ -743,14 +841,14 @@ void N6110_ReplyCallDivert(u16 MessageLength, u8 *MessageBuffer, u8 MessageType)
       CurrentCallDivert->Enabled=false;
     }
 
       CurrentCallDivert->Enabled=false;
     }
 
-    CurrentCallDivertError=GE_NONE;\r
+    CurrentCallDivertError=GE_NONE;
     break;
 
     break;
 
-  case 0x03:\r
+  case 0x03:
 #ifdef DEBUG
     fprintf(stdout, _("Message: Call divert status receiving error ?\n"));
 #ifdef DEBUG
     fprintf(stdout, _("Message: Call divert status receiving error ?\n"));
-#endif\r
-    CurrentCallDivertError=GE_UNKNOWN;\r
+#endif
+    CurrentCallDivertError=GE_UNKNOWN;
     break;
   }
 }
     break;
   }
 }
@@ -768,8 +866,8 @@ GSM_Error N6110_CallDivert(GSM_CallDivert *cd)
   int length = 0x09;
 
   switch (cd->Operation) {
   int length = 0x09;
 
   switch (cd->Operation) {
-    case GSM_CDV_Register:\r
-    case GSM_CDV_Enable:\r
+    case GSM_CDV_Register:
+    case GSM_CDV_Enable:
       req[4] = 0x03;
       req[8] = 0x01;
       req[29]= GSM_PackSemiOctetNumber(cd->Number, req + 9, false);
       req[4] = 0x03;
       req[8] = 0x01;
       req[29]= GSM_PackSemiOctetNumber(cd->Number, req + 9, false);
@@ -816,96 +914,96 @@ GSM_Error N6110_CallDivert(GSM_CallDivert *cd)
 
   return error;
 }
 
   return error;
 }
-\r
-GSM_Error N6110_Tests()\r
-{\r
-  unsigned char buffer[3]={0x00,0x01,0xcf};\r
-  unsigned char buffer3[8]={0x00,0x01,0xce,0x1d,0xfe,0x23,0x00,0x00};\r
+
+GSM_Error N6110_Tests()
+{
+  unsigned char buffer[3]={0x00,0x01,0xcf};
+  unsigned char buffer3[8]={0x00,0x01,0xce,0x1d,0xfe,0x23,0x00,0x00};
   
   GSM_Error error;
   
   GSM_Error error;
-\r
-  error=N6110_EnableExtendedCommands(0x01);\r
+
+  error=N6110_EnableExtendedCommands(0x01);
   if (error!=GE_NONE) return error;
   if (error!=GE_NONE) return error;
-\r
-  //make almost all tests\r
-  Protocol->SendMessage(8, 0x40, buffer3);\r
-\r
-  while (GSM->Initialise(PortDevice, "50", CurrentConnectionType, CurrentRLP_RXCallback)!=GE_NONE) {};\r
-\r
-  sleep(2);\r
-\r
-  return NULL_SendMessageSequence\r
-    (200, &CurrentNetworkInfoError, 3, 0x40, buffer);  \r
-}\r
-\r
-void N6110_DisplayTestsInfo(u8 *MessageBuffer) {\r
-\r
-  int i;\r
-\r
-  CurrentNetworkInfoError=GE_NONE;\r
-\r
-  for (i=0;i<MessageBuffer[3];i++) {\r
-    switch (i) {\r
-      case 0: fprintf(stdout,_("Unknown(%i)              "),i);break;\r
-      case 1: fprintf(stdout,_("MCU ROM checksum        "));break;\r
-      case 2: fprintf(stdout,_("MCU RAM interface       "));break;\r
-      case 3: fprintf(stdout,_("MCU RAM component       "));break;\r
-      case 4: fprintf(stdout,_("MCU EEPROM interface    "));break;\r
-      case 5: fprintf(stdout,_("MCU EEPROM component    "));break;\r
-      case 6: fprintf(stdout,_("Real Time Clock battery "));break;\r
-      case 7: fprintf(stdout,_("CCONT interface         "));break;\r
-      case 8: fprintf(stdout,_("AD converter            "));break;\r
-      case 9: fprintf(stdout,_("SW Reset                "));break;\r
-      case 10:fprintf(stdout,_("Power Off               "));break;\r
-      case 11:fprintf(stdout,_("Security Data           "));break;\r
-      case 12:fprintf(stdout,_("EEPROM Tune checksum    "));break;\r
-      case 13:fprintf(stdout,_("PPM checksum            "));break;\r
-      case 14:fprintf(stdout,_("MCU download DSP        "));break;\r
-      case 15:fprintf(stdout,_("DSP alive               "));break;\r
-      case 16:fprintf(stdout,_("COBBA serial            "));break;\r
-      case 17:fprintf(stdout,_("COBBA paraller          "));break;\r
-      case 18:fprintf(stdout,_("EEPROM security checksum"));break;\r
-      case 19:fprintf(stdout,_("PPM validity            "));break;\r
-      case 20:fprintf(stdout,_("Warranty state          "));break;\r
-      case 21:fprintf(stdout,_("Simlock check           "));break;\r
-      case 22:fprintf(stdout,_("IMEI check?             "));break;//from PC-Locals.is OK?\r
-      default:fprintf(stdout,_("Unknown(%i)             "),i);break;\r
-    }\r
-    switch (MessageBuffer[4+i]) {\r
-      case 0:   fprintf(stdout,_(" : done, result OK"));break;\r
-      case 0xff:fprintf(stdout,_(" : not done, result unknown"));break;\r
-      case 254: fprintf(stdout,_(" : done, result NOT OK"));break;\r
-      default:  fprintf(stdout,_(" : result unknown(%i)"),MessageBuffer[4+i]);break;\r
-    }\r
-    fprintf(stdout,_("\n"));\r
-  }\r
-}\r
 
 
-void N6110_ReplySimlockInfo(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+  //make almost all tests
+  Protocol->SendMessage(8, 0x40, buffer3);
 
 
-  int i, j;
-  
-  char uni[100];
-    \r
-#ifdef DEBUG
-  fprintf(stdout, _("Message: Simlock info received\n"));
-\r
-  j=0;\r
-  for (i=0; i < 12; i++)\r
-  {\r
-    if (j<24) {\r
-      fprintf(stdout,_("%c"), ('0' + (MessageBuffer[9+i] >> 4)));\r
-      j++;\r
-    }\r
-    if (j==5 || j==15) fprintf(stdout, _("\n"));\r
-    if (j!=15) {\r
-      if (j<24) {\r
-        fprintf(stdout,_("%c"), ('0' + (MessageBuffer[9+i] & 0x0f)));\r
-       j++;\r
-      }\r
-    } else j++;\r
-    if (j==20 || j==24) fprintf(stdout, _("\n"));\r
-  }\r
+  while (GSM->Initialise(PortDevice, "50", CurrentConnectionType, CurrentRLP_RXCallback)!=GE_NONE) {};
+
+  sleep(2);
+
+  return NULL_SendMessageSequence
+    (200, &CurrentNetworkInfoError, 3, 0x40, buffer);  
+}
+
+void N6110_DisplayTestsInfo(u8 *MessageBuffer) {
+
+  int i;
+
+  CurrentNetworkInfoError=GE_NONE;
+
+  for (i=0;i<MessageBuffer[3];i++) {
+    switch (i) {
+      case 0: fprintf(stdout,_("Unknown(%i)              "),i);break;
+      case 1: fprintf(stdout,_("MCU ROM checksum        "));break;
+      case 2: fprintf(stdout,_("MCU RAM interface       "));break;
+      case 3: fprintf(stdout,_("MCU RAM component       "));break;
+      case 4: fprintf(stdout,_("MCU EEPROM interface    "));break;
+      case 5: fprintf(stdout,_("MCU EEPROM component    "));break;
+      case 6: fprintf(stdout,_("Real Time Clock battery "));break;
+      case 7: fprintf(stdout,_("CCONT interface         "));break;
+      case 8: fprintf(stdout,_("AD converter            "));break;
+      case 9: fprintf(stdout,_("SW Reset                "));break;
+      case 10:fprintf(stdout,_("Power Off               "));break;
+      case 11:fprintf(stdout,_("Security Data           "));break;
+      case 12:fprintf(stdout,_("EEPROM Tune checksum    "));break;
+      case 13:fprintf(stdout,_("PPM checksum            "));break;
+      case 14:fprintf(stdout,_("MCU download DSP        "));break;
+      case 15:fprintf(stdout,_("DSP alive               "));break;
+      case 16:fprintf(stdout,_("COBBA serial            "));break;
+      case 17:fprintf(stdout,_("COBBA paraller          "));break;
+      case 18:fprintf(stdout,_("EEPROM security checksum"));break;
+      case 19:fprintf(stdout,_("PPM validity            "));break;
+      case 20:fprintf(stdout,_("Warranty state          "));break;
+      case 21:fprintf(stdout,_("Simlock check           "));break;
+      case 22:fprintf(stdout,_("IMEI check?             "));break;//from PC-Locals.is OK?
+      default:fprintf(stdout,_("Unknown(%i)             "),i);break;
+    }
+    switch (MessageBuffer[4+i]) {
+      case 0:   fprintf(stdout,_(" : done, result OK"));break;
+      case 0xff:fprintf(stdout,_(" : not done, result unknown"));break;
+      case 254: fprintf(stdout,_(" : done, result NOT OK"));break;
+      default:  fprintf(stdout,_(" : result unknown(%i)"),MessageBuffer[4+i]);break;
+    }
+    fprintf(stdout,_("\n"));
+  }
+}
+
+void N6110_ReplySimlockInfo(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int i, j;
+  
+  char uni[100];
+    
+#ifdef DEBUG
+  fprintf(stdout, _("Message: Simlock info received\n"));
+
+  j=0;
+  for (i=0; i < 12; i++)
+  {
+    if (j<24) {
+      fprintf(stdout,_("%c"), ('0' + (MessageBuffer[9+i] >> 4)));
+      j++;
+    }
+    if (j==5 || j==15) fprintf(stdout, _("\n"));
+    if (j!=15) {
+      if (j<24) {
+        fprintf(stdout,_("%c"), ('0' + (MessageBuffer[9+i] & 0x0f)));
+       j++;
+      }
+    } else j++;
+    if (j==20 || j==24) fprintf(stdout, _("\n"));
+  }
       
   if ((MessageBuffer[6] & 1) == 1) fprintf(stdout,_("lock 1 closed\n"));
   if ((MessageBuffer[6] & 2) == 2) fprintf(stdout,_("lock 2 closed\n"));
       
   if ((MessageBuffer[6] & 1) == 1) fprintf(stdout,_("lock 1 closed\n"));
   if ((MessageBuffer[6] & 2) == 2) fprintf(stdout,_("lock 2 closed\n"));
@@ -967,17 +1065,17 @@ void N6110_ReplySimlockInfo(u16 MessageLength, u8 *MessageBuffer, u8 MessageType
   CurrentSimlockInfoError=GE_NONE;
 }
 
   CurrentSimlockInfoError=GE_NONE;
 }
 
-GSM_Error N6110_SimlockInfo(GSM_AllSimlocks *siml)\r
-{\r
-\r  GSM_Error error;
-  unsigned char req[] = {0x00,0x01,0x8a,0x00};\r\r
-  error=N6110_EnableExtendedCommands(0x01);\r
+GSM_Error N6110_SimlockInfo(GSM_AllSimlocks *siml)
+{
+  GSM_Error error;
+  unsigned char req[] = {0x00,0x01,0x8a,0x00};
+  error=N6110_EnableExtendedCommands(0x01);
   if (error!=GE_NONE) return error;
 
   CurrentSimLock=siml;
  
   if (error!=GE_NONE) return error;
 
   CurrentSimLock=siml;
  
-  return NULL_SendMessageSequence (50, &CurrentSimlockInfoError, 4, 0x40, req);  \r
-}\r
+  return NULL_SendMessageSequence (50, &CurrentSimlockInfoError, 4, 0x40, req);  
+}
 
 void N6110_ReplyResetPhoneSettings(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
 
 
 void N6110_ReplyResetPhoneSettings(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
 
@@ -988,4646 +1086,4728 @@ void N6110_ReplyResetPhoneSettings(u16 MessageLength, u8 *MessageBuffer, u8 Mess
   CurrentResetPhoneSettingsError=GE_NONE;
 }
 
   CurrentResetPhoneSettingsError=GE_NONE;
 }
 
-GSM_Error N6110_ResetPhoneSettings()\r
-{\r
-\r  GSM_Error error;
-  unsigned char req[] = {0x00,0x01,0x65,0x08,0x00};\r  \r
-  error=N6110_EnableExtendedCommands(0x01);\r
+GSM_Error N6110_ResetPhoneSettings()
+{
+  GSM_Error error;
+  unsigned char req[] = {0x00,0x01,0x65,0x08,0x00};  
+  error=N6110_EnableExtendedCommands(0x01);
   if (error!=GE_NONE) return error;
 
   if (error!=GE_NONE) return error;
 
-  return NULL_SendMessageSequence\r
-    (50, &CurrentResetPhoneSettingsError, 5, 0x40, req);  \r
-}\r\r
+  return NULL_SendMessageSequence
+    (50, &CurrentResetPhoneSettingsError, 5, 0x40, req);  
+}
+
+#endif /* UCLINUX */
+
 GSM_Error N6110_GetManufacturer(char *manufacturer)
 {
        strcpy (manufacturer, "Nokia");
        return (GE_NONE);
 }
 
 GSM_Error N6110_GetManufacturer(char *manufacturer)
 {
        strcpy (manufacturer, "Nokia");
        return (GE_NONE);
 }
 
-GSM_Error N6110_GetVoiceMailbox ( GSM_PhonebookEntry *entry)\r
-{\r
-  unsigned char req[] = {N6110_FRAME_HEADER, 0x01, 0x00, 0x00, 0x00};\r
-\r
-  GSM_Error error;\r
-  \r
-  CurrentPhonebookEntry = entry;\r
-\r
-  req[4] = N6110_MEMORY_VOICE;\r
-  req[5] = 0x00; /* Location - isn't important, but... */\r
-\r
-  error=NULL_SendMessageSequence\r
-    (20, &CurrentPhonebookError, 7, 0x03, req);\r
-    \r
-  CurrentPhonebookEntry = NULL;\r
-  \r
-  return error;\r
-}\r
-\r
-void N6110_ReplyGetOperatorName(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int i, count;\r
-  \r
-  GSM_Bitmap NullBitmap;\r
-\r
-  DecodeNetworkCode(MessageBuffer+5, NullBitmap.netcode);\r
-  \r
-  count=8;\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: Info about downloaded operator name received: %s network (for gnokii \"%s\", for phone \""),\r
-          NullBitmap.netcode,\r
-         GSM_GetNetworkName(NullBitmap.netcode));      \r
-#endif\r
-      \r
-  i=count;\r
-  while (MessageBuffer[count]!=0) {\r
-#ifdef DEBUG\r
-    fprintf(stdout,_("%c"),MessageBuffer[count]);\r
-#endif\r
-    count++;\r
-  }\r
-      \r
- strcpy(CurrentGetOperatorNameNetwork->Code, NullBitmap.netcode);\r
- strncpy(CurrentGetOperatorNameNetwork->Name, MessageBuffer+i,count-i+1);\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout,_("\")\n"));\r
-#endif\r
-          \r
-  CurrentGetOperatorNameError=GE_NONE;\r
-}\r
-\r
-GSM_Error N6110_GetOperatorName (GSM_Network *operator)\r
-{\r
-  unsigned char req[] = { 0x00,0x01,0x8c,0x00};\r
-\r
-  GSM_Error error;\r
-\r
-  error=N6110_EnableExtendedCommands(0x01);\r
-  if (error!=GE_NONE) return error;\r
-\r
-  CurrentGetOperatorNameNetwork = operator;\r
-\r
-  error=NULL_SendMessageSequence\r
-    (20, &CurrentGetOperatorNameError, 4, 0x40, req);\r
-\r
-  CurrentGetOperatorNameNetwork = NULL;\r
-  \r
-  return error;\r
-}\r
-\r
-void N6110_ReplySetOperatorName(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-    \r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: Downloaded operator name changed\n"));\r
-#endif    \r
-\r
-  CurrentSetOperatorNameError=GE_NONE;      \r
-}\r
-\r
-GSM_Error N6110_SetOperatorName (GSM_Network *operator)\r
-{\r
-  unsigned char req[256] = { 0x00,0x01,0x8b,0x00,\r
-                             0x00,0x00, /* MCC */\r
-                            0x00};     /* MNC */\r
-\r
-  GSM_Error error;\r
-\r
-  error=N6110_EnableExtendedCommands(0x01);\r
-  if (error!=GE_NONE) return error;\r
-\r
-  EncodeNetworkCode(req+4,operator->Code);\r
-\r
-  strncpy(req+7,operator->Name,200);\r
-    \r
-  return NULL_SendMessageSequence\r
-    (20, &CurrentSetOperatorNameError, 8+strlen(operator->Name), 0x40, req);\r
-}\r
-\r
-void N6110_ReplyGetMemoryStatus(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch (MessageBuffer[3]) {\r
-\r
-  case 0x08:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Memory status received:\n"));\r
-\r
-    fprintf(stdout, _("   Memory Type: %s\n"), N6110_MemoryType_String[MessageBuffer[4]]);\r
-    fprintf(stdout, _("   Used: %d\n"), MessageBuffer[6]);\r
-    fprintf(stdout, _("   Free: %d\n"), MessageBuffer[5]);\r
-#endif /* DEBUG */\r
-\r
-    CurrentMemoryStatus->Used = MessageBuffer[6];\r
-    CurrentMemoryStatus->Free = MessageBuffer[5];\r
-    CurrentMemoryStatusError = GE_NONE;\r
-\r
-    break;\r
-\r
-  case 0x09:\r
-\r
-#ifdef DEBUG\r
-    switch (MessageBuffer[4]) {\r
-      case 0x6f:\r
-       fprintf(stdout, _("Message: Memory status error, phone is probably powered off.\n"));break;\r
-      case 0x7d:\r
-       fprintf(stdout, _("Message: Memory status error, memory type not supported by phone model.\n"));break;\r
-      case 0x8d:\r
-       fprintf(stdout, _("Message: Memory status error, waiting for security code.\n"));break;\r
-      default:\r
-       fprintf(stdout, _("Message: Unknown Memory status error, subtype (MessageBuffer[4]) = %02x\n"),MessageBuffer[4]);break;\r
-    }\r
-#endif\r
-\r
-    switch (MessageBuffer[4]) {\r
-      case 0x6f:CurrentMemoryStatusError = GE_TIMEOUT;break;\r
-      case 0x7d:CurrentMemoryStatusError = GE_INTERNALERROR;break;\r
-      case 0x8d:CurrentMemoryStatusError = GE_INVALIDSECURITYCODE;break;\r
-      default:break;\r
-    }\r
-\r
-    break;\r
-\r
-  }\r
-}\r
-\r
-/* This function is used to get storage status from the phone. It currently\r
-   supports two different memory areas - internal and SIM. */\r
-GSM_Error N6110_GetMemoryStatus(GSM_MemoryStatus *Status)\r
-{\r
-  unsigned char req[] = { N6110_FRAME_HEADER,\r
-                          0x07, /* MemoryStatus request */\r
-                          0x00  /* MemoryType */\r
-                        };\r
-\r
-  GSM_Error error;\r
-  \r
-  CurrentMemoryStatus = Status;\r
-\r
-  req[4] = N6110_GetMemoryType(Status->MemoryType);\r
-\r
-  error=NULL_SendMessageSequence\r
-    (20, &CurrentMemoryStatusError, 5, 0x03, req);\r
-\r
-  CurrentMemoryStatus = NULL;\r
-\r
-  return error;\r
-}\r
-\r
-void N6110_ReplyGetNetworkInfo(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  GSM_NetworkInfo NullNetworkInfo;\r
-  \r
-  /* Make sure we are expecting NetworkInfo frame */\r
-  if (CurrentNetworkInfo && CurrentNetworkInfoError == GE_BUSY) {\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Network informations:\n"));\r
-#endif\r
-  } else {\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Network informations not requested, but received:\n"));\r
-#endif\r
-  }\r
-      \r
-  sprintf(NullNetworkInfo.NetworkCode, "%x%x%x %x%x", MessageBuffer[14] & 0x0f, MessageBuffer[14] >>4, MessageBuffer[15] & 0x0f, MessageBuffer[16] & 0x0f, MessageBuffer[16] >>4);\r
-\r
-  sprintf(NullNetworkInfo.CellID, "%02x%02x", MessageBuffer[10], MessageBuffer[11]);\r
-\r
-  sprintf(NullNetworkInfo.LAC, "%02x%02x", MessageBuffer[12], MessageBuffer[13]);\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("   CellID: %s\n"), NullNetworkInfo.CellID);\r
-  fprintf(stdout, _("   LAC: %s\n"), NullNetworkInfo.LAC);\r
-  fprintf(stdout, _("   Network code: %s\n"), NullNetworkInfo.NetworkCode);\r
-  fprintf(stdout, _("   Network name: %s (%s)\n"),\r
-                     GSM_GetNetworkName(NullNetworkInfo.NetworkCode),\r
-                     GSM_GetCountryName(NullNetworkInfo.NetworkCode));\r
-  fprintf(stdout, _("   Status: "));\r
-\r
-  switch (MessageBuffer[8]) {\r
-    case 0x01: fprintf(stdout, _("home network selected")); break;\r
-    case 0x02: fprintf(stdout, _("roaming network")); break;\r
-    case 0x03: fprintf(stdout, _("requesting network")); break;\r
-    case 0x04: fprintf(stdout, _("not registered in the network")); break;\r
-    default: fprintf(stdout, _("unknown"));\r
-  }\r
-\r
-  fprintf(stdout, "\n");\r
-\r
-  fprintf(stdout, _("   Network selection: %s\n"), MessageBuffer[9]==1?_("manual"):_("automatic"));\r
-#endif /* DEBUG */\r
-\r
-  /* Make sure we are expecting NetworkInfo frame */\r
-  if (CurrentNetworkInfo && CurrentNetworkInfoError == GE_BUSY)\r
-    *CurrentNetworkInfo=NullNetworkInfo;\r
-\r
-  CurrentNetworkInfoError = GE_NONE;      \r
-}\r
-\r
-GSM_Error N6110_GetNetworkInfo(GSM_NetworkInfo *NetworkInfo)\r
-{\r
-  unsigned char req[] = { N6110_FRAME_HEADER,\r
-                          0x70\r
-                        };\r
-\r
-  GSM_Error error;\r
-  \r
-  CurrentNetworkInfo = NetworkInfo;\r
-  \r
-  error=NULL_SendMessageSequence\r
-    (20, &CurrentNetworkInfoError, 4, 0x0a, req);\r
-\r
-  CurrentNetworkInfo = NULL;\r
-\r
-  return error;\r
-}\r
-\r
-void N6110_ReplyGetProductProfileSetting(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int i;\r
-  \r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: Product Profile Settings received -"));\r
-  for (i=0;i<4;i++) fprintf(stdout, _(" %02x"),MessageBuffer[3+i]);\r
-  fprintf(stdout, _("\n"));  \r
-#endif\r
-\r
-  for (i=0;i<4;i++) CurrentPPS[i]=MessageBuffer[3+i];\r
-\r
-  CurrentProductProfileSettingsError=GE_NONE;      \r
-}\r
-\r
-GSM_Error N6110_GetProductProfileSetting (GSM_PPS *PPS)\r
-{\r
-  unsigned char req[] = { 0x00, 0x01,0x6a };\r
-  \r
-  int i,j;\r
-\r
-  GSM_Error error;\r
-\r
-  error=N6110_EnableExtendedCommands(0x01);\r
-  if (error!=GE_NONE) return error;\r
-\r
-  error=NULL_SendMessageSequence\r
-    (20, &CurrentProductProfileSettingsError, 3, 0x40, req);\r
-  if (error!=GE_NONE) return error;    \r
-  \r
-  switch (PPS->Name) {\r
-    case PPS_ALS      : PPS->bool_value=(CurrentPPS[1]&32); break;\r
-    case PPS_GamesMenu: PPS->bool_value=(CurrentPPS[3]&64); break;\r
-    case PPS_HRData   : PPS->bool_value=(CurrentPPS[0]&64); break;\r
-    case PPS_14400Data: PPS->bool_value=(CurrentPPS[0]&128);break;\r
-    case PPS_EFR      : PPS->int_value =(CurrentPPS[0]&1)    +(CurrentPPS[0]&2);    break;\r
-    case PPS_FR       : PPS->int_value =(CurrentPPS[0]&16)/16+(CurrentPPS[0]&32)/16;break;\r
-    case PPS_HR       : PPS->int_value =(CurrentPPS[0]&4)/4  +(CurrentPPS[0]&8)/4;  break;\r
-    case PPS_VibraMenu: PPS->bool_value=(CurrentPPS[4]&64); break;\r
-    case PPS_LCDContrast:\r
-         PPS->int_value=0;\r
-         j=1;\r
-         for (i=0;i<5;i++) {\r
-          if (CurrentPPS[3]&j) PPS->int_value=PPS->int_value+j;\r
-          j=j*2;\r
-        }\r
-        PPS->int_value=PPS->int_value*100/32;\r
-         break;\r
-\r
-  }\r
-  \r
-  return (GE_NONE);\r
-}\r
-\r
-void N6110_ReplySetProductProfileSetting(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#ifdef DEBUG\r
-  int i;\r
-  
-  fprintf(stdout, _("Message: Product Profile Settings set to"));\r
-  for (i=0;i<4;i++) fprintf(stdout, _(" %02x"),CurrentPPS[i]);\r
-  fprintf(stdout, _("\n"));  \r
-#endif\r
-     \r
-  CurrentProductProfileSettingsError=GE_NONE;     \r
-}\r
-\r
-GSM_Error N6110_SetProductProfileSetting (GSM_PPS *PPS)\r
-{\r
-  unsigned char req[] = { 0x00, 0x01,0x6b, \r
-                          0x00, 0x00, 0x00, 0x00 }; /* bytes with Product Profile Setings */\r
-  unsigned char settings[32];\r
-  \r
-  GSM_PPS OldPPS;\r
-  \r
-  int i,j,z;\r
-  \r
-  GSM_Error error;\r
-\r
-  error=N6110_EnableExtendedCommands(0x01);\r
-  if (error!=GE_NONE) return error;\r
-  \r
-  OldPPS.Name=PPS_ALS;\r
-  error=N6110_GetProductProfileSetting(&OldPPS);\r
-  if (error!=GE_NONE) return error;\r
-  \r
-  j=128;z=0;\r
-  for (i=0;i<32;i++) {\r
-    if (CurrentPPS[z]&j)\r
-      settings[i]='1';\r
-    else\r
-      settings[i]='0';    \r
-    if (j==1) {\r
-      j=128;\r
-      z++;\r
-    } else j=j/2;\r
-  }\r
-  \r
-#ifdef DEBUG\r
-  fprintf(stdout,_("Current settings: "));\r
-  for (i=0;i<32;i++) {\r
-    fprintf(stdout,_("%c"),settings[i]);    \r
-  }\r
-  fprintf(stdout,_("\n"));\r
-#endif\r
-\r
-  switch (PPS->Name) {\r
-    case PPS_ALS      :settings[10]=PPS->bool_value?'1':'0';break;\r
-    case PPS_HRData   :settings[ 5]=PPS->bool_value?'1':'0';break;\r
-    case PPS_14400Data:settings[ 6]=PPS->bool_value?'1':'0';break;\r
-    default           :break;\r
-  }\r
-    \r
-  j=128;z=0;\r
-  for (i=0;i<32;i++) {\r
-    if (settings[i]=='1') req[z+3]=req[z+3]+j;\r
-    if (j==1) {\r
-      j=128;\r
-      z++;\r
-    } else j=j/2;\r
-  }  \r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout,_("Current settings: "));\r
-  for (i=0;i<4;i++) {\r
-    fprintf(stdout,_("%i "),req[i+3]);    \r
-  }\r
-  fprintf(stdout,_("\n"));\r
-#endif\r
-\r
-  for (i=0;i<4;i++) {\r
-   CurrentPPS[i]=req[i+3];    \r
-  }\r
-\r
-  return NULL_SendMessageSequence\r
-    (20, &CurrentProductProfileSettingsError, 7, 0x40, req);\r
-}\r
-\r
-void N6110_ReplyPressKey(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-    if (MessageBuffer[4]==CurrentPressKeyEvent) CurrentPressKeyError=GE_NONE;\r
-                                           else CurrentPressKeyError=GE_UNKNOWN; /* MessageBuffer[4] = 0x05 */\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Result of key "));\r
-    switch (MessageBuffer[4])\r
-    {\r
-      case PRESSPHONEKEY:   fprintf(stdout, _("press OK\n"));break;\r
-      case RELEASEPHONEKEY: fprintf(stdout, _("release OK\n"));break;\r
-      default:              fprintf(stdout, _("press or release - error\n"));break;\r
-    }\r
-#endif /* DEBUG */\r
-}\r
-\r
-GSM_Error N6110_PressKey(int key, int event)\r
-{\r
-  unsigned char req[] = {N6110_FRAME_HEADER, 0x42, 0x01, 0x00, 0x01};\r
-  \r
-  req[4]=event; /* if we press or release key */\r
-  req[5]=key;\r
-  \r
-  CurrentPressKeyEvent=event;\r
-  \r
-  return NULL_SendMessageSequence\r
-    (10, &CurrentPressKeyError, 7, 0x0c, req);\r
-}\r
-\r
-void N6110_ReplyDisplayOutput(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  /* Hopefully is 64 larger as FB38_MAX* / N6110_MAX* */\r
-  char model[64];\r
-\r
-  int i, j;\r
-\r
-  char uni[100];\r
-    \r
-  switch(MessageBuffer[3]) {\r
-\r
-  /* Phone sends displayed texts */\r
-  case 0x50:\r
-    NewX=MessageBuffer[6];\r
-    NewY=MessageBuffer[5];\r
-\r
-    DecodeUnicode (uni, MessageBuffer+8, MessageBuffer[7]);\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("New displayed text (%i %i): \"%s\"\n"),NewX,NewY,uni);      \r
-#endif /* DEBUG */\r
-\r
-    while (N6110_GetModel(model)  != GE_NONE)\r
-      sleep(1);\r
-\r
-    /* With these rules it works almost excellent with my N5110 */\r
-    /* I don't have general rule :-(, that's why you must experiment */\r
-    /* with your phone. Nokia could make it better. MW */\r
-    /* It's almost OK for N5110*/\r
-    /* FIX ME: it will be the same for N5130 and 3210 too*/\r
-    if (!strcmp(model,"NSE-1"))\r
-    {\r
-      /* OldX==1000 means - it's first time */\r
-      if (OldX==1000) {\r
-      \r
-        /* Clean table */\r
-        for (i=0;i<5+1;i++) {\r
-          for (j=0;j<27+1;j++) {PhoneScreen[i][j]=' ';}\r
-      }\r
-      OldX=0;\r
-    }\r
-\r
-    if ((OldX==0 && OldY==31 && NewX==29 && NewY==46) ||\r
-        (OldX==0 && OldY==13 && NewX==23 && NewY==46)) {\r
-      /* Clean the line with current text */\r
-      for (j=0;j<27+1;j++) {PhoneScreen[NewY/(47/5)][j]=' ';}\r
-      \r
-      /* Inserts text into table */\r
-      for (i=0; i<MessageBuffer[7];i++) {      \r
-        PhoneScreen[NewY/(47/5)][NewX/(84/27)+i]=uni[i];\r
-      }\r
-\r
-    }\r
-\r
-    if ((OldX==0 && OldY==21 && NewX==0 && NewY==10) ||\r
-        (OldX==0 && OldY==10 && NewX==35 && NewY==46)) {\r
-    } else {\r
-      if ((OldX!=0 && NewX==0 && NewY!=6) ||\r
-          (OldX==0 && NewX!=0 && OldY!=13 && OldY!=22) ||\r
-          (OldX==0 && NewX==0 && NewY<OldY && (NewY!=13 || OldY!=26)) ||\r
-          (OldY==5 && NewY!=5) ||\r
-          (OldX==0 && OldY==13 && NewX==23 && NewY==46)) {\r
-\r
-        /* Writes "old" screen */\r
-        for (i=0;i<5+1;i++) {\r
-          for (j=0;j<27+1;j++) {fprintf(stdout,_("%c"),PhoneScreen[i][j]);}\r
-           fprintf(stdout,_("\n"));\r
-         }\r
-       \r
-         /* Clean table */\r
-          for (i=0;i<5+1;i++) {\r
-           for (j=0;j<27+1;j++) {PhoneScreen[i][j]=' ';}\r
-         }\r
-        }\r
-      }\r
-      \r
-      /* Clean the line with current text */\r
-      for (j=0;j<27+1;j++) {PhoneScreen[NewY/(47/5)][j]=' ';}\r
-      \r
-      /* Inserts text into table */\r
-      for (i=0; i<MessageBuffer[7];i++) {      \r
-        PhoneScreen[NewY/(47/5)][NewX/(84/27)+i]=uni[i];\r
-      }\r
-      \r
-      OldY=NewY;\r
-      OldX=NewX;\r
-    } else {\r
-#ifndef DEBUG\r
-      fprintf(stdout, _("%s\n"),uni);      \r
-#endif\r
-    }\r
-\r
-    break;\r
\r
-  case 0x54:\r
-      \r
-    if (MessageBuffer[4]==1)\r
-    {\r
-      \r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Display output successfully disabled/enabled.\n"));\r
-#endif /* DEBUG */\r
-\r
-      CurrentDisplayOutputError=GE_NONE;\r
-    }\r
-       \r
-    break;\r
-  }\r
-}\r
-\r
-GSM_Error SetDisplayOutput(unsigned char state)\r
-{\r
-  unsigned char req[] = { N6110_FRAME_HEADER,\r
-                          0x53, 0x00};\r
-\r
-  req[4]=state;\r
-  \r
-  return NULL_SendMessageSequence\r
-    (30, &CurrentDisplayOutputError, 5, 0x0d, req);\r
-}\r
-\r
-GSM_Error N6110_EnableDisplayOutput()\r
-{\r
-  return SetDisplayOutput(0x01);\r
-}\r
\r
-GSM_Error N6110_DisableDisplayOutput()\r
-{\r
-  return SetDisplayOutput(0x02);\r
-}\r
-\r
-/* If it is interesting for somebody: we can use 0x40 msg for it\r
-   and it will work for all phones. See n6110.txt for details */\r
-GSM_Error N6110_AnswerCall(char s)\r
-{\r
-       unsigned char req0[] = { N6110_FRAME_HEADER, 0x42,0x05,0x01,0x07,                                0xa2,0x88,0x81,0x21,0x15,0x63,0xa8,0x00,0x00,\r
-                           0x07,0xa3,0xb8,0x81,0x20,0x15,0x63,0x80};\r
-       unsigned char req[] = { N6110_FRAME_HEADER, 0x06, 0x00, 0x00};\r
-\r
-       req[4]=s;\r
-\r
-#ifdef DEBUG\r
-       fprintf(stdout,_("Answering call %d\n\r"),s);\r
-#endif\r
-\r
-       Protocol->SendMessage(sizeof(req0), 0x01, req0);\r
-       sleep(1);\r
-\r
-       return NULL_SendMessageSequence\r
-               (20, &CurrentMagicError, sizeof(req) , 0x01, req);\r
-}\r
-\r
-void N6110_ReplyGetProfile(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch (MessageBuffer[3]) {\r
-\r
-  /* Profile feature */\r
-  case 0x14:   \r
-\r
-    switch(GetModelFeature (FN_PROFILES)) {\r
-      case F_PROF33:\r
-        switch (MessageBuffer[6]) {\r
-          case 0x00: CurrentProfile->KeypadTone  = MessageBuffer[8]; break;\r
-          case 0x01: CurrentProfile->CallAlert   = MessageBuffer[8]; break;\r
-          case 0x02: CurrentProfile->Ringtone    = MessageBuffer[8]; break;\r
-          case 0x03: CurrentProfile->Volume      = MessageBuffer[8]; break;\r
-          case 0x04: CurrentProfile->MessageTone = MessageBuffer[8]; break;\r
-          case 0x05: CurrentProfile->Vibration   = MessageBuffer[8]; break;\r
-          case 0x06: CurrentProfile->WarningTone = MessageBuffer[8]; break;\r
-          case 0x07: CurrentProfile->ScreenSaver = MessageBuffer[8]; break;      \r
-          default:\r
-#ifdef DEBUG\r
-           fprintf(stdout,_("feature %i = value %i\n\n"),MessageBuffer[6],MessageBuffer[8]);\r
-#endif\r
-            break;\r
-        }\r
-        break;\r
-      default:\r
-        switch (MessageBuffer[6]) {\r
-          case 0x00: CurrentProfile->KeypadTone      = MessageBuffer[8];break;\r
-          case 0x01: CurrentProfile->Lights          = MessageBuffer[8];break;\r
-          case 0x02: CurrentProfile->CallAlert       = MessageBuffer[8];break;\r
-          case 0x03: CurrentProfile->Ringtone        = MessageBuffer[8];break;\r
-          case 0x04: CurrentProfile->Volume          = MessageBuffer[8];break;\r
-          case 0x05: CurrentProfile->MessageTone     = MessageBuffer[8];break;\r
-          case 0x06: CurrentProfile->Vibration       = MessageBuffer[8];break;\r
-          case 0x07: CurrentProfile->WarningTone     = MessageBuffer[8];break;\r
-          case 0x08: CurrentProfile->CallerGroups    = MessageBuffer[8];break;\r
-          case 0x09: CurrentProfile->AutomaticAnswer = MessageBuffer[8];break;\r
-          default:\r
-#ifdef DEBUG\r
-           fprintf(stdout,_("feature %i = value %i\n\n"),MessageBuffer[6],MessageBuffer[8]);\r
-#endif\r
-            break;\r
-        }\r
-        break;\r
-    }\r
-\r
-    CurrentProfileError = GE_NONE;\r
-    break;\r
-\r
-  /* Incoming profile name */\r
-  case 0x1b:   \r
-\r
-    if (MessageBuffer[9] == 0x00) {\r
-      CurrentProfile->DefaultName=MessageBuffer[8];\r
-    } else {\r
-      CurrentProfile->DefaultName=-1;      \r
-       \r
-      /* Here name is in Unicode */\r
-      if (GetModelFeature (FN_PROFILES)==F_PROF33) {\r
-       DecodeUnicode (CurrentProfile->Name, MessageBuffer+10, MessageBuffer[9]/2);\r
-      } else {\r
-        /* ...here not */\r
-        sprintf(CurrentProfile->Name, MessageBuffer + 10, MessageBuffer[9]);\r
-        CurrentProfile->Name[MessageBuffer[9]] = '\0';\r
-      }\r
-    }\r
-\r
-    CurrentProfileError = GE_NONE;\r
-    break;\r
-\r
-  }\r
-}\r
-\r
-/* Needs SIM card with PIN in phone */\r
-GSM_Error N6110_GetProfile(GSM_Profile *Profile)\r
-{\r
-  int i;\r
-  \r
-  unsigned char name_req[] = { N6110_FRAME_HEADER, 0x1a, 0x00};\r
-  unsigned char feat_req[] = { N6110_FRAME_HEADER, 0x13, 0x01, 0x00, 0x00};\r
-\r
-  GSM_Error error;\r
-  \r
-  CurrentProfile = Profile;\r
-\r
-  /* When after sending all frames feature==253, it means, that it is not\r
-     supported */\r
-  CurrentProfile->KeypadTone=253;\r
-  CurrentProfile->Lights=253;    \r
-  CurrentProfile->CallAlert=253; \r
-  CurrentProfile->Ringtone=253;  \r
-  CurrentProfile->Volume=253;    \r
-  CurrentProfile->MessageTone=253;\r
-  CurrentProfile->WarningTone=253;\r
-  CurrentProfile->Vibration=253;  \r
-  CurrentProfile->CallerGroups=253;\r
-  CurrentProfile->ScreenSaver=253; \r
-  CurrentProfile->AutomaticAnswer=253;\r
-\r
-  name_req[4] = Profile->Number;\r
-\r
-  error=NULL_SendMessageSequence\r
-    (20, &CurrentProfileError, 5, 0x05, name_req);\r
-  if (error!=GE_NONE) return error;\r
-\r
-  for (i = 0x00; i <= 0x09; i++) {\r
-\r
-    feat_req[5] = Profile->Number;\r
-    \r
-    feat_req[6] = i;\r
-\r
-    error=NULL_SendMessageSequence\r
-      (20, &CurrentProfileError, 7, 0x05, feat_req);\r
-    if (error!=GE_NONE) return error;\r
-  }\r
-\r
-  if (Profile->DefaultName > -1)\r
-  {\r
-    switch(GetModelFeature (FN_PROFILES)) {\r
-      case F_PROF33:\r
-        switch (Profile->DefaultName) {\r
-          case 0x00: sprintf(Profile->Name, "General");break;\r
-          case 0x01: sprintf(Profile->Name, "Silent");break;\r
-          case 0x02: sprintf(Profile->Name, "Descreet");break;\r
-          case 0x03: sprintf(Profile->Name, "Loud");break;\r
-          case 0x04: sprintf(Profile->Name, "My style");break;\r
-          case 0x05: Profile->Name[0]=0;break;\r
-          default  : sprintf(Profile->Name, "Unknown (%i)", Profile->DefaultName);break;\r
-       }\r
-        break;\r
-      case F_PROF51:\r
-        switch (Profile->DefaultName) {\r
-          case 0x00: sprintf(Profile->Name, "Personal");break;\r
-          case 0x01: sprintf(Profile->Name, "Car");break;\r
-          case 0x02: sprintf(Profile->Name, "Headset");break;\r
-          default  : sprintf(Profile->Name, "Unknown (%i)", Profile->DefaultName);break;\r
-        }\r
-        break;\r
-      case F_PROF61:\r
-        switch (Profile->DefaultName) {\r
-          case 0x00: sprintf(Profile->Name, "General");break;\r
-          case 0x01: sprintf(Profile->Name, "Silent");break;\r
-          case 0x02: sprintf(Profile->Name, "Meeting");break;\r
-          case 0x03: sprintf(Profile->Name, "Outdoor");break;\r
-          case 0x04: sprintf(Profile->Name, "Pager");break;\r
-          case 0x05: sprintf(Profile->Name, "Car");break;\r
-          case 0x06: sprintf(Profile->Name, "Headset");break;\r
-          default  : sprintf(Profile->Name, "Unknown (%i)", Profile->DefaultName);break;\r
-       }\r
-        break;\r
-    }\r
-  }\r
-  \r
-  return (GE_NONE);\r
-\r
-}\r
-\r
-void N6110_ReplySetProfile(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch (MessageBuffer[3]) {\r
-\r
-  /* Profile feature change result */\r
-  case 0x11:   \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Profile feature change result.\n"));\r
-#endif /* DEBUG */\r
-    CurrentProfileError = GE_NONE;\r
-    break;\r
-\r
-  /* Profile name set result */\r
-  case 0x1d:   \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Profile name change result.\n"));\r
-#endif /* DEBUG */\r
-    CurrentProfileError = GE_NONE;\r
-    break;\r
-\r
-  }\r
-}\r
-\r
-GSM_Error N6110_SetProfileFeature(u8 profile, u8 feature, u8 value)\r
-{\r
-  unsigned char feat_req[] = { N6110_FRAME_HEADER, 0x10, 0x01,\r
-                               0x00, 0x00, 0x00};\r
-\r
-  feat_req[5]=profile;\r
-  feat_req[6]=feature;\r
-  feat_req[7]=value;\r
-\r
-  return NULL_SendMessageSequence\r
-    (20, &CurrentProfileError, 8, 0x05, feat_req);\r
-}\r
-\r
-GSM_Error N6110_SetProfile(GSM_Profile *Profile)\r
-{\r
-  int i,value;\r
-\r
-  unsigned char name_req[40] = { N6110_FRAME_HEADER, 0x1c, 0x01, 0x03,\r
-                                 0x00, 0x00, 0x00};\r
-\r
-  GSM_Error error;\r
-  \r
-  name_req[7] = Profile->Number;\r
-  name_req[8] = strlen(Profile->Name);\r
-  name_req[6] = name_req[8] + 2;\r
-\r
-  for (i = 0; i < name_req[8]; i++)\r
-    name_req[9 + i] = Profile->Name[i];\r
-\r
-  error=NULL_SendMessageSequence\r
-    (20, &CurrentProfileError, name_req[8] + 9, 0x05, name_req);\r
-  if (error!=GE_NONE) return error;\r
-\r
-  for (i = 0x00; i <= 0x09; i++) {\r
-\r
-    switch (i) {\r
-      case 0x00: value = Profile->KeypadTone; break;\r
-      case 0x01: value = Profile->Lights; break;\r
-      case 0x02: value = Profile->CallAlert; break;\r
-      case 0x03: value = Profile->Ringtone; break;\r
-      case 0x04: value = Profile->Volume; break;\r
-      case 0x05: value = Profile->MessageTone; break;\r
-      case 0x06: value = Profile->Vibration; break;\r
-      case 0x07: value = Profile->WarningTone; break;\r
-      case 0x08: value = Profile->CallerGroups; break;\r
-      case 0x09: value = Profile->AutomaticAnswer; break;\r
-      default  : value = 0; break;
-    }\r
-\r
-    error=N6110_SetProfileFeature(Profile->Number,i,value);\r
-    if (error!=GE_NONE) return error;\r
-  }\r
-\r
-  return (GE_NONE);\r
-}\r
-\r
-bool N6110_SendRLPFrame(RLP_F96Frame *frame, bool out_dtx)\r
-{\r
-  u8 req[60] = { 0x00, 0xd9 };\r
-               \r
-  /* Discontinuos transmission (DTX).  See section 5.6 of GSM 04.22 version\r
-     7.0.1. */\r
-       \r
-  if (out_dtx)\r
-    req[1]=0x01;\r
-\r
-  memcpy(req+2, (u8 *) frame, 32);\r
-\r
-  return (Protocol->SendFrame(32, 0xf0, req));\r
-}\r
-\r
-void N6110_ReplyGetCalendarNote(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int i, j;\r
-\r
-  u8 mychar1;\r
-\r
-  wchar_t wc;  \r
-    \r
-  switch (MessageBuffer[4]) {\r
-\r
-    case 0x01:\r
-      \r
-      CurrentCalendarNote->Type=MessageBuffer[8];\r
-\r
-      DecodeDateTime(MessageBuffer+9, &CurrentCalendarNote->Time);\r
-\r
-      DecodeDateTime(MessageBuffer+16, &CurrentCalendarNote->Alarm);\r
-\r
-      CurrentCalendarNote->Text[0]=0;\r
-      \r
-      if (GetModelFeature (FN_CALENDAR)==F_CAL33) {\r
-        i=0;\r
-        if (CurrentCalendarNote->Type == GCN_REMINDER) i=1; //first char is subset\r
-        switch (MessageBuffer[24]) {\r
-          case 3:\r
-#ifdef DEBUG\r
-            fprintf(stdout,_("Subset 3 in reminder note !\n"));\r
-#endif\r
-            while (i!=MessageBuffer[23]) {\r
-              j=0;\r
-              if (i!=MessageBuffer[23]-1) {\r
-               if (MessageBuffer[24+i]>=0xc2) {\r
-                 DecodeWithUTF8Alphabet(MessageBuffer[24+i], MessageBuffer[24+i+1], &mychar1);\r
-                  CurrentCalendarNote->Text[strlen(CurrentCalendarNote->Text)+1]=0;\r
-                  CurrentCalendarNote->Text[strlen(CurrentCalendarNote->Text)]=mychar1;\r
-                 j=-1;\r
-                 i++;\r
-               }\r
-             }\r
-              if (j!=-1) {\r
-                CurrentCalendarNote->Text[strlen(CurrentCalendarNote->Text)+1]=0;\r
-                CurrentCalendarNote->Text[strlen(CurrentCalendarNote->Text)]=MessageBuffer[24+i];\r
-              }\r
-             i++;\r
-            }\r
-            break;\r
-          case 2:\r
-#ifdef DEBUG\r
-            fprintf(stdout,_("Subset 2 in reminder note !\n"));\r
-#endif\r
-            while (i!=MessageBuffer[23]) {\r
-             wc = MessageBuffer[24+i] | (0x00 << 8);\r
-              CurrentCalendarNote->Text[strlen(CurrentCalendarNote->Text)+1]=0;\r
-              CurrentCalendarNote->Text[strlen(CurrentCalendarNote->Text)]=\r
-                     DecodeWithUnicodeAlphabet(wc);\r
-             i++;\r
-            }\r
-            break;\r
-          case 1:\r
-#ifdef DEBUG\r
-            fprintf(stdout,_("Subset 1 in reminder note !\n"));\r
-#endif\r
-            memcpy(CurrentCalendarNote->Text,MessageBuffer+24+i,MessageBuffer[23]-i);\r
-            CurrentCalendarNote->Text[MessageBuffer[23]-i]=0;\r
-            break;\r
-          default:\r
-#ifdef DEBUG\r
-            fprintf(stdout,_("Unknown subset in reminder note !\n"));\r
-#endif\r
-            memcpy(CurrentCalendarNote->Text,MessageBuffer+24+i,MessageBuffer[23]-i);\r
-            CurrentCalendarNote->Text[MessageBuffer[23]-i]=0;\r
-            break;\r
-        }\r
-      } else {\r
-        memcpy(CurrentCalendarNote->Text,MessageBuffer+24,MessageBuffer[23]);\r
-        CurrentCalendarNote->Text[MessageBuffer[23]]=0;\r
-      }\r
-      \r
-      if (CurrentCalendarNote->Type == GCN_CALL) {\r
-        memcpy(CurrentCalendarNote->Phone,MessageBuffer+24+MessageBuffer[23]+1,MessageBuffer[24+MessageBuffer[23]]);\r
-        CurrentCalendarNote->Phone[MessageBuffer[24+MessageBuffer[23]]]=0;\r
-      }\r
-\r
-      CurrentCalendarNote->Recurrance=0;\r
-\r
-      CurrentCalendarNote->AlarmType=0;\r
-\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Calendar note received.\n"));\r
-\r
-      fprintf(stdout, _("   Date: %d-%02d-%02d\n"), CurrentCalendarNote->Time.Year,\r
-                                           CurrentCalendarNote->Time.Month,\r
-                                           CurrentCalendarNote->Time.Day);\r
-\r
-      fprintf(stdout, _("   Time: %02d:%02d:%02d\n"), CurrentCalendarNote->Time.Hour,\r
-                                           CurrentCalendarNote->Time.Minute,\r
-                                           CurrentCalendarNote->Time.Second);\r
-\r
-      /* Some messages do not have alarm set up */\r
-      if (CurrentCalendarNote->Alarm.Year != 0) {\r
-        fprintf(stdout, _("   Alarm date: %d-%02d-%02d\n"), CurrentCalendarNote->Alarm.Year,\r
-                                                CurrentCalendarNote->Alarm.Month,\r
-                                                CurrentCalendarNote->Alarm.Day);\r
-\r
-       fprintf(stdout, _("   Alarm time: %02d:%02d:%02d\n"), CurrentCalendarNote->Alarm.Hour,\r
-                                                CurrentCalendarNote->Alarm.Minute,\r
-                                                 CurrentCalendarNote->Alarm.Second);\r
-      }\r
-\r
-      fprintf(stdout, _("   Type: %d\n"), CurrentCalendarNote->Type);\r
-      fprintf(stdout, _("   Text: %s\n"), CurrentCalendarNote->Text);\r
-\r
-      if (CurrentCalendarNote->Type == GCN_CALL)\r
-        fprintf(stdout, _("   Phone: %s\n"), CurrentCalendarNote->Phone);\r
-#endif /* DEBUG */\r
-\r
-      CurrentCalendarNoteError=GE_NONE;\r
-      break;\r
-\r
-    case 0x93:\r
-\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Calendar note not available\n"));\r
-#endif /* DEBUG */\r
-\r
-      CurrentCalendarNoteError=GE_INVALIDCALNOTELOCATION;\r
-      break;\r
-\r
-    default:\r
-\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Calendar note error\n"));\r
-#endif /* DEBUG */\r
-\r
-      CurrentCalendarNoteError=GE_INTERNALERROR;\r
-      break;\r
-\r
-  }\r
-}\r
-\r
-GSM_Error N6110_GetCalendarNote(GSM_CalendarNote *CalendarNote)\r
-{\r
-\r
-  unsigned char req[] = { N6110_FRAME_HEADER,\r
-                          0x66, 0x00\r
-                        };\r
-  GSM_Error error;\r
-\r
-  req[4]=CalendarNote->Location;\r
-\r
-  CurrentCalendarNote = CalendarNote;\r
-\r
-  error=NULL_SendMessageSequence\r
-    (20, &CurrentCalendarNoteError, 5, 0x13, req);\r
-\r
-  CurrentCalendarNote = NULL;\r
-\r
-  return error;\r
-}\r
-\r
-void N6110_ReplyWriteCalendarNote(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#ifdef DEBUG\r
-  switch(MessageBuffer[4]) {\r
-    /* This message is also sent when the user enters the new entry on keypad */\r
-    case 0x01:\r
-      fprintf(stdout, _("Message: Calendar note write succesfull!\n"));break;      \r
-    case 0x73:\r
-      fprintf(stdout, _("Message: Calendar note write failed!\n"));break;\r
-    case 0x7d:\r
-      fprintf(stdout, _("Message: Calendar note write failed!\n"));break;\r
-    default:\r
-      fprintf(stdout, _("Unknown message of type 0x13 and subtype 0x65\n"));break;\r
-  }\r
-#endif\r
-\r
-  switch(MessageBuffer[4]) {\r
-    case 0x01: CurrentCalendarNoteError=GE_NONE; break;      \r
-    case 0x73: CurrentCalendarNoteError=GE_INTERNALERROR; break;\r
-    case 0x7d: CurrentCalendarNoteError=GE_INTERNALERROR; break;\r
-    default  : AppendLogText("Unknown msg\n",false); break;\r
-  }\r
-}\r
-\r
-GSM_Error N6110_WriteCalendarNote(GSM_CalendarNote *CalendarNote)\r
-{\r
-\r
-  unsigned char req[200] = { N6110_FRAME_HEADER,\r
-                             0x64, 0x01, 0x10,\r
-                             0x00, /* Length of the rest of the frame. */\r
-                             0x00, /* The type of calendar note */\r
-                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
-                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r
-                        };\r
-\r
-  typedef struct {\r
-    char *model;\r
-    unsigned char call;\r
-    unsigned char meeting;\r
-    unsigned char birthday;\r
-    unsigned char reminder;\r
-  } calendar_model_length;\r
-  \r
-  /* Length of entries */\r
-  calendar_model_length calendar_lengths[] =\r
-  {\r
-    /*model,CallTo,Meeting,Birthday,Reminder*/\r
-    {"NHM-5",0x24,0x24,0x24,0x24}, //Reminder from phone, other quesses\r
-    {"NHM-6",0x24,0x24,0x24,0x24}, //Reminder from phone, other quesses\r
-    {"NSE-3",0x1e,0x14,0x14,0x1e}, //from NCDS3 [HKEY_LOCAL_MACHINE\Software\Nokia\Data Suite\3.0\Calendar]\r
-    {"NSM-1",0x1e,0x18,0x18,0x24}, //from NCDS3 \r
-    {"NSK-3",0x1e,0x14,0x14,0x1e}, //from NCDS3 \r
-    {"NSB-3",0x20,0x14,0x14,0x1e}, //from NCDS3\r
-    {"",     0,   0,   0,   0   }  //end of table\r
-  };\r
-\r
-  int i, j, current;\r
-\r
-  u8 mychar;\r
-  
-  u8 mychar1,mychar2;
-  \r
-  GSM_Error error;\r
-  \r
-  /* Hopefully is 64 larger as FB38_MAX* / N6110_MAX* */\r
-  char model[64];\r
-\r
-  req[7]=CalendarNote->Type;\r
-\r
-  EncodeDateTime(req+8, &CalendarNote->Time);\r
-  req[14] = CalendarNote->Time.Timezone;\r
-\r
-  if (CalendarNote->Alarm.Year) {\r
-    EncodeDateTime(req+15, &CalendarNote->Alarm);\r
-    req[21] = CalendarNote->Alarm.Timezone;\r
-  }\r
-\r
-  req[22]=strlen(CalendarNote->Text);\r
-  \r
-  current=23;\r
-\r
-  if (GetModelFeature (FN_CALENDAR)==F_CAL33 && CalendarNote->Type==GCN_REMINDER) {\r
-    req[22]++;           // one additional char\r
-    req[current++]=0x01; //we use now subset 1\r
-  }\r
-    \r
-  for (i=0; i<strlen(CalendarNote->Text); i++) {\r
-    j=0;\r
-    mychar=CalendarNote->Text[i];\r
-    if (GetModelFeature (FN_CALENDAR)==F_CAL33 && CalendarNote->Type==GCN_REMINDER) {\r
-      if (EncodeWithUTF8Alphabet(mychar,&mychar1,&mychar2)) {
-          req[current++]=mychar1;\r
-         req[current++]=mychar2;\r
-          req[23]=0x03; //use subset 3\r
-          req[22]++;    // one additional char\r
-         j=-1;\r
-      }
-    }\r
-    if (j!=-1) {\r
-      /* Enables/disables blinking */\r
-      if (mychar=='~') req[current++]=0x01;\r
-                  else req[current++]=mychar;\r
-    }\r
-  }\r
-\r
-  req[current++]=strlen(CalendarNote->Phone);\r
-\r
-  for (i=0; i<strlen(CalendarNote->Phone); i++)\r
-    req[current++]=CalendarNote->Phone[i];\r
-\r
-  while (N6110_GetModel(model)  != GE_NONE)\r
-    sleep(1);\r
-\r
-  /* Checking maximal length */\r
-  i=0;\r
-  while (strcmp(calendar_lengths[i].model,"")) {\r
-    if (!strcmp(calendar_lengths[i].model,model)) {\r
-      switch (CalendarNote->Type) {\r
-        case GCN_REMINDER:if (req[22]>calendar_lengths[i].reminder) return GE_TOOLONG;break;\r
-        case GCN_MEETING :if (req[22]>calendar_lengths[i].meeting)  return GE_TOOLONG;break;\r
-        case GCN_BIRTHDAY:if (req[22]>calendar_lengths[i].birthday) return GE_TOOLONG;break;\r
-        case GCN_CALL    :if (strlen(CalendarNote->Phone)>calendar_lengths[i].call) return GE_TOOLONG;break;\r
-      }\r
-      break;\r
-    }\r
-    i++;\r
-  }\r
-\r
-  CurrentCalendarNote = CalendarNote;\r
-\r
-  error=NULL_SendMessageSequence\r
-    (20, &CurrentCalendarNoteError, current, 0x13, req);\r
-\r
-  CurrentCalendarNote = NULL;\r
-\r
-  return error;\r
-}\r
-\r
-void N6110_ReplyDeleteCalendarNote(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#ifdef DEBUG\r
-  switch (MessageBuffer[4]) {\r
-    /* This message is also sent when the user deletes an old entry on\r
-       keypad or moves an old entry somewhere (there is also `write'\r
-       message). */\r
-    case 0x01:fprintf(stdout, _("Message: Calendar note deleted\n"));break;\r
-    case 0x93:fprintf(stdout, _("Message: Calendar note can't be deleted\n"));break;\r
-    default  :fprintf(stdout, _("Message: Calendar note deleting error\n"));break;\r
-  }\r
-#endif\r
-\r
-  switch (MessageBuffer[4]) {\r
-    case 0x01:CurrentCalendarNoteError=GE_NONE;break;\r
-    case 0x93:CurrentCalendarNoteError=GE_INVALIDCALNOTELOCATION;break;\r
-    default  :CurrentCalendarNoteError=GE_INTERNALERROR;break;\r
-  }\r
-}\r
-\r
-GSM_Error N6110_DeleteCalendarNote(GSM_CalendarNote *CalendarNote)\r
-{\r
-\r
-  unsigned char req[] = { N6110_FRAME_HEADER,\r
-                          0x68, 0x00\r
-                        };\r
-\r
-  req[4]=CalendarNote->Location;\r
-\r
-  return NULL_SendMessageSequence (20, &CurrentCalendarNoteError, 5, 0x13, req);\r
-}\r
-\r
-void N6110_ReplyRFBatteryLevel(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Phone status received:\n"));\r
-    fprintf(stdout, _("   Mode: "));\r
-\r
-    switch (MessageBuffer[4]) {\r
-\r
-      case 0x01:\r
-\r
-       fprintf(stdout, _("registered within the network\n"));\r
-       break;\r
-             \r
-      /* I was really amazing why is there a hole in the type of 0x02, now I\r
-        know... */\r
-      case 0x02: fprintf(stdout, _("call in progress\n"));          break; /* ringing or already answered call */\r
-      case 0x03: fprintf(stdout, _("waiting for security code\n")); break;\r
-      case 0x04: fprintf(stdout, _("powered off\n"));               break;\r
-      default  : fprintf(stdout, _("unknown\n"));\r
-\r
-    }\r
-\r
-    fprintf(stdout, _("   Power source: "));\r
-\r
-    switch (MessageBuffer[7]) {\r
-\r
-      case 0x01: fprintf(stdout, _("AC/DC\n"));   break;\r
-      case 0x02: fprintf(stdout, _("battery\n")); break;\r
-      default  : fprintf(stdout, _("unknown\n"));\r
-\r
-    }\r
-\r
-    fprintf(stdout, _("   Battery Level: %d\n"), MessageBuffer[8]);\r
-    fprintf(stdout, _("   Signal strength: %d\n"), MessageBuffer[5]);\r
-#endif /* DEBUG */\r
-\r
-    CurrentRFLevel=MessageBuffer[5];\r
-    CurrentBatteryLevel=MessageBuffer[8];\r
-    CurrentPowerSource=MessageBuffer[7];\r
-}\r
-\r
-\r
-GSM_Error N6110_GetRFLevel(GSM_RFUnits *units, float *level)\r
-{\r
-\r
-  /* FIXME - these values are from 3810 code, may be incorrect.  Map from\r
-     values returned in status packet to the the values returned by the AT+CSQ\r
-     command. */\r
-  float        csq_map[5] = {0, 8, 16, 24, 31};\r
-\r
-  int timeout=10;\r
-  int rf_level;\r
-  \r
-  char screen[NM_MAX_SCREEN_WIDTH];\r
-\r
-  CurrentRFLevel=-1;\r
-    \r
-  if (GetModelFeature (FN_NOPOWERFRAME)==F_NOPOWER) {\r
-\r
-    if (N6110_NetMonitor(1, screen)!=GE_NONE)\r
-      return GE_INTERNALERROR;\r
-    \r
-    rf_level=4;\r
-    \r
-    if (screen[4]!='-') {\r
-      if (screen[5]=='9' && screen[6]>'4') rf_level=1;\r
-      if (screen[5]=='9' && screen[6]<'5') rf_level=2;\r
-      if (screen[5]=='8' && screen[6]>'4') rf_level=3;      \r
-    } else rf_level=0;\r
-\r
-    /* Arbitrary units. */\r
-    if (*units == GRF_Arbitrary) {\r
-      *level = rf_level;\r
-      return (GE_NONE);\r
-    }\r
-    \r
-  } else {\r
-    N6110_SendStatusRequest();\r
-\r
-    /* Wait for timeout or other error. */\r
-    while (timeout != 0 && CurrentRFLevel == -1 ) {\r
-\r
-      if (--timeout == 0)\r
-        return (GE_TIMEOUT);\r
-\r
-      usleep (100000);\r
-    }\r
-\r
-    /* Make copy in case it changes. */\r
-    rf_level = CurrentRFLevel;\r
-\r
-    if (rf_level == -1)\r
-      return (GE_NOLINK);\r
-\r
-    /* Now convert between the different units we support. */\r
-\r
-    /* Arbitrary units. */\r
-    if (*units == GRF_Arbitrary) {\r
-      *level = rf_level;\r
-      return (GE_NONE);\r
-    }\r
-\r
-    /* CSQ units. */\r
-    if (*units == GRF_CSQ) {\r
-\r
-      if (rf_level <=4)\r
-        *level = csq_map[rf_level];\r
-      else\r
-        *level = 99; /* Unknown/undefined */\r
-\r
-      return (GE_NONE);\r
-    }\r
-  }\r
-\r
-  /* Unit type is one we don't handle so return error */\r
-  return (GE_INTERNALERROR);\r
-}\r
-\r
-\r
-GSM_Error N6110_GetBatteryLevel(GSM_BatteryUnits *units, float *level)\r
-{\r
-\r  int timeout=10;\r
-  int batt_level;\r
-\r
-  char screen[NM_MAX_SCREEN_WIDTH];\r
-\r
-  CurrentBatteryLevel=-1;\r
-\r
-  if (GetModelFeature (FN_NOPOWERFRAME)==F_NOPOWER) {\r
-\r
-    if (N6110_NetMonitor(23, screen)!=GE_NONE)\r
-      return GE_NOLINK;\r
-    \r
-    batt_level=4;\r
-    \r
-    if (screen[29]=='7') batt_level=3;\r
-    if (screen[29]=='5') batt_level=2;\r
-    if (screen[29]=='2') batt_level=1;\r
-    \r
-    /* Only units we handle at present are GBU_Arbitrary */\r
-    if (*units == GBU_Arbitrary) {\r
-      *level = batt_level;\r
-      return (GE_NONE);\r
-    }\r
-\r
-    return (GE_INTERNALERROR);    \r
-    \r
-  } else {\r
-    N6110_SendStatusRequest();\r
-\r
-    /* Wait for timeout or other error. */\r
-    while (timeout != 0 && CurrentBatteryLevel == -1 ) {\r
-\r
-      if (--timeout == 0)\r
-        return (GE_TIMEOUT);\r
-\r
-      usleep (100000);\r
-    }\r
-\r
-    /* Take copy in case it changes. */\r
-    batt_level = CurrentBatteryLevel;\r
-\r
-    if (batt_level != -1) {\r
-\r
-      /* Only units we handle at present are GBU_Arbitrary */\r
-      if (*units == GBU_Arbitrary) {\r
-        *level = batt_level;\r
-        return (GE_NONE);\r
-      }\r
-\r
-      return (GE_INTERNALERROR);\r
-    }\r
-    else\r
-      return (GE_NOLINK);\r
-  }\r
-}\r
-\r
-GSM_Error N6110_GetPowerSource(GSM_PowerSource *source)\r
-{\r
-\r
-  int timeout=10;\r
-\r
-  char screen[NM_MAX_SCREEN_WIDTH];\r
-\r
-  CurrentPowerSource=-1;\r
-\r
-  if (GetModelFeature (FN_NOPOWERFRAME)==F_NOPOWER) {    \r
-\r
-    if (N6110_NetMonitor(20, screen)!=GE_NONE)\r
-      return GE_NOLINK;\r
-    \r
-    CurrentPowerSource=GPS_ACDC;\r
-\r
-    if (screen[6]=='x') CurrentPowerSource=GPS_BATTERY;\r
-\r
-    *source=CurrentPowerSource;        \r
-    \r
-    return GE_NONE;    \r
-  } else {\r
-    N6110_SendStatusRequest();\r
-\r
-    /* Wait for timeout or other error. */\r
-    while (timeout != 0 && CurrentPowerSource == -1 ) {\r
-\r
-      if (--timeout == 0)\r
-        return (GE_TIMEOUT);\r
-\r
-      usleep (100000);\r
-    }\r
-\r
-    if (CurrentPowerSource != -1) {\r
-      *source=CurrentPowerSource;\r
-      return (GE_NONE);\r
-    }\r
-    else\r
-      return (GE_NOLINK);\r
-  }\r
-}\r
-\r
-void N6110_ReplyGetDisplayStatus(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int i;\r
-\r
-  for (i=0; i<MessageBuffer[4];i++)\r
-    if (MessageBuffer[2*i+6]==2)\r
-      CurrentDisplayStatus|=1<<(MessageBuffer[2*i+5]-1);\r
-    else\r
-      CurrentDisplayStatus&= (0xff - (1<<(MessageBuffer[2*i+5]-1)));\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Call in progress: %s\n"), CurrentDisplayStatus & (1<<DS_Call_In_Progress)?"on":"off");\r
-  fprintf(stdout, _("Unknown: %s\n"),          CurrentDisplayStatus & (1<<DS_Unknown)?"on":"off");\r
-  fprintf(stdout, _("Unread SMS: %s\n"),       CurrentDisplayStatus & (1<<DS_Unread_SMS)?"on":"off");\r
-  fprintf(stdout, _("Voice call: %s\n"),       CurrentDisplayStatus & (1<<DS_Voice_Call)?"on":"off");\r
-  fprintf(stdout, _("Fax call active: %s\n"),  CurrentDisplayStatus & (1<<DS_Fax_Call)?"on":"off");\r
-  fprintf(stdout, _("Data call active: %s\n"), CurrentDisplayStatus & (1<<DS_Data_Call)?"on":"off");\r
-  fprintf(stdout, _("Keyboard lock: %s\n"),    CurrentDisplayStatus & (1<<DS_Keyboard_Lock)?"on":"off");\r
-  fprintf(stdout, _("SMS storage full: %s\n"), CurrentDisplayStatus & (1<<DS_SMS_Storage_Full)?"on":"off");\r
-#endif /* DEBUG */\r
-\r
-  CurrentDisplayStatusError=GE_NONE;\r
-}\r
-\r
-GSM_Error N6110_GetDisplayStatus(int *Status) {\r
-\r
-  unsigned char req[4]={ N6110_FRAME_HEADER, 0x51 };\r
-\r
-  GSM_Error error;\r
-\r
-  error=NULL_SendMessageSequence\r
-    (10, &CurrentDisplayStatusError, 4, 0x0d, req);\r
-  if (error!=GE_NONE) return error;\r
-  \r
-  *Status=CurrentDisplayStatus;\r
-\r
-  return GE_NONE;\r
-}\r
-\r
-GSM_Error N6110_DialVoice(char *Number) {\r
-/* This commented sequence doesn't work on N3210/3310/6210/7110 */\r
-//  unsigned char req[64]={N6110_FRAME_HEADER, 0x01};\r
-//  unsigned char req_end[]={0x05, 0x01, 0x01, 0x05, 0x81, 0x01, 0x00, 0x00, 0x01};\r
-//  int i=0;\r
-//  req[4]=strlen(Number);\r
-//  for(i=0; i < strlen(Number) ; i++)\r
-//   req[5+i]=Number[i];\r
-//  memcpy(req+5+strlen(Number), req_end, 10);\r
-//  return NULL_SendMessageSequence\r
-//    (20, &CurrentDialVoiceError, 13+strlen(Number), 0x01, req);\r
-\r
-  unsigned char req[64]={0x00,0x01,0x7c,\r
-                         0x01}; //call command\r
-\r
-  int i=0;                      \r
-  \r
-  GSM_Error error;\r
-\r
-  error=N6110_EnableExtendedCommands(0x01);\r
-  if (error!=GE_NONE) return error;\r
-\r
-  for(i=0; i < strlen(Number) ; i++) req[4+i]=Number[i];\r
-  \r
-  req[4+i+1]=0;\r
-  \r
-  return NULL_SendMessageSequence\r
-    (20, &CurrentDialVoiceError, 4+strlen(Number)+1, 0x40, req);  \r
-}\r
-\r
-/* Dial a data call - type specifies request to use: \r
-     type 0 should normally be used\r
-     type 1 should be used when calling a digital line - corresponds to ats35=0\r
-     Maybe one day we'll know what they mean!\r
-*/\r
-GSM_Error N6110_DialData(char *Number, char type, void (* callpassup)(char c))
+#ifndef UCLINUX
+
+GSM_Error N6110_GetVoiceMailbox ( GSM_PhonebookEntry *entry)
 {
 {
-       unsigned char req[100]   = { N6110_FRAME_HEADER, 0x01 };
-       unsigned char *req_end;
-       unsigned char req_end0[] = { 0x01,  /* make a data call = type 0x01 */
-                                    0x02,0x01,0x05,0x81,0x01,0x00,0x00,0x01,0x02,0x0a,
-                                    0x07,0xa2,0x88,0x81,0x21,0x15,0x63,0xa8,0x00,0x00 };
-       unsigned char req_end1[] = { 0x01,
-                                    0x02,0x01,0x05,0x81,0x01,0x00,0x00,0x01,0x02,0x0a,
-                                    0x07,0xa1,0x88,0x89,0x21,0x15,0x63,0xa0,0x00,0x06,
-                                    0x88,0x90,0x21,0x48,0x40,0xbb };
-       unsigned char req2[]     = { N6110_FRAME_HEADER, 0x42,0x05,0x01,
-                                    0x07,0xa2,0xc8,0x81,0x21,0x15,0x63,0xa8,0x00,0x00,
-                                    0x07,0xa3,0xb8,0x81,0x20,0x15,0x63,0x80,0x01,0x60 };
-       unsigned char req3[]     = { N6110_FRAME_HEADER, 0x42,0x05,0x01,
-                                    0x07,0xa2,0x88,0x81,0x21,0x15,0x63,0xa8,0x00,0x00,
-                                    0x07,0xa3,0xb8,0x81,0x20,0x15,0x63,0x80 };
-       unsigned char req4[]     = { N6110_FRAME_HEADER, 0x42,0x05,0x81,
-                                    0x07,0xa1,0x88,0x89,0x21,0x15,0x63,0xa0,0x00,0x06,
-                                    0x88,0x90,0x21,0x48,0x40,0xbb,0x07,0xa3,0xb8,0x81,
-                                    0x20,0x15,0x63,0x80 };
+  unsigned char req[] = {N6110_FRAME_HEADER, 0x01, 0x00, 0x00, 0x00};
 
 
-       int i = 0;
-       u8 size;
+  GSM_Error error;
+  
+  CurrentPhonebookEntry = entry;
 
 
-       CurrentCallPassup=callpassup;
+  req[4] = N6110_MEMORY_VOICE;
+  req[5] = 0x00; /* Location - isn't important, but... */
 
 
-       switch (type) {
-       case 0:
-               req_end = req_end0;
-               size = sizeof(req_end0);
-               break;
-       case 1:
-               Protocol->SendMessage(sizeof(req3), 0x01, req3);
-               Protocol->SendMessage(sizeof(req4), 0x01, req4);
-               req_end = req_end1;
-               size = sizeof(req_end1);
-               break;
-       case -1:   /* Just used to set the call passup */
-               return GE_NONE;
-               break;
-       default:
-               req_end = req_end0;
-               size = sizeof(req_end0);
-               break;
-       }
+  error=NULL_SendMessageSequence
+    (20, &CurrentPhonebookError, 7, 0x03, req);
+    
+  CurrentPhonebookEntry = NULL;
+  
+  return error;
+}
 
 
-       req[4] = strlen(Number);
+void N6110_ReplyGetOperatorName(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
 
 
-       for(i = 0; i < strlen(Number) ; i++)
-               req[5+i] = Number[i];
+  int i, count;
+  
+  GSM_Bitmap NullBitmap;
 
 
-       memcpy(req + 5 + strlen(Number), req_end, size);
+  DecodeNetworkCode(MessageBuffer+5, NullBitmap.netcode);
+  
+  count=8;
 
 
-       Protocol->SendMessage(5 + size + strlen(Number), 0x01, req);
-       if (type != 1) Protocol->SendMessage(26, 0x01, req2);
+#ifdef DEBUG
+  fprintf(stdout, _("Message: Info about downloaded operator name received: %s network (for gnokii \"%s\", for phone \""),
+          NullBitmap.netcode,
+         GSM_GetNetworkName(NullBitmap.netcode));      
+#endif
+      
+  i=count;
+  while (MessageBuffer[count]!=0) {
+#ifdef DEBUG
+    fprintf(stdout,_("%c"),MessageBuffer[count]);
+#endif
+    count++;
+  }
+      
+ strcpy(CurrentGetOperatorNameNetwork->Code, NullBitmap.netcode);
+ strncpy(CurrentGetOperatorNameNetwork->Name, MessageBuffer+i,count-i+1);
 
 
-       return (GE_NONE);
+#ifdef DEBUG
+  fprintf(stdout,_("\")\n"));
+#endif
+          
+  CurrentGetOperatorNameError=GE_NONE;
 }
 
 }
 
-GSM_Error N6110_GetIncomingCallNr(char *Number)\r
-{\r
-\r
-  if (*CurrentIncomingCall != ' ') {\r
-    strcpy(Number, CurrentIncomingCall);\r
-    return GE_NONE;\r
-  }\r
-  else\r
-    return GE_BUSY;\r
-}\r
-
-GSM_Error N6110_CancelCall(void)
+GSM_Error N6110_GetOperatorName (GSM_Network *operator)
 {
 {
-//  This frame & method works only on 61xx/51xx
-//  unsigned char req[] = { N6110_FRAME_HEADER, 0x08, 0x00, 0x85};
-//  req[4]=CurrentCallSequenceNumber;
-//  Protocol->SendMessage(6, 0x01, req);
-//  return GE_NONE;
+  unsigned char req[] = { 0x00,0x01,0x8c,0x00};
+
   GSM_Error error;
 
   GSM_Error error;
 
-  unsigned char req[]={0x00,0x01,0x7c,0x03};
-    
-  /* Checking */
   error=N6110_EnableExtendedCommands(0x01);
   if (error!=GE_NONE) return error;
 
   error=N6110_EnableExtendedCommands(0x01);
   if (error!=GE_NONE) return error;
 
-  return NULL_SendMessageSequence (20, &CurrentDialVoiceError, 4, 0x40, req);   
-}  
-\r
-void N6110_ReplyEnterSecurityCode(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-    \r
-  switch(MessageBuffer[3]) {\r
-\r
-  case 0x0b:\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Security code accepted.\n"));\r
-#endif /* DEBUG */\r
-    CurrentSecurityCodeError = GE_NONE;\r
-    break;\r
-\r
-  default:\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Security code is wrong. You're not my big owner :-)\n"));\r
-#endif /* DEBUG */\r
-    CurrentSecurityCodeError = GE_INVALIDSECURITYCODE;\r
-  }\r
-}\r
-\r
-GSM_Error N6110_EnterSecurityCode(GSM_SecurityCode SecurityCode)\r
-{\r
-\r
-  unsigned char req[15] = { N6110_FRAME_HEADER,\r
-                            0x0a, /* Enter code request. */\r
-                            0x00  /* Type of the entered code. */\r
-                            };\r
-  int i=0;\r
-\r
-  req[4]=SecurityCode.Type;\r
-\r
-  for (i=0; i<strlen(SecurityCode.Code);i++)\r
-    req[5+i]=SecurityCode.Code[i];\r
-\r
-  req[5+strlen(SecurityCode.Code)]=0x00;\r
-  req[6+strlen(SecurityCode.Code)]=0x00;\r
-\r
-  return NULL_SendMessageSequence\r
-    (20, &CurrentSecurityCodeError, 7+strlen(SecurityCode.Code), 0x08, req);\r
-}\r
-\r
-void N6110_ReplyGetSecurityCodeStatus(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-    \r
-  *CurrentSecurityCodeStatus = MessageBuffer[4];\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: Security Code status received: "));\r
-\r
-  switch(*CurrentSecurityCodeStatus) {\r
-\r
-    case GSCT_SecurityCode: fprintf(stdout, _("waiting for Security Code.\n")); break;\r
-    case GSCT_Pin         : fprintf(stdout, _("waiting for PIN.\n")); break;\r
-    case GSCT_Pin2        : fprintf(stdout, _("waiting for PIN2.\n")); break;\r
-    case GSCT_Puk         : fprintf(stdout, _("waiting for PUK.\n")); break;\r
-    case GSCT_Puk2        : fprintf(stdout, _("waiting for PUK2.\n")); break;\r
-    case GSCT_None        : fprintf(stdout, _("nothing to enter.\n")); break;\r
-    default               : fprintf(stdout, _("Unknown!\n"));\r
-  }\r
-      \r
-#endif /* DEBUG */\r
-\r
-  CurrentSecurityCodeError = GE_NONE;\r
-}\r
-\r
-GSM_Error N6110_GetSecurityCodeStatus(int *Status)\r
-{\r
-\r
-  unsigned char req[4] = { N6110_FRAME_HEADER,\r
-                           0x07\r
-                         };\r
-\r
-  CurrentSecurityCodeStatus=Status;\r
-\r
-  return NULL_SendMessageSequence\r
-    (20, &CurrentSecurityCodeError, 4, 0x08, req);\r
-}\r
-\r
-void N6110_ReplyGetSecurityCode(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int i;\r
-  \r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: Security code received: "));\r
-  switch (MessageBuffer[3]) {\r
-    case GSCT_SecurityCode: fprintf(stdout, _("Security code"));break;\r
-    case GSCT_Pin:  fprintf(stdout, _("PIN"));break;\r
-    case GSCT_Pin2: fprintf(stdout, _("PIN2"));break;\r
-    case GSCT_Puk:  fprintf(stdout, _("PUK"));break;\r
-    case GSCT_Puk2: fprintf(stdout, _("PUK2"));break;\r
-    default: fprintf(stdout, _("unknown !"));break;\r
-  }\r
-  if (MessageBuffer[4]==1) {\r
-    fprintf(stdout, _(" allowed, value \""));\r
-    if (MessageBuffer[3]==GSCT_SecurityCode) {\r
-      for (i=0;i<5;i++) {fprintf(stdout, _("%c"), MessageBuffer[5+i]);}\r
-    }\r
-    if (MessageBuffer[3]==GSCT_Pin || MessageBuffer[3]==GSCT_Pin2 ||\r
-       MessageBuffer[3]==GSCT_Puk || MessageBuffer[3]==GSCT_Puk2) {\r
-      for (i=0;i<4;i++) {fprintf(stdout, _("%c"), MessageBuffer[5+i]);}\r
-    }\r
-    fprintf(stdout, _("\""));\r
-  } else {\r
-    fprintf(stdout, _(" not allowed"));  \r
-  }\r
-  fprintf(stdout, _("\n"));  \r
-#endif /* DEBUG */\r
-      \r
-  if (CurrentSecurityCode->Type==MessageBuffer[3] /* We wanted this code */\r
-          && MessageBuffer[4]==1) {                      /* It's allowed */\r
-    if (MessageBuffer[3]==GSCT_SecurityCode) {\r
-      for (i=0;i<5;i++) {CurrentSecurityCode->Code[i]=MessageBuffer[5+i];}\r
-      CurrentSecurityCode->Code[5]=0;\r
-    }\r
-    if (MessageBuffer[3]==GSCT_Pin || MessageBuffer[3]==GSCT_Pin2 ||\r
-       MessageBuffer[3]==GSCT_Puk || MessageBuffer[3]==GSCT_Puk2) {\r
-      for (i=0;i<4;i++) {CurrentSecurityCode->Code[i]=MessageBuffer[5+i];}\r
-      CurrentSecurityCode->Code[4]=0;\r
-    }\r
-    CurrentSecurityCodeError=GE_NONE;\r
-  } else\r
-    CurrentSecurityCodeError=GE_INVALIDSECURITYCODE;\r
-}\r
-\r
-GSM_Error N6110_GetSecurityCode(GSM_SecurityCode *SecurityCode)\r
-{\r
-\r
-  unsigned char req[4] = { 0x00,\r
-                           0x01,0x6e, /* Get code request. */\r
-                          0x00 };    /* Type of the requested code. */\r
-\r
-  GSM_Error error;\r
-  \r
-  error=N6110_EnableExtendedCommands(0x01);\r
-  if (error!=GE_NONE) return error;\r
-  \r
-  req[3]=SecurityCode->Type;\r
-\r
-  CurrentSecurityCode=SecurityCode;\r
-\r
-  return NULL_SendMessageSequence\r
-    (20, &CurrentSecurityCodeError, 4, 0x40, req);\r
-}\r
-\r
-void N6110_ReplyPlayTone(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: answer for PlayTone frame\n"));      \r
-#endif\r
-      \r
-  CurrentPlayToneError=GE_NONE;      \r
-}\r
-\r
-GSM_Error N6110_PlayTone(int Herz, u8 Volume)\r
-{\r
-  unsigned char req[6] = { 0x00,0x01,0x8f,\r
-                           0x00,   /* Volume */\r
-                          0x00,   /* HerzLo */\r
-                          0x00 }; /* HerzHi */\r
-\r
-  GSM_Error error;\r
-\r
-  /* PlayTone wasn't used earlier */\r
-  if (CurrentPlayToneError==GE_UNKNOWN) {\r
-    if (CurrentConnectionType!=GCT_MBUS)\r
-      CurrentDisableKeepAlive=true;\r
-\r
-    error=N6110_EnableExtendedCommands(0x01);\r
-    if (error!=GE_NONE) return error;\r
-  }\r
-\r
-  /* For Herz==255*255 we have silent */  \r
-  if (Herz!=255*255) {\r
-    req[3]=Volume;\r
-\r
-    req[5]=Herz%256;\r
-    req[4]=Herz/256;\r
-  } else {\r
-    req[3]=0;\r
-\r
-    req[5]=0;\r
-    req[4]=0;\r
-  }\r
-\r
-#ifdef WIN32\r
-  /* For Herz==255*255 we have silent and additionaly\r
-     we wait for phone answer - it's important for MBUS */\r
-  if (Herz==255*255) {\r
-    error=NULL_SendMessageSequence\r
-      (20, &CurrentPlayToneError, 6, 0x40, req);\r
-\r
-    CurrentPlayToneError=GE_UNKNOWN;\r
-    CurrentDisableKeepAlive=false;\r
-\r
-    if (error!=GE_NONE) return error;\r
-  } else {\r
-    Protocol->SendMessage(6,0x40,req);\r
-  }\r
-#else\r
-  error=NULL_SendMessageSequence\r
-    (20, &CurrentPlayToneError, 6, 0x40, req);\r
-\r
-  /* For Herz==255*255 we wait for phone answer - it's important for MBUS */\r
-  if (Herz==255*255) {\r
-    CurrentPlayToneError=GE_UNKNOWN;\r
-    CurrentDisableKeepAlive=false;\r
-  }\r
-  \r
-  if (error!=GE_NONE) return error;\r
-\r
-#endif\r
-    \r
-  return(GE_NONE);\r
-}\r
-\r
-void N6110_ReplyGetDateTime(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  if (MessageBuffer[4]==0x01) {\r
-    DecodeDateTime(MessageBuffer+8, CurrentDateTime);\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Date and time\n"));\r
-    fprintf(stdout, _("   Time: %02d:%02d:%02d\n"), CurrentDateTime->Hour, CurrentDateTime->Minute, CurrentDateTime->Second);\r
-    fprintf(stdout, _("   Date: %4d/%02d/%02d\n"), CurrentDateTime->Year, CurrentDateTime->Month, CurrentDateTime->Day);\r
-#endif /* DEBUG */\r
-\r
-    CurrentDateTime->IsSet=true;\r
-  } else {\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Date and time not set in phone\n"));\r
-#endif\r
-\r
-    CurrentDateTime->IsSet=false;\r
-  }\r
-      \r
-  CurrentDateTimeError=GE_NONE;\r
-}\r
-\r
-GSM_Error N6110_GetDateTime(GSM_DateTime *date_time)\r
-{\r
-  return N6110_PrivGetDateTime(date_time,0x11);\r
-}\r
-\r
-GSM_Error N6110_PrivGetDateTime(GSM_DateTime *date_time, int msgtype)\r
-{\r
-  unsigned char req[] = {N6110_FRAME_HEADER, 0x62};\r
-\r
-  CurrentDateTime=date_time;\r
-\r
-  return NULL_SendMessageSequence\r
-    (50, &CurrentDateTimeError, 4, msgtype, req);\r
-}\r
-\r
-void N6110_ReplyGetAlarm(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: Alarm\n"));\r
-  fprintf(stdout, _("   Alarm: %02d:%02d\n"), MessageBuffer[9], MessageBuffer[10]);\r
-  fprintf(stdout, _("   Alarm is %s\n"), (MessageBuffer[8]==2) ? _("on"):_("off"));\r
-#endif /* DEBUG */\r
-\r
-  CurrentAlarm->Hour=MessageBuffer[9];\r
-  CurrentAlarm->Minute=MessageBuffer[10];\r
-  CurrentAlarm->Second=0;\r
-\r
-  CurrentAlarm->IsSet=(MessageBuffer[8]==2);\r
-\r
-  CurrentAlarmError=GE_NONE;\r
-}\r
-\r
-GSM_Error N6110_GetAlarm(int alarm_number, GSM_DateTime *date_time)\r
-{\r
-  return N6110_PrivGetAlarm(alarm_number,date_time,0x11);\r
-}\r
-\r
-GSM_Error N6110_PrivGetAlarm(int alarm_number, GSM_DateTime *date_time, int msgtype)\r
-{\r
-  unsigned char req[] = {N6110_FRAME_HEADER, 0x6d};\r
-\r
-  CurrentAlarm=date_time;\r
-\r
-  return NULL_SendMessageSequence\r
-    (50, &CurrentAlarmError, 4, msgtype, req);\r
-}\r
-\r
-void N6110_ReplyGetSMSCenter(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-  \r
-  switch (MessageBuffer[3]) {\r
-\r
-  case 0x34:\r
-\r
-    CurrentMessageCenter->No=MessageBuffer[4];\r
-    CurrentMessageCenter->Format=MessageBuffer[6];\r
-    CurrentMessageCenter->Validity=MessageBuffer[8];\r
-    sprintf(CurrentMessageCenter->Name, "%s", MessageBuffer+33);\r
-\r
-    sprintf(CurrentMessageCenter->DefaultRecipient, "%s", GSM_UnpackSemiOctetNumber(MessageBuffer+9,false));\r
-\r
-    sprintf(CurrentMessageCenter->Number, "%s", GSM_UnpackSemiOctetNumber(MessageBuffer+21,false));\r
-      \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: SMS Center received:\n"));\r
-    fprintf(stdout, _("   %d. SMS Center name is %s\n"), CurrentMessageCenter->No, CurrentMessageCenter->Name);\r
-    fprintf(stdout, _("   SMS Center number is %s\n"), CurrentMessageCenter->Number);\r
-    fprintf(stdout, _("   Default recipient number is %s\n"), CurrentMessageCenter->DefaultRecipient);\r
-      \r
-    fprintf(stdout, _("   SMS Center message format is "));\r
-\r
-    switch (CurrentMessageCenter->Format) {\r
-\r
-      case GSMF_Text  : fprintf(stdout, _("Text"));   break;\r
-      case GSMF_Paging: fprintf(stdout, _("Paging")); break;\r
-      case GSMF_Fax   : fprintf(stdout, _("Fax"));    break;\r
-      case GSMF_Email : fprintf(stdout, _("Email"));  break;\r
-      default         : fprintf(stdout, _("Unknown"));\r
-    }\r
-\r
-    fprintf(stdout, "\n");\r
-\r
-    fprintf(stdout, _("   SMS Center message validity is "));\r
-\r
-    switch (CurrentMessageCenter->Validity) {\r
-\r
-      case GSMV_1_Hour  : fprintf(stdout, _("1 hour"));      break;\r
-      case GSMV_6_Hours : fprintf(stdout, _("6 hours"));     break;\r
-      case GSMV_24_Hours: fprintf(stdout, _("24 hours"));    break;\r
-      case GSMV_72_Hours: fprintf(stdout, _("72 hours"));    break;\r
-      case GSMV_1_Week  : fprintf(stdout, _("1 week"));      break;\r
-      case GSMV_Max_Time: fprintf(stdout, _("Maximum time"));break;\r
-      default           : fprintf(stdout, _("Unknown"));\r
-    }\r
-\r
-    fprintf(stdout, "\n");\r
-\r
-#endif /* DEBUG */\r
-\r
-    CurrentMessageCenterError=GE_NONE;\r
-\r
-    break;\r
-\r
-  case 0x35:\r
-\r
-    /* Number of entries depends on SIM card */\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: SMS Center error received:\n"));\r
-    fprintf(stdout, _("   The request for SMS Center failed.\n"));\r
-#endif /* DEBUG */\r
-\r
-    /* FIXME: appropriate error. */\r
-    CurrentMessageCenterError=GE_INTERNALERROR;\r
-\r
-    break;  \r
-\r
-  }\r
-}\r
-\r
-/* This function sends to the mobile phone a request for the SMS Center */\r
-GSM_Error N6110_GetSMSCenter(GSM_MessageCenter *MessageCenter)\r
-{\r
-  unsigned char req[] = { N6110_FRAME_HEADER, 0x33, 0x64,\r
-                          0x00 /* SMS Center Number. */\r
-                        };\r
-\r
-  req[5]=MessageCenter->No;\r
-\r
-  CurrentMessageCenter=MessageCenter;\r
-\r
-  return NULL_SendMessageSequence\r
-    (50, &CurrentMessageCenterError, 6, 0x02, req);\r
-}\r
-\r
-void N6110_ReplySetSMSCenter(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: SMS Center correctly set.\n"));\r
-#endif\r
-  CurrentMessageCenterError=GE_NONE;\r
-}\r
-\r
-/* This function set the SMS Center profile on the phone. */\r
-GSM_Error N6110_SetSMSCenter(GSM_MessageCenter *MessageCenter)\r
-{\r
-  unsigned char req[64] = { N6110_FRAME_HEADER, 0x30, 0x64,\r
-                            0x00, /* SMS Center Number. */\r
-                            0x00, /* Unknown. */\r
-                            0x00, /* SMS Message Format. */\r
-                            0x00, /* Unknown. */\r
-                            0x00, /* Validity. */\r
-                            0,0,0,0,0,0,0,0,0,0,0,0, /* Default recipient number */\r
-                            0,0,0,0,0,0,0,0,0,0,0,0 /* Message Center Number. */\r
-                            /* Message Center Name. */\r
-                          };\r
-\r
-  req[5]=MessageCenter->No;\r
-  req[7]=MessageCenter->Format;\r
-  req[9]=MessageCenter->Validity;\r
-\r
-  req[10]=GSM_PackSemiOctetNumber(MessageCenter->DefaultRecipient, req+11, false);\r
-\r
-  req[22]=GSM_PackSemiOctetNumber(MessageCenter->Number, req+23, false);\r
-\r
-  sprintf(req+34, "%s", MessageCenter->Name);\r
-\r
-  CurrentMessageCenter=MessageCenter;\r
-\r
-  return NULL_SendMessageSequence\r
-    (50, &CurrentMessageCenterError, 35+strlen(MessageCenter->Name), 0x02, req);\r
-}\r
-\r
-void N6110_ReplyGetSMSStatus(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch (MessageBuffer[3]) {\r
-\r
-  case 0x37:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: SMS Status Received\n"));\r
-    fprintf(stdout, _("   The number of messages: %d\n"), MessageBuffer[10]);\r
-    fprintf(stdout, _("   Unread messages: %d\n"), MessageBuffer[11]);\r
-#endif /* DEBUG */\r
-\r
-    CurrentSMSStatus->UnRead = MessageBuffer[11];\r
-    CurrentSMSStatus->Number = MessageBuffer[10];\r
-    \r
-    CurrentSMSStatusError = GE_NONE;\r
-    break;\r
-\r
-  case 0x38:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: SMS Status error, probably not authorized by PIN\n"));\r
-#endif /* DEBUG */\r
-\r
-    CurrentSMSStatusError = GE_INTERNALERROR;\r
-    break;\r
-         \r
-  }\r
-}\r
-\r
-GSM_Error N6110_GetSMSStatus(GSM_SMSStatus *Status)\r
-{\r
-  unsigned char req[] = {N6110_FRAME_HEADER, 0x36, 0x64};\r
-\r
-  CurrentSMSStatus = Status;\r
-\r
-  return NULL_SendMessageSequence\r
-    (10, &CurrentSMSStatusError, 5, 0x14, req);\r
-}\r
+  CurrentGetOperatorNameNetwork = operator;
 
 
-GSM_Error N6110_GetSMSFolders ( GSM_SMSFolders *folders)
-{
-  folders->number=2;
+  error=NULL_SendMessageSequence
+    (20, &CurrentGetOperatorNameError, 4, 0x40, req);
 
 
-  strcpy(folders->Folder[0].Name,"Inbox");
-  strcpy(folders->Folder[1].Name,"Outbox");
+  CurrentGetOperatorNameNetwork = NULL;
   
   
-  return GE_NONE;
+  return error;
 }
 }
-\r
-GSM_Error N6110_GetIMEI(char *imei)\r
-{\r
-  if (strlen(Current_IMEI)>0) {\r
-    strncpy (imei, Current_IMEI, GSM_MAX_IMEI_LENGTH);\r
-    return (GE_NONE);\r
-  }\r
-  else\r
-    return (GE_TRYAGAIN);\r
-}\r
-\r
-GSM_Error N6110_GetRevision(char *revision)\r
-{\r
-\r
-  if (strlen(Current_Revision)>0) {\r
-    strncpy (revision, Current_Revision, GSM_MAX_REVISION_LENGTH);\r
-    return (GE_NONE);\r
-  }\r
-  else\r
-    return (GE_TRYAGAIN);\r
-}\r
-\r
-GSM_Error N6110_GetModel(char *model)\r
-{\r
-  if (strlen(Current_Model)>0) {\r
-    strncpy (model, Current_Model, GSM_MAX_MODEL_LENGTH);\r
-    return (GE_NONE);\r
-  }\r
-  else\r
-    return (GE_TRYAGAIN);\r
-}\r
-\r
-void N6110_ReplySetDateTime(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch (MessageBuffer[4]) {\r
-\r
-    case 0x01:\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Date and time set correctly\n"));\r
-#endif /* DEBUG */\r
-      CurrentSetDateTimeError=GE_NONE;\r
-      break;\r
-      \r
-    default:\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Date and time setting error\n"));\r
-#endif /* DEBUG */\r
-      CurrentSetDateTimeError=GE_INVALIDDATETIME;\r
-\r
-  }\r
-}\r
-\r
-/* Needs SIM card with PIN in phone */\r
-GSM_Error N6110_SetDateTime(GSM_DateTime *date_time)\r
-{\r
-  return N6110_PrivSetDateTime(date_time,0x11);\r
-}\r
-\r
-/* Needs SIM card with PIN in phone */\r
-GSM_Error N6110_PrivSetDateTime(GSM_DateTime *date_time, int msgtype)\r
-{\r
-\r
-  unsigned char req[] = { N6110_FRAME_HEADER,\r
-                         0x60, /* set-time subtype */\r
-                         0x01, 0x01, 0x07, /* unknown */\r
-                         0x00, 0x00, /* Year (0x07cf = 1999) */\r
-                         0x00, 0x00, /* Month Day */\r
-                         0x00, 0x00, /* Hours Minutes */\r
-                         0x00 /* Unknown, but not seconds - try 59 and wait 1 sec. */\r
-                       };\r
-\r
-  EncodeDateTime(req+7, date_time);\r
-\r
-  return NULL_SendMessageSequence\r
-    (20, &CurrentSetDateTimeError, 14, msgtype, req);\r
-}\r
-\r
-void N6110_ReplySetAlarm(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch (MessageBuffer[4]) {\r
-\r
-    case 0x01:\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Alarm set correctly\n"));\r
-#endif /* DEBUG */\r
-      CurrentSetAlarmError=GE_NONE;\r
-      break;\r
-      \r
-    default:\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Alarm setting error\n"));\r
-#endif /* DEBUG */\r
-      CurrentSetAlarmError=GE_INVALIDDATETIME;\r
-\r
-  }\r
-}\r
-\r
-/* FIXME: we should also allow to set the alarm off :-) */\r
-GSM_Error N6110_SetAlarm(int alarm_number, GSM_DateTime *date_time)\r
-{\r
-  return N6110_PrivSetAlarm(alarm_number,date_time, 0x11);\r
-}\r
-\r
-/* FIXME: we should also allow to set the alarm off :-) */\r
-GSM_Error N6110_PrivSetAlarm(int alarm_number, GSM_DateTime *date_time, int msgtype)\r
-{\r
-\r
-  unsigned char req[] = { N6110_FRAME_HEADER,\r
-                         0x6b, /* set-alarm subtype */\r
-                         0x01, 0x20, 0x03, /* unknown */\r
-                         0x02,       /* should be alarm on/off, but it don't works */\r
-                         0x00, 0x00, /* Hours Minutes */\r
-                         0x00 /* Unknown, but not seconds - try 59 and wait 1 sec. */\r
-                       };\r
-\r
-  req[8] = date_time->Hour;\r
-  req[9] = date_time->Minute;\r
-\r
-  return NULL_SendMessageSequence\r
-    (50, &CurrentSetAlarmError, 11, msgtype, req);\r
-}\r
-\r
-void N6110_ReplyGetMemoryLocation(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  /* Hopefully is 64 larger as FB38_MAX* / N6110_MAX* */\r
-  char model[64];\r
-\r
-  int i, tmp, count;\r
-    \r
-  switch (MessageBuffer[3]) {\r
-\r
-  case 0x02:\r
-\r
-    CurrentPhonebookEntry->Empty = true;\r
-\r
-    count=MessageBuffer[5];\r
-         \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Phonebook entry received:\n"));\r
-    fprintf(stdout, _("   Name: "));\r
-\r
-    for (tmp=0; tmp <count; tmp++)\r
-    {\r
-      if (MessageBuffer[6+tmp]==1) fprintf(stdout, "%c", '~'); else //enables/disables blinking\r
-      if (MessageBuffer[6+tmp]==0) fprintf(stdout, "%c", '`'); else //hides rest ot contents\r
-      fprintf(stdout, "%c", MessageBuffer[6+tmp]);\r
-    }\r
-\r
-    fprintf(stdout, "\n");\r
-#endif /* DEBUG */\r
-\r
-    while (N6110_GetModel(model)  != GE_NONE)\r
-      sleep(1);\r
-        \r
-    if (GetModelFeature (FN_PHONEBOOK)==F_PBK33) {//pbk with Unicode\r
-      DecodeUnicode (CurrentPhonebookEntry->Name, MessageBuffer+6, count/2);\r
-      CurrentPhonebookEntry->Name[count/2] = 0x00;\r
-    } else {\r
-      memcpy(CurrentPhonebookEntry->Name, MessageBuffer + 6, count);\r
-      CurrentPhonebookEntry->Name[count] = 0x00;\r
-    }\r
-\r
-    CurrentPhonebookEntry->Empty = false;\r
-\r
-    for (tmp=0; tmp <count; tmp++)\r
-    {\r
-      if (GetModelFeature (FN_PHONEBOOK)==F_PBK33) {//pbk with Unicode\r
-        /* We check only 1'st, 3'rd, ... char */\r
-        if (tmp%2!=0 && MessageBuffer[6+tmp]==1) CurrentPhonebookEntry->Name[tmp/2]='~'; //enables/disables blinking\r
-        if (tmp%2!=0 && MessageBuffer[6+tmp]==0) CurrentPhonebookEntry->Name[tmp/2]='`'; //hides rest ot contents\r
-      } else {\r
-        if (MessageBuffer[6+tmp]==1) CurrentPhonebookEntry->Name[tmp]='~'; //enables/disables blinking\r
-        if (MessageBuffer[6+tmp]==0) CurrentPhonebookEntry->Name[tmp]='`'; //hides rest ot contents\r
-      }\r
-    }\r
-\r
-    i=7+count;\r
-    count=MessageBuffer[6+count];\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("   Number: "));\r
-\r
-    for (tmp=0; tmp <count; tmp++)\r
-      fprintf(stdout, "%c", MessageBuffer[i+tmp]);\r
-\r
-    fprintf(stdout, "\n");\r
-#endif /* DEBUG */\r
-\r
-    memcpy(CurrentPhonebookEntry->Number, MessageBuffer + i, count);\r
-    CurrentPhonebookEntry->Number[count] = 0x00;\r
-    CurrentPhonebookEntry->Group = MessageBuffer[i+count];\r
-      \r
-    /* Phone doesn't have entended phonebook */\r
-    CurrentPhonebookEntry->SubEntriesCount = 0;\r
-\r
-    /* But for these memories data is saved and we can save it using 7110/6210 style */\r
-    if (CurrentPhonebookEntry->MemoryType==GMT_DC ||\r
-        CurrentPhonebookEntry->MemoryType==GMT_RC ||\r
-        CurrentPhonebookEntry->MemoryType==GMT_MC) {\r
-        CurrentPhonebookEntry->SubEntriesCount = 1;\r
-        CurrentPhonebookEntry->SubEntries[0].EntryType=N7110_ENTRYTYPE_DATE;\r
-        CurrentPhonebookEntry->SubEntries[0].NumberType=0;\r
-        CurrentPhonebookEntry->SubEntries[0].BlockNumber=1;\r
-        DecodeDateTime(MessageBuffer+(i+count+2),&CurrentPhonebookEntry->SubEntries[0].data.Date);\r
-\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("   Date: "));\r
-      fprintf(stdout, "%02u.%02u.%04u\n",\r
-          CurrentPhonebookEntry->SubEntries[0].data.Date.Day,\r
-          CurrentPhonebookEntry->SubEntries[0].data.Date.Month,\r
-          CurrentPhonebookEntry->SubEntries[0].data.Date.Year);\r
-      fprintf(stdout, _("   Time: "));\r
-      fprintf(stdout, "%02u:%02u:%02u\n",\r
-          CurrentPhonebookEntry->SubEntries[0].data.Date.Hour,\r
-          CurrentPhonebookEntry->SubEntries[0].data.Date.Minute,\r
-          CurrentPhonebookEntry->SubEntries[0].data.Date.Second);\r
-#endif /* DEBUG */\r
-\r
-      /* These values are set, when date and time unavailable in phone.\r
-         Values from 3310 - in other can be different */\r
-      if (CurrentPhonebookEntry->SubEntries[0].data.Date.Day==20 &&\r
-          CurrentPhonebookEntry->SubEntries[0].data.Date.Month==1 &&\r
-          CurrentPhonebookEntry->SubEntries[0].data.Date.Year==2118 &&\r
-          CurrentPhonebookEntry->SubEntries[0].data.Date.Hour==3 &&\r
-         CurrentPhonebookEntry->SubEntries[0].data.Date.Minute==14 &&\r
-         CurrentPhonebookEntry->SubEntries[0].data.Date.Second==7)\r
-          CurrentPhonebookEntry->SubEntriesCount = 0;\r
-    }\r
-\r
-    /* Signal no error to calling code. */\r
-    CurrentPhonebookError = GE_NONE;\r
-\r
-    break;\r
-\r
-  case 0x03:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Phonebook read entry error received:\n"));\r
-#endif /* DEBUG */\r
-\r
-    switch (MessageBuffer[4]) {\r
-\r
-      case 0x7d:\r
-#ifdef DEBUG\r
-       fprintf(stdout, _("   Invalid memory type!\n"));\r
-#endif /* DEBUG */\r
-       CurrentPhonebookError = GE_INVALIDMEMORYTYPE;\r
-       break;\r
-\r
-      default:\r
-#ifdef DEBUG\r
-       fprintf(stdout, _("   Unknown error!\n"));\r
-#endif /* DEBUG */\r
-       CurrentPhonebookError = GE_INTERNALERROR;\r
-    }\r
-\r
-    break;\r
-\r
-  }\r
-}\r
-\r
-/* Routine to get specifed phone book location.  Designed to be called by\r
-   application.  Will block until location is retrieved or a timeout/error\r
-   occurs. */\r
-GSM_Error N6110_GetMemoryLocation(GSM_PhonebookEntry *entry)\r
-{\r
-  unsigned char req[] = {N6110_FRAME_HEADER, 0x01, 0x00, 0x00, 0x00};\r
-\r
-  CurrentPhonebookEntry = entry;\r
-\r
-  req[4] = N6110_GetMemoryType(entry->MemoryType);\r
-  req[5] = entry->Location;\r
-\r
-  return NULL_SendMessageSequence\r
-    (50, &CurrentPhonebookError, 7, 0x03, req);\r
-}\r
-\r
-void N6110_ReplyWritePhonebookLocation(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch (MessageBuffer[3]) {\r
-\r
-  case 0x05:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Phonebook written correctly.\n"));\r
-#endif /* DEBUG */\r
-    CurrentPhonebookError = GE_NONE;\r
-    break;\r
-\r
-  case 0x06:\r
-\r
-    switch (MessageBuffer[4]) {\r
-      /* FIXME: other errors? When I send the phonebook with index of 350 it\r
-         still report error 0x7d :-( */\r
-      case 0x7d:\r
-#ifdef DEBUG\r
-        fprintf(stdout, _("Message: Phonebook not written - name is too long.\n"));\r
-#endif /* DEBUG */\r
-       CurrentPhonebookError = GE_PHBOOKNAMETOOLONG;\r
-       break;\r
-\r
-      default:\r
-#ifdef DEBUG\r
-       fprintf(stdout, _("   Unknown error!\n"));\r
-#endif /* DEBUG */\r
-       CurrentPhonebookError = GE_INTERNALERROR;\r
-    }\r
-  }\r
-}\r
-\r
-/* Routine to write phonebook location in phone. Designed to be called by\r
-   application code. Will block until location is written or timeout\r
-   occurs. */\r
-GSM_Error N6110_WritePhonebookLocation(GSM_PhonebookEntry *entry)\r
-{\r
-  unsigned char req[128] = { N6110_FRAME_HEADER, 0x04, 0x00, 0x00 };\r
-  int i=0, current=0;\r
-\r
-  req[4] = N6110_GetMemoryType(entry->MemoryType);\r
-  req[5] = entry->Location;\r
-\r
-  current=7;\r
-\r
-  if (GetModelFeature (FN_PHONEBOOK)==F_PBK33) {\r
-\r
-     req[6] = strlen(entry->Name)*2;\r
-\r
-     EncodeUnicode (req+current,entry->Name ,strlen(entry->Name));\r
-     \r
-     for (i=0; i<strlen(entry->Name); i++)\r
-     {\r
-       /* here we encode "special" chars */\r
-       if (entry->Name[i]=='~') req[current+i*2]=1; //enables/disables blinking\r
-       if (entry->Name[i]=='`') req[current+i*2]=0; //hides rest ot contents\r
-     }\r
-\r
-     current+=strlen(entry->Name)*2;\r
-  } else {\r
-\r
-    req[6] = strlen(entry->Name);\r
-\r
-    for (i=0; i<strlen(entry->Name); i++)\r
-    {\r
-      req[current+i] = entry->Name[i];\r
-\r
-      /* here we encode "special" chars */\r
-      if (entry->Name[i]=='~') req[current+i]=1; //enables/disables blinking\r
-      if (entry->Name[i]=='`') req[current+i]=0; //hides rest ot contents\r
-    }\r
-\r
-    current+=strlen(entry->Name);\r
-  }\r
-\r
-  req[current++]=strlen(entry->Number);\r
-\r
-  for (i=0; i<strlen(entry->Number); i++)\r
-    req[current+i] = entry->Number[i];\r
-\r
-  current+=strlen(entry->Number);\r
-\r
-  /* Jano: This allow to save 14 characters name into SIM memory, when\r
-     No Group is selected. */\r
-  if (entry->Group == 5)\r
-    req[current++]=0xff;\r
-  else\r
-    req[current++]=entry->Group;\r
-\r
-  return NULL_SendMessageSequence\r
-    (50, &CurrentPhonebookError, current, 0x03, req);\r
-}\r
-\r
-void N6110_ReplyNetmonitor(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch(MessageBuffer[3]) {\r
-\r
-    case 0x00:\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Netmonitor correctly set.\n"));\r
-#endif /* DEBUG */\r
-      CurrentNetmonitorError=GE_NONE;  \r
-      break;\r
-      \r
-    default:\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Netmonitor menu %d received:\n"), MessageBuffer[3]);\r
-      fprintf(stdout, "%s\n", MessageBuffer+4);\r
-#endif /* DEBUG */\r
-\r
-      strcpy(CurrentNetmonitor, MessageBuffer+4);\r
-\r
-      CurrentNetmonitorError=GE_NONE;  \r
-  }\r
-}\r
-\r
-GSM_Error N6110_NetMonitor(unsigned char mode, char *Screen)\r
-{\r
-  unsigned char req[] = { 0x00, 0x01, 0x7e, 0x00 };\r
-  \r
-  GSM_Error error;\r
-  \r
-  error=N6110_EnableExtendedCommands(0x01);\r
-  if (error!=GE_NONE) return error;\r
-\r
-  CurrentNetmonitor=Screen;\r
-\r
-  req[3]=mode;\r
-\r
-  return NULL_SendMessageSequence\r
-    (20, &CurrentNetmonitorError, 4, 0x40, req);\r
-}\r
-\r
-/* Doesn't work in N3210. */\r
-/* In other allow to access phone menu without SIM card (just send any sequence) */\r
-GSM_Error N6110_SendDTMF(char *String)\r
-{\r
-  unsigned char req[64] = { N6110_FRAME_HEADER, 0x50,\r
-                            0x00 /* Length of DTMF string. */\r
-                          };\r
-                         \r
-  u8 length=strlen(String);\r
-\r
-  if (length>59) length=59;\r
-  \r
-  req[4] = length;\r
-  \r
-  memcpy(req+5,String,length);\r
-\r
-  return NULL_SendMessageSequence\r
-    (20, &CurrentSendDTMFError, 5+length, 0x01, req);\r
-}\r
-\r
-void N6110_ReplyGetSpeedDial(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch (MessageBuffer[3]) {\r
-\r
-  case 0x17:\r
-\r
-    switch (MessageBuffer[4]) {\r
-      case 0x02: CurrentSpeedDialEntry->MemoryType = GMT_ME;\r
-      default  : CurrentSpeedDialEntry->MemoryType = GMT_SM;\r
-    }\r
-      \r
-    CurrentSpeedDialEntry->Location = MessageBuffer[5];\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Speed dial entry received:\n"));\r
-    fprintf(stdout, _("   Location: %d\n"), CurrentSpeedDialEntry->Location);\r
-    fprintf(stdout, _("   MemoryType: %s\n"), N6110_MemoryType_String[CurrentSpeedDialEntry->MemoryType]);\r
-    fprintf(stdout, _("   Number: %d\n"), CurrentSpeedDialEntry->Number);\r
-#endif /* DEBUG */\r
-\r
-    CurrentSpeedDialError=GE_NONE;\r
-    break;\r
-\r
-  case 0x18:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Speed dial entry error\n"));\r
-#endif /* DEBUG */\r
-    CurrentSpeedDialError=GE_INVALIDSPEEDDIALLOCATION;\r
-    break;\r
-\r
-  }\r
-}\r
-\r
-GSM_Error N6110_GetSpeedDial(GSM_SpeedDial *entry)\r
-{\r
-\r
-  unsigned char req[] = { N6110_FRAME_HEADER,\r
-                          0x16,\r
-                          0x00  /* The number of speed dial. */\r
-                        };\r
-\r
-  CurrentSpeedDialEntry = entry;\r
-\r
-  req[4] = entry->Number;\r
-\r
-  return NULL_SendMessageSequence\r
-    (20, &CurrentSpeedDialError, 5, 0x03, req);\r
-}\r
-\r
-void N6110_ReplySetSpeedDial(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch (MessageBuffer[3]) {\r
-\r
-  case 0x1a:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Speed dial entry set.\n"));\r
-#endif /* DEBUG */\r
-    CurrentSpeedDialError=GE_NONE;\r
-    break;\r
-\r
-  case 0x1b:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Speed dial entry setting error.\n"));\r
-#endif /* DEBUG */\r
-    CurrentSpeedDialError=GE_INVALIDSPEEDDIALLOCATION;\r
-    break;\r
-\r
-  }\r
-}\r
-\r
-GSM_Error N6110_SetSpeedDial(GSM_SpeedDial *entry)\r
-{\r
-\r
-  unsigned char req[] = { N6110_FRAME_HEADER,\r
-                          0x19,\r
-                          0x00, /* Number */\r
-                          0x00, /* Memory Type */\r
-                          0x00  /* Location */\r
-                        };\r
-\r
-  req[4] = entry->Number;\r
-\r
-  switch (entry->MemoryType) {\r
-    case GMT_ME: req[5] = 0x02;\r
-    default    : req[5] = 0x03;\r
-  }\r
-\r
-  req[6] = entry->Location;\r
-\r
-  return NULL_SendMessageSequence\r
-    (20, &CurrentSpeedDialError, 7, 0x03, req);\r
-}\r
-\r
-/* This function finds parts of SMS in frame used in new Nokia phones\r
-   in internal protocols (they're coded according to GSM 03.40), copies them\r
-   to GSM_ETSISMSMessage and calls GSM_DecodeETSISMS to decode\r
-   GSM_ETSISMSMessage to GSM_SMSMessage structure */\r
-GSM_Error GSM_DecodeNokiaSMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int length)\r
-{\r
-  SMS_MessageType PDU=SMS_Deliver;\r
-  GSM_ETSISMSMessage ETSI;\r
-  int offset=0,i;\r
-\r
-  ETSI.firstbyte=req[12];\r
-\r
-  /* See GSM 03.40 section 9.2.3.1 */\r
-  if ((ETSI.firstbyte & 0x03) == 0x01) PDU=SMS_Submit;\r
-  if ((ETSI.firstbyte & 0x03) == 0x02) PDU=SMS_Status_Report;\r
-\r
-  switch (PDU) {\r
-    case SMS_Submit       : offset=5;break;\r
-    case SMS_Deliver      : offset=4;break;\r
-    case SMS_Status_Report: offset=3;break;\r
-    default:                break;\r
-  }\r
-\r
-  for (i=0;i<req[0]+1;i++)\r
-    ETSI.SMSCNumber[i]=req[i];\r
-\r
-  for (i=0;i<((req[12+offset]+1)/2+1)+1;i++)\r
-    ETSI.Number[i]=req[i+12+offset];\r
-\r
-  switch (PDU) {\r
-    case SMS_Submit:\r
-      ETSI.TPDCS=req[10+offset];\r
-      ETSI.TPUDL=req[11+offset];\r
-      ETSI.TPVP=0;  //no support for now\r
-      ETSI.TPPID=0; //no support for now\r
-      for(i=31+offset;i<length;i++)\r
-        ETSI.MessageText[i-31-offset]=req[i];\r
-      break;\r
-    case SMS_Deliver:\r
-      ETSI.TPDCS=req[10+offset];\r
-      ETSI.TPUDL=req[11+offset];\r
-      ETSI.TPPID=0; //no support for now\r
-      for(i=31+offset;i<length;i++)\r
-        ETSI.MessageText[i-31-offset]=req[i];\r
-      for(i=0;i<7;i++)\r
-        ETSI.DeliveryDateTime[i]=req[i+24+offset];\r
-      break;\r
-    case SMS_Status_Report:\r
-      for(i=0;i<7;i++)\r
-        ETSI.DeliveryDateTime[i]=req[i+24+offset];\r
-      ETSI.TPStatus=req[14];\r
-      for(i=0;i<7;i++)\r
-        ETSI.SMSCDateTime[i]=req[i+34];\r
-      break;\r
-    default:\r
-      break;\r
-  }\r
-\r
-  GSM_DecodeETSISMS(SMS, &ETSI);\r
-\r
-  SMS->Name[0]=0;\r
-\r
-  return GE_NONE;\r
-}\r
-\r
-void N6110_ReplyGetSMSMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int offset;\r
-  \r
-  switch (MessageBuffer[3]) {\r
-\r
-  case 0x08:\r
-\r
-    switch (MessageBuffer[7]) {\r
-\r
-      case 0x00:\r
-       CurrentSMSMessage->Type = GST_SMS;\r
-        CurrentSMSMessage->folder=GST_INBOX;\r
-       offset=4;\r
-        break;\r
-\r
-      case 0x01:\r
-        CurrentSMSMessage->Type = GST_DR;\r
-       CurrentSMSMessage->folder=GST_INBOX;\r
-       offset=3;\r
-        break;\r
-\r
-      case 0x02:\r
-       CurrentSMSMessage->Type = GST_SMS;\r
-       CurrentSMSMessage->folder=GST_OUTBOX;\r
-       offset=5;\r
-        break;\r
-\r
-      default:\r
-        CurrentSMSMessage->Type = GST_UN;\r
-       offset=4;\r
-        break;\r
-\r
-    }\r
-\r
-    /* Field Short Message Status - MessageBuffer[4] seems not to be\r
-       compliant with GSM 07.05 spec.\r
-       Meaning     Nokia protocol      GMS spec\r
-       ----------------------------------------------------\r
-       MO Sent     0x05                        0x07 or 0x01\r
-       MO Not sent 0x07                        0x06 or 0x00\r
-       MT Read    0x01                 0x05 or 0x01\r
-       MT Not read 0x03                        0x04 or 0x00\r
-       ----------------------------------------------------\r
-       See GSM 07.05 section 2.5.2.6 and correct me if I'm wrong.\r
-       \r
-                                        Pawel Kot */\r
-\r
-    if (MessageBuffer[4] & 0x02) CurrentSMSMessage->Status = GSS_NOTSENTREAD;\r
-                            else CurrentSMSMessage->Status = GSS_SENTREAD;\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Number: %d\n"), MessageBuffer[6]);\r
-\r
-    if (CurrentSMSMessage->folder!=1) { //GST_OUTBOX\r
-      fprintf(stdout, _("Message: Received SMS (mobile terminated)\n"));\r
-    } else {\r
-      fprintf(stdout, _("Message: Outbox message (mobile originated)\n"));\r
-    }\r
-\r
-    if (CurrentSMSMessage->Type == GST_DR) fprintf(stdout, _("   Delivery Report\n"));\r
-    if (CurrentSMSMessage->Type == GST_UN) fprintf(stdout, _("   Unknown type\n"));\r
-\r
-    if (CurrentSMSMessage->folder==1) { //GST_OUTBOX\r
-      if (CurrentSMSMessage->Status) fprintf(stdout, _("   Sent\n"));\r
-                                else fprintf(stdout, _("   Not sent\n"));\r
-    } else {\r
-      if (CurrentSMSMessage->Status) fprintf(stdout, _("   Read\n"));\r
-                                else fprintf(stdout, _("   Not read\n"));\r
-    }\r
-#endif\r
-\r
-    CurrentSMSPointer=GSM_DecodeNokiaSMSFrame(CurrentSMSMessage, MessageBuffer+8, MessageLength-8);\r
-\r
-    CurrentSMSMessage->MemoryType = MessageBuffer[5];\r
-    CurrentSMSMessage->MessageNumber = MessageBuffer[6];\r
\r
-    /* Signal no error to calling code. */\r
-    CurrentSMSMessageError = GE_NONE;\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, "\n");\r
-#endif\r
-\r
-    break;\r
-\r
-  case 0x09:\r
-\r
-    /* We have requested invalid or empty location. */\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: SMS reading failed\n"));\r
-\r
-    switch (MessageBuffer[4]) {\r
-      case 0x02:\r
-        fprintf(stdout, _("   Invalid location!\n"));break;\r
-      case 0x07:\r
-       fprintf(stdout, _("   Empty SMS location.\n"));break;\r
-      case 0x0c:\r
-       fprintf(stdout, _("   No access to memory (no PIN on card ?)\n"));break;\r
-      default:      \r
-        fprintf(stdout, _("   Error code %i - please report it \n"),MessageBuffer[4]);break;\r
-    }\r
-#endif /* DEBUG */\r
-\r
-    switch (MessageBuffer[4]) {\r
-      case 0x02:CurrentSMSMessageError = GE_INVALIDSMSLOCATION;break;\r
-      case 0x07:CurrentSMSMessageError = GE_EMPTYSMSLOCATION;break;\r
-      case 0x0c:CurrentSMSMessageError = GE_NOACCESS;break;\r
-      default  :CurrentSMSMessageError = GE_UNKNOWN;break;\r
-    }\r
-\r
-    break;\r
-\r
-  }\r
-}\r
-\r
-GSM_Error N6110_GetSMSMessage(GSM_SMSMessage *message)\r
-{\r
-\r
-  unsigned char req[] = { N6110_FRAME_HEADER,\r
-                          0x07,\r
-                          0x02, /* Unknown */\r
-                          0x00, /* Location */\r
-                          0x01, 0x64};\r
-\r
-  int timeout = 60;\r
-\r
-  /* State machine code writes data to these variables when it comes in. */\r
-\r
-  CurrentSMSMessage = message;\r
-  CurrentSMSMessageError = GE_BUSY;\r
-\r
-  req[5] = message->Location;\r
-\r
-  /* Send request */\r
-  Protocol->SendMessage(8, 0x02, req);\r
-\r
-  /* Wait for timeout or other error. */\r
-  while (timeout != 0 && (CurrentSMSMessageError == GE_BUSY || CurrentSMSMessageError == GE_SMSWAITING)) {\r
-\r
-    if (--timeout == 0)\r
-      return (GE_TIMEOUT);\r
-\r
-    usleep (100000);\r
-  }\r
-\r
-  return (CurrentSMSMessageError);\r
-}\r
-\r
-void N6110_ReplyDeleteSMSMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: SMS deleted successfully.\n"));\r
-#endif /* DEBUG */\r
-\r
-  CurrentSMSMessageError = GE_NONE;    \r
-}\r
-\r
-GSM_Error N6110_DeleteSMSMessage(GSM_SMSMessage *message)\r
-{\r
-  unsigned char req[] = {N6110_FRAME_HEADER, 0x0a, 0x02, 0x00};\r
-\r
-  req[5] = message->Location;\r
-\r
-  return NULL_SendMessageSequence\r
-    (50, &CurrentSMSMessageError, 6, 0x14, req);\r
-}\r
 
 
-/* FIXME: do we need more than SMS_Submit and SMS_Deliver ? */
-GSM_Error GSM_EncodeNokiaSMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int *length, SMS_MessageType PDU)
-{
-  GSM_ETSISMSMessage ETSI;
-  int i,offset=0;
+void N6110_ReplySetOperatorName(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+    
+#ifdef DEBUG
+  fprintf(stdout, _("Message: Downloaded operator name changed\n"));
+#endif    
 
 
-  GSM_EncodeETSISMS(SMS, &ETSI, PDU, length);
+  CurrentSetOperatorNameError=GE_NONE;      
+}
 
 
-  /* Cleaning */
-  for (i=0;i<36;i++) req[i]=0;
+GSM_Error N6110_SetOperatorName (GSM_Network *operator)
+{
+  unsigned char req[256] = { 0x00,0x01,0x8b,0x00,
+                             0x00,0x00, /* MCC */
+                            0x00};     /* MNC */
 
 
-  req[12]=ETSI.firstbyte;
+  GSM_Error error;
 
 
-  for (i=0;i<ETSI.SMSCNumber[0]+1;i++)
-    req[i]=ETSI.SMSCNumber[i];
+  error=N6110_EnableExtendedCommands(0x01);
+  if (error!=GE_NONE) return error;
 
 
-  switch (PDU) {
-    case SMS_Submit:
-      offset=5;
-      for (i=0;i<((ETSI.Number[0]+1)/2+1)+1;i++)
-        req[i+12+offset]=ETSI.Number[i];
-      req[10+offset]=ETSI.TPDCS;
-      req[11+offset]=ETSI.TPUDL;
-      req[24+offset]=ETSI.TPVP;
-#ifdef DEBUG
-//      fprintf(stdout,_("   First byte: %02x\n"),ETSI.firstbyte);
-//      fprintf(stdout,_("   TP-VP: %02x\n"),ETSI.TPVP);
-//      fprintf(stdout,_("   TP-DCS: %02x\n"),ETSI.TPDCS);
-#endif
-//    req[]=ETSI.TPPID;
-      for(i=0;i<*length;i++)
-        req[i+31+offset]=ETSI.MessageText[i];
-      break;
+  EncodeNetworkCode(req+4,operator->Code);
 
 
-    case SMS_Deliver:
-      offset=4;
-      for (i=0;i<((ETSI.Number[0]+1)/2+1)+1;i++)
-        req[i+12+offset]=ETSI.Number[i];
-      req[10+offset]=ETSI.TPDCS;
-      req[11+offset]=ETSI.TPUDL;
-//    req[]=ETSI.TPPID;
-      for(i=0;i<*length;i++)
-        req[i+31+offset]=ETSI.MessageText[i];
-      for (i=0;i<7;i++)
-        req[24+offset+i]=ETSI.DeliveryDateTime[i];
-      break;
-    default:
-      break;
-  }
-  
-  *length=*length+offset;
-  
-  return GE_NONE;
+  strncpy(req+7,operator->Name,200);
+    
+  return NULL_SendMessageSequence
+    (20, &CurrentSetOperatorNameError, 8+strlen(operator->Name), 0x40, req);
 }
 }
-\r
-void N6110_ReplySendSMSMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-    \r
-  switch (MessageBuffer[3]) {\r
-\r
-  /* SMS message correctly sent to the network */\r
-  case 0x02:\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: SMS Message correctly sent.\n"));\r
-#endif /* DEBUG */\r
-    CurrentSMSMessageError = GE_SMSSENDOK;\r
-    break;\r
-\r
-  /* SMS message send to the network failed */\r
-  case 0x03:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Sending SMS Message failed, error: %i"),MessageBuffer[6]);\r
-      \r
-    switch (MessageBuffer[6]) {\r
-      case 1: fprintf(stdout,_(" (info \"Number not in use\")"));break;\r
-      case 21: fprintf(stdout,_(" (info \"Message not sent this time\")"));break;\r
-      case 28: fprintf(stdout,_(" (info \"Number not in use\")"));break;\r
-      case 38: fprintf(stdout,_(" (info \"Message not sent this time\")"));break;       case 50: fprintf(stdout,_(" (info \"Check operator services\")"));break;       \r
-      case 96: fprintf(stdout,_(" (info \"Message sending failed\")"));break;  \r
-      case 111: fprintf(stdout,_(" (info \"Message sending failed\")"));break; \r
-      case 166: fprintf(stdout,_(" (info \"Message sending failed\")"));break; \r
-      case 178: fprintf(stdout,_(" (info \"Message sending failed\")"));break; \r
-      case 252: fprintf(stdout,_(" (info \"Message sending failed\")"));break;        case 253: fprintf(stdout,_(" (info \"Message sending failed\")"));break; \r
-    }\r
-\r
-    fprintf(stdout,_("\n   For more details with errors see netmonitor manual (test 65) on www.marcin-wiacek.topnet.pl"));\r
-    fprintf(stdout,_("\n   If know their meaning, GSM specs decribing them, contact with me on marcin-wiacek@topnet.pl. THX\n"));\r
-#endif /* DEBUG */\r
-\r
-    CurrentSMSMessageError = GE_SMSSENDFAILED;\r
-    break;\r
-\r
-  }\r
-}\r
-\r
-GSM_Error N6110_SendSMSMessage(GSM_SMSMessage *SMS)\r
-{\r
-  GSM_Error error;\r
-\r
-  unsigned char req[256] = {\r
-    N6110_FRAME_HEADER,\r
-    0x01, 0x02, 0x00, /* SMS send request*/\r
-  };\r
-\r
-  int length;\r
-\r
-  error=GSM_EncodeNokiaSMSFrame(SMS, req+6, &length, SMS_Submit);    \r
-  if (error != GE_NONE) return error;\r
-\r
-  return NULL_SendMessageSequence\r
-    (200, &CurrentSMSMessageError, 42+length, 0x02, req);\r
-}\r
-\r
-void N6110_ReplySaveSMSMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch (MessageBuffer[3]) {\r
-\r
-  case 0x05:\r
-      \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("SMS Message stored at %d\n"), MessageBuffer[5]);\r
-#endif\r
-      \r
-    CurrentSMSMessage->MessageNumber=MessageBuffer[5];\r
-      \r
-    CurrentSMSMessageError = GE_NONE;\r
-    break;\r
-\r
-  case 0x06:\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("SMS saving failed\n"));\r
-    switch (MessageBuffer[4]) {\r
-      case 0x02:fprintf(stdout, _("   All locations busy.\n"));break;\r
-      case 0x03:fprintf(stdout, _("   Invalid location!\n"));break;\r
-      default  :fprintf(stdout, _("   Unknown error.\n"));break;\r
-    }\r
-#endif      \r
-      \r
-    switch (MessageBuffer[4]) {\r
-      case 0x02:CurrentSMSMessageError = GE_MEMORYFULL;break;\r
-      case 0x03:CurrentSMSMessageError = GE_INVALIDSMSLOCATION;break;\r
-      default  :CurrentSMSMessageError = GE_UNKNOWN;break;\r
-    }\r
-  }\r
-}\r
-\r
-/* GST_DR and GST_UN not supported ! */\r
-GSM_Error N6110_SaveSMSMessage(GSM_SMSMessage *SMS)\r
-{\r
-  unsigned char req[256] = {\r
-    N6110_FRAME_HEADER, 0x04, /* SMS save request*/\r
-    0x00, /* SMS Status. Different for Inbox and Outbox */\r
-    0x02, /* ?? */\r
-    0x00, /* SMS Location */\r
-    0x02, /* SMS Type */\r
-  };\r
-\r
-  int length;\r
-  SMS_MessageType PDU;\r
-  GSM_Error error;\r
-\r
-  if (SMS->Location) req[6] = SMS->Location;\r
-    \r
-  if (SMS->folder==0) { /*Inbox*/\r
-    req[4]=1;      /* SMS Status */\r
-    req[7] = 0x00; /* SMS Type */\r
-    PDU=SMS_Deliver;\r
-  } else {\r
-    req[4]=5;      /* SMS Status */\r
-    req[7] = 0x02; /* SMS Type */\r
-    PDU=SMS_Submit;\r
-  }\r
-  \r
-  if (SMS->Status == GSS_NOTSENTREAD) req[4] |= 0x02;  \r
-\r
-  error=GSM_EncodeNokiaSMSFrame(SMS, req+8, &length, PDU);  \r
-  if (error != GE_NONE) return error;\r
-\r
-  CurrentSMSMessage = SMS;\r
-\r
-  return NULL_SendMessageSequence\r
-    (70, &CurrentSMSMessageError, 39+length, 0x14, req);\r
-}\r
-\r
-void N6110_ReplySetCellBroadcast(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: Cell Broadcast enabled/disabled successfully.\n")); fflush (stdout);\r
-#endif\r
-\r
-  CurrentCBError = GE_NONE;\r
-}\r
-\r
-/* Enable and disable Cell Broadcasting */\r
-GSM_Error N6110_EnableCellBroadcast(void)\r
-{\r
-  unsigned char req[] = {N6110_FRAME_HEADER, 0x20,\r
-                         0x01, 0x01, 0x00, 0x00, 0x01, 0x01};\r
-\r
-#ifdef DEBUG\r
-  fprintf (stdout,"Enabling CB\n");\r
-#endif\r
-\r
-  CurrentCBMessage = (GSM_CBMessage *)malloc(sizeof (GSM_CBMessage));\r
-  CurrentCBMessage->Channel = 0;\r
-  CurrentCBMessage->New = false;\r
-  strcpy (CurrentCBMessage->Message,"");\r
-\r
-  return NULL_SendMessageSequence\r
-    (10, &CurrentCBError, 10, 0x02, req);\r
-}\r
-\r
-\r
-GSM_Error N6110_DisableCellBroadcast(void)\r
-{\r
-  /* Should work, but not tested fully */\r
-\r
-  unsigned char req[] = {N6110_FRAME_HEADER, 0x20,\r
-                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /*VERIFY*/\r
-\r
-  return NULL_SendMessageSequence\r
-    (10, &CurrentCBError, 10, 0x02, req);\r
-}\r
-\r
-void N6110_ReplyReadCellBroadcast(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int i, tmp;\r
-  unsigned char output[160];\r
-  \r
-  CurrentCBMessage->Channel = MessageBuffer[7];\r
-  CurrentCBMessage->New = true;\r
-  tmp=GSM_UnpackEightBitsToSeven(0, MessageBuffer[9], MessageBuffer[9], MessageBuffer+10, output);\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: CB received.\n")); fflush (stdout);\r
-\r
-  fprintf(stdout, _("Message: channel number %i\n"),MessageBuffer[7]);\r
-\r
-  fflush (stdout);\r
-\r
-  for (i=0; i<tmp;i++) {\r
-    fprintf(stdout, "%c", DecodeWithDefaultAlphabet(output[i]));\r
-  }\r
-\r
-  fprintf(stdout, "\n");\r
-#endif\r
-   \r
-  for (i=0; i<tmp; i++) {\r
-    CurrentCBMessage->Message[i] = DecodeWithDefaultAlphabet(output[i]);\r
-  }\r
-  CurrentCBMessage->Message[i]=0;\r
-}\r
-\r
-GSM_Error N6110_ReadCellBroadcast(GSM_CBMessage *Message)\r
-{\r
-#ifdef DEBUG\r
-   fprintf(stdout,"Reading CB\n");\r
-#endif\r
-\r
-  if (CurrentCBMessage != NULL) \r
-  {\r
-    if (CurrentCBMessage->New == true)\r
-    {\r
-#ifdef DEBUG\r
-  fprintf(stdout,"New CB received\n");\r
-#endif\r
-      Message->Channel = CurrentCBMessage->Channel;\r
-      strcpy(Message->Message,CurrentCBMessage->Message);\r
-      CurrentCBMessage->New = false;\r
-      return (GE_NONE);\r
-    }\r
-  }\r
-  return (GE_NONEWCBRECEIVED);\r
-}\r
-\r
-int N6110_MakeCallerGroupFrame(unsigned char *req,GSM_Bitmap Bitmap)\r
-{\r
-  int count=0;\r
-\r
-  req[count++]=Bitmap.number;\r
-  req[count++]=strlen(Bitmap.text);\r
-  memcpy(req+count,Bitmap.text,req[count-1]);\r
-  count+=req[count-1];\r
-  req[count++]=Bitmap.ringtone;\r
-\r
-  /* Setting for graphic:\r
-     0x00 - Off\r
-     0x01 - On\r
-     0x02 - View Graphics\r
-     0x03 - Send Graphics\r
-     0x04 - Send via IR\r
-     You can even set it higher but Nokia phones (my\r
-     6110 at least) will not show you the name of this\r
-     item in menu ;-)) Nokia is really joking here. */\r
-  if (Bitmap.enabled) req[count++]=0x01;\r
-                 else req[count++]=0x00;\r
-\r
-  req[count++]=(Bitmap.size+4)>>8;\r
-  req[count++]=(Bitmap.size+4)%0xff;\r
-  req[count++]=0x00;  /* Future extensions! */\r
-  req[count++]=Bitmap.width;\r
-  req[count++]=Bitmap.height;\r
-  req[count++]=0x01;  /* Just BW */\r
-  memcpy(req+count,Bitmap.bitmap,Bitmap.size);\r
-\r
-  return count+Bitmap.size;\r
-}\r
-\r
-int N6110_MakeOperatorLogoFrame(unsigned char *req,GSM_Bitmap Bitmap)\r
-{\r
-  int count=0;\r
-\r
-  EncodeNetworkCode(req+count, Bitmap.netcode);\r
-  count=count+3;\r
-\r
-  req[count++]=(Bitmap.size+4)>>8;\r
-  req[count++]=(Bitmap.size+4)%0xff;\r
-  req[count++]=0x00;  /* Infofield */\r
-  req[count++]=Bitmap.width;\r
-  req[count++]=Bitmap.height;\r
-  req[count++]=0x01;  /* Just BW */    \r
-  memcpy(req+count,Bitmap.bitmap,Bitmap.size);\r
-\r
-  return count+Bitmap.size;\r
-}\r
-\r
-int N6110_MakeStartupLogoFrame(unsigned char *req,GSM_Bitmap Bitmap)\r
-{\r
-  int count=0;\r
-\r
-  req[count++]=0x01;\r
-  req[count++]=Bitmap.height;\r
-  req[count++]=Bitmap.width;\r
-  memcpy(req+count,Bitmap.bitmap,Bitmap.size);\r
-\r
-  return count+Bitmap.size;\r
-}\r
-\r
-/* Set a bitmap or welcome-note */\r
-GSM_Error N6110_SetBitmap(GSM_Bitmap *Bitmap) {\r
-\r
-  unsigned char req[600] = { N6110_FRAME_HEADER };\r
-  u16 count=3;\r
-  u8 textlen;\r
-  \r
-  int timeout=50;\r
 
 
-  /* Direct uploading variables */
-  GSM_MultiSMSMessage SMS;
-  unsigned char buffer[1000] = {0x0c,0x01};
-  GSM_NetworkInfo NetworkInfo;
+#endif /* UCLINUX */
 
 
-  GSM_Error error;\r
-  /* Uploading with preview */
-  if (Bitmap->number==255 &&
-     (Bitmap->type==GSM_OperatorLogo || Bitmap->type==GSM_CallerLogo)) {
-    GSM_SaveBitmapToSMS(&SMS,Bitmap,false,false);
-    memcpy(buffer+2,SMS.SMS[0].UDH,SMS.SMS[0].UDH[0]+1);
+static void N6110_ReplyGetMemoryStatus(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
 
 
-    memcpy(buffer+2+SMS.SMS[0].UDH[0]+1,SMS.SMS[0].MessageText,SMS.SMS[0].Length);
+  switch (MessageBuffer[3]) {
 
 
-    buffer[2+SMS.SMS[0].UDH[0]+1+SMS.SMS[0].Length]=0x00;
+  case 0x08:
 
 
-    Protocol->SendMessage(2+SMS.SMS[0].UDH[0]+1+SMS.SMS[0].Length+1, 0x12, buffer);
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Memory status received:\n"));
 
 
-    GSM->GetNetworkInfo(&NetworkInfo); //need to make something
-    return GE_NONE; //no answer from phone
-  }
\r
-  CurrentSetBitmapError = GE_BUSY;  \r
-  \r
-  switch (Bitmap->type) {\r
-  case GSM_WelcomeNoteText:\r
-  case GSM_DealerNoteText:\r
-    req[count++]=0x18;\r
-    req[count++]=0x01; /* Only one block */\r
-\r
-    if (Bitmap->type==GSM_WelcomeNoteText)\r
-      req[count++]=0x02; /* Welcome text */\r
-    else\r
-      req[count++]=0x03; /* Dealer Welcome Note */\r
-\r
-    textlen=strlen(Bitmap->text);\r
-    req[count++]=textlen;\r
-    memcpy(req+count,Bitmap->text,textlen);\r
-      \r
-    count+=textlen;\r
-\r
-    Protocol->SendMessage(count, 0x05, req);\r
-    \r
-    break;\r
-\r
-  case GSM_StartupLogo:\r
-    if (Bitmap->number==0) {\r
-\r
-      /* For 33xx we first set animated logo to default */\r
-      if (GetModelFeature (FN_STARTUP)==F_STANIM) {\r
-        error=N6110_SetProfileFeature(0, 0x29, Bitmap->number);\r
-        if (error!=GE_NONE) return error;\r
-      }\r
-\r
-      req[count++]=0x18;\r
-      req[count++]=0x01; /* Only one block */\r
-      count=count+N6110_MakeStartupLogoFrame(req+5,*Bitmap); \r
-      Protocol->SendMessage(count, 0x05, req);\r
-    } else {\r
-      return N6110_SetProfileFeature(0, 0x29, Bitmap->number);\r
-    }\r
-    break;\r
-\r
-  case GSM_OperatorLogo:\r
-    req[count++]=0x30;  /* Store Op Logo */\r
-    req[count++]=0x01;  /* Location */\r
-    count=count+N6110_MakeOperatorLogoFrame(req+5,*Bitmap); 
-    Protocol->SendMessage(count, 0x05, req);\r
-    break;\r
-\r
-  case GSM_CallerLogo:\r
-    req[count++]=0x13;\r
-    count=count+N6110_MakeCallerGroupFrame(req+4,*Bitmap);\r
-    Protocol->SendMessage(count, 0x03, req);\r
-    break;\r
-\r
-  case GSM_PictureImage:\r
-    req[count++]=0x03;\r
-    req[count++]=Bitmap->number;\r
-    if (strcmp(Bitmap->Sender,"")) {\r
-       req[count]=GSM_PackSemiOctetNumber(Bitmap->Sender, req+count+1,true);\r
-\r
-       /* Convert number of semioctets to number of chars and add count */\r
-       textlen=req[count];\r
-       if (textlen % 2) textlen++;\r
-       count+=textlen / 2 + 1;\r
-\r
-       count++;\r
-    } else {\r
-      req[count++]=0x00;\r
-      req[count++]=0x00;\r
-    }\r
-    req[count++]=0x00;\r
-    req[count++]=strlen(Bitmap->text);\r
-    memcpy(req+count,Bitmap->text,strlen(Bitmap->text));\r
-    count+=strlen(Bitmap->text);\r
-    req[count++]=0x00;\r
-    req[count++]=Bitmap->width;\r
-    req[count++]=Bitmap->height;\r
-    req[count++]=0x01;\r
-    memcpy(req+count,Bitmap->bitmap,Bitmap->size);\r
-    Protocol->SendMessage(count+Bitmap->size, 0x47, req);\r
-    break;\r
-\r
-  case GSM_7110OperatorLogo:\r
-  case GSM_7110StartupLogo:\r
-  case GSM_6210StartupLogo:\r
-    return GE_NOTSUPPORTED;\r
-\r
-  case GSM_None:\r
-    return GE_NONE;\r
-  }\r
-\r
-  /* Wait for timeout or other error. */\r
-  while (timeout != 0 && CurrentSetBitmapError == GE_BUSY ) {\r
-          \r
-    if (--timeout == 0)\r
-      return (GE_TIMEOUT);\r
-                    \r
-    usleep (100000);\r
-  }\r
-\r
-  return CurrentSetBitmapError;\r
-}\r
-\r
-/* Get a bitmap from the phone */\r
-GSM_Error N6110_GetBitmap(GSM_Bitmap *Bitmap) {\r
-\r
-  unsigned char req[10] = { N6110_FRAME_HEADER };\r
-  u8 count=3;\r
-  \r
-  int timeout=100;\r
-  \r
-  CurrentGetBitmap=Bitmap; \r
-  CurrentGetBitmapError = GE_BUSY;  \r
-  \r
-  switch (CurrentGetBitmap->type) {\r
-  case GSM_StartupLogo:\r
-  case GSM_WelcomeNoteText:\r
-  case GSM_DealerNoteText:\r
-    req[count++]=0x16;\r
-    Protocol->SendMessage(count, 0x05, req);\r
-    break;\r
-  case GSM_OperatorLogo:\r
-    req[count++]=0x33;\r
-    req[count++]=0x01; /* Location 1 */\r
-    Protocol->SendMessage(count, 0x05, req);\r
-    break;\r
-  case GSM_CallerLogo:\r
-    req[count++]=0x10;\r
-    req[count++]=Bitmap->number;\r
-    Protocol->SendMessage(count, 0x03, req);\r
-    break;\r
-  case GSM_PictureImage:\r
-    req[count++]=0x01;\r
-    req[count++]=Bitmap->number;\r
-    Protocol->SendMessage(count, 0x47, req);\r
-    break;\r
-  case GSM_7110OperatorLogo:\r
-  case GSM_7110StartupLogo:\r
-  case GSM_6210StartupLogo:\r
-  default:\r
-    return GE_NOTSUPPORTED;\r
-  }\r
-\r
-  /* Wait for timeout or other error. */\r
-  while (timeout != 0 && CurrentGetBitmapError == GE_BUSY ) {\r
-          \r
-    if (--timeout == 0)\r
-      return (GE_TIMEOUT);\r
-                    \r
-    usleep (100000);\r
-  }\r
-\r
-  CurrentGetBitmap=NULL;\r
-\r
-  return CurrentGetBitmapError;\r
-}\r
-\r
-void N6110_ReplySetRingtone(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch (MessageBuffer[3]) {\r
-\r
-  /* Set ringtone OK */\r
-  case 0x37:       \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Ringtone set OK!\n"));\r
-#endif  \r
-    CurrentRingtoneError=GE_NONE; \r
-    break;      \r
-\r
-  /* Set ringtone error */\r
-  case 0x38:       \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Ringtone setting error !\n"));\r
-#endif  \r
-    CurrentRingtoneError=GE_NOTSUPPORTED; \r
-    break;      \r
-  }\r
-}\r
-\r
-GSM_Error N6110_SetRingTone(GSM_Ringtone *ringtone, int *maxlength)\r
-{\r
-  \r
-  char req[FB61_MAX_RINGTONE_FRAME_LENGTH+10] =\r
-      {N6110_FRAME_HEADER,\r
-       0x36,\r
-       0x00,  /* Location */\r
-       0x00,0x78};\r
-\r
-  int size=FB61_MAX_RINGTONE_FRAME_LENGTH;\r
-  /* Variables for preview uploading */
-  unsigned char buffer[FB61_MAX_RINGTONE_FRAME_LENGTH+50];
-  unsigned char buffer2[20];
-  GSM_NetworkInfo NetworkInfo;
+    fprintf(stdout, _("   Memory Type: %s\n"), N6110_MemoryType_String[MessageBuffer[4]]);
+    fprintf(stdout, _("   Used: %d\n"), MessageBuffer[6]);
+    fprintf(stdout, _("   Free: %d\n"), MessageBuffer[5]);
+#endif /* DEBUG */
 
 
-  /* Setting ringtone with preview */
-  if (ringtone->location==255) {
-    buffer[0]=0x0c;
-    buffer[1]=0x01;
-    EncodeUDHHeader(buffer2, GSM_RingtoneUDH);
-    memcpy(buffer+2,buffer2,buffer2[0]+1); //copying UDH
-    *maxlength=GSM_PackRingtone(ringtone, buffer+2+buffer2[0]+1, &size); //packing ringtone
-    Protocol->SendMessage(2+buffer2[0]+1+size, 0x12, buffer); //sending frame
-    GSM->GetNetworkInfo(&NetworkInfo); //need to make something
-    sleep(1);
-    return GE_NONE; //no answer from phone
-  }
-  \r
-  *maxlength=GSM_PackRingtone(ringtone, req+7, &size);\r
-\r
-  req[4]=ringtone->location-1;\r
-\r
-  return NULL_SendMessageSequence\r
-    (50, &CurrentRingtoneError, (size+7), 0x05, req);\r
-}\r
-\r
-void N6110_ReplyGetBinRingtone(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int i;\r
-  \r
-  switch (MessageBuffer[4]) {\r
-    case 0x00: /* location supported. We have ringtone */\r
-\r
-      /* Binary format used in N6150 */\r
-      if (MessageBuffer[5]==0x0c && MessageBuffer[6]==0x01 && MessageBuffer[7]==0x2c) {\r
-#ifdef DEBUG\r
-        fprintf(stdout,_("Message: ringtone \""));\r
-#endif      \r
-\r
-        /* Copying name */\r
-        i=8;\r
-        while (true) {\r
-#ifdef DEBUG\r
-          if (MessageBuffer[i]!=0)\r
-            fprintf(stdout,_("%c"),MessageBuffer[i]);\r
-#endif\r
-          CurrentGetBinRingtone->name[i-8]=MessageBuffer[i];\r
-          if (MessageBuffer[i]==0) break;\r
-          i++;\r
-        }\r
-\r
-#ifdef DEBUG    \r
-        fprintf(stdout,_("\" received from location %i\n"),MessageBuffer[3]+1);\r
-#endif\r
-      \r
-        /* Looking for end */\r
-        i=0;\r
-       while (true) {\r
-         if (MessageBuffer[i]==0x07 && MessageBuffer[i+1]==0x0b) {\r
-           i=i+2;break;\r
-         }\r
-         if (MessageBuffer[i]==0x0e && MessageBuffer[i+1]==0x0b) {\r
-           i=i+2;break;\r
-         }\r
-         i++;\r
-          if (i==MessageLength) break;\r
-       }\r
-         \r
-        /* Copying frame */\r
-        memcpy(CurrentGetBinRingtone->frame,MessageBuffer+3,i-3);\r
-        CurrentGetBinRingtone->length=i-3;\r
-      \r
-        CurrentBinRingtoneError=GE_NONE;\r
-        break;\r
-      }\r
-         \r
-      /* Binary format used in N3210 */\r
-      if (MessageBuffer[5]==0x10 && MessageBuffer[6]==0x01 && MessageBuffer[7]==0x2c) {      \r
-\r
-#ifdef DEBUG\r
-        fprintf(stdout,_("Message: ringtone \""));\r
-#endif      \r
-\r
-        /* Copying name */\r
-        i=8;\r
-        while (true) {\r
-#ifdef DEBUG\r
-          if (MessageBuffer[i]!=0)\r
-            fprintf(stdout,_("%c"),MessageBuffer[i]);\r
-#endif\r
-          CurrentGetBinRingtone->name[i-8]=MessageBuffer[i];\r
-          if (MessageBuffer[i]==0) break;\r
-          i++;\r
-        }\r
-\r
-#ifdef DEBUG    \r
-        fprintf(stdout,_("\" received from location %i\n"),MessageBuffer[3]+1);\r
-#endif\r
-\r
-        /* Here changes to get full compatibility with binary format used in N6150 */\r
-        MessageBuffer[3]=0;\r
-        MessageBuffer[4]=0;\r
-        MessageBuffer[5]=0x0c;\r
-        MessageBuffer[6]=0x01;\r
-        MessageBuffer[7]=0x2c;\r
-\r
-        /* Looking for end */\r
-        i=0;\r
-        while (true) {\r
-          if (MessageBuffer[i]==0x07 && MessageBuffer[i+1]==0x0b) {\r
-           i=i+2;break;\r
-         }\r
-         if (MessageBuffer[i]==0x0e && MessageBuffer[i+1]==0x0b) {\r
-           i=i+2;break;\r
-         }\r
-         i++;\r
-         if (i==MessageLength) break;\r
-        }\r
-         \r
-       /* Copying frame */\r
-        memcpy(CurrentGetBinRingtone->frame,MessageBuffer+3,i-3);\r
-\r
-        CurrentGetBinRingtone->length=i-3;\r
-           \r
-        CurrentBinRingtoneError=GE_NONE;         \r
-       break;\r
-      }\r
-\r
-      /* Copying frame */\r
-      memcpy(CurrentGetBinRingtone->frame,MessageBuffer,MessageLength);\r
-\r
-      CurrentGetBinRingtone->length=MessageLength;\r
-\r
-#ifdef DEBUG    \r
-      fprintf(stdout,_("Message: unknown binary format for ringtone received from location %i\n"),MessageBuffer[3]+1);\r
-#endif\r
-      CurrentBinRingtoneError=GE_UNKNOWNMODEL;\r
-      break;\r
-\r
-    default:\r
-\r
-#ifdef DEBUG\r
-      fprintf(stdout,_("Message: Phone doesn't support downloaded ringtones at location %i\n"),MessageBuffer[3]+1);\r
-#endif\r
-\r
-      CurrentBinRingtoneError=GE_INVALIDRINGLOCATION;  \r
-  }\r
-}\r
-\r
-GSM_Error N6110_GetBinRingTone(GSM_BinRingtone *ringtone)\r
-{\r
-  unsigned char req[] = { 0x00,0x01,0x9e,\r
-                          0x00 }; //location\r
-\r
-  GSM_Error error;\r
-  \r
-  CurrentGetBinRingtone=ringtone;\r
-  \r
-  error=N6110_EnableExtendedCommands(0x01);\r
-  if (error!=GE_NONE) return error;\r
-\r
-  req[3]=ringtone->location-1;\r
-  \r
-  return NULL_SendMessageSequence\r
-    (50, &CurrentBinRingtoneError, 4, 0x40, req);\r
-}\r
-\r
-void N6110_ReplySetBinRingtone(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch (MessageBuffer[4]) {\r
-    case 0x00: /* location supported. We set ringtone */\r
-#ifdef DEBUG\r
-      fprintf(stdout,_("Message: downloaded ringtone set at location %i\n"),MessageBuffer[3]+1);\r
-#endif\r
-      CurrentBinRingtoneError=GE_NONE;\r
-      break;\r
-\r
-    default:\r
-#ifdef DEBUG\r
-      fprintf(stdout,_("Message: Phone doesn't support downloaded ringtones at location %i\n"),MessageBuffer[3]+1);\r
-#endif\r
-      CurrentBinRingtoneError=GE_NOTSUPPORTED;   \r
-      break;\r
-  }\r
-}\r
-\r
-GSM_Error N6110_SetBinRingTone(GSM_BinRingtone *ringtone)\r
-{\r
-  unsigned char req[1000] = { 0x00,0x01,0xa0};\r
-\r
-  GSM_Error error;\r
-\r
-  GSM_BinRingtone ring;\r
-\r
-  /* Must be sure, that can upload ringtone to this phone */\r
-  ring.location=ringtone->location;\r
-  error=N6110_GetBinRingTone(&ring);\r
-  if (error!=GE_NONE) return error;\r
-    \r
-  error=N6110_EnableExtendedCommands(0x01);\r
-  if (error!=GE_NONE) return error;\r
-  \r
-  memcpy(req+3,ringtone->frame,ringtone->length);\r
-\r
-  req[3]=ringtone->location-1;\r
-  \r
-  return NULL_SendMessageSequence\r
-    (50, &CurrentBinRingtoneError, ringtone->length+3, 0x40, req);\r
-}\r
-\r
-GSM_Error N6110_Reset(unsigned char type)\r
-{  \r
-  return N6110_EnableExtendedCommands(type);\r
-}\r
-\r
-void N6110_Dispatch0x01Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int tmp, count;\r
-         \r
-  switch (MessageBuffer[3]) {\r
-\r
-  /* Unknown message - it has been seen after the 0x07 message (call\r
-     answered). Probably it has similar meaning. If you can solve\r
-     this - just mail me. Pavel Janík ml.\r
-\r
-     The message looks like this:\r
-\r
-     Msg Destination: PC\r
-     Msg Source: Phone\r
-     Msg Type: 01\r
-     Msg Unknown: 00\r
-     Msg Len: 0e\r
-\r
-     Phone: [01 ][08 ][00 ] is the header of the frame\r
-\r
-     [03 ] is the call message subtype\r
-\r
-     [05 ] is the call sequence number\r
-\r
-     [05 ] unknown \r
-\r
-     [00 ][01 ][03 ][02 ][91][00] are unknown but has been\r
-     seen in the Incoming call message (just after the\r
-     caller's name from the phonebook). But never change\r
-     between phone calls :-(\r
-  */\r
-\r
-  /* This may mean sequence number of 'just made' call - CK */\r
-  case 0x02:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Call message, type 0x02:"));\r
-    fprintf(stdout, _("   Exact meaning not known yet, sorry :-(\n"));\r
-#endif /* DEBUG */\r
-\r
-    break;\r
-\r
-  /* Possibly call OK */\r
-  /* JD: I think that this means "call in progress" (incomming or outgoing) */\r
-  case 0x03:\r
-    \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Call message, type 0x03:"));\r
-    fprintf(stdout, _("   Sequence nr. of the call: %d\n"), MessageBuffer[4]);\r
-    fprintf(stdout, _("   Exact meaning not known yet, sorry :-(\n"));\r
-#endif /* DEBUG */\r
-    \r
-    CurrentCallSequenceNumber=MessageBuffer[4];\r
-    CurrentIncomingCall[0]='D';\r
-    if (CurrentCallPassup) CurrentCallPassup('D');\r
-\r
-    break;\r
-\r
-  /* Remote end has gone away before you answer the call.  Probably your\r
-     mother-in-law or banker (which is worse?) ... */\r
-  case 0x04:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Remote end hang up.\n"));\r
-    fprintf(stdout, _("   Sequence nr. of the call: %d, error: %i"), MessageBuffer[4],MessageBuffer[6]);\r
-\r
-    switch (MessageBuffer[6]) {\r
-      case 28: fprintf(stdout,_(" (info \"Invalid phone number\")"));break;\r
-      case 34: fprintf(stdout,_(" (info \"Network busy\")"));break;\r
-      case 42: fprintf(stdout,_(" (info \"Network busy\")"));break;\r
-      case 47: fprintf(stdout,_(" (info \"Error in connection\")"));break;\r
-      case 50: fprintf(stdout,_(" (info \"Check operator services\")"));break;       case 76: fprintf(stdout,_(" (info \"Check operator services\")"));break;\r
-      case 111: fprintf(stdout,_(" (info \"Error in connection\")"));break;\r
-    }\r
-      \r
-    fprintf(stdout,_("\n   For more details with errors see netmonitor manual (test 39) on www.marcin-wiacek.topnet.pl"));\r
-    fprintf(stdout,_("\n   If know their meaning, GSM specs decribing them, contact with me on marcin-wiacek@topnet.pl. THX\n"));\r
-#endif /* DEBUG */\r
-\r
-    CurrentIncomingCall[0] = ' ';\r
-    if (CurrentCallPassup) CurrentCallPassup(' ');\r
-\r
-    break;\r
-\r
-  /* Incoming call alert */\r
-  case 0x05:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Incoming call alert:\n"));\r
-\r
-    /* We can have more then one call ringing - we can distinguish between\r
-       them */\r
-\r
-    fprintf(stdout, _("   Sequence nr. of the call: %d\n"), MessageBuffer[4]);\r
-    fprintf(stdout, _("   Number: "));\r
-\r
-    count=MessageBuffer[6];\r
-\r
-    for (tmp=0; tmp <count; tmp++)\r
-      fprintf(stdout, "%c", MessageBuffer[7+tmp]);\r
-\r
-    fprintf(stdout, "\n");\r
-\r
-    fprintf(stdout, _("   Name: "));\r
-\r
-    for (tmp=0; tmp <MessageBuffer[7+count]; tmp++)\r
-      fprintf(stdout, "%c", MessageBuffer[8+count+tmp]);\r
-\r
-    fprintf(stdout, "\n");\r
-#endif /* DEBUG */\r
-\r
-    count=MessageBuffer[6];\r
-\r
-    CurrentIncomingCall[0] = 0;\r
-    for (tmp=0; tmp <count; tmp++)\r
-      sprintf(CurrentIncomingCall, "%s%c", CurrentIncomingCall, MessageBuffer[7+tmp]);\r
-\r
-    break;\r
-\r
-  /* Call answered. Probably your girlfriend...*/\r
-  case 0x07:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Call answered.\n"));\r
-    fprintf(stdout, _("   Sequence nr. of the call: %d\n"), MessageBuffer[4]);\r
-#endif /* DEBUG */\r
-\r
-    break;\r
-\r
-  /* Call ended. Girlfriend is girlfriend, but time is money :-) */\r
-  case 0x09:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Call ended by your phone.\n"));\r
-    fprintf(stdout, _("   Sequence nr. of the call: %d\n"), MessageBuffer[4]);\r
-#endif /* DEBUG */\r
-\r
-    break;\r
-\r
-  /* This message has been seen with the message of subtype 0x09\r
-     after I hang the call.\r
-\r
-  Msg Destination: PC\r
-  Msg Source: Phone\r
-  Msg Type: 01 \r
-  Msg Unknown: 00\r
-  Msg Len: 08\r
-  Phone: [01 ][08 ][00 ][0a ][04 ][87 ][01 ][42B][1a ][c2 ]\r
-\r
-  What is the meaning of 87? Can you spell some magic light into\r
-  this issue?\r
-\r
-  */\r
-\r
-  /* Probably means call over - CK */\r
-  case 0x0a:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Call message, type 0x0a:"));\r
-    fprintf(stdout, _("   Sequence nr. of the call: %d\n"), MessageBuffer[4]);\r
-    fprintf(stdout, _("   Exact meaning not known yet, sorry :-(\n"));\r
-#endif /* DEBUG */\r
-\r
-    CurrentIncomingCall[0] = ' ';\r
-    if (CurrentCallPassup) CurrentCallPassup(' ');\r
-\r
-    break;\r
-\r
-  case 0x40:\r
-\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Answer for send DTMF or dial voice command\n"));\r
-#endif\r
-\r
-    if (CurrentSendDTMFError!=GE_NONE) CurrentSendDTMFError=GE_NONE;\r
-\r
-    if (CurrentDialVoiceError!=GE_NONE) CurrentDialVoiceError=GE_NONE;\r
-\r
-    break;\r
-     \r
-  default:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Unknown message of type 0x01\n"));\r
-#endif /* DEBUG */\r
-    AppendLogText("Unknown msg\n",false);\r
-\r
-    break;     /* Visual C Don't like empty cases */\r
-  }\r
-}\r
-\r
-void N6110_Dispatch0x03Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int tmp, count;\r
-    \r
-  switch (MessageBuffer[3]) {\r
-\r
-  case 0x04:\r
-\r
-    /* AFAIK, this frame isn't used anywhere - it's rather for testing :-) */\r
-    /* If you want see, if it works with your phone make something like that: */\r
-\r
-    /* unsigned char connect5[] = {N6110_FRAME_HEADER, 0x03}; */\r
-    /* Protocol->SendMessage(4, 0x04, connect5); */\r
-\r
-    /*                                        Marcin-Wiacek@TopNet.PL */\r
-    \r
-#ifdef WIN32\r
-    sprintf(Current_IMEI, "%s", MessageBuffer+5);\r
-    sprintf(Current_Model, "%s", MessageBuffer+21);\r
-    sprintf(Current_Revision, "SW%s, HW%s", MessageBuffer+41, MessageBuffer+35);\r
-#else\r
-    snprintf(Current_IMEI, GSM_MAX_IMEI_LENGTH, "%s", MessageBuffer+5);\r
-    snprintf(Current_Model, GSM_MAX_MODEL_LENGTH, "%s", MessageBuffer+21);\r
-    snprintf(Current_Revision, GSM_MAX_REVISION_LENGTH, "SW%s, HW%s", MessageBuffer+41, MessageBuffer+35);\r
-#endif\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Mobile phone identification received:\n"));\r
-    fprintf(stdout, _("   IMEI: %s\n"), Current_IMEI);\r
-    fprintf(stdout, _("   Model: %s\n"), Current_Model);\r
-    fprintf(stdout, _("   Production Code: %s\n"), MessageBuffer+27);\r
-    fprintf(stdout, _("   HW: %s\n"), MessageBuffer+35);\r
-    fprintf(stdout, _("   Firmware: %s\n"), MessageBuffer+41);\r
-#endif /* DEBUG */\r
-\r
-    break;\r
-\r
-  /* Get group data */    \r
-  /* [ID],[name_len],[name].,[ringtone],[graphicon],[lenhi],[lenlo],[bitmap] */\r
-  case 0x11:   \r
\r
-    if (CurrentGetBitmap!=NULL) {\r
-      if (CurrentGetBitmap->number==MessageBuffer[4]) {\r
-        count=MessageBuffer[5];\r
-        memcpy(CurrentGetBitmap->text,MessageBuffer+6,count);\r
-        CurrentGetBitmap->text[count]=0;\r
-\r
-#ifdef DEBUG   \r
-       fprintf(stdout, _("Message: Caller group datas\n"));\r
-       fprintf(stdout, _("Caller group name: %s\n"),CurrentGetBitmap->text);\r
-#endif /* DEBUG */\r
-\r
-       count+=6;\r
-\r
-       CurrentGetBitmap->ringtone=MessageBuffer[count++];\r
-#ifdef DEBUG   \r
-        fprintf(stdout, _("Caller group ringtone ID: %i"),CurrentGetBitmap->ringtone);\r
-        if (CurrentGetBitmap->ringtone==16) fprintf(stdout,_(" (default)"));\r
-       fprintf(stdout,_("\n"));\r
-#endif /* DEBUG */\r
-\r
-       CurrentGetBitmap->enabled=(MessageBuffer[count++]==1);\r
-#ifdef DEBUG   \r
-       fprintf(stdout, _("Caller group logo "));\r
-       if (CurrentGetBitmap->enabled)\r
-         fprintf(stdout, _("enabled \n"));\r
-       else\r
-         fprintf(stdout, _("disabled \n"));\r
-#endif /* DEBUG */     \r
-\r
-       CurrentGetBitmap->size=MessageBuffer[count++]<<8;\r
-       CurrentGetBitmap->size+=MessageBuffer[count++];\r
-#ifdef DEBUG   \r
-       fprintf(stdout, _("Bitmap size=%i\n"),CurrentGetBitmap->size);\r
-#endif /* DEBUG */\r
-\r
-       count++;\r
-       CurrentGetBitmap->width=MessageBuffer[count++];\r
-        CurrentGetBitmap->height=MessageBuffer[count++];\r
-       count++;\r
-       tmp=CurrentGetBitmap->height*CurrentGetBitmap->width/8;\r
-       if (CurrentGetBitmap->size>tmp) CurrentGetBitmap->size=tmp;\r
-       memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count,CurrentGetBitmap->size);\r
-       CurrentGetBitmapError=GE_NONE;\r
-      } else {\r
-#ifdef DEBUG   \r
-       fprintf(stdout, _("Message: Caller group datas received, but group number does not match (%i is not %i)\n"),MessageBuffer[4],CurrentGetBitmap->number);\r
-#endif\r
-      }\r
-    } else {\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Caller group data received but not requested!\n"));\r
-#endif\r
-    }\r
-    break;\r
-\r
-  /* Get group data error */\r
-  case 0x12:   \r
-      \r
-    CurrentGetBitmapError=GE_UNKNOWN;   \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Error attempting to get caller group data.\n"));\r
-#endif   \r
-    break;\r
-\r
-  /* Set group data OK */      \r
-  case 0x14:   \r
-      \r
-    CurrentSetBitmapError=GE_NONE;      \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Caller group data set correctly.\n"));\r
-#endif\r
-    break;\r
-\r
-  /* Set group data error */\r
-  case 0x15:   \r
-      \r
-    CurrentSetBitmapError=GE_UNKNOWN;      \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Error attempting to set caller group data\n"));\r
-#endif\r
-    break;  \r
-  \r
-  default:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Unknown message of type 0x03\n"));\r
-#endif /* DEBUG */\r
-    AppendLogText("Unknown msg\n",false);\r
-\r
-    break;     /* Visual C Don't like empty cases */\r
-  }\r
-}\r
-\r
-void N6110_Dispatch0x05Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int tmp, count, length;\r
-  bool issupported;\r
+    CurrentMemoryStatus->Used = MessageBuffer[6];
+    CurrentMemoryStatus->Free = MessageBuffer[5];
+    CurrentMemoryStatusError = GE_NONE;
 
 
-#ifdef DEBUG
-  int i;
-#endif
+    break;
 
 
-  switch (MessageBuffer[3]) {\r
-\r
-  /* Startup Logo */\r
-  case 0x17:  \r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Startup Logo, welcome note and dealer welcome note received.\n"));\r
-#endif\r
-\r
-    if (CurrentGetBitmap!=NULL) {\r
-       \r
-      issupported=false;\r
-       \r
-      count=5;\r
-       \r
-      for (tmp=0;tmp<MessageBuffer[4];tmp++){\r
-        switch (MessageBuffer[count++]) {\r
-        case 0x01:\r
-          if (CurrentGetBitmap->type==GSM_StartupLogo) {\r
-            CurrentGetBitmap->height=MessageBuffer[count++];\r
-           CurrentGetBitmap->width=MessageBuffer[count++];\r
-           CurrentGetBitmap->size=CurrentGetBitmap->height*CurrentGetBitmap->width/8;\r
-           length=CurrentGetBitmap->size;\r
-           memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count,length);\r
-          } else {\r
-           length=MessageBuffer[count++];\r
-           length=length*MessageBuffer[count++]/8;\r
-         }\r
-         count+=length;\r
-#ifdef DEBUG\r
-         fprintf(stdout, _("Startup logo supported - "));\r
-         if (length!=0) { fprintf(stdout, _("currently set\n"));   }\r
-                    else { fprintf(stdout, _("currently empty\n")); }\r
-#endif\r
-          if (CurrentGetBitmap->type==GSM_StartupLogo) issupported=true;\r
-         break;\r
-       case 0x02:\r
-         length=MessageBuffer[count];\r
-         if (CurrentGetBitmap->type==GSM_WelcomeNoteText) {\r
-            memcpy(CurrentGetBitmap->text,MessageBuffer+count+1,length);\r
-           CurrentGetBitmap->text[length]=0;\r
-         }\r
-#ifdef DEBUG\r
-          fprintf(stdout, _("Startup Text supported - "));\r
-          if (length!=0)\r
-         {\r
-           fprintf(stdout, _("currently set to \""));\r
-           for (i=0;i<length;i++) fprintf(stdout, _("%c"),MessageBuffer[count+1+i]);\r
-           fprintf(stdout, _("\"\n"));\r
-         } else {\r
-            fprintf(stdout, _("currently empty\n"));\r
-         }\r
-#endif\r
-         count+=length+1;\r
-          if (CurrentGetBitmap->type==GSM_WelcomeNoteText) issupported=true;\r
-         break;\r
-       case 0x03:\r
-         length=MessageBuffer[count];\r
-         if (CurrentGetBitmap->type==GSM_DealerNoteText) {\r
-            memcpy(CurrentGetBitmap->text,MessageBuffer+count+1,length);\r
-           CurrentGetBitmap->text[length]=0;\r
-         }\r
-#ifdef DEBUG\r
-         fprintf(stdout, _("Dealer Welcome supported - "));\r
-         if (length!=0)\r
-         {\r
-           fprintf(stdout, _("currently set to \""));\r
-           for (i=0;i<length;i++) fprintf(stdout, _("%c"),MessageBuffer[count+1+i]);\r
-           fprintf(stdout, _("\"\n"));\r
-         } else {\r
-            fprintf(stdout, _("currently empty\n"));\r
-         }\r
-#endif\r
-         count+=length+1;\r
-          if (CurrentGetBitmap->type==GSM_DealerNoteText) issupported=true;\r
-         break;\r
-        }\r
-      }\r
-      if (issupported) CurrentGetBitmapError=GE_NONE;\r
-                  else CurrentGetBitmapError=GE_NOTSUPPORTED;\r
-    } else {\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Startup logo received but not requested!\n"));\r
-#endif\r
-    }\r
-    break;\r
-\r
-  /* Set startup OK */\r
-  case 0x19:   \r
-    \r
-    CurrentSetBitmapError=GE_NONE;    \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Startup logo, welcome note or dealer welcome note correctly set.\n"));\r
-#endif  \r
-    break;      \r
-\r
-  /* Set Operator Logo OK */\r
-  case 0x31:   \r
-      \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Operator logo correctly set.\n"));\r
-#endif  \r
-\r
-    CurrentSetBitmapError=GE_NONE;      \r
-    break;\r
-\r
-  /* Set Operator Logo Error */      \r
-  case 0x32:  \r
-      \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Error setting operator logo!\n"));\r
-#endif\r
-\r
-    CurrentSetBitmapError=GE_UNKNOWN;        \r
-    break;\r
-\r
-  /* Operator Logo */\r
-  /* [location],[netcode x 3],[lenhi],[lenlo],[bitmap] */ \r
-  case 0x34:\r
\r
-    if (CurrentGetBitmap!=NULL) {\r
-\r
-      count=5;  /* Location ignored. */\r
-\r
-      DecodeNetworkCode(MessageBuffer+count, CurrentGetBitmap->netcode);
-      count=count+3;
-\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Operator Logo for %s (%s) network received.\n"),\r
-                          CurrentGetBitmap->netcode,\r
-                          GSM_GetNetworkName(CurrentGetBitmap->netcode));\r
-#endif  \r
-\r
-      CurrentGetBitmap->size=MessageBuffer[count++]<<8;\r
-      CurrentGetBitmap->size+=MessageBuffer[count++];\r
-      count++;\r
-      CurrentGetBitmap->width=MessageBuffer[count++];\r
-      CurrentGetBitmap->height=MessageBuffer[count++];\r
-      count++;\r
-      tmp=CurrentGetBitmap->height*CurrentGetBitmap->width/8;\r
-      if (CurrentGetBitmap->size>tmp) CurrentGetBitmap->size=tmp;\r
-      memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count,CurrentGetBitmap->size);\r
-      CurrentGetBitmapError=GE_NONE;\r
-    } else {\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: Operator logo received but not requested!\n"));\r
-#endif\r
-    }\r
-      \r
-    break;\r
-\r
-  /* Get op logo error */      \r
-  case 0x35:\r
-     \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Error getting operator logo!\n"));\r
-#endif  \r
-    CurrentGetBitmapError=GE_UNKNOWN; \r
-    break;\r
-\r
-  default:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Unknown message of type 0x05\n"));\r
-#endif /* DEBUG */\r
-    AppendLogText("Unknown msg\n",false);\r
-\r
-    break;\r
-  }\r
-}\r
-\r
-void N6110_Dispatch0x06Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int tmp;\r
-  unsigned char output[160];\r
+  case 0x09:
 
 #ifdef DEBUG
 
 #ifdef DEBUG
-  int i;
+    switch (MessageBuffer[4]) {
+      case 0x6f:
+       fprintf(stdout, _("Message: Memory status error, phone is probably powered off.\n"));break;
+      case 0x7d:
+       fprintf(stdout, _("Message: Memory status error, memory type not supported by phone model.\n"));break;
+      case 0x8d:
+       fprintf(stdout, _("Message: Memory status error, waiting for security code.\n"));break;
+      default:
+       fprintf(stdout, _("Message: Unknown Memory status error, subtype (MessageBuffer[4]) = %02x\n"),MessageBuffer[4]);break;
+    }
 #endif
 #endif
-    \r
-  switch (MessageBuffer[3]) {\r
-
-  case 0x05:\r
-\r
-    /* MessageBuffer[3] = 0x05\r
-       MessageBuffer[4] = 0x00\r
-       MessageBuffer[5] = 0x0f\r
-       MessageBuffer[6] = 0x03\r
-       MessageBuffer[7] = length of packed message\r
-\r
-       This is all I have seen - Gerry Anderson */\r
-\r
-    tmp=GSM_UnpackEightBitsToSeven(0, 82, 82, MessageBuffer+8, output);\r
-\r
-#ifdef DEBUG\r
-\r
-    fprintf(stdout, _("Message from Network operator: "));\r
-\r
-    for (i=0; i<tmp; i++)\r
-       fprintf(stdout, "%c", DecodeWithDefaultAlphabet(output[i]));\r
-\r
-    fprintf(stdout, "\n");\r
-\r
-#endif /* DEBUG */\r
-\r
-    break;\r
-\r
-  default:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Unknown message of type 0x06\n"));\r
-#endif /* DEBUG */\r
-    AppendLogText("Unknown msg\n",false);\r
-\r
-    break;\r
-  }\r
-}\r
-\r
-void N6110_Dispatch0x09Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-    \r
-  switch (MessageBuffer[3]) {\r
-    \r
-  case 0x80:    \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: SIM card login\n"));\r
-#endif\r
-    break;\r
-\r
-  case 0x81:    \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: SIM card logout\n"));\r
-#endif\r
-    break;\r
-      \r
-  default:\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Unknown message of type 0x09.\n"));      \r
-#endif\r
-    AppendLogText("Unknown msg\n",false);\r
-    break;\r
-  }\r
-}\r
-\r
-void N6110_Dispatch0x13Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  switch(MessageBuffer[3]) {\r
-    \r
-  case 0x6a:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Calendar Alarm active\n"));\r
-    fprintf(stdout, _("   Item number: %d\n"), MessageBuffer[4]);\r
-#endif /* DEBUG */\r
-\r
-  default:\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Unknown message of type 0x13.\n"));      \r
-#endif\r
-    AppendLogText("Unknown msg\n",false);\r
-    break;\r
-  }\r
-}\r
-\r
-void N6110_Dispatch0x40Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int i;\r
-  \r
-  switch(MessageBuffer[2]) {\r
-\r
-  case 0x02:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: ACK for simlock opening part 1\n"));\r
-#endif /* DEBUG */\r
-    \r
-    CurrentMagicError=GE_NONE;\r
-    break;\r
-    \r
-  case 0x7c:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Answer for call commands.\n"));\r
-#endif\r
-    \r
-    CurrentDialVoiceError=GE_NONE;      \r
-    break;\r
-      \r
-  case 0x81:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: ACK for simlock opening part 2\n"));\r
-#endif /* DEBUG */\r
-    \r
-    CurrentMagicError=GE_NONE;\r
-    break;\r
-\r
-  case 0x82:\r
-\r
-#ifdef DEBUG\r
-      fprintf(stdout, _("Message: ACK for simlock closing\n"));\r
-#endif /* DEBUG */\r
-    \r
-    CurrentMagicError=GE_NONE;\r
-    break;\r
-\r
-  case 0xd4:\r
-\r
-    switch (MessageBuffer[5]) {\r
-      case 0xa0:\r
-#ifdef DEBUG\r
-        fprintf(stdout,_("Message: EEPROM contest received\n"));\r
-#endif\r
-\r
-        if (MessageBuffer[8]!=0x00) {\r
-          for (i=9;i<MessageLength;i++) {\r
-            fprintf(stdout,_("%c"), MessageBuffer[i]);\r
-        }\r
-\r
-        CurrentMagicError=GE_NONE;\r
-      }\r
-      \r
-      break;\r
-    }\r
-      \r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Unknown message of type 0x40.\n"));\r
-#endif /* DEBUG */\r
-    AppendLogText("Unknown msg\n",false);      \r
-    break;\r
-\r
-  case 0xcf:\r
-\r
-    N6110_DisplayTestsInfo(MessageBuffer);\r
-    break;\r
-      \r
-  default:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Unknown message of type 0x40.\n"));\r
-#endif /* DEBUG */\r
-    AppendLogText("Unknown msg\n",false);\r
-    break;     /* Visual C Don't like empty cases */\r
-  }\r
-}\r
-\r
-void N6110_Dispatch0x47Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  int count;\r
-  \r
-  switch(MessageBuffer[3]) {\r
-    \r
-  case 0x02:\r
-\r
-    count=5;\r
-    \r
-    if (MessageBuffer[5]!=0) {\r
-      strcpy(CurrentGetBitmap->Sender,GSM_UnpackSemiOctetNumber(MessageBuffer+5,true));\r
-\r
-      while (MessageBuffer[count]!=0) {\r
-        count++;\r
-      }\r
-\r
-      count++;\r
-    } else {\r
-      strcpy(CurrentGetBitmap->Sender,"\0");\r
-\r
-      count+=3;\r
-    }\r
-\r
-    memcpy(CurrentGetBitmap->text,MessageBuffer+count+1,MessageBuffer[count]);\r
-    CurrentGetBitmap->text[MessageBuffer[count]]=0;\r
-\r
-    if (MessageBuffer[count]!=0)\r
-      count+=MessageBuffer[count];\r
-\r
-    count++;\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout,_("Picture Image received, text \"%s\", sender %s\n"),CurrentGetBitmap->text,CurrentGetBitmap->Sender);\r
-#endif\r
-\r
-    CurrentGetBitmap->width=MessageBuffer[count+1];\r
-    CurrentGetBitmap->height=MessageBuffer[count+2]; \r
-    CurrentGetBitmap->size=CurrentGetBitmap->height*CurrentGetBitmap->width/8;\r
-      \r
-    memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count+4,CurrentGetBitmap->size);\r
-      \r
-    CurrentGetBitmapError=GE_NONE;\r
-    break;\r
-\r
-  case 0x04:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout,_("Getting or setting Picture Image - OK\n"));\r
-#endif\r
-    CurrentSetBitmapError=GE_NONE;\r
-    CurrentGetBitmapError=GE_NONE;\r
-    break;     \r
-\r
-  case 0x05:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout,_("Setting Picture Image - invalid location or other error\n"));\r
-#endif\r
-    CurrentSetBitmapError=GE_UNKNOWN;\r
-    break;     \r
-\r
-  case 0x06:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout,_("Getting Picture Image - invalid location or other error\n"));\r
-#endif\r
-    CurrentGetBitmapError=GE_UNKNOWN;\r
-    break;     \r
-\r
-  default:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Unknown message of type 0x47.\n"));\r
-#endif /* DEBUG */\r
-    AppendLogText("Unknown msg\n",false);\r
-    break;     /* Visual C Don't like empty cases */\r
-  }\r
-}\r
-\r
-void N6110_DispatchACKMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-  char buffer[50];\r
-  \r
-  sprintf(buffer,"Received ACK %02x %02x\n",MessageBuffer[0],MessageBuffer[1]);\r
-  AppendLog(buffer,strlen(buffer),false);\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("[Received Ack of type %02x, seq: %2x]\n"), MessageBuffer[0],\r
-                                                                MessageBuffer[1]);\r
-#endif /* DEBUG */\r
-  \r
-  CurrentLinkOK = true;\r
-}\r
-\r
-void N6110_Dispatch0xD0Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-   \r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: The phone is powered on - seq 1.\n"));\r
-#endif /* DEBUG */\r
-\r
-}\r
-\r
-/* This function is used for parsing the RLP frame into fields. */\r
-void N6110_RX_HandleRLPMessage(u8 *MessageBuffer)\r
-{\r
-\r
-  RLP_F96Frame frame;\r
-  int count;\r
-  int valid = true;\r
-\r
-  /* We do not need RLP frame parsing to be done when we do not have callback\r
-     specified. */\r
-  if (CurrentRLP_RXCallback == NULL)\r
-    exit;\r
-    \r
-  /* Anybody know the official meaning of the first two bytes?\r
-     Nokia 6150 sends junk frames starting D9 01, and real frames starting\r
-     D9 00. We'd drop the junk frames anyway because the FCS is bad, but\r
-     it's tidier to do it here. We still need to call the callback function\r
-     to give it a chance to handle timeouts and/or transmit a frame */\r
-  if (MessageBuffer[0] == 0xd9 && MessageBuffer[1] == 0x01)\r
-    valid = false;\r
-\r
-  /* Nokia uses 240 bit frame size of RLP frames as per GSM 04.22\r
-     specification, so Header consists of 16 bits (2 bytes). See section 4.1\r
-     of the specification. */\r
-    \r
-  frame.Header[0] = MessageBuffer[2];\r
-  frame.Header[1] = MessageBuffer[3];\r
-\r
-  /* Next 200 bits (25 bytes) contain the Information. We store the\r
-     information in the Data array. */\r
-\r
-  for (count = 0; count < 25; count ++)\r
-    frame.Data[count] = MessageBuffer[4 + count];\r
-\r
-  /* The last 24 bits (3 bytes) contain FCS. */\r
-\r
-  frame.FCS[0] = MessageBuffer[29];\r
-  frame.FCS[1] = MessageBuffer[30];\r
-  frame.FCS[2] = MessageBuffer[31];\r
-\r
-  /* Here we pass the frame down in the input stream. */\r
-  CurrentRLP_RXCallback(valid ? &frame : NULL);\r
-}\r
-\r
-void N6110_Dispatch0xF4Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("Message: The phone is powered on - seq 2.\n"));\r
-#endif /* DEBUG */\r
-\r
-}\r
-\r
-void N6110_ReplyIncomingSMS(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
-\r
-  GSM_SMSMessage NullSMS;\r
-\r
-  switch (MessageBuffer[6]) {\r
-\r
-    case 0x00: NullSMS.Type = GST_SMS; NullSMS.folder = GST_INBOX; break;\r
-    case 0x01: NullSMS.Type = GST_DR;  NullSMS.folder = GST_INBOX; break;\r
-\r
-    /* Is it possible ? */\r
-    case 0x02: NullSMS.Type = GST_SMS; NullSMS.folder = GST_OUTBOX; break;      \r
-    default:   NullSMS.Type = GST_UN;                               break;\r
-  }\r
-\r
-#ifdef DEBUG\r
-  if (NullSMS.Type == GST_DR)\r
-    fprintf(stdout, _("Message: SMS Message (Report) Received\n"));\r
-  else \r
-    fprintf(stdout, _("Message: SMS Message Received\n"));  \r
-#endif /* DEBUG */\r
-\r
-  GSM_DecodeNokiaSMSFrame(&NullSMS, MessageBuffer+7, MessageLength-7);\r
-\r
-#ifdef DEBUG\r
-  fprintf(stdout, _("\n"));      \r
-#endif /* DEBUG */\r
-}\r
-\r
-void N6110_DispatchMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {\r
 
 
-  bool unknown=false;
+    switch (MessageBuffer[4]) {
+      case 0x6f:CurrentMemoryStatusError = GE_TIMEOUT;break;
+      case 0x7d:CurrentMemoryStatusError = GE_INTERNALERROR;break;
+      case 0x8d:CurrentMemoryStatusError = GE_INVALIDSECURITYCODE;break;
+      default:break;
+    }
 
 
-  /* Switch on the basis of the message type byte */\r
-  switch (MessageType) {\r
-         \r
-  /* Call information */\r
-  case 0x01:\r
-\r
-    N6110_Dispatch0x01Message(MessageLength, MessageBuffer, MessageType);\r
-    break;\r
-\r
-  /* SMS handling */\r
-  case 0x02:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x02:\r
-      case 0x03:N6110_ReplySendSMSMessage(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x10:N6110_ReplyIncomingSMS(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x21:N6110_ReplySetCellBroadcast(MessageLength, MessageBuffer, MessageType);break;\r
-      case 0x23:N6110_ReplyReadCellBroadcast(MessageLength, MessageBuffer, MessageType);break;\r
-      case 0x31:N6110_ReplySetSMSCenter(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x34:\r
-      case 0x35:N6110_ReplyGetSMSCenter(MessageLength,MessageBuffer,MessageType);break;\r
-      default  :unknown=true;break;\r
-    }\r
-    break;\r
-\r
-  /* Phonebook handling */\r
-  case 0x03:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x02:\r
-      case 0x03:N6110_ReplyGetMemoryLocation(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x05:\r
-      case 0x06:N6110_ReplyWritePhonebookLocation(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x08:\r
-      case 0x09:N6110_ReplyGetMemoryStatus(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x17:\r
-      case 0x18:N6110_ReplyGetSpeedDial(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x1a:\r
-      case 0x1b:N6110_ReplySetSpeedDial(MessageLength,MessageBuffer,MessageType);break;\r
-      default  :N6110_Dispatch0x03Message(MessageLength,MessageBuffer,MessageType);break;\r
-    }\r
-    break;\r
-\r
-  /* Phone status */    \r
-  case 0x04:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x02:N6110_ReplyRFBatteryLevel(MessageLength,MessageBuffer,MessageType);break;\r
-      default  :unknown=true;break;\r
-    }\r
-    break;\r
-      \r
-  /* Startup Logo, Operator Logo and Profiles. */\r
-  case 0x05:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x11:N6110_ReplySetProfile    (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x14:N6110_ReplyGetProfile    (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x1b:N6110_ReplyGetProfile    (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x1d:N6110_ReplySetProfile    (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x37:N6110_ReplySetRingtone   (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x38:N6110_ReplySetRingtone   (MessageLength,MessageBuffer,MessageType);break;\r
-      default  :N6110_Dispatch0x05Message(MessageLength,MessageBuffer,MessageType);break;\r
-    }\r
-    break;\r
-\r
-  /* Network Operator Message to handset -> Gerry Anderson & prepaid info */
-  /* Call diverts */
-  case 0x06:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x02:\r
-      case 0x03:N6110_ReplyCallDivert    (MessageLength,MessageBuffer,MessageType);break;\r
-      default  :N6110_Dispatch0x06Message(MessageLength,MessageBuffer,MessageType);break;\r
-    }\r
-    break;\r
-\r
-  /* Security code requests */\r
-  case 0x08:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x08:N6110_ReplyGetSecurityCodeStatus(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x0b:N6110_ReplyEnterSecurityCode    (MessageLength,MessageBuffer,MessageType);break;\r
-      default  :N6110_ReplyEnterSecurityCode    (MessageLength,MessageBuffer,MessageType);break;\r
-    }\r
-    break;\r
-\r
-  /* SIM login */\r
-  case 0x09:\r
-\r
-    N6110_Dispatch0x09Message(MessageLength, MessageBuffer, MessageType);\r
-    break;\r
-\r
-  /* Network info */\r
-  case 0x0a:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x71:N6110_ReplyGetNetworkInfo(MessageLength,MessageBuffer,MessageType);break;\r
-      default  :unknown=true;break;\r
-    }\r
-    break;\r
-\r
-  /* Simulating key pressing */\r
-  case 0x0c:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x43:N6110_ReplyPressKey(MessageLength,MessageBuffer,MessageType);break;\r
-      default  :unknown=true;break;\r
-    }\r
-    break;\r
-\r
-  /* Display */\r
-  case 0x0d:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x50:N6110_ReplyDisplayOutput   (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x52:N6110_ReplyGetDisplayStatus(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x54:N6110_ReplyDisplayOutput   (MessageLength,MessageBuffer,MessageType);break;\r
-      default  :unknown=true;break;\r
-    }\r
-    break;\r
-\r
-  /* Phone Clock and Alarm */\r
-  case 0x11:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x61:N6110_ReplySetDateTime(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x63:N6110_ReplyGetDateTime(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x6c:N6110_ReplySetAlarm   (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x6e:N6110_ReplyGetAlarm   (MessageLength,MessageBuffer,MessageType);break;\r
-      default  :unknown=true;break;\r
-    }\r
-    break;\r
-\r
-  /* Calendar notes handling */\r
-  case 0x13:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x65:N6110_ReplyWriteCalendarNote (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x67:N6110_ReplyGetCalendarNote   (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x69:N6110_ReplyDeleteCalendarNote(MessageLength,MessageBuffer,MessageType);break;\r
-      default  :N6110_Dispatch0x13Message    (MessageLength,MessageBuffer,MessageType);break;\r
-    }\r
-    break;\r
-\r
-  /* SMS Messages */\r
-  case 0x14:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x05:\r
-      case 0x06:N6110_ReplySaveSMSMessage  (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x08:\r
-      case 0x09:N6110_ReplyGetSMSMessage   (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x0b:N6110_ReplyDeleteSMSMessage(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x37:\r
-      case 0x38:N6110_ReplyGetSMSStatus    (MessageLength,MessageBuffer,MessageType);break;\r
-      default  :unknown=true;break;\r
-    }\r
-    break;\r
-\r
-  /* WAP */\r
-  case 0x3f:\r
-    switch (MessageBuffer[3]) {\r
-      case 0x01:\r
-      case 0x02:N7110_ReplyEnableWAPCommands(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x07:\r
-      case 0x08:N7110_ReplyGetWAPBookmark   (MessageLength,MessageBuffer,MessageType);break;
-      case 0x0a:
-      case 0x0b:N7110_ReplySetWAPBookmark   (MessageLength,MessageBuffer,MessageType);break;
-      case 0x16:
-      case 0x17:
-      case 0x1c:N7110_ReplyGetWAPSettings   (MessageLength,MessageBuffer,MessageType);break;
-      default  :unknown=true;break;\r
-    }\r
-    break;\r
-\r
-  /* Internal phone functions? */\r
-  case 0x40:\r
-    switch (MessageBuffer[2]) {\r
-      case 0x64:N6110_ReplyEnableExtendedCommands  (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x65:N6110_ReplyResetPhoneSettings      (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x66:N6110_ReplyIMEI                    (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x6a:N6110_ReplyGetProductProfileSetting(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x6b:N6110_ReplySetProductProfileSetting(MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x6e:N6110_ReplyGetSecurityCode         (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x7e:N6110_ReplyNetmonitor              (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x8a:N6110_ReplySimlockInfo             (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x8b:N6110_ReplySetOperatorName         (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x8c:N6110_ReplyGetOperatorName         (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x8f:N6110_ReplyPlayTone                (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0x9e:N6110_ReplyGetBinRingtone          (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0xa0:N6110_ReplySetBinRingtone          (MessageLength,MessageBuffer,MessageType);break;\r
-      case 0xc8:N6110_ReplyHW                      (MessageLength,MessageBuffer,MessageType);break;\r
-      default  :N6110_Dispatch0x40Message          (MessageLength,MessageBuffer,MessageType);break;\r
-    }\r
-    break;\r
-\r
-  /* Picture Images */\r
-  case 0x47:\r
-\r
-    N6110_Dispatch0x47Message(MessageLength, MessageBuffer, MessageType);\r
-    break;\r
-\r
-  /* Mobile phone identification */\r
-  case 0x64:\r
-\r
-    N6110_ReplyGetAuthentication(MessageLength, MessageBuffer, MessageType);\r
-    break;\r
-\r
-  /***** Acknowlegment of our frames. *****/\r
-  case FBUS_FRTYPE_ACK:\r
-\r
-    N6110_DispatchACKMessage(MessageLength, MessageBuffer, MessageType);\r
-    break;\r
-\r
-  /***** Power on message. *****/\r
-  case 0xd0:\r
-\r
-    N6110_Dispatch0xD0Message(MessageLength, MessageBuffer, MessageType);\r
-    break;\r
-\r
-  case 0xd2:\r
-\r
-    N6110_ReplyID(MessageLength, MessageBuffer, MessageType);\r
-    break;\r
-  \r
-  /***** RLP frame received. *****/\r
-  case 0xf1:\r
-\r
-    N6110_RX_HandleRLPMessage(MessageBuffer);\r
-    break;\r
-\r
-  /***** Power on message. *****/\r
-  case 0xf4:\r
-\r
-    N6110_Dispatch0xF4Message(MessageLength, MessageBuffer, MessageType);\r
-    break;\r
-\r
-  /***** Unknown message *****/\r
-  /* If you think that you know the exact meaning of other messages - please\r
-     let us know. */\r
-  default:\r
-\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Message: Unknown message type.\n"));\r
-#endif /* DEBUG */\r
-    AppendLogText("Unknown msg type\n",false);\r
-\r
-    unknown=false;\r
-    break;\r
-\r
-  }\r
-\r
-  if (unknown) {\r
-#ifdef DEBUG\r
-    fprintf(stdout, _("Unknown message of type %02x.\n"),MessageType);\r
-#endif\r
-    AppendLogText("Unknown msg\n",false);\r
-  }\r
-}\r
+    break;
+
+  }
+}
+
+/* This function is used to get storage status from the phone. It currently
+   supports two different memory areas - internal and SIM. */
+GSM_Error N6110_GetMemoryStatus(GSM_MemoryStatus *Status)
+{
+  unsigned char req[] = { N6110_FRAME_HEADER,
+                          0x07, /* MemoryStatus request */
+                          0x00  /* MemoryType */
+                        };
+
+  GSM_Error error;
+  
+  CurrentMemoryStatus = Status;
+
+  req[4] = N6110_GetMemoryType(Status->MemoryType);
+
+  error=NULL_SendMessageSequence
+    (20, &CurrentMemoryStatusError, 5, 0x03, req);
+
+  CurrentMemoryStatus = NULL;
+
+  return error;
+}
+
+#ifndef UCLINUX
+
+void N6110_ReplyGetNetworkInfo(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  GSM_NetworkInfo NullNetworkInfo;
+  
+  /* Make sure we are expecting NetworkInfo frame */
+  if (CurrentNetworkInfo && CurrentNetworkInfoError == GE_BUSY) {
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Network informations:\n"));
+#endif
+  } else {
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Network informations not requested, but received:\n"));
+#endif
+  }
+      
+  sprintf(NullNetworkInfo.NetworkCode, "%x%x%x %x%x", MessageBuffer[14] & 0x0f, MessageBuffer[14] >>4, MessageBuffer[15] & 0x0f, MessageBuffer[16] & 0x0f, MessageBuffer[16] >>4);
+
+  sprintf(NullNetworkInfo.CellID, "%02x%02x", MessageBuffer[10], MessageBuffer[11]);
+
+  sprintf(NullNetworkInfo.LAC, "%02x%02x", MessageBuffer[12], MessageBuffer[13]);
+
+#ifdef DEBUG
+  fprintf(stdout, _("   CellID: %s\n"), NullNetworkInfo.CellID);
+  fprintf(stdout, _("   LAC: %s\n"), NullNetworkInfo.LAC);
+  fprintf(stdout, _("   Network code: %s\n"), NullNetworkInfo.NetworkCode);
+  fprintf(stdout, _("   Network name: %s (%s)\n"),
+                     GSM_GetNetworkName(NullNetworkInfo.NetworkCode),
+                     GSM_GetCountryName(NullNetworkInfo.NetworkCode));
+  fprintf(stdout, _("   Status: "));
+
+  switch (MessageBuffer[8]) {
+    case 0x01: fprintf(stdout, _("home network selected")); break;
+    case 0x02: fprintf(stdout, _("roaming network")); break;
+    case 0x03: fprintf(stdout, _("requesting network")); break;
+    case 0x04: fprintf(stdout, _("not registered in the network")); break;
+    default: fprintf(stdout, _("unknown"));
+  }
+
+  fprintf(stdout, "\n");
+
+  fprintf(stdout, _("   Network selection: %s\n"), MessageBuffer[9]==1?_("manual"):_("automatic"));
+#endif /* DEBUG */
+
+  /* Make sure we are expecting NetworkInfo frame */
+  if (CurrentNetworkInfo && CurrentNetworkInfoError == GE_BUSY)
+    *CurrentNetworkInfo=NullNetworkInfo;
+
+  CurrentNetworkInfoError = GE_NONE;      
+}
+
+GSM_Error N6110_GetNetworkInfo(GSM_NetworkInfo *NetworkInfo)
+{
+  unsigned char req[] = { N6110_FRAME_HEADER,
+                          0x70
+                        };
+
+  GSM_Error error;
+  
+  CurrentNetworkInfo = NetworkInfo;
+  
+  error=NULL_SendMessageSequence
+    (20, &CurrentNetworkInfoError, 4, 0x0a, req);
+
+  CurrentNetworkInfo = NULL;
+
+  return error;
+}
+
+void N6110_ReplyGetProductProfileSetting(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int i;
+  
+#ifdef DEBUG
+  fprintf(stdout, _("Message: Product Profile Settings received -"));
+  for (i=0;i<4;i++) fprintf(stdout, _(" %02x"),MessageBuffer[3+i]);
+  fprintf(stdout, _("\n"));  
+#endif
+
+  for (i=0;i<4;i++) CurrentPPS[i]=MessageBuffer[3+i];
+
+  CurrentProductProfileSettingsError=GE_NONE;      
+}
+
+GSM_Error N6110_GetProductProfileSetting (GSM_PPS *PPS)
+{
+  unsigned char req[] = { 0x00, 0x01,0x6a };
+  
+  int i,j;
+
+  GSM_Error error;
+
+  error=N6110_EnableExtendedCommands(0x01);
+  if (error!=GE_NONE) return error;
+
+  error=NULL_SendMessageSequence
+    (20, &CurrentProductProfileSettingsError, 3, 0x40, req);
+  if (error!=GE_NONE) return error;    
+  
+  switch (PPS->Name) {
+    case PPS_ALS      : PPS->bool_value=(CurrentPPS[1]&32); break;
+    case PPS_GamesMenu: PPS->bool_value=(CurrentPPS[3]&64); break;
+    case PPS_HRData   : PPS->bool_value=(CurrentPPS[0]&64); break;
+    case PPS_14400Data: PPS->bool_value=(CurrentPPS[0]&128);break;
+    case PPS_EFR      : PPS->int_value =(CurrentPPS[0]&1)    +(CurrentPPS[0]&2);    break;
+    case PPS_FR       : PPS->int_value =(CurrentPPS[0]&16)/16+(CurrentPPS[0]&32)/16;break;
+    case PPS_HR       : PPS->int_value =(CurrentPPS[0]&4)/4  +(CurrentPPS[0]&8)/4;  break;
+    case PPS_VibraMenu: PPS->bool_value=(CurrentPPS[4]&64); break;
+    case PPS_LCDContrast:
+         PPS->int_value=0;
+         j=1;
+         for (i=0;i<5;i++) {
+          if (CurrentPPS[3]&j) PPS->int_value=PPS->int_value+j;
+          j=j*2;
+        }
+        PPS->int_value=PPS->int_value*100/32;
+         break;
+
+  }
+  
+  return (GE_NONE);
+}
+
+void N6110_ReplySetProductProfileSetting(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#ifdef DEBUG
+  int i;
+  
+  fprintf(stdout, _("Message: Product Profile Settings set to"));
+  for (i=0;i<4;i++) fprintf(stdout, _(" %02x"),CurrentPPS[i]);
+  fprintf(stdout, _("\n"));  
+#endif
+     
+  CurrentProductProfileSettingsError=GE_NONE;     
+}
+
+GSM_Error N6110_SetProductProfileSetting (GSM_PPS *PPS)
+{
+  unsigned char req[] = { 0x00, 0x01,0x6b, 
+                          0x00, 0x00, 0x00, 0x00 }; /* bytes with Product Profile Setings */
+  unsigned char settings[32];
+  
+  GSM_PPS OldPPS;
+  
+  int i,j,z;
+  
+  GSM_Error error;
+
+  error=N6110_EnableExtendedCommands(0x01);
+  if (error!=GE_NONE) return error;
+  
+  OldPPS.Name=PPS_ALS;
+  error=N6110_GetProductProfileSetting(&OldPPS);
+  if (error!=GE_NONE) return error;
+  
+  j=128;z=0;
+  for (i=0;i<32;i++) {
+    if (CurrentPPS[z]&j)
+      settings[i]='1';
+    else
+      settings[i]='0';    
+    if (j==1) {
+      j=128;
+      z++;
+    } else j=j/2;
+  }
+  
+#ifdef DEBUG
+  fprintf(stdout,_("Current settings: "));
+  for (i=0;i<32;i++) {
+    fprintf(stdout,_("%c"),settings[i]);    
+  }
+  fprintf(stdout,_("\n"));
+#endif
+
+  switch (PPS->Name) {
+    case PPS_ALS      :settings[10]=PPS->bool_value?'1':'0';break;
+    case PPS_HRData   :settings[ 5]=PPS->bool_value?'1':'0';break;
+    case PPS_14400Data:settings[ 6]=PPS->bool_value?'1':'0';break;
+    default           :break;
+  }
+    
+  j=128;z=0;
+  for (i=0;i<32;i++) {
+    if (settings[i]=='1') req[z+3]=req[z+3]+j;
+    if (j==1) {
+      j=128;
+      z++;
+    } else j=j/2;
+  }  
+
+#ifdef DEBUG
+  fprintf(stdout,_("Current settings: "));
+  for (i=0;i<4;i++) {
+    fprintf(stdout,_("%i "),req[i+3]);    
+  }
+  fprintf(stdout,_("\n"));
+#endif
+
+  for (i=0;i<4;i++) {
+   CurrentPPS[i]=req[i+3];    
+  }
+
+  return NULL_SendMessageSequence
+    (20, &CurrentProductProfileSettingsError, 7, 0x40, req);
+}
+
+void N6110_ReplyPressKey(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+    if (MessageBuffer[4]==CurrentPressKeyEvent) CurrentPressKeyError=GE_NONE;
+                                           else CurrentPressKeyError=GE_UNKNOWN; /* MessageBuffer[4] = 0x05 */
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Result of key "));
+    switch (MessageBuffer[4])
+    {
+      case PRESSPHONEKEY:   fprintf(stdout, _("press OK\n"));break;
+      case RELEASEPHONEKEY: fprintf(stdout, _("release OK\n"));break;
+      default:              fprintf(stdout, _("press or release - error\n"));break;
+    }
+#endif /* DEBUG */
+}
+
+GSM_Error N6110_PressKey(int key, int event)
+{
+  unsigned char req[] = {N6110_FRAME_HEADER, 0x42, 0x01, 0x00, 0x01};
+  
+  req[4]=event; /* if we press or release key */
+  req[5]=key;
+  
+  CurrentPressKeyEvent=event;
+  
+  return NULL_SendMessageSequence
+    (10, &CurrentPressKeyError, 7, 0x0c, req);
+}
+
+void N6110_ReplyDisplayOutput(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  /* Hopefully is 64 larger as FB38_MAX* / N6110_MAX* */
+  char model[64];
+
+  int i, j;
+
+  char uni[100];
+    
+  switch(MessageBuffer[3]) {
+
+  /* Phone sends displayed texts */
+  case 0x50:
+    NewX=MessageBuffer[6];
+    NewY=MessageBuffer[5];
+
+    DecodeUnicode (uni, MessageBuffer+8, MessageBuffer[7]);
+
+#ifdef DEBUG
+    fprintf(stdout, _("New displayed text (%i %i): \"%s\"\n"),NewX,NewY,uni);      
+#endif /* DEBUG */
+
+    while (N6110_GetModel(model)  != GE_NONE)
+      sleep(1);
+
+    /* With these rules it works almost excellent with my N5110 */
+    /* I don't have general rule :-(, that's why you must experiment */
+    /* with your phone. Nokia could make it better. MW */
+    /* It's almost OK for N5110*/
+    /* FIX ME: it will be the same for N5130 and 3210 too*/
+    if (!strcmp(model,"NSE-1"))
+    {
+      /* OldX==1000 means - it's first time */
+      if (OldX==1000) {
+      
+        /* Clean table */
+        for (i=0;i<5+1;i++) {
+          for (j=0;j<27+1;j++) {PhoneScreen[i][j]=' ';}
+      }
+      OldX=0;
+    }
+
+    if ((OldX==0 && OldY==31 && NewX==29 && NewY==46) ||
+        (OldX==0 && OldY==13 && NewX==23 && NewY==46)) {
+      /* Clean the line with current text */
+      for (j=0;j<27+1;j++) {PhoneScreen[NewY/(47/5)][j]=' ';}
+      
+      /* Inserts text into table */
+      for (i=0; i<MessageBuffer[7];i++) {      
+        PhoneScreen[NewY/(47/5)][NewX/(84/27)+i]=uni[i];
+      }
+
+    }
+
+    if ((OldX==0 && OldY==21 && NewX==0 && NewY==10) ||
+        (OldX==0 && OldY==10 && NewX==35 && NewY==46)) {
+    } else {
+      if ((OldX!=0 && NewX==0 && NewY!=6) ||
+          (OldX==0 && NewX!=0 && OldY!=13 && OldY!=22) ||
+          (OldX==0 && NewX==0 && NewY<OldY && (NewY!=13 || OldY!=26)) ||
+          (OldY==5 && NewY!=5) ||
+          (OldX==0 && OldY==13 && NewX==23 && NewY==46)) {
+
+        /* Writes "old" screen */
+        for (i=0;i<5+1;i++) {
+          for (j=0;j<27+1;j++) {fprintf(stdout,_("%c"),PhoneScreen[i][j]);}
+           fprintf(stdout,_("\n"));
+         }
+       
+         /* Clean table */
+          for (i=0;i<5+1;i++) {
+           for (j=0;j<27+1;j++) {PhoneScreen[i][j]=' ';}
+         }
+        }
+      }
+      
+      /* Clean the line with current text */
+      for (j=0;j<27+1;j++) {PhoneScreen[NewY/(47/5)][j]=' ';}
+      
+      /* Inserts text into table */
+      for (i=0; i<MessageBuffer[7];i++) {      
+        PhoneScreen[NewY/(47/5)][NewX/(84/27)+i]=uni[i];
+      }
+      
+      OldY=NewY;
+      OldX=NewX;
+    } else {
+#ifndef DEBUG
+      fprintf(stdout, _("%s\n"),uni);      
+#endif
+    }
+
+    break;
+  case 0x54:
+      
+    if (MessageBuffer[4]==1)
+    {
+      
+#ifdef DEBUG
+      fprintf(stdout, _("Display output successfully disabled/enabled.\n"));
+#endif /* DEBUG */
+
+      CurrentDisplayOutputError=GE_NONE;
+    }
+       
+    break;
+  }
+}
+
+GSM_Error SetDisplayOutput(unsigned char state)
+{
+  unsigned char req[] = { N6110_FRAME_HEADER,
+                          0x53, 0x00};
+
+  req[4]=state;
+  
+  return NULL_SendMessageSequence
+    (30, &CurrentDisplayOutputError, 5, 0x0d, req);
+}
+
+GSM_Error N6110_EnableDisplayOutput()
+{
+  return SetDisplayOutput(0x01);
+}
+GSM_Error N6110_DisableDisplayOutput()
+{
+  return SetDisplayOutput(0x02);
+}
+
+/* If it is interesting for somebody: we can use 0x40 msg for it
+   and it will work for all phones. See n6110.txt for details */
+GSM_Error N6110_AnswerCall(char s)
+{
+       unsigned char req0[] = { N6110_FRAME_HEADER, 0x42,0x05,0x01,0x07,                                0xa2,0x88,0x81,0x21,0x15,0x63,0xa8,0x00,0x00,
+                           0x07,0xa3,0xb8,0x81,0x20,0x15,0x63,0x80};
+       unsigned char req[] = { N6110_FRAME_HEADER, 0x06, 0x00, 0x00};
+
+       req[4]=s;
+
+#ifdef DEBUG
+       fprintf(stdout,_("Answering call %d\n\r"),s);
+#endif
+
+       Protocol->SendMessage(sizeof(req0), 0x01, req0);
+       sleep(1);
+
+       return NULL_SendMessageSequence
+               (20, &CurrentMagicError, sizeof(req) , 0x01, req);
+}
+
+void N6110_ReplyGetProfile(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch (MessageBuffer[3]) {
+
+  /* Profile feature */
+  case 0x14:   
+
+    switch(GetModelFeature (FN_PROFILES)) {
+      case F_PROF33:
+        switch (MessageBuffer[6]) {
+          case 0x00: CurrentProfile->KeypadTone  = MessageBuffer[8]; break;
+          case 0x01: CurrentProfile->CallAlert   = MessageBuffer[8]; break;
+          case 0x02: CurrentProfile->Ringtone    = MessageBuffer[8]; break;
+          case 0x03: CurrentProfile->Volume      = MessageBuffer[8]; break;
+          case 0x04: CurrentProfile->MessageTone = MessageBuffer[8]; break;
+          case 0x05: CurrentProfile->Vibration   = MessageBuffer[8]; break;
+          case 0x06: CurrentProfile->WarningTone = MessageBuffer[8]; break;
+          case 0x07: CurrentProfile->ScreenSaver = MessageBuffer[8]; break;      
+          default:
+#ifdef DEBUG
+           fprintf(stdout,_("feature %i = value %i\n\n"),MessageBuffer[6],MessageBuffer[8]);
+#endif
+            break;
+        }
+        break;
+      default:
+        switch (MessageBuffer[6]) {
+          case 0x00: CurrentProfile->KeypadTone      = MessageBuffer[8];break;
+          case 0x01: CurrentProfile->Lights          = MessageBuffer[8];break;
+          case 0x02: CurrentProfile->CallAlert       = MessageBuffer[8];break;
+          case 0x03: CurrentProfile->Ringtone        = MessageBuffer[8];break;
+          case 0x04: CurrentProfile->Volume          = MessageBuffer[8];break;
+          case 0x05: CurrentProfile->MessageTone     = MessageBuffer[8];break;
+          case 0x06: CurrentProfile->Vibration       = MessageBuffer[8];break;
+          case 0x07: CurrentProfile->WarningTone     = MessageBuffer[8];break;
+          case 0x08: CurrentProfile->CallerGroups    = MessageBuffer[8];break;
+          case 0x09: CurrentProfile->AutomaticAnswer = MessageBuffer[8];break;
+          default:
+#ifdef DEBUG
+           fprintf(stdout,_("feature %i = value %i\n\n"),MessageBuffer[6],MessageBuffer[8]);
+#endif
+            break;
+        }
+        break;
+    }
+
+    CurrentProfileError = GE_NONE;
+    break;
+
+  /* Incoming profile name */
+  case 0x1b:   
+
+    if (MessageBuffer[9] == 0x00) {
+      CurrentProfile->DefaultName=MessageBuffer[8];
+    } else {
+      CurrentProfile->DefaultName=-1;      
+       
+      /* Here name is in Unicode */
+      if (GetModelFeature (FN_PROFILES)==F_PROF33) {
+       DecodeUnicode (CurrentProfile->Name, MessageBuffer+10, MessageBuffer[9]/2);
+      } else {
+        /* ...here not */
+        sprintf(CurrentProfile->Name, MessageBuffer + 10, MessageBuffer[9]);
+        CurrentProfile->Name[MessageBuffer[9]] = '\0';
+      }
+    }
+
+    CurrentProfileError = GE_NONE;
+    break;
+
+  }
+}
+
+/* Needs SIM card with PIN in phone */
+GSM_Error N6110_GetProfile(GSM_Profile *Profile)
+{
+  int i;
+  
+  unsigned char name_req[] = { N6110_FRAME_HEADER, 0x1a, 0x00};
+  unsigned char feat_req[] = { N6110_FRAME_HEADER, 0x13, 0x01, 0x00, 0x00};
+
+  GSM_Error error;
+  
+  CurrentProfile = Profile;
+
+  /* When after sending all frames feature==253, it means, that it is not
+     supported */
+  CurrentProfile->KeypadTone=253;
+  CurrentProfile->Lights=253;    
+  CurrentProfile->CallAlert=253; 
+  CurrentProfile->Ringtone=253;  
+  CurrentProfile->Volume=253;    
+  CurrentProfile->MessageTone=253;
+  CurrentProfile->WarningTone=253;
+  CurrentProfile->Vibration=253;  
+  CurrentProfile->CallerGroups=253;
+  CurrentProfile->ScreenSaver=253; 
+  CurrentProfile->AutomaticAnswer=253;
+
+  name_req[4] = Profile->Number;
+
+  error=NULL_SendMessageSequence
+    (20, &CurrentProfileError, 5, 0x05, name_req);
+  if (error!=GE_NONE) return error;
+
+  for (i = 0x00; i <= 0x09; i++) {
+
+    feat_req[5] = Profile->Number;
+    
+    feat_req[6] = i;
+
+    error=NULL_SendMessageSequence
+      (20, &CurrentProfileError, 7, 0x05, feat_req);
+    if (error!=GE_NONE) return error;
+  }
+
+  if (Profile->DefaultName > -1)
+  {
+    switch(GetModelFeature (FN_PROFILES)) {
+      case F_PROF33:
+        switch (Profile->DefaultName) {
+          case 0x00: sprintf(Profile->Name, "General");break;
+          case 0x01: sprintf(Profile->Name, "Silent");break;
+          case 0x02: sprintf(Profile->Name, "Descreet");break;
+          case 0x03: sprintf(Profile->Name, "Loud");break;
+          case 0x04: sprintf(Profile->Name, "My style");break;
+          case 0x05: Profile->Name[0]=0;break;
+          default  : sprintf(Profile->Name, "Unknown (%i)", Profile->DefaultName);break;
+       }
+        break;
+      case F_PROF51:
+        switch (Profile->DefaultName) {
+          case 0x00: sprintf(Profile->Name, "Personal");break;
+          case 0x01: sprintf(Profile->Name, "Car");break;
+          case 0x02: sprintf(Profile->Name, "Headset");break;
+          default  : sprintf(Profile->Name, "Unknown (%i)", Profile->DefaultName);break;
+        }
+        break;
+      case F_PROF61:
+        switch (Profile->DefaultName) {
+          case 0x00: sprintf(Profile->Name, "General");break;
+          case 0x01: sprintf(Profile->Name, "Silent");break;
+          case 0x02: sprintf(Profile->Name, "Meeting");break;
+          case 0x03: sprintf(Profile->Name, "Outdoor");break;
+          case 0x04: sprintf(Profile->Name, "Pager");break;
+          case 0x05: sprintf(Profile->Name, "Car");break;
+          case 0x06: sprintf(Profile->Name, "Headset");break;
+          default  : sprintf(Profile->Name, "Unknown (%i)", Profile->DefaultName);break;
+       }
+        break;
+    }
+  }
+  
+  return (GE_NONE);
+
+}
+
+void N6110_ReplySetProfile(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch (MessageBuffer[3]) {
+
+  /* Profile feature change result */
+  case 0x11:   
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Profile feature change result.\n"));
+#endif /* DEBUG */
+    CurrentProfileError = GE_NONE;
+    break;
+
+  /* Profile name set result */
+  case 0x1d:   
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Profile name change result.\n"));
+#endif /* DEBUG */
+    CurrentProfileError = GE_NONE;
+    break;
+
+  }
+}
+
+GSM_Error N6110_SetProfileFeature(u8 profile, u8 feature, u8 value)
+{
+  unsigned char feat_req[] = { N6110_FRAME_HEADER, 0x10, 0x01,
+                               0x00, 0x00, 0x00};
+
+  feat_req[5]=profile;
+  feat_req[6]=feature;
+  feat_req[7]=value;
+
+  return NULL_SendMessageSequence
+    (20, &CurrentProfileError, 8, 0x05, feat_req);
+}
+
+GSM_Error N6110_SetProfile(GSM_Profile *Profile)
+{
+  int i,value;
+
+  unsigned char name_req[40] = { N6110_FRAME_HEADER, 0x1c, 0x01, 0x03,
+                                 0x00, 0x00, 0x00};
+
+  GSM_Error error;
+  
+  name_req[7] = Profile->Number;
+  name_req[8] = strlen(Profile->Name);
+  name_req[6] = name_req[8] + 2;
+
+  for (i = 0; i < name_req[8]; i++)
+    name_req[9 + i] = Profile->Name[i];
+
+  error=NULL_SendMessageSequence
+    (20, &CurrentProfileError, name_req[8] + 9, 0x05, name_req);
+  if (error!=GE_NONE) return error;
+
+  for (i = 0x00; i <= 0x09; i++) {
+
+    switch (i) {
+      case 0x00: value = Profile->KeypadTone; break;
+      case 0x01: value = Profile->Lights; break;
+      case 0x02: value = Profile->CallAlert; break;
+      case 0x03: value = Profile->Ringtone; break;
+      case 0x04: value = Profile->Volume; break;
+      case 0x05: value = Profile->MessageTone; break;
+      case 0x06: value = Profile->Vibration; break;
+      case 0x07: value = Profile->WarningTone; break;
+      case 0x08: value = Profile->CallerGroups; break;
+      case 0x09: value = Profile->AutomaticAnswer; break;
+      default  : value = 0; break;
+    }
+
+    error=N6110_SetProfileFeature(Profile->Number,i,value);
+    if (error!=GE_NONE) return error;
+  }
+
+  return (GE_NONE);
+}
+
+bool N6110_SendRLPFrame(RLP_F96Frame *frame, bool out_dtx)
+{
+  u8 req[60] = { 0x00, 0xd9 };
+               
+  /* Discontinuos transmission (DTX).  See section 5.6 of GSM 04.22 version
+     7.0.1. */
+       
+  if (out_dtx)
+    req[1]=0x01;
+
+  memcpy(req+2, (u8 *) frame, 32);
+
+  return (Protocol->SendFrame(32, 0xf0, req));
+}
+
+void N6110_ReplyGetCalendarNote(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int i, j;
+
+  u8 mychar1;
+
+  wchar_t wc;  
+    
+  switch (MessageBuffer[4]) {
+
+    case 0x01:
+      
+      CurrentCalendarNote->Type=MessageBuffer[8];
+
+      DecodeDateTime(MessageBuffer+9, &CurrentCalendarNote->Time);
+
+      DecodeDateTime(MessageBuffer+16, &CurrentCalendarNote->Alarm);
+
+      CurrentCalendarNote->Text[0]=0;
+      
+      if (GetModelFeature (FN_CALENDAR)==F_CAL33) {
+        i=0;
+        if (CurrentCalendarNote->Type == GCN_REMINDER) i=1; //first char is subset
+        switch (MessageBuffer[24]) {
+          case 3:
+#ifdef DEBUG
+            fprintf(stdout,_("Subset 3 in reminder note !\n"));
+#endif
+            while (i!=MessageBuffer[23]) {
+              j=0;
+              if (i!=MessageBuffer[23]-1) {
+               if (MessageBuffer[24+i]>=0xc2) {
+                 DecodeWithUTF8Alphabet(MessageBuffer[24+i], MessageBuffer[24+i+1], &mychar1);
+                  CurrentCalendarNote->Text[strlen(CurrentCalendarNote->Text)+1]=0;
+                  CurrentCalendarNote->Text[strlen(CurrentCalendarNote->Text)]=mychar1;
+                 j=-1;
+                 i++;
+               }
+             }
+              if (j!=-1) {
+                CurrentCalendarNote->Text[strlen(CurrentCalendarNote->Text)+1]=0;
+                CurrentCalendarNote->Text[strlen(CurrentCalendarNote->Text)]=MessageBuffer[24+i];
+              }
+             i++;
+            }
+            break;
+          case 2:
+#ifdef DEBUG
+            fprintf(stdout,_("Subset 2 in reminder note !\n"));
+#endif
+            while (i!=MessageBuffer[23]) {
+             wc = MessageBuffer[24+i] | (0x00 << 8);
+              CurrentCalendarNote->Text[strlen(CurrentCalendarNote->Text)+1]=0;
+              CurrentCalendarNote->Text[strlen(CurrentCalendarNote->Text)]=
+                     DecodeWithUnicodeAlphabet(wc);
+             i++;
+            }
+            break;
+          case 1:
+#ifdef DEBUG
+            fprintf(stdout,_("Subset 1 in reminder note !\n"));
+#endif
+            memcpy(CurrentCalendarNote->Text,MessageBuffer+24+i,MessageBuffer[23]-i);
+            CurrentCalendarNote->Text[MessageBuffer[23]-i]=0;
+            break;
+          default:
+#ifdef DEBUG
+            fprintf(stdout,_("Unknown subset in reminder note !\n"));
+#endif
+            memcpy(CurrentCalendarNote->Text,MessageBuffer+24+i,MessageBuffer[23]-i);
+            CurrentCalendarNote->Text[MessageBuffer[23]-i]=0;
+            break;
+        }
+      } else {
+        memcpy(CurrentCalendarNote->Text,MessageBuffer+24,MessageBuffer[23]);
+        CurrentCalendarNote->Text[MessageBuffer[23]]=0;
+      }
+      
+      if (CurrentCalendarNote->Type == GCN_CALL) {
+        memcpy(CurrentCalendarNote->Phone,MessageBuffer+24+MessageBuffer[23]+1,MessageBuffer[24+MessageBuffer[23]]);
+        CurrentCalendarNote->Phone[MessageBuffer[24+MessageBuffer[23]]]=0;
+      }
+
+      CurrentCalendarNote->Recurrance=0;
+
+      CurrentCalendarNote->AlarmType=0;
+
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Calendar note received.\n"));
+
+      fprintf(stdout, _("   Date: %d-%02d-%02d\n"), CurrentCalendarNote->Time.Year,
+                                           CurrentCalendarNote->Time.Month,
+                                           CurrentCalendarNote->Time.Day);
+
+      fprintf(stdout, _("   Time: %02d:%02d:%02d\n"), CurrentCalendarNote->Time.Hour,
+                                           CurrentCalendarNote->Time.Minute,
+                                           CurrentCalendarNote->Time.Second);
+
+      /* Some messages do not have alarm set up */
+      if (CurrentCalendarNote->Alarm.Year != 0) {
+        fprintf(stdout, _("   Alarm date: %d-%02d-%02d\n"), CurrentCalendarNote->Alarm.Year,
+                                                CurrentCalendarNote->Alarm.Month,
+                                                CurrentCalendarNote->Alarm.Day);
+
+       fprintf(stdout, _("   Alarm time: %02d:%02d:%02d\n"), CurrentCalendarNote->Alarm.Hour,
+                                                CurrentCalendarNote->Alarm.Minute,
+                                                 CurrentCalendarNote->Alarm.Second);
+      }
+
+      fprintf(stdout, _("   Type: %d\n"), CurrentCalendarNote->Type);
+      fprintf(stdout, _("   Text: %s\n"), CurrentCalendarNote->Text);
+
+      if (CurrentCalendarNote->Type == GCN_CALL)
+        fprintf(stdout, _("   Phone: %s\n"), CurrentCalendarNote->Phone);
+#endif /* DEBUG */
+
+      CurrentCalendarNoteError=GE_NONE;
+      break;
+
+    case 0x93:
+
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Calendar note not available\n"));
+#endif /* DEBUG */
+
+      CurrentCalendarNoteError=GE_INVALIDCALNOTELOCATION;
+      break;
+
+    default:
+
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Calendar note error\n"));
+#endif /* DEBUG */
+
+      CurrentCalendarNoteError=GE_INTERNALERROR;
+      break;
+
+  }
+}
+
+GSM_Error N6110_GetCalendarNote(GSM_CalendarNote *CalendarNote)
+{
+
+  unsigned char req[] = { N6110_FRAME_HEADER,
+                          0x66, 0x00
+                        };
+  GSM_Error error;
+
+  req[4]=CalendarNote->Location;
+
+  CurrentCalendarNote = CalendarNote;
+
+  error=NULL_SendMessageSequence
+    (20, &CurrentCalendarNoteError, 5, 0x13, req);
+
+  CurrentCalendarNote = NULL;
+
+  return error;
+}
+
+void N6110_ReplyWriteCalendarNote(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#ifdef DEBUG
+  switch(MessageBuffer[4]) {
+    /* This message is also sent when the user enters the new entry on keypad */
+    case 0x01:
+      fprintf(stdout, _("Message: Calendar note write succesfull!\n"));break;      
+    case 0x73:
+      fprintf(stdout, _("Message: Calendar note write failed!\n"));break;
+    case 0x7d:
+      fprintf(stdout, _("Message: Calendar note write failed!\n"));break;
+    default:
+      fprintf(stdout, _("Unknown message of type 0x13 and subtype 0x65\n"));break;
+  }
+#endif
+
+  switch(MessageBuffer[4]) {
+    case 0x01: CurrentCalendarNoteError=GE_NONE; break;      
+    case 0x73: CurrentCalendarNoteError=GE_INTERNALERROR; break;
+    case 0x7d: CurrentCalendarNoteError=GE_INTERNALERROR; break;
+    default  : AppendLogText("Unknown msg\n",false); break;
+  }
+}
+
+GSM_Error N6110_WriteCalendarNote(GSM_CalendarNote *CalendarNote)
+{
+
+  unsigned char req[200] = { N6110_FRAME_HEADER,
+                             0x64, 0x01, 0x10,
+                             0x00, /* Length of the rest of the frame. */
+                             0x00, /* The type of calendar note */
+                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+                        };
+
+  typedef struct {
+    char *model;
+    unsigned char call;
+    unsigned char meeting;
+    unsigned char birthday;
+    unsigned char reminder;
+  } calendar_model_length;
+  
+  /* Length of entries */
+  calendar_model_length calendar_lengths[] =
+  {
+    /*model,CallTo,Meeting,Birthday,Reminder*/
+    {"NHM-5",0x24,0x24,0x24,0x24}, //Reminder from phone, other quesses
+    {"NHM-6",0x24,0x24,0x24,0x24}, //Reminder from phone, other quesses
+    {"NSE-3",0x1e,0x14,0x14,0x1e}, //from NCDS3 [HKEY_LOCAL_MACHINE\Software\Nokia\Data Suite\3.0\Calendar]
+    {"NSM-1",0x1e,0x18,0x18,0x24}, //from NCDS3 
+    {"NSK-3",0x1e,0x14,0x14,0x1e}, //from NCDS3 
+    {"NSB-3",0x20,0x14,0x14,0x1e}, //from NCDS3
+    {"",     0,   0,   0,   0   }  //end of table
+  };
+
+  int i, j, current;
+
+  u8 mychar;
+  
+  u8 mychar1,mychar2;
+  
+  GSM_Error error;
+  
+  /* Hopefully is 64 larger as FB38_MAX* / N6110_MAX* */
+  char model[64];
+
+  req[7]=CalendarNote->Type;
+
+  EncodeDateTime(req+8, &CalendarNote->Time);
+  req[14] = CalendarNote->Time.Timezone;
+
+  if (CalendarNote->Alarm.Year) {
+    EncodeDateTime(req+15, &CalendarNote->Alarm);
+    req[21] = CalendarNote->Alarm.Timezone;
+  }
+
+  req[22]=strlen(CalendarNote->Text);
+  
+  current=23;
+
+  if (GetModelFeature (FN_CALENDAR)==F_CAL33 && CalendarNote->Type==GCN_REMINDER) {
+    req[22]++;           // one additional char
+    req[current++]=0x01; //we use now subset 1
+  }
+    
+  for (i=0; i<strlen(CalendarNote->Text); i++) {
+    j=0;
+    mychar=CalendarNote->Text[i];
+    if (GetModelFeature (FN_CALENDAR)==F_CAL33 && CalendarNote->Type==GCN_REMINDER) {
+      if (EncodeWithUTF8Alphabet(mychar,&mychar1,&mychar2)) {
+          req[current++]=mychar1;
+         req[current++]=mychar2;
+          req[23]=0x03; //use subset 3
+          req[22]++;    // one additional char
+         j=-1;
+      }
+    }
+    if (j!=-1) {
+      /* Enables/disables blinking */
+      if (mychar=='~') req[current++]=0x01;
+                  else req[current++]=mychar;
+    }
+  }
+
+  req[current++]=strlen(CalendarNote->Phone);
+
+  for (i=0; i<strlen(CalendarNote->Phone); i++)
+    req[current++]=CalendarNote->Phone[i];
+
+  while (N6110_GetModel(model)  != GE_NONE)
+    sleep(1);
+
+  /* Checking maximal length */
+  i=0;
+  while (strcmp(calendar_lengths[i].model,"")) {
+    if (!strcmp(calendar_lengths[i].model,model)) {
+      switch (CalendarNote->Type) {
+        case GCN_REMINDER:if (req[22]>calendar_lengths[i].reminder) return GE_TOOLONG;break;
+        case GCN_MEETING :if (req[22]>calendar_lengths[i].meeting)  return GE_TOOLONG;break;
+        case GCN_BIRTHDAY:if (req[22]>calendar_lengths[i].birthday) return GE_TOOLONG;break;
+        case GCN_CALL    :if (strlen(CalendarNote->Phone)>calendar_lengths[i].call) return GE_TOOLONG;break;
+      }
+      break;
+    }
+    i++;
+  }
+
+  CurrentCalendarNote = CalendarNote;
+
+  error=NULL_SendMessageSequence
+    (20, &CurrentCalendarNoteError, current, 0x13, req);
+
+  CurrentCalendarNote = NULL;
+
+  return error;
+}
+
+void N6110_ReplyDeleteCalendarNote(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#ifdef DEBUG
+  switch (MessageBuffer[4]) {
+    /* This message is also sent when the user deletes an old entry on
+       keypad or moves an old entry somewhere (there is also `write'
+       message). */
+    case 0x01:fprintf(stdout, _("Message: Calendar note deleted\n"));break;
+    case 0x93:fprintf(stdout, _("Message: Calendar note can't be deleted\n"));break;
+    default  :fprintf(stdout, _("Message: Calendar note deleting error\n"));break;
+  }
+#endif
+
+  switch (MessageBuffer[4]) {
+    case 0x01:CurrentCalendarNoteError=GE_NONE;break;
+    case 0x93:CurrentCalendarNoteError=GE_INVALIDCALNOTELOCATION;break;
+    default  :CurrentCalendarNoteError=GE_INTERNALERROR;break;
+  }
+}
+
+GSM_Error N6110_DeleteCalendarNote(GSM_CalendarNote *CalendarNote)
+{
+
+  unsigned char req[] = { N6110_FRAME_HEADER,
+                          0x68, 0x00
+                        };
+
+  req[4]=CalendarNote->Location;
+
+  return NULL_SendMessageSequence (20, &CurrentCalendarNoteError, 5, 0x13, req);
+}
+
+#endif /* UCLINUX */
+
+static void N6110_ReplyRFBatteryLevel(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Phone status received:\n"));
+    fprintf(stdout, _("   Mode: "));
+
+    switch (MessageBuffer[4]) {
+
+      case 0x01:
+
+       fprintf(stdout, _("registered within the network\n"));
+       break;
+             
+      /* I was really amazing why is there a hole in the type of 0x02, now I
+        know... */
+      case 0x02: fprintf(stdout, _("call in progress\n"));          break; /* ringing or already answered call */
+      case 0x03: fprintf(stdout, _("waiting for security code\n")); break;
+      case 0x04: fprintf(stdout, _("powered off\n"));               break;
+      default  : fprintf(stdout, _("unknown\n"));
+
+    }
+
+    fprintf(stdout, _("   Power source: "));
+
+    switch (MessageBuffer[7]) {
+
+      case 0x01: fprintf(stdout, _("AC/DC\n"));   break;
+      case 0x02: fprintf(stdout, _("battery\n")); break;
+      default  : fprintf(stdout, _("unknown\n"));
+
+    }
+
+    fprintf(stdout, _("   Battery Level: %d\n"), MessageBuffer[8]);
+    fprintf(stdout, _("   Signal strength: %d\n"), MessageBuffer[5]);
+#endif /* DEBUG */
+
+    CurrentRFLevel=MessageBuffer[5];
+    CurrentBatteryLevel=MessageBuffer[8];
+    CurrentPowerSource=MessageBuffer[7];
+}
+
+
+GSM_Error N6110_GetRFLevel(GSM_RFUnits *units, float *level)
+{
+
+  /* FIXME - these values are from 3810 code, may be incorrect.  Map from
+     values returned in status packet to the the values returned by the AT+CSQ
+     command. */
+  float        csq_map[5] = {0, 8, 16, 24, 31};
+
+  int timeout=10;
+  int rf_level;
+  
+  char screen[NM_MAX_SCREEN_WIDTH];
+
+  CurrentRFLevel=-1;
+    
+  if (GetModelFeature (FN_NOPOWERFRAME)==F_NOPOWER) {
+
+#ifndef UCLINUX
+    if (N6110_NetMonitor(1, screen)!=GE_NONE)
+      return GE_INTERNALERROR;
+#endif /* UCLINUX */
+    
+    rf_level=4;
+    
+    if (screen[4]!='-') {
+      if (screen[5]=='9' && screen[6]>'4') rf_level=1;
+      if (screen[5]=='9' && screen[6]<'5') rf_level=2;
+      if (screen[5]=='8' && screen[6]>'4') rf_level=3;      
+    } else rf_level=0;
+
+    /* Arbitrary units. */
+    if (*units == GRF_Arbitrary) {
+      *level = rf_level;
+      return (GE_NONE);
+    }
+    
+  } else {
+    N6110_SendStatusRequest();
+
+    /* Wait for timeout or other error. */
+    while (timeout != 0 && CurrentRFLevel == -1 ) {
+
+      if (--timeout == 0)
+        return (GE_TIMEOUT);
+
+      usleep (100000);
+    }
+
+    /* Make copy in case it changes. */
+    rf_level = CurrentRFLevel;
+
+    if (rf_level == -1)
+      return (GE_NOLINK);
+
+    /* Now convert between the different units we support. */
+
+    /* Arbitrary units. */
+    if (*units == GRF_Arbitrary) {
+      *level = rf_level;
+      return (GE_NONE);
+    }
+
+    /* CSQ units. */
+    if (*units == GRF_CSQ) {
+
+      if (rf_level <=4)
+        *level = csq_map[rf_level];
+      else
+        *level = 99; /* Unknown/undefined */
+
+      return (GE_NONE);
+    }
+  }
+
+  /* Unit type is one we don't handle so return error */
+  return (GE_INTERNALERROR);
+}
+
+
+GSM_Error N6110_GetBatteryLevel(GSM_BatteryUnits *units, float *level)
+{
+  int timeout=10;
+  int batt_level;
+
+  char screen[NM_MAX_SCREEN_WIDTH];
+
+  CurrentBatteryLevel=-1;
+
+  if (GetModelFeature (FN_NOPOWERFRAME)==F_NOPOWER) {
+
+#ifndef UCLINUX
+    if (N6110_NetMonitor(23, screen)!=GE_NONE)
+      return GE_NOLINK;
+#endif /* UCLINUX */
+    
+    batt_level=4;
+    
+    if (screen[29]=='7') batt_level=3;
+    if (screen[29]=='5') batt_level=2;
+    if (screen[29]=='2') batt_level=1;
+    
+    /* Only units we handle at present are GBU_Arbitrary */
+    if (*units == GBU_Arbitrary) {
+      *level = batt_level;
+      return (GE_NONE);
+    }
+
+    return (GE_INTERNALERROR);    
+    
+  } else {
+    N6110_SendStatusRequest();
+
+    /* Wait for timeout or other error. */
+    while (timeout != 0 && CurrentBatteryLevel == -1 ) {
+
+      if (--timeout == 0)
+        return (GE_TIMEOUT);
+
+      usleep (100000);
+    }
+
+    /* Take copy in case it changes. */
+    batt_level = CurrentBatteryLevel;
+
+    if (batt_level != -1) {
+
+      /* Only units we handle at present are GBU_Arbitrary */
+      if (*units == GBU_Arbitrary) {
+        *level = batt_level;
+        return (GE_NONE);
+      }
+
+      return (GE_INTERNALERROR);
+    }
+    else
+      return (GE_NOLINK);
+  }
+}
+
+GSM_Error N6110_GetPowerSource(GSM_PowerSource *source)
+{
+
+  int timeout=10;
+
+  char screen[NM_MAX_SCREEN_WIDTH];
+
+  CurrentPowerSource=-1;
+
+  if (GetModelFeature (FN_NOPOWERFRAME)==F_NOPOWER) {    
+
+#ifndef UCLINUX
+    if (N6110_NetMonitor(20, screen)!=GE_NONE)
+      return GE_NOLINK;
+#endif /* UCLINUX */
+    
+    CurrentPowerSource=GPS_ACDC;
+
+    if (screen[6]=='x') CurrentPowerSource=GPS_BATTERY;
+
+    *source=CurrentPowerSource;        
+    
+    return GE_NONE;    
+  } else {
+    N6110_SendStatusRequest();
+
+    /* Wait for timeout or other error. */
+    while (timeout != 0 && CurrentPowerSource == -1 ) {
+
+      if (--timeout == 0)
+        return (GE_TIMEOUT);
+
+      usleep (100000);
+    }
+
+    if (CurrentPowerSource != -1) {
+      *source=CurrentPowerSource;
+      return (GE_NONE);
+    }
+    else
+      return (GE_NOLINK);
+  }
+}
+
+#ifndef UCLINUX
+
+static void N6110_ReplyGetDisplayStatus(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int i;
+
+  for (i=0; i<MessageBuffer[4];i++)
+    if (MessageBuffer[2*i+6]==2)
+      CurrentDisplayStatus|=1<<(MessageBuffer[2*i+5]-1);
+    else
+      CurrentDisplayStatus&= (0xff - (1<<(MessageBuffer[2*i+5]-1)));
+
+#ifdef DEBUG
+  fprintf(stdout, _("Call in progress: %s\n"), CurrentDisplayStatus & (1<<DS_Call_In_Progress)?"on":"off");
+  fprintf(stdout, _("Unknown: %s\n"),          CurrentDisplayStatus & (1<<DS_Unknown)?"on":"off");
+  fprintf(stdout, _("Unread SMS: %s\n"),       CurrentDisplayStatus & (1<<DS_Unread_SMS)?"on":"off");
+  fprintf(stdout, _("Voice call: %s\n"),       CurrentDisplayStatus & (1<<DS_Voice_Call)?"on":"off");
+  fprintf(stdout, _("Fax call active: %s\n"),  CurrentDisplayStatus & (1<<DS_Fax_Call)?"on":"off");
+  fprintf(stdout, _("Data call active: %s\n"), CurrentDisplayStatus & (1<<DS_Data_Call)?"on":"off");
+  fprintf(stdout, _("Keyboard lock: %s\n"),    CurrentDisplayStatus & (1<<DS_Keyboard_Lock)?"on":"off");
+  fprintf(stdout, _("SMS storage full: %s\n"), CurrentDisplayStatus & (1<<DS_SMS_Storage_Full)?"on":"off");
+#endif /* DEBUG */
+
+  CurrentDisplayStatusError=GE_NONE;
+}
+
+GSM_Error N6110_GetDisplayStatus(int *Status) {
+
+  unsigned char req[4]={ N6110_FRAME_HEADER, 0x51 };
+
+  GSM_Error error;
+
+  error=NULL_SendMessageSequence
+    (10, &CurrentDisplayStatusError, 4, 0x0d, req);
+  if (error!=GE_NONE) return error;
+  
+  *Status=CurrentDisplayStatus;
+
+  return GE_NONE;
+}
+
+GSM_Error N6110_DialVoice(char *Number) {
+/* This commented sequence doesn't work on N3210/3310/6210/7110 */
+//  unsigned char req[64]={N6110_FRAME_HEADER, 0x01};
+//  unsigned char req_end[]={0x05, 0x01, 0x01, 0x05, 0x81, 0x01, 0x00, 0x00, 0x01};
+//  int i=0;
+//  req[4]=strlen(Number);
+//  for(i=0; i < strlen(Number) ; i++)
+//   req[5+i]=Number[i];
+//  memcpy(req+5+strlen(Number), req_end, 10);
+//  return NULL_SendMessageSequence
+//    (20, &CurrentDialVoiceError, 13+strlen(Number), 0x01, req);
+
+  unsigned char req[64]={0x00,0x01,0x7c,
+                         0x01}; //call command
+
+  int i=0;                      
+  
+  GSM_Error error;
+
+  error=N6110_EnableExtendedCommands(0x01);
+  if (error!=GE_NONE) return error;
+
+  for(i=0; i < strlen(Number) ; i++) req[4+i]=Number[i];
+  
+  req[4+i+1]=0;
+  
+  return NULL_SendMessageSequence
+    (20, &CurrentDialVoiceError, 4+strlen(Number)+1, 0x40, req);  
+}
+
+#endif /* UCLINUX */
+
+/* Dial a data call - type specifies request to use: 
+     type 0 should normally be used
+     type 1 should be used when calling a digital line - corresponds to ats35=0
+     Maybe one day we'll know what they mean!
+*/
+GSM_Error N6110_DialData(char *Number, char type, void (* callpassup)(char c))
+{
+       unsigned char req[100]   = { N6110_FRAME_HEADER, 0x01 };
+       unsigned char *req_end;
+       unsigned char req_end0[] = { 0x01,  /* make a data call = type 0x01 */
+                                    0x02,0x01,0x05,0x81,0x01,0x00,0x00,0x01,0x02,0x0a,
+                                    0x07,0xa2,0x88,0x81,0x21,0x15,0x63,0xa8,0x00,0x00 };
+       unsigned char req_end1[] = { 0x01,
+                                    0x02,0x01,0x05,0x81,0x01,0x00,0x00,0x01,0x02,0x0a,
+                                    0x07,0xa1,0x88,0x89,0x21,0x15,0x63,0xa0,0x00,0x06,
+                                    0x88,0x90,0x21,0x48,0x40,0xbb };
+       unsigned char req2[]     = { N6110_FRAME_HEADER, 0x42,0x05,0x01,
+                                    0x07,0xa2,0xc8,0x81,0x21,0x15,0x63,0xa8,0x00,0x00,
+                                    0x07,0xa3,0xb8,0x81,0x20,0x15,0x63,0x80,0x01,0x60 };
+       unsigned char req3[]     = { N6110_FRAME_HEADER, 0x42,0x05,0x01,
+                                    0x07,0xa2,0x88,0x81,0x21,0x15,0x63,0xa8,0x00,0x00,
+                                    0x07,0xa3,0xb8,0x81,0x20,0x15,0x63,0x80 };
+       unsigned char req4[]     = { N6110_FRAME_HEADER, 0x42,0x05,0x81,
+                                    0x07,0xa1,0x88,0x89,0x21,0x15,0x63,0xa0,0x00,0x06,
+                                    0x88,0x90,0x21,0x48,0x40,0xbb,0x07,0xa3,0xb8,0x81,
+                                    0x20,0x15,0x63,0x80 };
+
+       int i = 0;
+       u8 size;
+
+       CurrentCallPassup=callpassup;
+
+       switch (type) {
+       case 0:
+               req_end = req_end0;
+               size = sizeof(req_end0);
+               break;
+       case 1:
+               Protocol->SendMessage(sizeof(req3), 0x01, req3);
+               Protocol->SendMessage(sizeof(req4), 0x01, req4);
+               req_end = req_end1;
+               size = sizeof(req_end1);
+               break;
+       case -1:   /* Just used to set the call passup */
+               return GE_NONE;
+               break;
+       default:
+               req_end = req_end0;
+               size = sizeof(req_end0);
+               break;
+       }
+
+       req[4] = strlen(Number);
+
+       for(i = 0; i < strlen(Number) ; i++)
+               req[5+i] = Number[i];
+
+       memcpy(req + 5 + strlen(Number), req_end, size);
+
+       Protocol->SendMessage(5 + size + strlen(Number), 0x01, req);
+       if (type != 1) Protocol->SendMessage(26, 0x01, req2);
+
+       return (GE_NONE);
+}
+
+#ifndef UCLINUX
+
+GSM_Error N6110_GetIncomingCallNr(char *Number)
+{
+
+  if (*CurrentIncomingCall != ' ') {
+    strcpy(Number, CurrentIncomingCall);
+    return GE_NONE;
+  }
+  else
+    return GE_BUSY;
+}
+
+#endif /* UCLINUX */
+
+GSM_Error N6110_CancelCall(void)
+{
+//  This frame & method works only on 61xx/51xx
+//  unsigned char req[] = { N6110_FRAME_HEADER, 0x08, 0x00, 0x85};
+//  req[4]=CurrentCallSequenceNumber;
+//  Protocol->SendMessage(6, 0x01, req);
+//  return GE_NONE;
+  GSM_Error error;
+
+  unsigned char req[]={0x00,0x01,0x7c,0x03};
+    
+  /* Checking */
+  error=N6110_EnableExtendedCommands(0x01);
+  if (error!=GE_NONE) return error;
+
+  return NULL_SendMessageSequence (20, &CurrentDialVoiceError, 4, 0x40, req);   
+}  
+
+#ifndef UCLINUX
+
+void N6110_ReplyEnterSecurityCode(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+    
+  switch(MessageBuffer[3]) {
+
+  case 0x0b:
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Security code accepted.\n"));
+#endif /* DEBUG */
+    CurrentSecurityCodeError = GE_NONE;
+    break;
+
+  default:
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Security code is wrong. You're not my big owner :-)\n"));
+#endif /* DEBUG */
+    CurrentSecurityCodeError = GE_INVALIDSECURITYCODE;
+  }
+}
+
+GSM_Error N6110_EnterSecurityCode(GSM_SecurityCode SecurityCode)
+{
+
+  unsigned char req[15] = { N6110_FRAME_HEADER,
+                            0x0a, /* Enter code request. */
+                            0x00  /* Type of the entered code. */
+                            };
+  int i=0;
+
+  req[4]=SecurityCode.Type;
+
+  for (i=0; i<strlen(SecurityCode.Code);i++)
+    req[5+i]=SecurityCode.Code[i];
+
+  req[5+strlen(SecurityCode.Code)]=0x00;
+  req[6+strlen(SecurityCode.Code)]=0x00;
+
+  return NULL_SendMessageSequence
+    (20, &CurrentSecurityCodeError, 7+strlen(SecurityCode.Code), 0x08, req);
+}
+
+void N6110_ReplyGetSecurityCodeStatus(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+    
+  *CurrentSecurityCodeStatus = MessageBuffer[4];
+
+#ifdef DEBUG
+  fprintf(stdout, _("Message: Security Code status received: "));
+
+  switch(*CurrentSecurityCodeStatus) {
+
+    case GSCT_SecurityCode: fprintf(stdout, _("waiting for Security Code.\n")); break;
+    case GSCT_Pin         : fprintf(stdout, _("waiting for PIN.\n")); break;
+    case GSCT_Pin2        : fprintf(stdout, _("waiting for PIN2.\n")); break;
+    case GSCT_Puk         : fprintf(stdout, _("waiting for PUK.\n")); break;
+    case GSCT_Puk2        : fprintf(stdout, _("waiting for PUK2.\n")); break;
+    case GSCT_None        : fprintf(stdout, _("nothing to enter.\n")); break;
+    default               : fprintf(stdout, _("Unknown!\n"));
+  }
+      
+#endif /* DEBUG */
+
+  CurrentSecurityCodeError = GE_NONE;
+}
+
+GSM_Error N6110_GetSecurityCodeStatus(int *Status)
+{
+
+  unsigned char req[4] = { N6110_FRAME_HEADER,
+                           0x07
+                         };
+
+  CurrentSecurityCodeStatus=Status;
+
+  return NULL_SendMessageSequence
+    (20, &CurrentSecurityCodeError, 4, 0x08, req);
+}
+
+void N6110_ReplyGetSecurityCode(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int i;
+  
+#ifdef DEBUG
+  fprintf(stdout, _("Message: Security code received: "));
+  switch (MessageBuffer[3]) {
+    case GSCT_SecurityCode: fprintf(stdout, _("Security code"));break;
+    case GSCT_Pin:  fprintf(stdout, _("PIN"));break;
+    case GSCT_Pin2: fprintf(stdout, _("PIN2"));break;
+    case GSCT_Puk:  fprintf(stdout, _("PUK"));break;
+    case GSCT_Puk2: fprintf(stdout, _("PUK2"));break;
+    default: fprintf(stdout, _("unknown !"));break;
+  }
+  if (MessageBuffer[4]==1) {
+    fprintf(stdout, _(" allowed, value \""));
+    if (MessageBuffer[3]==GSCT_SecurityCode) {
+      for (i=0;i<5;i++) {fprintf(stdout, _("%c"), MessageBuffer[5+i]);}
+    }
+    if (MessageBuffer[3]==GSCT_Pin || MessageBuffer[3]==GSCT_Pin2 ||
+       MessageBuffer[3]==GSCT_Puk || MessageBuffer[3]==GSCT_Puk2) {
+      for (i=0;i<4;i++) {fprintf(stdout, _("%c"), MessageBuffer[5+i]);}
+    }
+    fprintf(stdout, _("\""));
+  } else {
+    fprintf(stdout, _(" not allowed"));  
+  }
+  fprintf(stdout, _("\n"));  
+#endif /* DEBUG */
+      
+  if (CurrentSecurityCode->Type==MessageBuffer[3] /* We wanted this code */
+          && MessageBuffer[4]==1) {                      /* It's allowed */
+    if (MessageBuffer[3]==GSCT_SecurityCode) {
+      for (i=0;i<5;i++) {CurrentSecurityCode->Code[i]=MessageBuffer[5+i];}
+      CurrentSecurityCode->Code[5]=0;
+    }
+    if (MessageBuffer[3]==GSCT_Pin || MessageBuffer[3]==GSCT_Pin2 ||
+       MessageBuffer[3]==GSCT_Puk || MessageBuffer[3]==GSCT_Puk2) {
+      for (i=0;i<4;i++) {CurrentSecurityCode->Code[i]=MessageBuffer[5+i];}
+      CurrentSecurityCode->Code[4]=0;
+    }
+    CurrentSecurityCodeError=GE_NONE;
+  } else
+    CurrentSecurityCodeError=GE_INVALIDSECURITYCODE;
+}
+
+GSM_Error N6110_GetSecurityCode(GSM_SecurityCode *SecurityCode)
+{
+
+  unsigned char req[4] = { 0x00,
+                           0x01,0x6e, /* Get code request. */
+                          0x00 };    /* Type of the requested code. */
+
+  GSM_Error error;
+  
+  error=N6110_EnableExtendedCommands(0x01);
+  if (error!=GE_NONE) return error;
+  
+  req[3]=SecurityCode->Type;
+
+  CurrentSecurityCode=SecurityCode;
+
+  return NULL_SendMessageSequence
+    (20, &CurrentSecurityCodeError, 4, 0x40, req);
+}
+
+void N6110_ReplyPlayTone(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#ifdef DEBUG
+  fprintf(stdout, _("Message: answer for PlayTone frame\n"));      
+#endif
+      
+  CurrentPlayToneError=GE_NONE;      
+}
+
+GSM_Error N6110_PlayTone(int Herz, u8 Volume)
+{
+  unsigned char req[6] = { 0x00,0x01,0x8f,
+                           0x00,   /* Volume */
+                          0x00,   /* HerzLo */
+                          0x00 }; /* HerzHi */
+
+  GSM_Error error;
+
+  /* PlayTone wasn't used earlier */
+  if (CurrentPlayToneError==GE_UNKNOWN) {
+    if (CurrentConnectionType!=GCT_MBUS)
+      CurrentDisableKeepAlive=true;
+
+    error=N6110_EnableExtendedCommands(0x01);
+    if (error!=GE_NONE) return error;
+  }
+
+  /* For Herz==255*255 we have silent */  
+  if (Herz!=255*255) {
+    req[3]=Volume;
+
+    req[5]=Herz%256;
+    req[4]=Herz/256;
+  } else {
+    req[3]=0;
+
+    req[5]=0;
+    req[4]=0;
+  }
+
+#ifdef WIN32
+  /* For Herz==255*255 we have silent and additionaly
+     we wait for phone answer - it's important for MBUS */
+  if (Herz==255*255) {
+    error=NULL_SendMessageSequence
+      (20, &CurrentPlayToneError, 6, 0x40, req);
+
+    CurrentPlayToneError=GE_UNKNOWN;
+    CurrentDisableKeepAlive=false;
+
+    if (error!=GE_NONE) return error;
+  } else {
+    Protocol->SendMessage(6,0x40,req);
+  }
+#else
+  error=NULL_SendMessageSequence
+    (20, &CurrentPlayToneError, 6, 0x40, req);
+
+  /* For Herz==255*255 we wait for phone answer - it's important for MBUS */
+  if (Herz==255*255) {
+    CurrentPlayToneError=GE_UNKNOWN;
+    CurrentDisableKeepAlive=false;
+  }
+  
+  if (error!=GE_NONE) return error;
+
+#endif
+    
+  return(GE_NONE);
+}
+
+void N6110_ReplyGetDateTime(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  if (MessageBuffer[4]==0x01) {
+    DecodeDateTime(MessageBuffer+8, CurrentDateTime);
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Date and time\n"));
+    fprintf(stdout, _("   Time: %02d:%02d:%02d\n"), CurrentDateTime->Hour, CurrentDateTime->Minute, CurrentDateTime->Second);
+    fprintf(stdout, _("   Date: %4d/%02d/%02d\n"), CurrentDateTime->Year, CurrentDateTime->Month, CurrentDateTime->Day);
+#endif /* DEBUG */
+
+    CurrentDateTime->IsSet=true;
+  } else {
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Date and time not set in phone\n"));
+#endif
+
+    CurrentDateTime->IsSet=false;
+  }
+      
+  CurrentDateTimeError=GE_NONE;
+}
+
+GSM_Error N6110_GetDateTime(GSM_DateTime *date_time)
+{
+  return N6110_PrivGetDateTime(date_time,0x11);
+}
+
+GSM_Error N6110_PrivGetDateTime(GSM_DateTime *date_time, int msgtype)
+{
+  unsigned char req[] = {N6110_FRAME_HEADER, 0x62};
+
+  CurrentDateTime=date_time;
+
+  return NULL_SendMessageSequence
+    (50, &CurrentDateTimeError, 4, msgtype, req);
+}
+
+void N6110_ReplyGetAlarm(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#ifdef DEBUG
+  fprintf(stdout, _("Message: Alarm\n"));
+  fprintf(stdout, _("   Alarm: %02d:%02d\n"), MessageBuffer[9], MessageBuffer[10]);
+  fprintf(stdout, _("   Alarm is %s\n"), (MessageBuffer[8]==2) ? _("on"):_("off"));
+#endif /* DEBUG */
+
+  CurrentAlarm->Hour=MessageBuffer[9];
+  CurrentAlarm->Minute=MessageBuffer[10];
+  CurrentAlarm->Second=0;
+
+  CurrentAlarm->IsSet=(MessageBuffer[8]==2);
+
+  CurrentAlarmError=GE_NONE;
+}
+
+GSM_Error N6110_GetAlarm(int alarm_number, GSM_DateTime *date_time)
+{
+  return N6110_PrivGetAlarm(alarm_number,date_time,0x11);
+}
+
+GSM_Error N6110_PrivGetAlarm(int alarm_number, GSM_DateTime *date_time, int msgtype)
+{
+  unsigned char req[] = {N6110_FRAME_HEADER, 0x6d};
+
+  CurrentAlarm=date_time;
+
+  return NULL_SendMessageSequence
+    (50, &CurrentAlarmError, 4, msgtype, req);
+}
+
+void N6110_ReplyGetSMSCenter(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+  
+  switch (MessageBuffer[3]) {
+
+  case 0x34:
+
+    CurrentMessageCenter->No=MessageBuffer[4];
+    CurrentMessageCenter->Format=MessageBuffer[6];
+    CurrentMessageCenter->Validity=MessageBuffer[8];
+    sprintf(CurrentMessageCenter->Name, "%s", MessageBuffer+33);
+
+    sprintf(CurrentMessageCenter->DefaultRecipient, "%s", GSM_UnpackSemiOctetNumber(MessageBuffer+9,false));
+
+    sprintf(CurrentMessageCenter->Number, "%s", GSM_UnpackSemiOctetNumber(MessageBuffer+21,false));
+      
+#ifdef DEBUG
+    fprintf(stdout, _("Message: SMS Center received:\n"));
+    fprintf(stdout, _("   %d. SMS Center name is %s\n"), CurrentMessageCenter->No, CurrentMessageCenter->Name);
+    fprintf(stdout, _("   SMS Center number is %s\n"), CurrentMessageCenter->Number);
+    fprintf(stdout, _("   Default recipient number is %s\n"), CurrentMessageCenter->DefaultRecipient);
+      
+    fprintf(stdout, _("   SMS Center message format is "));
+
+    switch (CurrentMessageCenter->Format) {
+
+      case GSMF_Text  : fprintf(stdout, _("Text"));   break;
+      case GSMF_Paging: fprintf(stdout, _("Paging")); break;
+      case GSMF_Fax   : fprintf(stdout, _("Fax"));    break;
+      case GSMF_Email : fprintf(stdout, _("Email"));  break;
+      default         : fprintf(stdout, _("Unknown"));
+    }
+
+    fprintf(stdout, "\n");
+
+    fprintf(stdout, _("   SMS Center message validity is "));
+
+    switch (CurrentMessageCenter->Validity) {
+
+      case GSMV_1_Hour  : fprintf(stdout, _("1 hour"));      break;
+      case GSMV_6_Hours : fprintf(stdout, _("6 hours"));     break;
+      case GSMV_24_Hours: fprintf(stdout, _("24 hours"));    break;
+      case GSMV_72_Hours: fprintf(stdout, _("72 hours"));    break;
+      case GSMV_1_Week  : fprintf(stdout, _("1 week"));      break;
+      case GSMV_Max_Time: fprintf(stdout, _("Maximum time"));break;
+      default           : fprintf(stdout, _("Unknown"));
+    }
+
+    fprintf(stdout, "\n");
+
+#endif /* DEBUG */
+
+    CurrentMessageCenterError=GE_NONE;
+
+    break;
+
+  case 0x35:
+
+    /* Number of entries depends on SIM card */
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: SMS Center error received:\n"));
+    fprintf(stdout, _("   The request for SMS Center failed.\n"));
+#endif /* DEBUG */
+
+    /* FIXME: appropriate error. */
+    CurrentMessageCenterError=GE_INTERNALERROR;
+
+    break;  
+
+  }
+}
+
+/* This function sends to the mobile phone a request for the SMS Center */
+GSM_Error N6110_GetSMSCenter(GSM_MessageCenter *MessageCenter)
+{
+  unsigned char req[] = { N6110_FRAME_HEADER, 0x33, 0x64,
+                          0x00 /* SMS Center Number. */
+                        };
+
+  req[5]=MessageCenter->No;
+
+  CurrentMessageCenter=MessageCenter;
+
+  return NULL_SendMessageSequence
+    (50, &CurrentMessageCenterError, 6, 0x02, req);
+}
+
+void N6110_ReplySetSMSCenter(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#ifdef DEBUG
+  fprintf(stdout, _("Message: SMS Center correctly set.\n"));
+#endif
+  CurrentMessageCenterError=GE_NONE;
+}
+
+/* This function set the SMS Center profile on the phone. */
+GSM_Error N6110_SetSMSCenter(GSM_MessageCenter *MessageCenter)
+{
+  unsigned char req[64] = { N6110_FRAME_HEADER, 0x30, 0x64,
+                            0x00, /* SMS Center Number. */
+                            0x00, /* Unknown. */
+                            0x00, /* SMS Message Format. */
+                            0x00, /* Unknown. */
+                            0x00, /* Validity. */
+                            0,0,0,0,0,0,0,0,0,0,0,0, /* Default recipient number */
+                            0,0,0,0,0,0,0,0,0,0,0,0 /* Message Center Number. */
+                            /* Message Center Name. */
+                          };
+
+  req[5]=MessageCenter->No;
+  req[7]=MessageCenter->Format;
+  req[9]=MessageCenter->Validity;
+
+  req[10]=GSM_PackSemiOctetNumber(MessageCenter->DefaultRecipient, req+11, false);
+
+  req[22]=GSM_PackSemiOctetNumber(MessageCenter->Number, req+23, false);
+
+  sprintf(req+34, "%s", MessageCenter->Name);
+
+  CurrentMessageCenter=MessageCenter;
+
+  return NULL_SendMessageSequence
+    (50, &CurrentMessageCenterError, 35+strlen(MessageCenter->Name), 0x02, req);
+}
+
+void N6110_ReplyGetSMSStatus(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch (MessageBuffer[3]) {
+
+  case 0x37:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: SMS Status Received\n"));
+    fprintf(stdout, _("   The number of messages: %d\n"), MessageBuffer[10]);
+    fprintf(stdout, _("   Unread messages: %d\n"), MessageBuffer[11]);
+#endif /* DEBUG */
+
+    CurrentSMSStatus->UnRead = MessageBuffer[11];
+    CurrentSMSStatus->Number = MessageBuffer[10];
+    
+    CurrentSMSStatusError = GE_NONE;
+    break;
+
+  case 0x38:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: SMS Status error, probably not authorized by PIN\n"));
+#endif /* DEBUG */
+
+    CurrentSMSStatusError = GE_INTERNALERROR;
+    break;
+         
+  }
+}
+
+GSM_Error N6110_GetSMSStatus(GSM_SMSStatus *Status)
+{
+  unsigned char req[] = {N6110_FRAME_HEADER, 0x36, 0x64};
+
+  CurrentSMSStatus = Status;
+
+  return NULL_SendMessageSequence
+    (10, &CurrentSMSStatusError, 5, 0x14, req);
+}
+
+GSM_Error N6110_GetSMSFolders ( GSM_SMSFolders *folders)
+{
+  folders->number=2;
+
+  strcpy(folders->Folder[0].Name,"Inbox");
+  strcpy(folders->Folder[1].Name,"Outbox");
+  
+  return GE_NONE;
+}
+
+GSM_Error N6110_GetIMEI(char *imei)
+{
+  if (strlen(Current_IMEI)>0) {
+    strncpy (imei, Current_IMEI, GSM_MAX_IMEI_LENGTH);
+    return (GE_NONE);
+  }
+  else
+    return (GE_TRYAGAIN);
+}
+
+GSM_Error N6110_GetRevision(char *revision)
+{
+
+  if (strlen(Current_Revision)>0) {
+    strncpy (revision, Current_Revision, GSM_MAX_REVISION_LENGTH);
+    return (GE_NONE);
+  }
+  else
+    return (GE_TRYAGAIN);
+}
+
+#endif /* UCLINUX */
+
+static GSM_Error N6110_GetModel(char *model)
+{
+  if (strlen(Current_Model)>0) {
+    strncpy (model, Current_Model, GSM_MAX_MODEL_LENGTH);
+    return (GE_NONE);
+  }
+  else
+    return (GE_TRYAGAIN);
+}
+
+#ifndef UCLINUX
+
+void N6110_ReplySetDateTime(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch (MessageBuffer[4]) {
+
+    case 0x01:
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Date and time set correctly\n"));
+#endif /* DEBUG */
+      CurrentSetDateTimeError=GE_NONE;
+      break;
+      
+    default:
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Date and time setting error\n"));
+#endif /* DEBUG */
+      CurrentSetDateTimeError=GE_INVALIDDATETIME;
+
+  }
+}
+
+/* Needs SIM card with PIN in phone */
+GSM_Error N6110_SetDateTime(GSM_DateTime *date_time)
+{
+  return N6110_PrivSetDateTime(date_time,0x11);
+}
+
+/* Needs SIM card with PIN in phone */
+GSM_Error N6110_PrivSetDateTime(GSM_DateTime *date_time, int msgtype)
+{
+
+  unsigned char req[] = { N6110_FRAME_HEADER,
+                         0x60, /* set-time subtype */
+                         0x01, 0x01, 0x07, /* unknown */
+                         0x00, 0x00, /* Year (0x07cf = 1999) */
+                         0x00, 0x00, /* Month Day */
+                         0x00, 0x00, /* Hours Minutes */
+                         0x00 /* Unknown, but not seconds - try 59 and wait 1 sec. */
+                       };
+
+  EncodeDateTime(req+7, date_time);
+
+  return NULL_SendMessageSequence
+    (20, &CurrentSetDateTimeError, 14, msgtype, req);
+}
+
+void N6110_ReplySetAlarm(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch (MessageBuffer[4]) {
+
+    case 0x01:
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Alarm set correctly\n"));
+#endif /* DEBUG */
+      CurrentSetAlarmError=GE_NONE;
+      break;
+      
+    default:
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Alarm setting error\n"));
+#endif /* DEBUG */
+      CurrentSetAlarmError=GE_INVALIDDATETIME;
+
+  }
+}
+
+/* FIXME: we should also allow to set the alarm off :-) */
+GSM_Error N6110_SetAlarm(int alarm_number, GSM_DateTime *date_time)
+{
+  return N6110_PrivSetAlarm(alarm_number,date_time, 0x11);
+}
+
+/* FIXME: we should also allow to set the alarm off :-) */
+GSM_Error N6110_PrivSetAlarm(int alarm_number, GSM_DateTime *date_time, int msgtype)
+{
+
+  unsigned char req[] = { N6110_FRAME_HEADER,
+                         0x6b, /* set-alarm subtype */
+                         0x01, 0x20, 0x03, /* unknown */
+                         0x02,       /* should be alarm on/off, but it don't works */
+                         0x00, 0x00, /* Hours Minutes */
+                         0x00 /* Unknown, but not seconds - try 59 and wait 1 sec. */
+                       };
+
+  req[8] = date_time->Hour;
+  req[9] = date_time->Minute;
+
+  return NULL_SendMessageSequence
+    (50, &CurrentSetAlarmError, 11, msgtype, req);
+}
+
+#endif /* UCLINUX */
+
+static void N6110_ReplyGetMemoryLocation(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  /* Hopefully is 64 larger as FB38_MAX* / N6110_MAX* */
+  char model[64];
+
+  int i, tmp, count;
+    
+  switch (MessageBuffer[3]) {
+
+  case 0x02:
+
+    CurrentPhonebookEntry->Empty = true;
+
+    count=MessageBuffer[5];
+         
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Phonebook entry received:\n"));
+    fprintf(stdout, _("   Name: "));
+
+    for (tmp=0; tmp <count; tmp++)
+    {
+      if (MessageBuffer[6+tmp]==1) fprintf(stdout, "%c", '~'); else //enables/disables blinking
+      if (MessageBuffer[6+tmp]==0) fprintf(stdout, "%c", '`'); else //hides rest ot contents
+      fprintf(stdout, "%c", MessageBuffer[6+tmp]);
+    }
+
+    fprintf(stdout, "\n");
+#endif /* DEBUG */
+
+    while (N6110_GetModel(model)  != GE_NONE)
+      sleep(1);
+        
+    if (GetModelFeature (FN_PHONEBOOK)==F_PBK33) {//pbk with Unicode
+      DecodeUnicode (CurrentPhonebookEntry->Name, MessageBuffer+6, count/2);
+      CurrentPhonebookEntry->Name[count/2] = 0x00;
+    } else {
+      memcpy(CurrentPhonebookEntry->Name, MessageBuffer + 6, count);
+      CurrentPhonebookEntry->Name[count] = 0x00;
+    }
+
+    CurrentPhonebookEntry->Empty = false;
+
+    for (tmp=0; tmp <count; tmp++)
+    {
+      if (GetModelFeature (FN_PHONEBOOK)==F_PBK33) {//pbk with Unicode
+        /* We check only 1'st, 3'rd, ... char */
+        if (tmp%2!=0 && MessageBuffer[6+tmp]==1) CurrentPhonebookEntry->Name[tmp/2]='~'; //enables/disables blinking
+        if (tmp%2!=0 && MessageBuffer[6+tmp]==0) CurrentPhonebookEntry->Name[tmp/2]='`'; //hides rest ot contents
+      } else {
+        if (MessageBuffer[6+tmp]==1) CurrentPhonebookEntry->Name[tmp]='~'; //enables/disables blinking
+        if (MessageBuffer[6+tmp]==0) CurrentPhonebookEntry->Name[tmp]='`'; //hides rest ot contents
+      }
+    }
+
+    i=7+count;
+    count=MessageBuffer[6+count];
+
+#ifdef DEBUG
+    fprintf(stdout, _("   Number: "));
+
+    for (tmp=0; tmp <count; tmp++)
+      fprintf(stdout, "%c", MessageBuffer[i+tmp]);
+
+    fprintf(stdout, "\n");
+#endif /* DEBUG */
+
+    memcpy(CurrentPhonebookEntry->Number, MessageBuffer + i, count);
+    CurrentPhonebookEntry->Number[count] = 0x00;
+    CurrentPhonebookEntry->Group = MessageBuffer[i+count];
+      
+    /* Phone doesn't have entended phonebook */
+    CurrentPhonebookEntry->SubEntriesCount = 0;
+
+    /* But for these memories data is saved and we can save it using 7110/6210 style */
+    if (CurrentPhonebookEntry->MemoryType==GMT_DC ||
+        CurrentPhonebookEntry->MemoryType==GMT_RC ||
+        CurrentPhonebookEntry->MemoryType==GMT_MC) {
+        CurrentPhonebookEntry->SubEntriesCount = 1;
+        CurrentPhonebookEntry->SubEntries[0].EntryType=N7110_ENTRYTYPE_DATE;
+        CurrentPhonebookEntry->SubEntries[0].NumberType=0;
+        CurrentPhonebookEntry->SubEntries[0].BlockNumber=1;
+        DecodeDateTime(MessageBuffer+(i+count+2),&CurrentPhonebookEntry->SubEntries[0].data.Date);
+
+#ifdef DEBUG
+      fprintf(stdout, _("   Date: "));
+      fprintf(stdout, "%02u.%02u.%04u\n",
+          CurrentPhonebookEntry->SubEntries[0].data.Date.Day,
+          CurrentPhonebookEntry->SubEntries[0].data.Date.Month,
+          CurrentPhonebookEntry->SubEntries[0].data.Date.Year);
+      fprintf(stdout, _("   Time: "));
+      fprintf(stdout, "%02u:%02u:%02u\n",
+          CurrentPhonebookEntry->SubEntries[0].data.Date.Hour,
+          CurrentPhonebookEntry->SubEntries[0].data.Date.Minute,
+          CurrentPhonebookEntry->SubEntries[0].data.Date.Second);
+#endif /* DEBUG */
+
+      /* These values are set, when date and time unavailable in phone.
+         Values from 3310 - in other can be different */
+      if (CurrentPhonebookEntry->SubEntries[0].data.Date.Day==20 &&
+          CurrentPhonebookEntry->SubEntries[0].data.Date.Month==1 &&
+          CurrentPhonebookEntry->SubEntries[0].data.Date.Year==2118 &&
+          CurrentPhonebookEntry->SubEntries[0].data.Date.Hour==3 &&
+         CurrentPhonebookEntry->SubEntries[0].data.Date.Minute==14 &&
+         CurrentPhonebookEntry->SubEntries[0].data.Date.Second==7)
+          CurrentPhonebookEntry->SubEntriesCount = 0;
+    }
+
+    /* Signal no error to calling code. */
+    CurrentPhonebookError = GE_NONE;
+
+    break;
+
+  case 0x03:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Phonebook read entry error received:\n"));
+#endif /* DEBUG */
+
+    switch (MessageBuffer[4]) {
+
+      case 0x7d:
+#ifdef DEBUG
+       fprintf(stdout, _("   Invalid memory type!\n"));
+#endif /* DEBUG */
+       CurrentPhonebookError = GE_INVALIDMEMORYTYPE;
+       break;
+
+      default:
+#ifdef DEBUG
+       fprintf(stdout, _("   Unknown error!\n"));
+#endif /* DEBUG */
+       CurrentPhonebookError = GE_INTERNALERROR;
+    }
+
+    break;
+
+  }
+}
+
+/* Routine to get specifed phone book location.  Designed to be called by
+   application.  Will block until location is retrieved or a timeout/error
+   occurs. */
+GSM_Error N6110_GetMemoryLocation(GSM_PhonebookEntry *entry)
+{
+  unsigned char req[] = {N6110_FRAME_HEADER, 0x01, 0x00, 0x00, 0x00};
+
+  CurrentPhonebookEntry = entry;
+
+  req[4] = N6110_GetMemoryType(entry->MemoryType);
+  req[5] = entry->Location;
+
+  return NULL_SendMessageSequence
+    (50, &CurrentPhonebookError, 7, 0x03, req);
+}
+
+static void N6110_ReplyWritePhonebookLocation(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch (MessageBuffer[3]) {
+
+  case 0x05:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Phonebook written correctly.\n"));
+#endif /* DEBUG */
+    CurrentPhonebookError = GE_NONE;
+    break;
+
+  case 0x06:
+
+    switch (MessageBuffer[4]) {
+      /* FIXME: other errors? When I send the phonebook with index of 350 it
+         still report error 0x7d :-( */
+      case 0x7d:
+#ifdef DEBUG
+        fprintf(stdout, _("Message: Phonebook not written - name is too long.\n"));
+#endif /* DEBUG */
+       CurrentPhonebookError = GE_PHBOOKNAMETOOLONG;
+       break;
+
+      default:
+#ifdef DEBUG
+       fprintf(stdout, _("   Unknown error!\n"));
+#endif /* DEBUG */
+       CurrentPhonebookError = GE_INTERNALERROR;
+    }
+  }
+}
+
+/* Routine to write phonebook location in phone. Designed to be called by
+   application code. Will block until location is written or timeout
+   occurs. */
+GSM_Error N6110_WritePhonebookLocation(GSM_PhonebookEntry *entry)
+{
+  unsigned char req[128] = { N6110_FRAME_HEADER, 0x04, 0x00, 0x00 };
+  int i=0, current=0;
+
+  req[4] = N6110_GetMemoryType(entry->MemoryType);
+  req[5] = entry->Location;
+
+  current=7;
+
+  if (GetModelFeature (FN_PHONEBOOK)==F_PBK33) {
+
+     req[6] = strlen(entry->Name)*2;
+
+     EncodeUnicode (req+current,entry->Name ,strlen(entry->Name));
+     
+     for (i=0; i<strlen(entry->Name); i++)
+     {
+       /* here we encode "special" chars */
+       if (entry->Name[i]=='~') req[current+i*2]=1; //enables/disables blinking
+       if (entry->Name[i]=='`') req[current+i*2]=0; //hides rest ot contents
+     }
+
+     current+=strlen(entry->Name)*2;
+  } else {
+
+    req[6] = strlen(entry->Name);
+
+    for (i=0; i<strlen(entry->Name); i++)
+    {
+      req[current+i] = entry->Name[i];
+
+      /* here we encode "special" chars */
+      if (entry->Name[i]=='~') req[current+i]=1; //enables/disables blinking
+      if (entry->Name[i]=='`') req[current+i]=0; //hides rest ot contents
+    }
+
+    current+=strlen(entry->Name);
+  }
+
+  req[current++]=strlen(entry->Number);
+
+  for (i=0; i<strlen(entry->Number); i++)
+    req[current+i] = entry->Number[i];
+
+  current+=strlen(entry->Number);
+
+  /* Jano: This allow to save 14 characters name into SIM memory, when
+     No Group is selected. */
+  if (entry->Group == 5)
+    req[current++]=0xff;
+  else
+    req[current++]=entry->Group;
+
+  return NULL_SendMessageSequence
+    (50, &CurrentPhonebookError, current, 0x03, req);
+}
+
+#ifndef UCLINUX
+
+void N6110_ReplyNetmonitor(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch(MessageBuffer[3]) {
+
+    case 0x00:
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Netmonitor correctly set.\n"));
+#endif /* DEBUG */
+      CurrentNetmonitorError=GE_NONE;  
+      break;
+      
+    default:
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Netmonitor menu %d received:\n"), MessageBuffer[3]);
+      fprintf(stdout, "%s\n", MessageBuffer+4);
+#endif /* DEBUG */
+
+      strcpy(CurrentNetmonitor, MessageBuffer+4);
+
+      CurrentNetmonitorError=GE_NONE;  
+  }
+}
+
+GSM_Error N6110_NetMonitor(unsigned char mode, char *Screen)
+{
+  unsigned char req[] = { 0x00, 0x01, 0x7e, 0x00 };
+  
+  GSM_Error error;
+  
+  error=N6110_EnableExtendedCommands(0x01);
+  if (error!=GE_NONE) return error;
+
+  CurrentNetmonitor=Screen;
+
+  req[3]=mode;
+
+  return NULL_SendMessageSequence
+    (20, &CurrentNetmonitorError, 4, 0x40, req);
+}
+
+/* Doesn't work in N3210. */
+/* In other allow to access phone menu without SIM card (just send any sequence) */
+GSM_Error N6110_SendDTMF(char *String)
+{
+  unsigned char req[64] = { N6110_FRAME_HEADER, 0x50,
+                            0x00 /* Length of DTMF string. */
+                          };
+                         
+  u8 length=strlen(String);
+
+  if (length>59) length=59;
+  
+  req[4] = length;
+  
+  memcpy(req+5,String,length);
+
+  return NULL_SendMessageSequence
+    (20, &CurrentSendDTMFError, 5+length, 0x01, req);
+}
+
+void N6110_ReplyGetSpeedDial(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch (MessageBuffer[3]) {
+
+  case 0x17:
+
+    switch (MessageBuffer[4]) {
+      case 0x02: CurrentSpeedDialEntry->MemoryType = GMT_ME;
+      default  : CurrentSpeedDialEntry->MemoryType = GMT_SM;
+    }
+      
+    CurrentSpeedDialEntry->Location = MessageBuffer[5];
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Speed dial entry received:\n"));
+    fprintf(stdout, _("   Location: %d\n"), CurrentSpeedDialEntry->Location);
+    fprintf(stdout, _("   MemoryType: %s\n"), N6110_MemoryType_String[CurrentSpeedDialEntry->MemoryType]);
+    fprintf(stdout, _("   Number: %d\n"), CurrentSpeedDialEntry->Number);
+#endif /* DEBUG */
+
+    CurrentSpeedDialError=GE_NONE;
+    break;
+
+  case 0x18:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Speed dial entry error\n"));
+#endif /* DEBUG */
+    CurrentSpeedDialError=GE_INVALIDSPEEDDIALLOCATION;
+    break;
+
+  }
+}
+
+GSM_Error N6110_GetSpeedDial(GSM_SpeedDial *entry)
+{
+
+  unsigned char req[] = { N6110_FRAME_HEADER,
+                          0x16,
+                          0x00  /* The number of speed dial. */
+                        };
+
+  CurrentSpeedDialEntry = entry;
+
+  req[4] = entry->Number;
+
+  return NULL_SendMessageSequence
+    (20, &CurrentSpeedDialError, 5, 0x03, req);
+}
+
+void N6110_ReplySetSpeedDial(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch (MessageBuffer[3]) {
+
+  case 0x1a:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Speed dial entry set.\n"));
+#endif /* DEBUG */
+    CurrentSpeedDialError=GE_NONE;
+    break;
+
+  case 0x1b:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Speed dial entry setting error.\n"));
+#endif /* DEBUG */
+    CurrentSpeedDialError=GE_INVALIDSPEEDDIALLOCATION;
+    break;
+
+  }
+}
+
+GSM_Error N6110_SetSpeedDial(GSM_SpeedDial *entry)
+{
+
+  unsigned char req[] = { N6110_FRAME_HEADER,
+                          0x19,
+                          0x00, /* Number */
+                          0x00, /* Memory Type */
+                          0x00  /* Location */
+                        };
+
+  req[4] = entry->Number;
+
+  switch (entry->MemoryType) {
+    case GMT_ME: req[5] = 0x02;
+    default    : req[5] = 0x03;
+  }
+
+  req[6] = entry->Location;
+
+  return NULL_SendMessageSequence
+    (20, &CurrentSpeedDialError, 7, 0x03, req);
+}
+
+/* This function finds parts of SMS in frame used in new Nokia phones
+   in internal protocols (they're coded according to GSM 03.40), copies them
+   to GSM_ETSISMSMessage and calls GSM_DecodeETSISMS to decode
+   GSM_ETSISMSMessage to GSM_SMSMessage structure */
+GSM_Error GSM_DecodeNokiaSMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int length)
+{
+  SMS_MessageType PDU=SMS_Deliver;
+  GSM_ETSISMSMessage ETSI;
+  int offset=0,i;
+
+  ETSI.firstbyte=req[12];
+
+  /* See GSM 03.40 section 9.2.3.1 */
+  if ((ETSI.firstbyte & 0x03) == 0x01) PDU=SMS_Submit;
+  if ((ETSI.firstbyte & 0x03) == 0x02) PDU=SMS_Status_Report;
+
+  switch (PDU) {
+    case SMS_Submit       : offset=5;break;
+    case SMS_Deliver      : offset=4;break;
+    case SMS_Status_Report: offset=3;break;
+    default:                break;
+  }
+
+  for (i=0;i<req[0]+1;i++)
+    ETSI.SMSCNumber[i]=req[i];
+
+  for (i=0;i<((req[12+offset]+1)/2+1)+1;i++)
+    ETSI.Number[i]=req[i+12+offset];
+
+  switch (PDU) {
+    case SMS_Submit:
+      ETSI.TPDCS=req[10+offset];
+      ETSI.TPUDL=req[11+offset];
+      ETSI.TPVP=0;  //no support for now
+      ETSI.TPPID=0; //no support for now
+      for(i=31+offset;i<length;i++)
+        ETSI.MessageText[i-31-offset]=req[i];
+      break;
+    case SMS_Deliver:
+      ETSI.TPDCS=req[10+offset];
+      ETSI.TPUDL=req[11+offset];
+      ETSI.TPPID=0; //no support for now
+      for(i=31+offset;i<length;i++)
+        ETSI.MessageText[i-31-offset]=req[i];
+      for(i=0;i<7;i++)
+        ETSI.DeliveryDateTime[i]=req[i+24+offset];
+      break;
+    case SMS_Status_Report:
+      for(i=0;i<7;i++)
+        ETSI.DeliveryDateTime[i]=req[i+24+offset];
+      ETSI.TPStatus=req[14];
+      for(i=0;i<7;i++)
+        ETSI.SMSCDateTime[i]=req[i+34];
+      break;
+    default:
+      break;
+  }
+
+  GSM_DecodeETSISMS(SMS, &ETSI);
+
+  SMS->Name[0]=0;
+
+  return GE_NONE;
+}
+
+void N6110_ReplyGetSMSMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int offset;
+  
+  switch (MessageBuffer[3]) {
+
+  case 0x08:
+
+    switch (MessageBuffer[7]) {
+
+      case 0x00:
+       CurrentSMSMessage->Type = GST_SMS;
+        CurrentSMSMessage->folder=GST_INBOX;
+       offset=4;
+        break;
+
+      case 0x01:
+        CurrentSMSMessage->Type = GST_DR;
+       CurrentSMSMessage->folder=GST_INBOX;
+       offset=3;
+        break;
+
+      case 0x02:
+       CurrentSMSMessage->Type = GST_SMS;
+       CurrentSMSMessage->folder=GST_OUTBOX;
+       offset=5;
+        break;
+
+      default:
+        CurrentSMSMessage->Type = GST_UN;
+       offset=4;
+        break;
+
+    }
+
+    /* Field Short Message Status - MessageBuffer[4] seems not to be
+       compliant with GSM 07.05 spec.
+       Meaning     Nokia protocol      GMS spec
+       ----------------------------------------------------
+       MO Sent     0x05                        0x07 or 0x01
+       MO Not sent 0x07                        0x06 or 0x00
+       MT Read    0x01                 0x05 or 0x01
+       MT Not read 0x03                        0x04 or 0x00
+       ----------------------------------------------------
+       See GSM 07.05 section 2.5.2.6 and correct me if I'm wrong.
+       
+                                        Pawel Kot */
+
+    if (MessageBuffer[4] & 0x02) CurrentSMSMessage->Status = GSS_NOTSENTREAD;
+                            else CurrentSMSMessage->Status = GSS_SENTREAD;
+
+#ifdef DEBUG
+    fprintf(stdout, _("Number: %d\n"), MessageBuffer[6]);
+
+    if (CurrentSMSMessage->folder!=1) { //GST_OUTBOX
+      fprintf(stdout, _("Message: Received SMS (mobile terminated)\n"));
+    } else {
+      fprintf(stdout, _("Message: Outbox message (mobile originated)\n"));
+    }
+
+    if (CurrentSMSMessage->Type == GST_DR) fprintf(stdout, _("   Delivery Report\n"));
+    if (CurrentSMSMessage->Type == GST_UN) fprintf(stdout, _("   Unknown type\n"));
+
+    if (CurrentSMSMessage->folder==1) { //GST_OUTBOX
+      if (CurrentSMSMessage->Status) fprintf(stdout, _("   Sent\n"));
+                                else fprintf(stdout, _("   Not sent\n"));
+    } else {
+      if (CurrentSMSMessage->Status) fprintf(stdout, _("   Read\n"));
+                                else fprintf(stdout, _("   Not read\n"));
+    }
+#endif
+
+    CurrentSMSPointer=GSM_DecodeNokiaSMSFrame(CurrentSMSMessage, MessageBuffer+8, MessageLength-8);
+
+    CurrentSMSMessage->MemoryType = MessageBuffer[5];
+    CurrentSMSMessage->MessageNumber = MessageBuffer[6];
+    /* Signal no error to calling code. */
+    CurrentSMSMessageError = GE_NONE;
+
+#ifdef DEBUG
+    fprintf(stdout, "\n");
+#endif
+
+    break;
+
+  case 0x09:
+
+    /* We have requested invalid or empty location. */
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: SMS reading failed\n"));
+
+    switch (MessageBuffer[4]) {
+      case 0x02:
+        fprintf(stdout, _("   Invalid location!\n"));break;
+      case 0x07:
+       fprintf(stdout, _("   Empty SMS location.\n"));break;
+      case 0x0c:
+       fprintf(stdout, _("   No access to memory (no PIN on card ?)\n"));break;
+      default:      
+        fprintf(stdout, _("   Error code %i - please report it \n"),MessageBuffer[4]);break;
+    }
+#endif /* DEBUG */
+
+    switch (MessageBuffer[4]) {
+      case 0x02:CurrentSMSMessageError = GE_INVALIDSMSLOCATION;break;
+      case 0x07:CurrentSMSMessageError = GE_EMPTYSMSLOCATION;break;
+      case 0x0c:CurrentSMSMessageError = GE_NOACCESS;break;
+      default  :CurrentSMSMessageError = GE_UNKNOWN;break;
+    }
+
+    break;
+
+  }
+}
+
+GSM_Error N6110_GetSMSMessage(GSM_SMSMessage *message)
+{
+
+  unsigned char req[] = { N6110_FRAME_HEADER,
+                          0x07,
+                          0x02, /* Unknown */
+                          0x00, /* Location */
+                          0x01, 0x64};
+
+  int timeout = 60;
+
+  /* State machine code writes data to these variables when it comes in. */
+
+  CurrentSMSMessage = message;
+  CurrentSMSMessageError = GE_BUSY;
+
+  req[5] = message->Location;
+
+  /* Send request */
+  Protocol->SendMessage(8, 0x02, req);
+
+  /* Wait for timeout or other error. */
+  while (timeout != 0 && (CurrentSMSMessageError == GE_BUSY || CurrentSMSMessageError == GE_SMSWAITING)) {
+
+    if (--timeout == 0)
+      return (GE_TIMEOUT);
+
+    usleep (100000);
+  }
+
+  return (CurrentSMSMessageError);
+}
+
+void N6110_ReplyDeleteSMSMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#ifdef DEBUG
+  fprintf(stdout, _("Message: SMS deleted successfully.\n"));
+#endif /* DEBUG */
+
+  CurrentSMSMessageError = GE_NONE;    
+}
+
+GSM_Error N6110_DeleteSMSMessage(GSM_SMSMessage *message)
+{
+  unsigned char req[] = {N6110_FRAME_HEADER, 0x0a, 0x02, 0x00};
+
+  req[5] = message->Location;
+
+  return NULL_SendMessageSequence
+    (50, &CurrentSMSMessageError, 6, 0x14, req);
+}
+
+/* FIXME: do we need more than SMS_Submit and SMS_Deliver ? */
+GSM_Error GSM_EncodeNokiaSMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int *length, SMS_MessageType PDU)
+{
+  GSM_ETSISMSMessage ETSI;
+  int i,offset=0;
+
+  GSM_EncodeETSISMS(SMS, &ETSI, PDU, length);
+
+  /* Cleaning */
+  for (i=0;i<36;i++) req[i]=0;
+
+  req[12]=ETSI.firstbyte;
+
+  for (i=0;i<ETSI.SMSCNumber[0]+1;i++)
+    req[i]=ETSI.SMSCNumber[i];
+
+  switch (PDU) {
+    case SMS_Submit:
+      offset=5;
+      for (i=0;i<((ETSI.Number[0]+1)/2+1)+1;i++)
+        req[i+12+offset]=ETSI.Number[i];
+      req[10+offset]=ETSI.TPDCS;
+      req[11+offset]=ETSI.TPUDL;
+      req[24+offset]=ETSI.TPVP;
+#ifdef DEBUG
+//      fprintf(stdout,_("   First byte: %02x\n"),ETSI.firstbyte);
+//      fprintf(stdout,_("   TP-VP: %02x\n"),ETSI.TPVP);
+//      fprintf(stdout,_("   TP-DCS: %02x\n"),ETSI.TPDCS);
+#endif
+//    req[]=ETSI.TPPID;
+      for(i=0;i<*length;i++)
+        req[i+31+offset]=ETSI.MessageText[i];
+      break;
+
+    case SMS_Deliver:
+      offset=4;
+      for (i=0;i<((ETSI.Number[0]+1)/2+1)+1;i++)
+        req[i+12+offset]=ETSI.Number[i];
+      req[10+offset]=ETSI.TPDCS;
+      req[11+offset]=ETSI.TPUDL;
+//    req[]=ETSI.TPPID;
+      for(i=0;i<*length;i++)
+        req[i+31+offset]=ETSI.MessageText[i];
+      for (i=0;i<7;i++)
+        req[24+offset+i]=ETSI.DeliveryDateTime[i];
+      break;
+    default:
+      break;
+  }
+  
+  *length=*length+offset;
+  
+  return GE_NONE;
+}
+
+void N6110_ReplySendSMSMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+    
+  switch (MessageBuffer[3]) {
+
+  /* SMS message correctly sent to the network */
+  case 0x02:
+#ifdef DEBUG
+    fprintf(stdout, _("Message: SMS Message correctly sent.\n"));
+#endif /* DEBUG */
+    CurrentSMSMessageError = GE_SMSSENDOK;
+    break;
+
+  /* SMS message send to the network failed */
+  case 0x03:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Sending SMS Message failed, error: %i"),MessageBuffer[6]);
+      
+    switch (MessageBuffer[6]) {
+      case 1: fprintf(stdout,_(" (info \"Number not in use\")"));break;
+      case 21: fprintf(stdout,_(" (info \"Message not sent this time\")"));break;
+      case 28: fprintf(stdout,_(" (info \"Number not in use\")"));break;
+      case 38: fprintf(stdout,_(" (info \"Message not sent this time\")"));break;       case 50: fprintf(stdout,_(" (info \"Check operator services\")"));break;       
+      case 96: fprintf(stdout,_(" (info \"Message sending failed\")"));break;  
+      case 111: fprintf(stdout,_(" (info \"Message sending failed\")"));break; 
+      case 166: fprintf(stdout,_(" (info \"Message sending failed\")"));break; 
+      case 178: fprintf(stdout,_(" (info \"Message sending failed\")"));break; 
+      case 252: fprintf(stdout,_(" (info \"Message sending failed\")"));break;        case 253: fprintf(stdout,_(" (info \"Message sending failed\")"));break; 
+    }
+
+    fprintf(stdout,_("\n   For more details with errors see netmonitor manual (test 65) on www.marcin-wiacek.topnet.pl"));
+    fprintf(stdout,_("\n   If know their meaning, GSM specs decribing them, contact with me on marcin-wiacek@topnet.pl. THX\n"));
+#endif /* DEBUG */
+
+    CurrentSMSMessageError = GE_SMSSENDFAILED;
+    break;
+
+  }
+}
+
+GSM_Error N6110_SendSMSMessage(GSM_SMSMessage *SMS)
+{
+  GSM_Error error;
+
+  unsigned char req[256] = {
+    N6110_FRAME_HEADER,
+    0x01, 0x02, 0x00, /* SMS send request*/
+  };
+
+  int length;
+
+  error=GSM_EncodeNokiaSMSFrame(SMS, req+6, &length, SMS_Submit);    
+  if (error != GE_NONE) return error;
+
+  return NULL_SendMessageSequence
+    (200, &CurrentSMSMessageError, 42+length, 0x02, req);
+}
+
+void N6110_ReplySaveSMSMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch (MessageBuffer[3]) {
+
+  case 0x05:
+      
+#ifdef DEBUG
+    fprintf(stdout, _("SMS Message stored at %d\n"), MessageBuffer[5]);
+#endif
+      
+    CurrentSMSMessage->MessageNumber=MessageBuffer[5];
+      
+    CurrentSMSMessageError = GE_NONE;
+    break;
+
+  case 0x06:
+#ifdef DEBUG
+    fprintf(stdout, _("SMS saving failed\n"));
+    switch (MessageBuffer[4]) {
+      case 0x02:fprintf(stdout, _("   All locations busy.\n"));break;
+      case 0x03:fprintf(stdout, _("   Invalid location!\n"));break;
+      default  :fprintf(stdout, _("   Unknown error.\n"));break;
+    }
+#endif      
+      
+    switch (MessageBuffer[4]) {
+      case 0x02:CurrentSMSMessageError = GE_MEMORYFULL;break;
+      case 0x03:CurrentSMSMessageError = GE_INVALIDSMSLOCATION;break;
+      default  :CurrentSMSMessageError = GE_UNKNOWN;break;
+    }
+  }
+}
+
+/* GST_DR and GST_UN not supported ! */
+GSM_Error N6110_SaveSMSMessage(GSM_SMSMessage *SMS)
+{
+  unsigned char req[256] = {
+    N6110_FRAME_HEADER, 0x04, /* SMS save request*/
+    0x00, /* SMS Status. Different for Inbox and Outbox */
+    0x02, /* ?? */
+    0x00, /* SMS Location */
+    0x02, /* SMS Type */
+  };
+
+  int length;
+  SMS_MessageType PDU;
+  GSM_Error error;
+
+  if (SMS->Location) req[6] = SMS->Location;
+    
+  if (SMS->folder==0) { /*Inbox*/
+    req[4]=1;      /* SMS Status */
+    req[7] = 0x00; /* SMS Type */
+    PDU=SMS_Deliver;
+  } else {
+    req[4]=5;      /* SMS Status */
+    req[7] = 0x02; /* SMS Type */
+    PDU=SMS_Submit;
+  }
+  
+  if (SMS->Status == GSS_NOTSENTREAD) req[4] |= 0x02;  
+
+  error=GSM_EncodeNokiaSMSFrame(SMS, req+8, &length, PDU);  
+  if (error != GE_NONE) return error;
+
+  CurrentSMSMessage = SMS;
+
+  return NULL_SendMessageSequence
+    (70, &CurrentSMSMessageError, 39+length, 0x14, req);
+}
+
+void N6110_ReplySetCellBroadcast(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#ifdef DEBUG
+  fprintf(stdout, _("Message: Cell Broadcast enabled/disabled successfully.\n")); fflush (stdout);
+#endif
+
+  CurrentCBError = GE_NONE;
+}
+
+/* Enable and disable Cell Broadcasting */
+GSM_Error N6110_EnableCellBroadcast(void)
+{
+  unsigned char req[] = {N6110_FRAME_HEADER, 0x20,
+                         0x01, 0x01, 0x00, 0x00, 0x01, 0x01};
+
+#ifdef DEBUG
+  fprintf (stdout,"Enabling CB\n");
+#endif
+
+  CurrentCBMessage = (GSM_CBMessage *)malloc(sizeof (GSM_CBMessage));
+  CurrentCBMessage->Channel = 0;
+  CurrentCBMessage->New = false;
+  strcpy (CurrentCBMessage->Message,"");
+
+  return NULL_SendMessageSequence
+    (10, &CurrentCBError, 10, 0x02, req);
+}
+
+
+GSM_Error N6110_DisableCellBroadcast(void)
+{
+  /* Should work, but not tested fully */
+
+  unsigned char req[] = {N6110_FRAME_HEADER, 0x20,
+                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /*VERIFY*/
+
+  return NULL_SendMessageSequence
+    (10, &CurrentCBError, 10, 0x02, req);
+}
+
+void N6110_ReplyReadCellBroadcast(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int i, tmp;
+  unsigned char output[160];
+  
+  CurrentCBMessage->Channel = MessageBuffer[7];
+  CurrentCBMessage->New = true;
+  tmp=GSM_UnpackEightBitsToSeven(0, MessageBuffer[9], MessageBuffer[9], MessageBuffer+10, output);
+
+#ifdef DEBUG
+  fprintf(stdout, _("Message: CB received.\n")); fflush (stdout);
+
+  fprintf(stdout, _("Message: channel number %i\n"),MessageBuffer[7]);
+
+  fflush (stdout);
+
+  for (i=0; i<tmp;i++) {
+    fprintf(stdout, "%c", DecodeWithDefaultAlphabet(output[i]));
+  }
+
+  fprintf(stdout, "\n");
+#endif
+   
+  for (i=0; i<tmp; i++) {
+    CurrentCBMessage->Message[i] = DecodeWithDefaultAlphabet(output[i]);
+  }
+  CurrentCBMessage->Message[i]=0;
+}
+
+GSM_Error N6110_ReadCellBroadcast(GSM_CBMessage *Message)
+{
+#ifdef DEBUG
+   fprintf(stdout,"Reading CB\n");
+#endif
+
+  if (CurrentCBMessage != NULL) 
+  {
+    if (CurrentCBMessage->New == true)
+    {
+#ifdef DEBUG
+  fprintf(stdout,"New CB received\n");
+#endif
+      Message->Channel = CurrentCBMessage->Channel;
+      strcpy(Message->Message,CurrentCBMessage->Message);
+      CurrentCBMessage->New = false;
+      return (GE_NONE);
+    }
+  }
+  return (GE_NONEWCBRECEIVED);
+}
+
+int N6110_MakeCallerGroupFrame(unsigned char *req,GSM_Bitmap Bitmap)
+{
+  int count=0;
+
+  req[count++]=Bitmap.number;
+  req[count++]=strlen(Bitmap.text);
+  memcpy(req+count,Bitmap.text,req[count-1]);
+  count+=req[count-1];
+  req[count++]=Bitmap.ringtone;
+
+  /* Setting for graphic:
+     0x00 - Off
+     0x01 - On
+     0x02 - View Graphics
+     0x03 - Send Graphics
+     0x04 - Send via IR
+     You can even set it higher but Nokia phones (my
+     6110 at least) will not show you the name of this
+     item in menu ;-)) Nokia is really joking here. */
+  if (Bitmap.enabled) req[count++]=0x01;
+                 else req[count++]=0x00;
+
+  req[count++]=(Bitmap.size+4)>>8;
+  req[count++]=(Bitmap.size+4)%0xff;
+  req[count++]=0x00;  /* Future extensions! */
+  req[count++]=Bitmap.width;
+  req[count++]=Bitmap.height;
+  req[count++]=0x01;  /* Just BW */
+  memcpy(req+count,Bitmap.bitmap,Bitmap.size);
+
+  return count+Bitmap.size;
+}
+
+int N6110_MakeOperatorLogoFrame(unsigned char *req,GSM_Bitmap Bitmap)
+{
+  int count=0;
+
+  EncodeNetworkCode(req+count, Bitmap.netcode);
+  count=count+3;
+
+  req[count++]=(Bitmap.size+4)>>8;
+  req[count++]=(Bitmap.size+4)%0xff;
+  req[count++]=0x00;  /* Infofield */
+  req[count++]=Bitmap.width;
+  req[count++]=Bitmap.height;
+  req[count++]=0x01;  /* Just BW */    
+  memcpy(req+count,Bitmap.bitmap,Bitmap.size);
+
+  return count+Bitmap.size;
+}
+
+int N6110_MakeStartupLogoFrame(unsigned char *req,GSM_Bitmap Bitmap)
+{
+  int count=0;
+
+  req[count++]=0x01;
+  req[count++]=Bitmap.height;
+  req[count++]=Bitmap.width;
+  memcpy(req+count,Bitmap.bitmap,Bitmap.size);
+
+  return count+Bitmap.size;
+}
+
+/* Set a bitmap or welcome-note */
+GSM_Error N6110_SetBitmap(GSM_Bitmap *Bitmap) {
+
+  unsigned char req[600] = { N6110_FRAME_HEADER };
+  u16 count=3;
+  u8 textlen;
+  
+  int timeout=50;
+
+  /* Direct uploading variables */
+  GSM_MultiSMSMessage SMS;
+  unsigned char buffer[1000] = {0x0c,0x01};
+  GSM_NetworkInfo NetworkInfo;
+
+  GSM_Error error;
+  /* Uploading with preview */
+  if (Bitmap->number==255 &&
+     (Bitmap->type==GSM_OperatorLogo || Bitmap->type==GSM_CallerLogo)) {
+    GSM_SaveBitmapToSMS(&SMS,Bitmap,false,false);
+    memcpy(buffer+2,SMS.SMS[0].UDH,SMS.SMS[0].UDH[0]+1);
+
+    memcpy(buffer+2+SMS.SMS[0].UDH[0]+1,SMS.SMS[0].MessageText,SMS.SMS[0].Length);
+
+    buffer[2+SMS.SMS[0].UDH[0]+1+SMS.SMS[0].Length]=0x00;
+
+    Protocol->SendMessage(2+SMS.SMS[0].UDH[0]+1+SMS.SMS[0].Length+1, 0x12, buffer);
+
+    GSM->GetNetworkInfo(&NetworkInfo); //need to make something
+    return GE_NONE; //no answer from phone
+  }
+  CurrentSetBitmapError = GE_BUSY;  
+  
+  switch (Bitmap->type) {
+  case GSM_WelcomeNoteText:
+  case GSM_DealerNoteText:
+    req[count++]=0x18;
+    req[count++]=0x01; /* Only one block */
+
+    if (Bitmap->type==GSM_WelcomeNoteText)
+      req[count++]=0x02; /* Welcome text */
+    else
+      req[count++]=0x03; /* Dealer Welcome Note */
+
+    textlen=strlen(Bitmap->text);
+    req[count++]=textlen;
+    memcpy(req+count,Bitmap->text,textlen);
+      
+    count+=textlen;
+
+    Protocol->SendMessage(count, 0x05, req);
+    
+    break;
+
+  case GSM_StartupLogo:
+    if (Bitmap->number==0) {
+
+      /* For 33xx we first set animated logo to default */
+      if (GetModelFeature (FN_STARTUP)==F_STANIM) {
+        error=N6110_SetProfileFeature(0, 0x29, Bitmap->number);
+        if (error!=GE_NONE) return error;
+      }
+
+      req[count++]=0x18;
+      req[count++]=0x01; /* Only one block */
+      count=count+N6110_MakeStartupLogoFrame(req+5,*Bitmap); 
+      Protocol->SendMessage(count, 0x05, req);
+    } else {
+      return N6110_SetProfileFeature(0, 0x29, Bitmap->number);
+    }
+    break;
+
+  case GSM_OperatorLogo:
+    req[count++]=0x30;  /* Store Op Logo */
+    req[count++]=0x01;  /* Location */
+    count=count+N6110_MakeOperatorLogoFrame(req+5,*Bitmap); 
+    Protocol->SendMessage(count, 0x05, req);
+    break;
+
+  case GSM_CallerLogo:
+    req[count++]=0x13;
+    count=count+N6110_MakeCallerGroupFrame(req+4,*Bitmap);
+    Protocol->SendMessage(count, 0x03, req);
+    break;
+
+  case GSM_PictureImage:
+    req[count++]=0x03;
+    req[count++]=Bitmap->number;
+    if (strcmp(Bitmap->Sender,"")) {
+       req[count]=GSM_PackSemiOctetNumber(Bitmap->Sender, req+count+1,true);
+
+       /* Convert number of semioctets to number of chars and add count */
+       textlen=req[count];
+       if (textlen % 2) textlen++;
+       count+=textlen / 2 + 1;
+
+       count++;
+    } else {
+      req[count++]=0x00;
+      req[count++]=0x00;
+    }
+    req[count++]=0x00;
+    req[count++]=strlen(Bitmap->text);
+    memcpy(req+count,Bitmap->text,strlen(Bitmap->text));
+    count+=strlen(Bitmap->text);
+    req[count++]=0x00;
+    req[count++]=Bitmap->width;
+    req[count++]=Bitmap->height;
+    req[count++]=0x01;
+    memcpy(req+count,Bitmap->bitmap,Bitmap->size);
+    Protocol->SendMessage(count+Bitmap->size, 0x47, req);
+    break;
+
+  case GSM_7110OperatorLogo:
+  case GSM_7110StartupLogo:
+  case GSM_6210StartupLogo:
+    return GE_NOTSUPPORTED;
+
+  case GSM_None:
+    return GE_NONE;
+  }
+
+  /* Wait for timeout or other error. */
+  while (timeout != 0 && CurrentSetBitmapError == GE_BUSY ) {
+          
+    if (--timeout == 0)
+      return (GE_TIMEOUT);
+                    
+    usleep (100000);
+  }
+
+  return CurrentSetBitmapError;
+}
+
+/* Get a bitmap from the phone */
+GSM_Error N6110_GetBitmap(GSM_Bitmap *Bitmap) {
+
+  unsigned char req[10] = { N6110_FRAME_HEADER };
+  u8 count=3;
+  
+  int timeout=100;
+  
+  CurrentGetBitmap=Bitmap; 
+  CurrentGetBitmapError = GE_BUSY;  
+  
+  switch (CurrentGetBitmap->type) {
+  case GSM_StartupLogo:
+  case GSM_WelcomeNoteText:
+  case GSM_DealerNoteText:
+    req[count++]=0x16;
+    Protocol->SendMessage(count, 0x05, req);
+    break;
+  case GSM_OperatorLogo:
+    req[count++]=0x33;
+    req[count++]=0x01; /* Location 1 */
+    Protocol->SendMessage(count, 0x05, req);
+    break;
+  case GSM_CallerLogo:
+    req[count++]=0x10;
+    req[count++]=Bitmap->number;
+    Protocol->SendMessage(count, 0x03, req);
+    break;
+  case GSM_PictureImage:
+    req[count++]=0x01;
+    req[count++]=Bitmap->number;
+    Protocol->SendMessage(count, 0x47, req);
+    break;
+  case GSM_7110OperatorLogo:
+  case GSM_7110StartupLogo:
+  case GSM_6210StartupLogo:
+  default:
+    return GE_NOTSUPPORTED;
+  }
+
+  /* Wait for timeout or other error. */
+  while (timeout != 0 && CurrentGetBitmapError == GE_BUSY ) {
+          
+    if (--timeout == 0)
+      return (GE_TIMEOUT);
+                    
+    usleep (100000);
+  }
+
+  CurrentGetBitmap=NULL;
+
+  return CurrentGetBitmapError;
+}
+
+void N6110_ReplySetRingtone(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch (MessageBuffer[3]) {
+
+  /* Set ringtone OK */
+  case 0x37:       
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Ringtone set OK!\n"));
+#endif  
+    CurrentRingtoneError=GE_NONE; 
+    break;      
+
+  /* Set ringtone error */
+  case 0x38:       
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Ringtone setting error !\n"));
+#endif  
+    CurrentRingtoneError=GE_NOTSUPPORTED; 
+    break;      
+  }
+}
+
+GSM_Error N6110_SetRingTone(GSM_Ringtone *ringtone, int *maxlength)
+{
+  
+  char req[FB61_MAX_RINGTONE_FRAME_LENGTH+10] =
+      {N6110_FRAME_HEADER,
+       0x36,
+       0x00,  /* Location */
+       0x00,0x78};
+
+  int size=FB61_MAX_RINGTONE_FRAME_LENGTH;
+  /* Variables for preview uploading */
+  unsigned char buffer[FB61_MAX_RINGTONE_FRAME_LENGTH+50];
+  unsigned char buffer2[20];
+  GSM_NetworkInfo NetworkInfo;
+
+  /* Setting ringtone with preview */
+  if (ringtone->location==255) {
+    buffer[0]=0x0c;
+    buffer[1]=0x01;
+    EncodeUDHHeader(buffer2, GSM_RingtoneUDH);
+    memcpy(buffer+2,buffer2,buffer2[0]+1); //copying UDH
+    *maxlength=GSM_PackRingtone(ringtone, buffer+2+buffer2[0]+1, &size); //packing ringtone
+    Protocol->SendMessage(2+buffer2[0]+1+size, 0x12, buffer); //sending frame
+    GSM->GetNetworkInfo(&NetworkInfo); //need to make something
+    sleep(1);
+    return GE_NONE; //no answer from phone
+  }
+  
+  *maxlength=GSM_PackRingtone(ringtone, req+7, &size);
+
+  req[4]=ringtone->location-1;
+
+  return NULL_SendMessageSequence
+    (50, &CurrentRingtoneError, (size+7), 0x05, req);
+}
+
+void N6110_ReplyGetBinRingtone(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int i;
+  
+  switch (MessageBuffer[4]) {
+    case 0x00: /* location supported. We have ringtone */
+
+      /* Binary format used in N6150 */
+      if (MessageBuffer[5]==0x0c && MessageBuffer[6]==0x01 && MessageBuffer[7]==0x2c) {
+#ifdef DEBUG
+        fprintf(stdout,_("Message: ringtone \""));
+#endif      
+
+        /* Copying name */
+        i=8;
+        while (true) {
+#ifdef DEBUG
+          if (MessageBuffer[i]!=0)
+            fprintf(stdout,_("%c"),MessageBuffer[i]);
+#endif
+          CurrentGetBinRingtone->name[i-8]=MessageBuffer[i];
+          if (MessageBuffer[i]==0) break;
+          i++;
+        }
+
+#ifdef DEBUG    
+        fprintf(stdout,_("\" received from location %i\n"),MessageBuffer[3]+1);
+#endif
+      
+        /* Looking for end */
+        i=0;
+       while (true) {
+         if (MessageBuffer[i]==0x07 && MessageBuffer[i+1]==0x0b) {
+           i=i+2;break;
+         }
+         if (MessageBuffer[i]==0x0e && MessageBuffer[i+1]==0x0b) {
+           i=i+2;break;
+         }
+         i++;
+          if (i==MessageLength) break;
+       }
+         
+        /* Copying frame */
+        memcpy(CurrentGetBinRingtone->frame,MessageBuffer+3,i-3);
+        CurrentGetBinRingtone->length=i-3;
+      
+        CurrentBinRingtoneError=GE_NONE;
+        break;
+      }
+         
+      /* Binary format used in N3210 */
+      if (MessageBuffer[5]==0x10 && MessageBuffer[6]==0x01 && MessageBuffer[7]==0x2c) {      
+
+#ifdef DEBUG
+        fprintf(stdout,_("Message: ringtone \""));
+#endif      
+
+        /* Copying name */
+        i=8;
+        while (true) {
+#ifdef DEBUG
+          if (MessageBuffer[i]!=0)
+            fprintf(stdout,_("%c"),MessageBuffer[i]);
+#endif
+          CurrentGetBinRingtone->name[i-8]=MessageBuffer[i];
+          if (MessageBuffer[i]==0) break;
+          i++;
+        }
+
+#ifdef DEBUG    
+        fprintf(stdout,_("\" received from location %i\n"),MessageBuffer[3]+1);
+#endif
+
+        /* Here changes to get full compatibility with binary format used in N6150 */
+        MessageBuffer[3]=0;
+        MessageBuffer[4]=0;
+        MessageBuffer[5]=0x0c;
+        MessageBuffer[6]=0x01;
+        MessageBuffer[7]=0x2c;
+
+        /* Looking for end */
+        i=0;
+        while (true) {
+          if (MessageBuffer[i]==0x07 && MessageBuffer[i+1]==0x0b) {
+           i=i+2;break;
+         }
+         if (MessageBuffer[i]==0x0e && MessageBuffer[i+1]==0x0b) {
+           i=i+2;break;
+         }
+         i++;
+         if (i==MessageLength) break;
+        }
+         
+       /* Copying frame */
+        memcpy(CurrentGetBinRingtone->frame,MessageBuffer+3,i-3);
+
+        CurrentGetBinRingtone->length=i-3;
+           
+        CurrentBinRingtoneError=GE_NONE;         
+       break;
+      }
+
+      /* Copying frame */
+      memcpy(CurrentGetBinRingtone->frame,MessageBuffer,MessageLength);
+
+      CurrentGetBinRingtone->length=MessageLength;
+
+#ifdef DEBUG    
+      fprintf(stdout,_("Message: unknown binary format for ringtone received from location %i\n"),MessageBuffer[3]+1);
+#endif
+      CurrentBinRingtoneError=GE_UNKNOWNMODEL;
+      break;
+
+    default:
+
+#ifdef DEBUG
+      fprintf(stdout,_("Message: Phone doesn't support downloaded ringtones at location %i\n"),MessageBuffer[3]+1);
+#endif
+
+      CurrentBinRingtoneError=GE_INVALIDRINGLOCATION;  
+  }
+}
+
+GSM_Error N6110_GetBinRingTone(GSM_BinRingtone *ringtone)
+{
+  unsigned char req[] = { 0x00,0x01,0x9e,
+                          0x00 }; //location
+
+  GSM_Error error;
+  
+  CurrentGetBinRingtone=ringtone;
+  
+  error=N6110_EnableExtendedCommands(0x01);
+  if (error!=GE_NONE) return error;
+
+  req[3]=ringtone->location-1;
+  
+  return NULL_SendMessageSequence
+    (50, &CurrentBinRingtoneError, 4, 0x40, req);
+}
+
+void N6110_ReplySetBinRingtone(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch (MessageBuffer[4]) {
+    case 0x00: /* location supported. We set ringtone */
+#ifdef DEBUG
+      fprintf(stdout,_("Message: downloaded ringtone set at location %i\n"),MessageBuffer[3]+1);
+#endif
+      CurrentBinRingtoneError=GE_NONE;
+      break;
+
+    default:
+#ifdef DEBUG
+      fprintf(stdout,_("Message: Phone doesn't support downloaded ringtones at location %i\n"),MessageBuffer[3]+1);
+#endif
+      CurrentBinRingtoneError=GE_NOTSUPPORTED;   
+      break;
+  }
+}
+
+GSM_Error N6110_SetBinRingTone(GSM_BinRingtone *ringtone)
+{
+  unsigned char req[1000] = { 0x00,0x01,0xa0};
+
+  GSM_Error error;
+
+  GSM_BinRingtone ring;
+
+  /* Must be sure, that can upload ringtone to this phone */
+  ring.location=ringtone->location;
+  error=N6110_GetBinRingTone(&ring);
+  if (error!=GE_NONE) return error;
+    
+  error=N6110_EnableExtendedCommands(0x01);
+  if (error!=GE_NONE) return error;
+  
+  memcpy(req+3,ringtone->frame,ringtone->length);
+
+  req[3]=ringtone->location-1;
+  
+  return NULL_SendMessageSequence
+    (50, &CurrentBinRingtoneError, ringtone->length+3, 0x40, req);
+}
+
+#endif /* UCLINUX */
+
+GSM_Error N6110_Reset(unsigned char type)
+{  
+  return N6110_EnableExtendedCommands(type);
+}
+
+void N6110_Dispatch0x01Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int count;
+#ifdef DEBUG
+       int tmp;
+#endif
+         
+  switch (MessageBuffer[3]) {
+
+  /* Unknown message - it has been seen after the 0x07 message (call
+     answered). Probably it has similar meaning. If you can solve
+     this - just mail me. Pavel Janík ml.
+
+     The message looks like this:
+
+     Msg Destination: PC
+     Msg Source: Phone
+     Msg Type: 01
+     Msg Unknown: 00
+     Msg Len: 0e
+
+     Phone: [01 ][08 ][00 ] is the header of the frame
+
+     [03 ] is the call message subtype
+
+     [05 ] is the call sequence number
+
+     [05 ] unknown 
+
+     [00 ][01 ][03 ][02 ][91][00] are unknown but has been
+     seen in the Incoming call message (just after the
+     caller's name from the phonebook). But never change
+     between phone calls :-(
+  */
+
+  /* This may mean sequence number of 'just made' call - CK */
+  case 0x02:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Call message, type 0x02:"));
+    fprintf(stdout, _("   Exact meaning not known yet, sorry :-(\n"));
+#endif /* DEBUG */
+
+    break;
+
+  /* Possibly call OK */
+  /* JD: I think that this means "call in progress" (incomming or outgoing) */
+  case 0x03:
+    
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Call message, type 0x03:"));
+    fprintf(stdout, _("   Sequence nr. of the call: %d\n"), MessageBuffer[4]);
+    fprintf(stdout, _("   Exact meaning not known yet, sorry :-(\n"));
+#endif /* DEBUG */
+    
+    CurrentCallSequenceNumber=MessageBuffer[4];
+#ifndef UCLINUX
+    CurrentIncomingCall[0]='D';
+#endif /* UCLINUX */
+    if (CurrentCallPassup) CurrentCallPassup('D');
+
+    break;
+
+  /* Remote end has gone away before you answer the call.  Probably your
+     mother-in-law or banker (which is worse?) ... */
+  case 0x04:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Remote end hang up.\n"));
+    fprintf(stdout, _("   Sequence nr. of the call: %d, error: %i"), MessageBuffer[4],MessageBuffer[6]);
+
+    switch (MessageBuffer[6]) {
+      case 28: fprintf(stdout,_(" (info \"Invalid phone number\")"));break;
+      case 34: fprintf(stdout,_(" (info \"Network busy\")"));break;
+      case 42: fprintf(stdout,_(" (info \"Network busy\")"));break;
+      case 47: fprintf(stdout,_(" (info \"Error in connection\")"));break;
+      case 50: fprintf(stdout,_(" (info \"Check operator services\")"));break;       case 76: fprintf(stdout,_(" (info \"Check operator services\")"));break;
+      case 111: fprintf(stdout,_(" (info \"Error in connection\")"));break;
+    }
+      
+    fprintf(stdout,_("\n   For more details with errors see netmonitor manual (test 39) on www.marcin-wiacek.topnet.pl"));
+    fprintf(stdout,_("\n   If know their meaning, GSM specs decribing them, contact with me on marcin-wiacek@topnet.pl. THX\n"));
+#endif /* DEBUG */
+
+#ifndef UCLINUX
+    CurrentIncomingCall[0] = ' ';
+#endif /* UCLINUX */
+    if (CurrentCallPassup) CurrentCallPassup(' ');
+
+    break;
+
+  /* Incoming call alert */
+  case 0x05:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Incoming call alert:\n"));
+
+    /* We can have more then one call ringing - we can distinguish between
+       them */
+
+    fprintf(stdout, _("   Sequence nr. of the call: %d\n"), MessageBuffer[4]);
+    fprintf(stdout, _("   Number: "));
+
+    count=MessageBuffer[6];
+
+    for (tmp=0; tmp <count; tmp++)
+      fprintf(stdout, "%c", MessageBuffer[7+tmp]);
+
+    fprintf(stdout, "\n");
+
+    fprintf(stdout, _("   Name: "));
+
+    for (tmp=0; tmp <MessageBuffer[7+count]; tmp++)
+      fprintf(stdout, "%c", MessageBuffer[8+count+tmp]);
+
+    fprintf(stdout, "\n");
+#endif /* DEBUG */
+
+    count=MessageBuffer[6];
+
+#ifndef UCLINUX
+    CurrentIncomingCall[0] = 0;
+    for (tmp=0; tmp <count; tmp++)
+      sprintf(CurrentIncomingCall, "%s%c", CurrentIncomingCall, MessageBuffer[7+tmp]);
+#endif /* UCLINUX */
+
+    break;
+
+  /* Call answered. Probably your girlfriend...*/
+  case 0x07:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Call answered.\n"));
+    fprintf(stdout, _("   Sequence nr. of the call: %d\n"), MessageBuffer[4]);
+#endif /* DEBUG */
+
+    break;
+
+  /* Call ended. Girlfriend is girlfriend, but time is money :-) */
+  case 0x09:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Call ended by your phone.\n"));
+    fprintf(stdout, _("   Sequence nr. of the call: %d\n"), MessageBuffer[4]);
+#endif /* DEBUG */
+
+    break;
+
+  /* This message has been seen with the message of subtype 0x09
+     after I hang the call.
+
+  Msg Destination: PC
+  Msg Source: Phone
+  Msg Type: 01 
+  Msg Unknown: 00
+  Msg Len: 08
+  Phone: [01 ][08 ][00 ][0a ][04 ][87 ][01 ][42B][1a ][c2 ]
+
+  What is the meaning of 87? Can you spell some magic light into
+  this issue?
+
+  */
+
+  /* Probably means call over - CK */
+  case 0x0a:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Call message, type 0x0a:"));
+    fprintf(stdout, _("   Sequence nr. of the call: %d\n"), MessageBuffer[4]);
+    fprintf(stdout, _("   Exact meaning not known yet, sorry :-(\n"));
+#endif /* DEBUG */
+
+#ifndef UCLINUX
+    CurrentIncomingCall[0] = ' ';
+#endif /* UCLINUX */
+    if (CurrentCallPassup) CurrentCallPassup(' ');
+
+    break;
+
+  case 0x40:
+
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Answer for send DTMF or dial voice command\n"));
+#endif
+
+#ifndef UCLINUX
+    if (CurrentSendDTMFError!=GE_NONE) CurrentSendDTMFError=GE_NONE;
+#endif /* UCLINUX */
+
+    if (CurrentDialVoiceError!=GE_NONE) CurrentDialVoiceError=GE_NONE;
+
+    break;
+     
+  default:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Unknown message of type 0x01\n"));
+#endif /* DEBUG */
+    AppendLogText("Unknown msg\n",false);
+
+    break;     /* Visual C Don't like empty cases */
+  }
+}
+
+#ifndef UCLINUX
+
+static void N6110_Dispatch0x03Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int tmp, count;
+    
+  switch (MessageBuffer[3]) {
+
+  case 0x04:
+
+    /* AFAIK, this frame isn't used anywhere - it's rather for testing :-) */
+    /* If you want see, if it works with your phone make something like that: */
+
+    /* unsigned char connect5[] = {N6110_FRAME_HEADER, 0x03}; */
+    /* Protocol->SendMessage(4, 0x04, connect5); */
+
+    /*                                        Marcin-Wiacek@TopNet.PL */
+    
+#if defined(WIN32) || defined(UCLINUX)
+    sprintf(Current_IMEI, "%s", MessageBuffer+5);
+    sprintf(Current_Model, "%s", MessageBuffer+21);
+    sprintf(Current_Revision, "SW%s, HW%s", MessageBuffer+41, MessageBuffer+35);
+#else
+    snprintf(Current_IMEI, GSM_MAX_IMEI_LENGTH, "%s", MessageBuffer+5);
+    snprintf(Current_Model, GSM_MAX_MODEL_LENGTH, "%s", MessageBuffer+21);
+    snprintf(Current_Revision, GSM_MAX_REVISION_LENGTH, "SW%s, HW%s", MessageBuffer+41, MessageBuffer+35);
+#endif
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Mobile phone identification received:\n"));
+    fprintf(stdout, _("   IMEI: %s\n"), Current_IMEI);
+    fprintf(stdout, _("   Model: %s\n"), Current_Model);
+    fprintf(stdout, _("   Production Code: %s\n"), MessageBuffer+27);
+    fprintf(stdout, _("   HW: %s\n"), MessageBuffer+35);
+    fprintf(stdout, _("   Firmware: %s\n"), MessageBuffer+41);
+#endif /* DEBUG */
+
+    break;
+
+  /* Get group data */    
+  /* [ID],[name_len],[name].,[ringtone],[graphicon],[lenhi],[lenlo],[bitmap] */
+  case 0x11:   
+    if (CurrentGetBitmap!=NULL) {
+      if (CurrentGetBitmap->number==MessageBuffer[4]) {
+        count=MessageBuffer[5];
+        memcpy(CurrentGetBitmap->text,MessageBuffer+6,count);
+        CurrentGetBitmap->text[count]=0;
+
+#ifdef DEBUG   
+       fprintf(stdout, _("Message: Caller group datas\n"));
+       fprintf(stdout, _("Caller group name: %s\n"),CurrentGetBitmap->text);
+#endif /* DEBUG */
+
+       count+=6;
+
+       CurrentGetBitmap->ringtone=MessageBuffer[count++];
+#ifdef DEBUG   
+        fprintf(stdout, _("Caller group ringtone ID: %i"),CurrentGetBitmap->ringtone);
+        if (CurrentGetBitmap->ringtone==16) fprintf(stdout,_(" (default)"));
+       fprintf(stdout,_("\n"));
+#endif /* DEBUG */
+
+       CurrentGetBitmap->enabled=(MessageBuffer[count++]==1);
+#ifdef DEBUG   
+       fprintf(stdout, _("Caller group logo "));
+       if (CurrentGetBitmap->enabled)
+         fprintf(stdout, _("enabled \n"));
+       else
+         fprintf(stdout, _("disabled \n"));
+#endif /* DEBUG */     
+
+       CurrentGetBitmap->size=MessageBuffer[count++]<<8;
+       CurrentGetBitmap->size+=MessageBuffer[count++];
+#ifdef DEBUG   
+       fprintf(stdout, _("Bitmap size=%i\n"),CurrentGetBitmap->size);
+#endif /* DEBUG */
+
+       count++;
+       CurrentGetBitmap->width=MessageBuffer[count++];
+        CurrentGetBitmap->height=MessageBuffer[count++];
+       count++;
+       tmp=CurrentGetBitmap->height*CurrentGetBitmap->width/8;
+       if (CurrentGetBitmap->size>tmp) CurrentGetBitmap->size=tmp;
+       memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count,CurrentGetBitmap->size);
+       CurrentGetBitmapError=GE_NONE;
+      } else {
+#ifdef DEBUG   
+       fprintf(stdout, _("Message: Caller group datas received, but group number does not match (%i is not %i)\n"),MessageBuffer[4],CurrentGetBitmap->number);
+#endif
+      }
+    } else {
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Caller group data received but not requested!\n"));
+#endif
+    }
+    break;
+
+  /* Get group data error */
+  case 0x12:   
+      
+    CurrentGetBitmapError=GE_UNKNOWN;   
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Error attempting to get caller group data.\n"));
+#endif   
+    break;
+
+  /* Set group data OK */      
+  case 0x14:   
+      
+    CurrentSetBitmapError=GE_NONE;      
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Caller group data set correctly.\n"));
+#endif
+    break;
+
+  /* Set group data error */
+  case 0x15:   
+      
+    CurrentSetBitmapError=GE_UNKNOWN;      
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Error attempting to set caller group data\n"));
+#endif
+    break;  
+  
+  default:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Unknown message of type 0x03\n"));
+#endif /* DEBUG */
+    AppendLogText("Unknown msg\n",false);
+
+    break;     /* Visual C Don't like empty cases */
+  }
+}
+
+static void N6110_Dispatch0x05Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int tmp, count, length;
+  bool issupported;
+
+#ifdef DEBUG
+  int i;
+#endif
+
+  switch (MessageBuffer[3]) {
+
+  /* Startup Logo */
+  case 0x17:  
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Startup Logo, welcome note and dealer welcome note received.\n"));
+#endif
+
+    if (CurrentGetBitmap!=NULL) {
+       
+      issupported=false;
+       
+      count=5;
+       
+      for (tmp=0;tmp<MessageBuffer[4];tmp++){
+        switch (MessageBuffer[count++]) {
+        case 0x01:
+          if (CurrentGetBitmap->type==GSM_StartupLogo) {
+            CurrentGetBitmap->height=MessageBuffer[count++];
+           CurrentGetBitmap->width=MessageBuffer[count++];
+           CurrentGetBitmap->size=CurrentGetBitmap->height*CurrentGetBitmap->width/8;
+           length=CurrentGetBitmap->size;
+           memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count,length);
+          } else {
+           length=MessageBuffer[count++];
+           length=length*MessageBuffer[count++]/8;
+         }
+         count+=length;
+#ifdef DEBUG
+         fprintf(stdout, _("Startup logo supported - "));
+         if (length!=0) { fprintf(stdout, _("currently set\n"));   }
+                    else { fprintf(stdout, _("currently empty\n")); }
+#endif
+          if (CurrentGetBitmap->type==GSM_StartupLogo) issupported=true;
+         break;
+       case 0x02:
+         length=MessageBuffer[count];
+         if (CurrentGetBitmap->type==GSM_WelcomeNoteText) {
+            memcpy(CurrentGetBitmap->text,MessageBuffer+count+1,length);
+           CurrentGetBitmap->text[length]=0;
+         }
+#ifdef DEBUG
+          fprintf(stdout, _("Startup Text supported - "));
+          if (length!=0)
+         {
+           fprintf(stdout, _("currently set to \""));
+           for (i=0;i<length;i++) fprintf(stdout, _("%c"),MessageBuffer[count+1+i]);
+           fprintf(stdout, _("\"\n"));
+         } else {
+            fprintf(stdout, _("currently empty\n"));
+         }
+#endif
+         count+=length+1;
+          if (CurrentGetBitmap->type==GSM_WelcomeNoteText) issupported=true;
+         break;
+       case 0x03:
+         length=MessageBuffer[count];
+         if (CurrentGetBitmap->type==GSM_DealerNoteText) {
+            memcpy(CurrentGetBitmap->text,MessageBuffer+count+1,length);
+           CurrentGetBitmap->text[length]=0;
+         }
+#ifdef DEBUG
+         fprintf(stdout, _("Dealer Welcome supported - "));
+         if (length!=0)
+         {
+           fprintf(stdout, _("currently set to \""));
+           for (i=0;i<length;i++) fprintf(stdout, _("%c"),MessageBuffer[count+1+i]);
+           fprintf(stdout, _("\"\n"));
+         } else {
+            fprintf(stdout, _("currently empty\n"));
+         }
+#endif
+         count+=length+1;
+          if (CurrentGetBitmap->type==GSM_DealerNoteText) issupported=true;
+         break;
+        }
+      }
+      if (issupported) CurrentGetBitmapError=GE_NONE;
+                  else CurrentGetBitmapError=GE_NOTSUPPORTED;
+    } else {
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Startup logo received but not requested!\n"));
+#endif
+    }
+    break;
+
+  /* Set startup OK */
+  case 0x19:   
+    
+    CurrentSetBitmapError=GE_NONE;    
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Startup logo, welcome note or dealer welcome note correctly set.\n"));
+#endif  
+    break;      
+
+  /* Set Operator Logo OK */
+  case 0x31:   
+      
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Operator logo correctly set.\n"));
+#endif  
+
+    CurrentSetBitmapError=GE_NONE;      
+    break;
+
+  /* Set Operator Logo Error */      
+  case 0x32:  
+      
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Error setting operator logo!\n"));
+#endif
+
+    CurrentSetBitmapError=GE_UNKNOWN;        
+    break;
+
+  /* Operator Logo */
+  /* [location],[netcode x 3],[lenhi],[lenlo],[bitmap] */ 
+  case 0x34:
+    if (CurrentGetBitmap!=NULL) {
+
+      count=5;  /* Location ignored. */
+
+      DecodeNetworkCode(MessageBuffer+count, CurrentGetBitmap->netcode);
+      count=count+3;
+
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Operator Logo for %s (%s) network received.\n"),
+                          CurrentGetBitmap->netcode,
+                          GSM_GetNetworkName(CurrentGetBitmap->netcode));
+#endif  
+
+      CurrentGetBitmap->size=MessageBuffer[count++]<<8;
+      CurrentGetBitmap->size+=MessageBuffer[count++];
+      count++;
+      CurrentGetBitmap->width=MessageBuffer[count++];
+      CurrentGetBitmap->height=MessageBuffer[count++];
+      count++;
+      tmp=CurrentGetBitmap->height*CurrentGetBitmap->width/8;
+      if (CurrentGetBitmap->size>tmp) CurrentGetBitmap->size=tmp;
+      memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count,CurrentGetBitmap->size);
+      CurrentGetBitmapError=GE_NONE;
+    } else {
+#ifdef DEBUG
+      fprintf(stdout, _("Message: Operator logo received but not requested!\n"));
+#endif
+    }
+      
+    break;
+
+  /* Get op logo error */      
+  case 0x35:
+     
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Error getting operator logo!\n"));
+#endif  
+    CurrentGetBitmapError=GE_UNKNOWN; 
+    break;
+
+  default:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Unknown message of type 0x05\n"));
+#endif /* DEBUG */
+    AppendLogText("Unknown msg\n",false);
+
+    break;
+  }
+}
+
+static void N6110_Dispatch0x06Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int tmp;
+  unsigned char output[160];
+
+#ifdef DEBUG
+  int i;
+#endif
+    
+  switch (MessageBuffer[3]) {
+
+  case 0x05:
+
+    /* MessageBuffer[3] = 0x05
+       MessageBuffer[4] = 0x00
+       MessageBuffer[5] = 0x0f
+       MessageBuffer[6] = 0x03
+       MessageBuffer[7] = length of packed message
+
+       This is all I have seen - Gerry Anderson */
+
+    tmp=GSM_UnpackEightBitsToSeven(0, 82, 82, MessageBuffer+8, output);
+
+#ifdef DEBUG
+
+    fprintf(stdout, _("Message from Network operator: "));
+
+    for (i=0; i<tmp; i++)
+       fprintf(stdout, "%c", DecodeWithDefaultAlphabet(output[i]));
+
+    fprintf(stdout, "\n");
+
+#endif /* DEBUG */
+
+    break;
+
+  default:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Unknown message of type 0x06\n"));
+#endif /* DEBUG */
+    AppendLogText("Unknown msg\n",false);
+
+    break;
+  }
+}
+
+#endif /* UCLINUX */
+
+static void N6110_Dispatch0x09Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+    
+  switch (MessageBuffer[3]) {
+    
+  case 0x80:    
+#ifdef DEBUG
+    fprintf(stdout, _("Message: SIM card login\n"));
+#endif
+    break;
+
+  case 0x81:    
+#ifdef DEBUG
+    fprintf(stdout, _("Message: SIM card logout\n"));
+#endif
+    break;
+      
+  default:
+#ifdef DEBUG
+    fprintf(stdout, _("Unknown message of type 0x09.\n"));      
+#endif
+    AppendLogText("Unknown msg\n",false);
+    break;
+  }
+}
+
+#ifndef UCLINUX
+
+static void N6110_Dispatch0x13Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  switch(MessageBuffer[3]) {
+    
+  case 0x6a:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Calendar Alarm active\n"));
+    fprintf(stdout, _("   Item number: %d\n"), MessageBuffer[4]);
+#endif /* DEBUG */
+
+  default:
+#ifdef DEBUG
+    fprintf(stdout, _("Unknown message of type 0x13.\n"));      
+#endif
+    AppendLogText("Unknown msg\n",false);
+    break;
+  }
+}
+
+#endif /* UCLINUX */
+
+void N6110_Dispatch0x40Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int i;
+  
+  switch(MessageBuffer[2]) {
+
+  case 0x02:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: ACK for simlock opening part 1\n"));
+#endif /* DEBUG */
+    
+    CurrentMagicError=GE_NONE;
+    break;
+    
+  case 0x7c:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Answer for call commands.\n"));
+#endif
+    
+    CurrentDialVoiceError=GE_NONE;      
+    break;
+      
+  case 0x81:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: ACK for simlock opening part 2\n"));
+#endif /* DEBUG */
+    
+    CurrentMagicError=GE_NONE;
+    break;
+
+  case 0x82:
+
+#ifdef DEBUG
+      fprintf(stdout, _("Message: ACK for simlock closing\n"));
+#endif /* DEBUG */
+    
+    CurrentMagicError=GE_NONE;
+    break;
+
+  case 0xd4:
+
+    switch (MessageBuffer[5]) {
+      case 0xa0:
+#ifdef DEBUG
+        fprintf(stdout,_("Message: EEPROM contest received\n"));
+#endif
+
+        if (MessageBuffer[8]!=0x00) {
+          for (i=9;i<MessageLength;i++) {
+            fprintf(stdout,_("%c"), MessageBuffer[i]);
+        }
+
+        CurrentMagicError=GE_NONE;
+      }
+      
+      break;
+    }
+      
+#ifdef DEBUG
+    fprintf(stdout, _("Unknown message of type 0x40.\n"));
+#endif /* DEBUG */
+    AppendLogText("Unknown msg\n",false);      
+    break;
+
+#ifndef UCLINUX
+  case 0xcf:
+
+    N6110_DisplayTestsInfo(MessageBuffer);
+    break;
+#endif /* UCLINUX */
+      
+  default:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Unknown message of type 0x40.\n"));
+#endif /* DEBUG */
+    AppendLogText("Unknown msg\n",false);
+    break;     /* Visual C Don't like empty cases */
+  }
+}
+
+#ifndef UCLINUX
+
+static void N6110_Dispatch0x47Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  int count;
+  
+  switch(MessageBuffer[3]) {
+    
+  case 0x02:
+
+    count=5;
+    
+    if (MessageBuffer[5]!=0) {
+      strcpy(CurrentGetBitmap->Sender,GSM_UnpackSemiOctetNumber(MessageBuffer+5,true));
+
+      while (MessageBuffer[count]!=0) {
+        count++;
+      }
+
+      count++;
+    } else {
+      strcpy(CurrentGetBitmap->Sender,"\0");
+
+      count+=3;
+    }
+
+    memcpy(CurrentGetBitmap->text,MessageBuffer+count+1,MessageBuffer[count]);
+    CurrentGetBitmap->text[MessageBuffer[count]]=0;
+
+    if (MessageBuffer[count]!=0)
+      count+=MessageBuffer[count];
+
+    count++;
+
+#ifdef DEBUG
+    fprintf(stdout,_("Picture Image received, text \"%s\", sender %s\n"),CurrentGetBitmap->text,CurrentGetBitmap->Sender);
+#endif
+
+    CurrentGetBitmap->width=MessageBuffer[count+1];
+    CurrentGetBitmap->height=MessageBuffer[count+2]; 
+    CurrentGetBitmap->size=CurrentGetBitmap->height*CurrentGetBitmap->width/8;
+      
+    memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count+4,CurrentGetBitmap->size);
+      
+    CurrentGetBitmapError=GE_NONE;
+    break;
+
+  case 0x04:
+
+#ifdef DEBUG
+    fprintf(stdout,_("Getting or setting Picture Image - OK\n"));
+#endif
+    CurrentSetBitmapError=GE_NONE;
+    CurrentGetBitmapError=GE_NONE;
+    break;     
+
+  case 0x05:
+
+#ifdef DEBUG
+    fprintf(stdout,_("Setting Picture Image - invalid location or other error\n"));
+#endif
+    CurrentSetBitmapError=GE_UNKNOWN;
+    break;     
+
+  case 0x06:
+
+#ifdef DEBUG
+    fprintf(stdout,_("Getting Picture Image - invalid location or other error\n"));
+#endif
+    CurrentGetBitmapError=GE_UNKNOWN;
+    break;     
+
+  default:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Unknown message of type 0x47.\n"));
+#endif /* DEBUG */
+    AppendLogText("Unknown msg\n",false);
+    break;     /* Visual C Don't like empty cases */
+  }
+}
+
+#endif /* UCLINUX */
+
+void N6110_DispatchACKMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+  char buffer[50];
+  
+  sprintf(buffer,"Received ACK %02x %02x\n",MessageBuffer[0],MessageBuffer[1]);
+  AppendLog(buffer,strlen(buffer),false);
+
+#ifdef DEBUG
+  fprintf(stdout, _("[Received Ack of type %02x, seq: %2x]\n"), MessageBuffer[0],
+                                                                MessageBuffer[1]);
+#endif /* DEBUG */
+  
+  CurrentLinkOK = true;
+}
+
+static void N6110_Dispatch0xD0Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+   
+#ifdef DEBUG
+  fprintf(stdout, _("Message: The phone is powered on - seq 1.\n"));
+#endif /* DEBUG */
+
+}
+
+/* This function is used for parsing the RLP frame into fields. */
+void N6110_RX_HandleRLPMessage(u8 *MessageBuffer)
+{
+
+  RLP_F96Frame frame;
+  int count;
+  int valid = true;
+
+  /* We do not need RLP frame parsing to be done when we do not have callback
+     specified. */
+  if (CurrentRLP_RXCallback == NULL)
+    return;
+    
+  /* Anybody know the official meaning of the first two bytes?
+     Nokia 6150 sends junk frames starting D9 01, and real frames starting
+     D9 00. We'd drop the junk frames anyway because the FCS is bad, but
+     it's tidier to do it here. We still need to call the callback function
+     to give it a chance to handle timeouts and/or transmit a frame */
+  if (MessageBuffer[0] == 0xd9 && MessageBuffer[1] == 0x01)
+    valid = false;
+
+  /* Nokia uses 240 bit frame size of RLP frames as per GSM 04.22
+     specification, so Header consists of 16 bits (2 bytes). See section 4.1
+     of the specification. */
+    
+  frame.Header[0] = MessageBuffer[2];
+  frame.Header[1] = MessageBuffer[3];
+
+  /* Next 200 bits (25 bytes) contain the Information. We store the
+     information in the Data array. */
+
+  for (count = 0; count < 25; count ++)
+    frame.Data[count] = MessageBuffer[4 + count];
+
+  /* The last 24 bits (3 bytes) contain FCS. */
+
+  frame.FCS[0] = MessageBuffer[29];
+  frame.FCS[1] = MessageBuffer[30];
+  frame.FCS[2] = MessageBuffer[31];
+
+  /* Here we pass the frame down in the input stream. */
+  CurrentRLP_RXCallback(valid ? &frame : NULL);
+}
+
+static void N6110_Dispatch0xF4Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+#ifdef DEBUG
+  fprintf(stdout, _("Message: The phone is powered on - seq 2.\n"));
+#endif /* DEBUG */
+
+}
+
+#ifndef UCLINUX
+
+void N6110_ReplyIncomingSMS(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  GSM_SMSMessage NullSMS;
+
+  switch (MessageBuffer[6]) {
+
+    case 0x00: NullSMS.Type = GST_SMS; NullSMS.folder = GST_INBOX; break;
+    case 0x01: NullSMS.Type = GST_DR;  NullSMS.folder = GST_INBOX; break;
+
+    /* Is it possible ? */
+    case 0x02: NullSMS.Type = GST_SMS; NullSMS.folder = GST_OUTBOX; break;      
+    default:   NullSMS.Type = GST_UN;                               break;
+  }
+
+#ifdef DEBUG
+  if (NullSMS.Type == GST_DR)
+    fprintf(stdout, _("Message: SMS Message (Report) Received\n"));
+  else 
+    fprintf(stdout, _("Message: SMS Message Received\n"));  
+#endif /* DEBUG */
+
+  GSM_DecodeNokiaSMSFrame(&NullSMS, MessageBuffer+7, MessageLength-7);
+
+#ifdef DEBUG
+  fprintf(stdout, _("\n"));      
+#endif /* DEBUG */
+}
+
+#endif /* UCLINUX */
+
+void N6110_DispatchMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) {
+
+  bool unknown=false;
+
+  /* Switch on the basis of the message type byte */
+  switch (MessageType) {
+         
+  /* Call information */
+  case 0x01:
+
+    N6110_Dispatch0x01Message(MessageLength, MessageBuffer, MessageType);
+    break;
+
+#ifndef UCLINUX
+  /* SMS handling */
+  case 0x02:
+    switch (MessageBuffer[3]) {
+      case 0x02:
+      case 0x03:N6110_ReplySendSMSMessage(MessageLength,MessageBuffer,MessageType);break;
+      case 0x10:N6110_ReplyIncomingSMS(MessageLength,MessageBuffer,MessageType);break;
+      case 0x21:N6110_ReplySetCellBroadcast(MessageLength, MessageBuffer, MessageType);break;
+      case 0x23:N6110_ReplyReadCellBroadcast(MessageLength, MessageBuffer, MessageType);break;
+      case 0x31:N6110_ReplySetSMSCenter(MessageLength,MessageBuffer,MessageType);break;
+      case 0x34:
+      case 0x35:N6110_ReplyGetSMSCenter(MessageLength,MessageBuffer,MessageType);break;
+      default  :unknown=true;break;
+    }
+    break;
+#endif /* UCLINUX */
+
+  /* Phonebook handling */
+  case 0x03:
+    switch (MessageBuffer[3]) {
+      case 0x02:
+      case 0x03:N6110_ReplyGetMemoryLocation(MessageLength,MessageBuffer,MessageType);break;
+      case 0x05:
+      case 0x06:N6110_ReplyWritePhonebookLocation(MessageLength,MessageBuffer,MessageType);break;
+      case 0x08:
+      case 0x09:N6110_ReplyGetMemoryStatus(MessageLength,MessageBuffer,MessageType);break;
+#ifndef UCLINUX
+      case 0x17:
+      case 0x18:N6110_ReplyGetSpeedDial(MessageLength,MessageBuffer,MessageType);break;
+      case 0x1a:
+      case 0x1b:N6110_ReplySetSpeedDial(MessageLength,MessageBuffer,MessageType);break;
+      default  :N6110_Dispatch0x03Message(MessageLength,MessageBuffer,MessageType);break;
+#endif /* UCLINUX */
+    }
+    break;
+
+  /* Phone status */    
+  case 0x04:
+    switch (MessageBuffer[3]) {
+      case 0x02:N6110_ReplyRFBatteryLevel(MessageLength,MessageBuffer,MessageType);break;
+      default  :unknown=true;break;
+    }
+    break;
+      
+#ifndef UCLINUX
+  /* Startup Logo, Operator Logo and Profiles. */
+  case 0x05:
+    switch (MessageBuffer[3]) {
+      case 0x11:N6110_ReplySetProfile    (MessageLength,MessageBuffer,MessageType);break;
+      case 0x14:N6110_ReplyGetProfile    (MessageLength,MessageBuffer,MessageType);break;
+      case 0x1b:N6110_ReplyGetProfile    (MessageLength,MessageBuffer,MessageType);break;
+      case 0x1d:N6110_ReplySetProfile    (MessageLength,MessageBuffer,MessageType);break;
+      case 0x37:N6110_ReplySetRingtone   (MessageLength,MessageBuffer,MessageType);break;
+      case 0x38:N6110_ReplySetRingtone   (MessageLength,MessageBuffer,MessageType);break;
+      default  :N6110_Dispatch0x05Message(MessageLength,MessageBuffer,MessageType);break;
+    }
+    break;
+
+  /* Network Operator Message to handset -> Gerry Anderson & prepaid info */
+  /* Call diverts */
+  case 0x06:
+    switch (MessageBuffer[3]) {
+      case 0x02:
+      case 0x03:N6110_ReplyCallDivert    (MessageLength,MessageBuffer,MessageType);break;
+      default  :N6110_Dispatch0x06Message(MessageLength,MessageBuffer,MessageType);break;
+    }
+    break;
+
+  /* Security code requests */
+  case 0x08:
+    switch (MessageBuffer[3]) {
+      case 0x08:N6110_ReplyGetSecurityCodeStatus(MessageLength,MessageBuffer,MessageType);break;
+      case 0x0b:N6110_ReplyEnterSecurityCode    (MessageLength,MessageBuffer,MessageType);break;
+      default  :N6110_ReplyEnterSecurityCode    (MessageLength,MessageBuffer,MessageType);break;
+    }
+    break;
+#endif /* UCLINUX */
+
+  /* SIM login */
+  case 0x09:
+
+    N6110_Dispatch0x09Message(MessageLength, MessageBuffer, MessageType);
+    break;
+
+#ifndef UCLINUX
+  /* Network info */
+  case 0x0a:
+    switch (MessageBuffer[3]) {
+      case 0x71:N6110_ReplyGetNetworkInfo(MessageLength,MessageBuffer,MessageType);break;
+      default  :unknown=true;break;
+    }
+    break;
+
+  /* Simulating key pressing */
+  case 0x0c:
+    switch (MessageBuffer[3]) {
+      case 0x43:N6110_ReplyPressKey(MessageLength,MessageBuffer,MessageType);break;
+      default  :unknown=true;break;
+    }
+    break;
+
+  /* Display */
+  case 0x0d:
+    switch (MessageBuffer[3]) {
+      case 0x50:N6110_ReplyDisplayOutput   (MessageLength,MessageBuffer,MessageType);break;
+      case 0x52:N6110_ReplyGetDisplayStatus(MessageLength,MessageBuffer,MessageType);break;
+      case 0x54:N6110_ReplyDisplayOutput   (MessageLength,MessageBuffer,MessageType);break;
+      default  :unknown=true;break;
+    }
+    break;
+
+  /* Phone Clock and Alarm */
+  case 0x11:
+    switch (MessageBuffer[3]) {
+      case 0x61:N6110_ReplySetDateTime(MessageLength,MessageBuffer,MessageType);break;
+      case 0x63:N6110_ReplyGetDateTime(MessageLength,MessageBuffer,MessageType);break;
+      case 0x6c:N6110_ReplySetAlarm   (MessageLength,MessageBuffer,MessageType);break;
+      case 0x6e:N6110_ReplyGetAlarm   (MessageLength,MessageBuffer,MessageType);break;
+      default  :unknown=true;break;
+    }
+    break;
+
+  /* Calendar notes handling */
+  case 0x13:
+    switch (MessageBuffer[3]) {
+      case 0x65:N6110_ReplyWriteCalendarNote (MessageLength,MessageBuffer,MessageType);break;
+      case 0x67:N6110_ReplyGetCalendarNote   (MessageLength,MessageBuffer,MessageType);break;
+      case 0x69:N6110_ReplyDeleteCalendarNote(MessageLength,MessageBuffer,MessageType);break;
+      default  :N6110_Dispatch0x13Message    (MessageLength,MessageBuffer,MessageType);break;
+    }
+    break;
+
+  /* SMS Messages */
+  case 0x14:
+    switch (MessageBuffer[3]) {
+      case 0x05:
+      case 0x06:N6110_ReplySaveSMSMessage  (MessageLength,MessageBuffer,MessageType);break;
+      case 0x08:
+      case 0x09:N6110_ReplyGetSMSMessage   (MessageLength,MessageBuffer,MessageType);break;
+      case 0x0b:N6110_ReplyDeleteSMSMessage(MessageLength,MessageBuffer,MessageType);break;
+      case 0x37:
+      case 0x38:N6110_ReplyGetSMSStatus    (MessageLength,MessageBuffer,MessageType);break;
+      default  :unknown=true;break;
+    }
+    break;
+
+  /* WAP */
+  case 0x3f:
+    switch (MessageBuffer[3]) {
+      case 0x01:
+      case 0x02:N7110_ReplyEnableWAPCommands(MessageLength,MessageBuffer,MessageType);break;
+      case 0x07:
+      case 0x08:N7110_ReplyGetWAPBookmark   (MessageLength,MessageBuffer,MessageType);break;
+      case 0x0a:
+      case 0x0b:N7110_ReplySetWAPBookmark   (MessageLength,MessageBuffer,MessageType);break;
+      case 0x16:
+      case 0x17:
+      case 0x1c:N7110_ReplyGetWAPSettings   (MessageLength,MessageBuffer,MessageType);break;
+      default  :unknown=true;break;
+    }
+    break;
+#endif /* UCLINUX */
+
+  /* Internal phone functions? */
+  case 0x40:
+    switch (MessageBuffer[2]) {
+      case 0x64:N6110_ReplyEnableExtendedCommands  (MessageLength,MessageBuffer,MessageType);break;
+#ifndef UCLINUX
+      case 0x65:N6110_ReplyResetPhoneSettings      (MessageLength,MessageBuffer,MessageType);break;
+#endif /* UCLINUX */
+      case 0x66:N6110_ReplyIMEI                    (MessageLength,MessageBuffer,MessageType);break;
+#ifndef UCLINUX
+      case 0x6a:N6110_ReplyGetProductProfileSetting(MessageLength,MessageBuffer,MessageType);break;
+      case 0x6b:N6110_ReplySetProductProfileSetting(MessageLength,MessageBuffer,MessageType);break;
+      case 0x6e:N6110_ReplyGetSecurityCode         (MessageLength,MessageBuffer,MessageType);break;
+      case 0x7e:N6110_ReplyNetmonitor              (MessageLength,MessageBuffer,MessageType);break;
+      case 0x8a:N6110_ReplySimlockInfo             (MessageLength,MessageBuffer,MessageType);break;
+      case 0x8b:N6110_ReplySetOperatorName         (MessageLength,MessageBuffer,MessageType);break;
+      case 0x8c:N6110_ReplyGetOperatorName         (MessageLength,MessageBuffer,MessageType);break;
+      case 0x8f:N6110_ReplyPlayTone                (MessageLength,MessageBuffer,MessageType);break;
+      case 0x9e:N6110_ReplyGetBinRingtone          (MessageLength,MessageBuffer,MessageType);break;
+      case 0xa0:N6110_ReplySetBinRingtone          (MessageLength,MessageBuffer,MessageType);break;
+#endif /* UCLINUX */
+      case 0xc8:N6110_ReplyHW                      (MessageLength,MessageBuffer,MessageType);break;
+      default  :N6110_Dispatch0x40Message          (MessageLength,MessageBuffer,MessageType);break;
+    }
+    break;
+
+#ifndef UCLINUX
+  /* Picture Images */
+  case 0x47:
+
+    N6110_Dispatch0x47Message(MessageLength, MessageBuffer, MessageType);
+    break;
+#endif /* UCLINUX */
+
+  /* Mobile phone identification */
+  case 0x64:
+
+    N6110_ReplyGetAuthentication(MessageLength, MessageBuffer, MessageType);
+    break;
+
+  /***** Acknowlegment of our frames. *****/
+  case FBUS_FRTYPE_ACK:
+
+    N6110_DispatchACKMessage(MessageLength, MessageBuffer, MessageType);
+    break;
+
+  /***** Power on message. *****/
+  case 0xd0:
+
+    N6110_Dispatch0xD0Message(MessageLength, MessageBuffer, MessageType);
+    break;
+
+  case 0xd2:
+
+    N6110_ReplyID(MessageLength, MessageBuffer, MessageType);
+    break;
+  
+  /***** RLP frame received. *****/
+  case 0xf1:
+
+    N6110_RX_HandleRLPMessage(MessageBuffer);
+    break;
+
+  /***** Power on message. *****/
+  case 0xf4:
+
+    N6110_Dispatch0xF4Message(MessageLength, MessageBuffer, MessageType);
+    break;
+
+  /***** Unknown message *****/
+  /* If you think that you know the exact meaning of other messages - please
+     let us know. */
+  default:
+
+#ifdef DEBUG
+    fprintf(stdout, _("Message: Unknown message type.\n"));
+#endif /* DEBUG */
+    AppendLogText("Unknown msg type\n",false);
+
+    unknown=false;
+    break;
+
+  }
+
+  if (unknown) {
+#ifdef DEBUG
+    fprintf(stdout, _("Unknown message of type %02x.\n"),MessageType);
+#endif
+    AppendLogText("Unknown msg\n",false);
+  }
+}
index 392837e..127dd0e 100644 (file)
@@ -11,6 +11,8 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 /* "Turn on" prototypes in n-at.h */
 
 #define __n_at_c 
 /* "Turn on" prototypes in n-at.h */
 
 #define __n_at_c 
index 7536d61..d76c4b0 100644 (file)
@@ -10,6 +10,8 @@
   phones.\r
 \r
 */\r
   phones.\r
 \r
 */\r
+
+#include "config.h"
 \r
 /* "Turn on" prototypes in n-sniff.h */\r
 \r
 \r
 /* "Turn on" prototypes in n-sniff.h */\r
 \r
index 6afbb18..8a6ce21 100644 (file)
@@ -10,6 +10,8 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 /* "Turn on" prototypes in AT.h */
 #define __AT_c 
 
 /* "Turn on" prototypes in AT.h */
 #define __AT_c 
 
@@ -42,7 +44,7 @@ GSM_Protocol AT_Functions = {
 /* Local variables */
 u16 BufferCount;
 
 /* Local variables */
 u16 BufferCount;
 
-u16 MessageLength;
+static u16 MessageLength;
 
 u8 MessageBuffer[AT_MAX_RECEIVE_LENGTH * 6];
 
 
 u8 MessageBuffer[AT_MAX_RECEIVE_LENGTH * 6];
 
index 46a6e8f..2cc8aae 100644 (file)
@@ -10,6 +10,8 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 /* "Turn on" prototypes in fbus.h */
 #define __fbus_c 
 
 /* "Turn on" prototypes in fbus.h */
 #define __fbus_c 
 
 #include "protocol/fbus.h"
 #include "protocol/at.h"
 #include "newmodules/newat.h"
 #include "protocol/fbus.h"
 #include "protocol/at.h"
 #include "newmodules/newat.h"
+#ifndef UCLINUX
 #include "newmodules/n6110.h"
 #include "newmodules/n6110.h"
+#endif /* UCLINUX */
 #include "misc.h"
 
 #include "misc.h"
 
+static GSM_Error FBUS_Initialise(char *port_device, char *initlength,
+                          GSM_ConnectionType connection,
+                          void (*rlp_callback)(RLP_F96Frame *frame));
+
+static int FBUS_SendMessage(u16 message_length, u8 message_type, u8 *buffer);
+static int FBUS_SendFrame(u16 message_length, u8 message_type, u8 *buffer);
+static void FBUS_Terminate(void);
+static void FBUS_RX_StateMachine(unsigned char rx_byte);
+
 GSM_Protocol FBUS_Functions = {
   FBUS_Initialise,
   FBUS_SendMessage,
 GSM_Protocol FBUS_Functions = {
   FBUS_Initialise,
   FBUS_SendMessage,
@@ -44,24 +57,24 @@ GSM_Protocol FBUS_Functions = {
 };
 
 /* Local variables */
 };
 
 /* Local variables */
-enum FBUS_RX_States RX_State;
+static enum FBUS_RX_States RX_State;
 
 
-u8 MessageDestination, MessageSource;
+static u8 MessageDestination, MessageSource;
 
 
-u16 BufferCount, MultiBufferCount;
+static u16 BufferCount;
 
 
-u16 MessageLength, MultiMessageLength;
+static u16 MessageLength, MultiMessageLength;
 
 
-bool RX_Multiple = false;
+static bool RX_Multiple = false;
 
 
-u8 MessageType,MultiMessageType;
+static u8 MessageType,MultiMessageType;
 
 
-u8 MessageBuffer[FBUS_MAX_RECEIVE_LENGTH * 6],MultiMessageBuffer[FBUS_MAX_RECEIVE_LENGTH * 6];
+static u8 MessageBuffer[FBUS_MAX_RECEIVE_LENGTH * 6],MultiMessageBuffer[FBUS_MAX_RECEIVE_LENGTH * 6];
 
 
-u8        RequestSequenceNumber = 0x00;
+static u8        RequestSequenceNumber = 0x00;
 
 #ifdef DEBUG   
 
 #ifdef DEBUG   
-char *N61_PrintDevice(int Device)
+static char *N61_PrintDevice(int Device)
 {
   switch (Device) {
 
 {
   switch (Device) {
 
@@ -75,7 +88,7 @@ char *N61_PrintDevice(int Device)
 /* N61_RX_DisplayMessage is called when a message we don't know about is
    received so that the user can see what is going back and forth, and perhaps
    shed some more light/explain another message type! */
 /* N61_RX_DisplayMessage is called when a message we don't know about is
    received so that the user can see what is going back and forth, and perhaps
    shed some more light/explain another message type! */
-void N61_RX_DisplayMessage()
+static void N61_RX_DisplayMessage()
 {
 #ifdef DEBUG
   fprintf(stdout, _("Msg Dest: %s\n"), N61_PrintDevice(MessageDestination));
 {
 #ifdef DEBUG
   fprintf(stdout, _("Msg Dest: %s\n"), N61_PrintDevice(MessageDestination));
@@ -203,7 +216,7 @@ int FBUS_SendMessage(u16 message_length, u8 message_type, u8 *buffer) {
   return (true);
 }
 
   return (true);
 }
 
-int FBUS_SendAck(u8 message_type, u8 message_seq) {
+static int FBUS_SendAck(u8 message_type, u8 message_seq) {
 
   unsigned char request[6];
 
 
   unsigned char request[6];
 
@@ -276,8 +289,8 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) {
   case FBUS_RX_Sync:
 
       if ((CurrentConnectionType==GCT_FBUS && rx_byte == FBUS_FRAME_ID) ||
   case FBUS_RX_Sync:
 
       if ((CurrentConnectionType==GCT_FBUS && rx_byte == FBUS_FRAME_ID) ||
-          ((CurrentConnectionType==GCT_Infrared ||
-          CurrentConnectionType==GCT_Tekram) && rx_byte == FBUS_IR_FRAME_ID)) {
+          0/*((CurrentConnectionType==GCT_Infrared ||
+          CurrentConnectionType==GCT_Tekram) && rx_byte == FBUS_IR_FRAME_ID)*/) {
 
         BufferCount = 0;
 
 
         BufferCount = 0;
 
@@ -511,7 +524,7 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) {
 }
   
 /* Called by initialisation code to open comm port in asynchronous mode. */
 }
   
 /* Called by initialisation code to open comm port in asynchronous mode. */
-bool FBUS_OpenSerial(void)
+static bool FBUS_OpenSerial(void)
 {
   /* Uncomment, if want to test first method for DLR3 */
 //  unsigned char req[3] = {"AT\r"};  
 {
   /* Uncomment, if want to test first method for DLR3 */
 //  unsigned char req[3] = {"AT\r"};  
@@ -547,6 +560,7 @@ bool FBUS_OpenSerial(void)
        device_setdtrrts(1, 0);
 
        break;
        device_setdtrrts(1, 0);
 
        break;
+#ifndef UCLINUX
      case GCT_DLR3:
 
 #ifdef DEBUG
      case GCT_DLR3:
 
 #ifdef DEBUG
@@ -627,6 +641,7 @@ bool FBUS_OpenSerial(void)
        /* It's more complicated and not done here */
        break;
 
        /* It's more complicated and not done here */
        break;
 
+#endif /* UCLINUX */
      default:
 #ifdef DEBUG
        fprintf(stdout,_("Wrong connection type for fbus module. Inform marcin-wiacek@topnet.pl about it\n"));
      default:
 #ifdef DEBUG
        fprintf(stdout,_("Wrong connection type for fbus module. Inform marcin-wiacek@topnet.pl about it\n"));
@@ -638,7 +653,7 @@ bool FBUS_OpenSerial(void)
 }
 
 /* Initialise variables and state machine. */
 }
 
 /* Initialise variables and state machine. */
-GSM_Error FBUS_Initialise(char *port_device, char *initlength,
+static GSM_Error FBUS_Initialise(char *port_device, char *initlength,
                           GSM_ConnectionType connection,
                           void (*rlp_callback)(RLP_F96Frame *frame))
 {
                           GSM_ConnectionType connection,
                           void (*rlp_callback)(RLP_F96Frame *frame))
 {
index b84ae9d..d2180af 100644 (file)
@@ -10,6 +10,8 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 /* "Turn on" prototypes in fbusirda.h */
 #define __fbusirda_c 
 
 /* "Turn on" prototypes in fbusirda.h */
 #define __fbusirda_c 
 
index b7cd0ba..a81cd4d 100644 (file)
@@ -10,6 +10,8 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 /* "Turn on" prototypes in MBUS.h */
 #define __MBUS_c 
 
 /* "Turn on" prototypes in MBUS.h */
 #define __MBUS_c 
 
index 87ea315..21b3fa6 100644 (file)
@@ -15,13 +15,17 @@ AC_CANONICAL_SYSTEM
 AC_PREFIX_DEFAULT("/usr/local")
 
 dnl ======================== Default setting
 AC_PREFIX_DEFAULT("/usr/local")
 
 dnl ======================== Default setting
-CFLAGS="-O2 -Wall"
+test -n "$CFLAGS"   || export CFLAGS="-O2 -Wall"
 ALL_LINGUAS="cs de et fi nl sk pl it"
 
 dnl ======================== Checks for programs.
 AC_PROG_CC
 ALL_LINGUAS="cs de et fi nl sk pl it"
 
 dnl ======================== Checks for programs.
 AC_PROG_CC
+AC_LANG_C
 AC_PROG_CPP
 AC_PROG_LEX
 AC_PROG_CPP
 AC_PROG_LEX
+if test -z "$AR";then
+       AC_PATH_PROG(AR, ar, no)
+fi
 AC_PATH_PROG(RM, rm, no)
 AC_PATH_PROG(FIND, find, no)
 AC_CHECK_PROGS(MAKE, gmake make)
 AC_PATH_PROG(RM, rm, no)
 AC_PATH_PROG(FIND, find, no)
 AC_CHECK_PROGS(MAKE, gmake make)
@@ -30,9 +34,22 @@ AC_PROG_INSTALL
 dnl Let us have $prefix variable aviable here
 test x"$prefix" = xNONE && prefix="$ac_default_prefix"
 
 dnl Let us have $prefix variable aviable here
 test x"$prefix" = xNONE && prefix="$ac_default_prefix"
 
+AC_ARG_WITH(cfg_model,
+       [  --with-cfg-model=5110   specifies the mobile phone model],,
+       [ with_cfg_model="5110" ])
+AC_DEFINE_UNQUOTED(CONFIG_CFG_MODEL, "$with_cfg_model")
+AC_ARG_WITH(cfg_port,
+       [  --with-cfg-port=/dev/ttyS0 specifies the mobile phone port],,
+       [ with_cfg_port="/dev/ttyS0" ])
+AC_DEFINE_UNQUOTED(CONFIG_CFG_PORT, "$with_cfg_port")
+AC_ARG_WITH(cfg_initlength,
+       [  --with-cfg-initlength=default specifies the mobile phone initlength],,
+       [ with_cfg_initlength="default" ])
+AC_DEFINE_UNQUOTED(CONFIG_CFG_INITLENGTH, "$with_cfg_initlength")
+
 AC_ARG_ENABLE(debug, 
        [  --enable-debug          compile with debug code],
 AC_ARG_ENABLE(debug, 
        [  --enable-debug          compile with debug code],
-       [ CFLAGS="-g -Wall"
+       [ #CFLAGS="-g -Wall"
          AC_DEFINE(DEBUG)
          debug="yes" ],
        [ debug="no"  ]
          AC_DEFINE(DEBUG)
          debug="yes" ],
        [ debug="no"  ]
@@ -70,9 +87,9 @@ AC_ARG_WITH(libintl,
 )
 
 AC_ARG_ENABLE(nls,
 )
 
 AC_ARG_ENABLE(nls,
-       [  --disable-nls           do not use NLS],
+       [  --enable-nls            force use of NLS],
        [ USE_NLS=$enableval ],
        [ USE_NLS=$enableval ],
-       [ USE_NLS=yes ]
+       [ USE_NLS=no ]
 )
 
 if test "$USE_NLS" = "yes"; then
 )
 
 if test "$USE_NLS" = "yes"; then
@@ -222,7 +239,7 @@ if test "x$PTHREAD_LIBS" = xerror; then
 fi
 
 dnl FIXME: do we really test here if libc contains this function?
 fi
 
 dnl FIXME: do we really test here if libc contains this function?
-if test "x$PTHREAD_LIBS" = xerror; then
+if test "x$PTHREAD_LIBS" = xerror -a "x$cross_compiling" = xno; then
    AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="",
       AC_MSG_ERROR(not found library: pthread !!!))
 fi
    AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="",
       AC_MSG_ERROR(not found library: pthread !!!))
 fi
@@ -444,8 +461,8 @@ LIBS="$LIBS $NLS_LIBS"
 
 PACKAGE=gnokii
 XPACKAGE=xgnokii
 
 PACKAGE=gnokii
 XPACKAGE=xgnokii
-VERSION=`cat VERSION`
-XVERSION=`cat xgnokii/VERSION`
+AC_DEFINE_UNQUOTED(VERSION, "`cat VERSION`")
+AC_DEFINE_UNQUOTED(XVERSION, "`cat xgnokii/VERSION`")
 HAVE_XGNOKII=$x_support
 
 case "$INSTALL" in
 HAVE_XGNOKII=$x_support
 
 case "$INSTALL" in
@@ -465,6 +482,7 @@ AC_CONFIG_HEADER(include/config.h)
 
 AC_SUBST(PACKAGE)
 AC_SUBST(VERSION)
 
 AC_SUBST(PACKAGE)
 AC_SUBST(VERSION)
+AC_SUBST(AR)
 AC_SUBST(XVERSION)
 AC_SUBST(XPACKAGE)
 AC_SUBST(XGNOKIIDIR)
 AC_SUBST(XVERSION)
 AC_SUBST(XPACKAGE)
 AC_SUBST(XGNOKIIDIR)
@@ -482,7 +500,6 @@ AC_SUBST(USE_UNIX98PTYS)
 AC_SUBST(HAVE_XGNOKII)
 
 AC_OUTPUT(
 AC_SUBST(HAVE_XGNOKII)
 
 AC_OUTPUT(
-   include/config.h.in
    Makefile.global
    po/Makefile.in
    packaging/RedHat/gnokii.spec
    Makefile.global
    po/Makefile.in
    packaging/RedHat/gnokii.spec
diff --git a/do b/do
new file mode 100755 (executable)
index 0000000..ec3e051
--- /dev/null
+++ b/do
@@ -0,0 +1,24 @@
+#! /bin/sh
+
+#target_m68k=1
+enable_debug=1
+cfg_port="ttyS0"
+
+exec 2>&1
+set -ex
+rm -f config.cache
+autoheader
+autoconf
+# rm -f config.cache
+if [ -n "$target_m68k" ];then
+       test -n "$CC"       || export CC="m68k-pic-coff-gcc"
+       test -n "$AR"       || export AR="m68k-pic-coff-ar"
+       test -n "$CFLAGS"   || export CFLAGS="-O2 -Wall -fPIC"
+       test -n "$CPPFLAGS" || export CPPFLAGS="-DUCCOMPAT=1 $CPPFLAGS"
+       test -n "$LDFLAGS"  || export LDFLAGS="gnokii/cleanup.c"
+fi
+export CPPFLAGS="-DUCLINUX=1 $CPPFLAGS"
+./configure --with-cfg-model=5110 --with-cfg-port=/dev/"$cfg_port" --without-x \
+               `if [ -n "$enable_debug" ];then echo "--enable-debug --enable-xdebug";fi`
+make clean
+make
index 7b4f938..01a8184 100644 (file)
@@ -121,6 +121,9 @@ int opterr = 1;
    This must be initialized on some systems to avoid linking in the
    system's own getopt implementation.  */
 
    This must be initialized on some systems to avoid linking in the
    system's own getopt implementation.  */
 
+#ifdef UCLINUX
+static
+#endif /* UCLINUX */
 int optopt = '?';
 
 /* Describe how to deal with options that follow non-option ARGV-elements.
 int optopt = '?';
 
 /* Describe how to deal with options that follow non-option ARGV-elements.
@@ -666,6 +669,8 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
   }
 }
 
   }
 }
 
+#ifndef UCLINUX
+
 int
 getopt (argc, argv, optstring)
      int argc;
 int
 getopt (argc, argv, optstring)
      int argc;
@@ -678,6 +683,8 @@ getopt (argc, argv, optstring)
                           0);
 }
 
                           0);
 }
 
+#endif /* UCLINUX */
+
 #endif /* _LIBC or not __GNU_LIBRARY__.  */
 \f
 #ifdef TEST
 #endif /* _LIBC or not __GNU_LIBRARY__.  */
 \f
 #ifdef TEST
index de8e2ad..a78fbf4 100644 (file)
@@ -75,6 +75,8 @@ getopt_long (argc, argv, options, long_options, opt_index)
    but does match a short option, it is parsed as a short option
    instead.  */
 
    but does match a short option, it is parsed as a short option
    instead.  */
 
+#ifndef UCLINUX
+
 int
 getopt_long_only (argc, argv, options, long_options, opt_index)
      int argc;
 int
 getopt_long_only (argc, argv, options, long_options, opt_index)
      int argc;
@@ -86,6 +88,8 @@ getopt_long_only (argc, argv, options, long_options, opt_index)
   return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
 }
 
   return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
 }
 
+#endif /* UCLINUX */
+
 
 #endif /* _LIBC or not __GNU_LIBRARY__.  */
 \f
 
 #endif /* _LIBC or not __GNU_LIBRARY__.  */
 \f
index 2018e7d..9783b42 100644 (file)
@@ -22,11 +22,15 @@ endif
 
 all: gnokii
 
 
 all: gnokii
 
-gnokii: $(OBJS) $(TOPDIR)/common/COMMON.o $(TOPDIR)/common/gsm-filetypes.o
-       $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LOADLIBES) $(LDLIBS) -o $@
+gnokii: $(OBJS) $(TOPDIR)/common/data.a $(TOPDIR)/common/common.a cleanup.o # $(TOPDIR)/common/gsm-filetypes.o
+       $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ -o $@
+#-L../common -lcommon ##$(LOADLIBES) $(LDLIBS)
 
 
-$(TOPDIR)/common/COMMON.o: 
-       $(MAKE) -C $(TOPDIR)/common COMMON.o
+$(TOPDIR)/common/common.a: 
+       $(MAKE) -C $(TOPDIR)/common common.a
+
+$(TOPDIR)/common/data.a:
+       $(MAKE) -C $(TOPDIR)/common data.a
 
 $(TOPDIR)/common/gsm-filetypes.o: 
        $(MAKE) -C $(TOPDIR)/common gsm-filetypes.o
 
 $(TOPDIR)/common/gsm-filetypes.o: 
        $(MAKE) -C $(TOPDIR)/common gsm-filetypes.o
@@ -43,7 +47,7 @@ gnokiilib: $(OBJS) $(TOPDIR)/common/libmygnokii.so
 makelib: gnokiilib
 
 clean:
 makelib: gnokiilib
 
 clean:
-       $(RM) $(OBJS) *~ depend gnokii gnokiilib *.exe core *.bak
+       $(RM) $(OBJS) cleanup.o *~ depend gnokii gnokiilib *.exe core *.bak
 
 install: all
        $(INSTALL) -d $(bindir)
 
 install: all
        $(INSTALL) -d $(bindir)
index 9daceb9..82b2b8b 100644 (file)
@@ -11,6 +11,8 @@
 
 */
 
 
 */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <time.h>
 #include <sys/stat.h>
 
 #include <time.h>
 #include <sys/stat.h>
 
+#ifdef UCLINUX
+/* <getopt.h> or "getopt.h" would include insufficient getopt.h from uClinux */
+#include "../getopt/getopt.h"
+#endif /* UCLINUX */
+
 #ifndef VC6
   #if defined(__svr4__) || defined(__FreeBSD__)
   #  include <strings.h>       /* for bzero */
 #ifndef VC6
   #if defined(__svr4__) || defined(__FreeBSD__)
   #  include <strings.h>       /* for bzero */
 #include "gsm-common.h"
 #include "gsm-api.h"
 #include "gsm-networks.h"
 #include "gsm-common.h"
 #include "gsm-api.h"
 #include "gsm-networks.h"
+#ifndef UCLINUX
 #include "gsm-ringtones.h"
 #include "gsm-bitmaps.h"
 #include "gsm-wap.h"
 #include "gsm-sms.h"
 #include "gsm-datetime.h"
 #include "gsm-ringtones.h"
 #include "gsm-bitmaps.h"
 #include "gsm-wap.h"
 #include "gsm-sms.h"
 #include "gsm-datetime.h"
+#endif /* UCLINUX */
 #include "gsm-phonebook.h"
 #include "gsm-phonebook.h"
+#ifndef UCLINUX
 #include "gsm-calendar.h"
 #include "gsm-calendar.h"
+#endif /* UCLINUX */
 #include "gsm-coding.h"
 #include "gsm-coding.h"
+#ifndef UCLINUX
 #include "newmodules/n6110.h"
 #include "newmodules/n6110.h"
+#endif
 #include "files/cfgreader.h"
 #include "files/cfgreader.h"
+#ifndef UCLINUX
 #include "files/gsm-filetypes.h"
 #include "files/gsm-filetypes.h"
+#endif /* UCLINUX */
 #include "gnokii.h"
 #include "gnokii.h"
+#ifdef UCLINUX
+#include "data/virtmodem.h"
+#endif /* UCLINUX */
 
 #ifdef USE_NLS
   #include <locale.h>
 #endif
 
 
 #ifdef USE_NLS
   #include <locale.h>
 #endif
 
-char *model;           /* Model from .gnokiirc file. */
-char *Port;            /* Port from .gnokiirc file */
-char *Initlength;      /* Init length from .gnokiirc file */
-char *Connection;      /* Connection type from .gnokiirc file */
+static char *model;           /* Model from .gnokiirc file. */
+static char *Port;            /* Port from .gnokiirc file */
+static char *Initlength;      /* Init length from .gnokiirc file */
+static char *Connection;      /* Connection type from .gnokiirc file */
+#ifndef UCLINUX
 char *SynchronizeTime; /* If we set date and time from computer to phone (from .gnokiirc file) */
 char *SynchronizeTime; /* If we set date and time from computer to phone (from .gnokiirc file) */
-char *BinDir;          /* Binaries directory from .gnokiirc file - not used here yet */
+#endif /* UCLINUX */
+static char *BinDir;          /* Binaries directory from .gnokiirc file - not used here yet */
 
 
-GSM_SMSMessage SMS[4];
+#ifdef DEBUG
+static GSM_SMSMessage SMS[4];
+#endif
   
   
+#ifndef UCLINUX
+
 char *GetProfileCallAlertString(int code) {
 
   switch (code) {
 char *GetProfileCallAlertString(int code) {
 
   switch (code) {
@@ -214,7 +238,7 @@ char *GetProfileCallerGroups(int code)
   return BufferProfileGroups;
 }
 
   return BufferProfileGroups;
 }
 
-char *print_error(GSM_Error e)
+static char *print_error(GSM_Error e)
 {
 
 //     case GE_DEVICEOPENFAILED:         return "Couldn't open specified serial device.";
 {
 
 //     case GE_DEVICEOPENFAILED:         return "Couldn't open specified serial device.";
@@ -264,7 +288,6 @@ char *print_error(GSM_Error e)
        }
 }
 
        }
 }
 
-
 GSM_Error GSM_ReadRingtoneFileOnConsole(char *FileName, GSM_Ringtone *ringtone)
 {
   GSM_Error error;
 GSM_Error GSM_ReadRingtoneFileOnConsole(char *FileName, GSM_Ringtone *ringtone)
 {
   GSM_Error error;
@@ -537,7 +560,9 @@ int GSM_SendMultiPartSMSOnConsole(GSM_MultiSMSMessage *MultiSMS, int argnum, int
   return 0;
 }
 
   return 0;
 }
 
-int GSM_SaveMultiPartSMSOnConsole(GSM_MultiSMSMessage *MultiSMS, int argnum, int argc, char *argv[],
+#endif /* UCLINUX */
+
+static int GSM_SaveMultiPartSMSOnConsole(GSM_MultiSMSMessage *MultiSMS, int argnum, int argc, char *argv[],
                                   bool inter, bool unicode, bool profile, bool scale) {
 
   int w,i;
                                   bool inter, bool unicode, bool profile, bool scale) {
 
   int w,i;
@@ -663,6 +688,8 @@ int GSM_SaveMultiPartSMSOnConsole(GSM_MultiSMSMessage *MultiSMS, int argnum, int
   return 0;
 }
 
   return 0;
 }
 
+#ifndef UCLINUX
+
 void GSM_PlayRingtoneOnConsole(GSM_Ringtone *ringtone)
 {
   int i;
 void GSM_PlayRingtoneOnConsole(GSM_Ringtone *ringtone)
 {
   int i;
@@ -682,9 +709,11 @@ void GSM_PlayRingtoneOnConsole(GSM_Ringtone *ringtone)
   GSM->PlayTone(255*255,0);
 }
 
   GSM->PlayTone(255*255,0);
 }
 
+#endif /* UCLINUX */
+
 /* This function shows the copyright and some informations usefull for
    debugging. */
 /* This function shows the copyright and some informations usefull for
    debugging. */
-int version(void)
+static int version(void)
 {
 
   fprintf(stdout, _("GNOKII Version %s\n"
 {
 
   fprintf(stdout, _("GNOKII Version %s\n"
@@ -698,22 +727,48 @@ int version(void)
 /* The function usage is only informative - it prints this program's usage and
    command-line options. */
 
 /* The function usage is only informative - it prints this program's usage and
    command-line options. */
 
-int usage(void)
+static int usage(void)
 {
 
 {
 
-  fprintf(stdout, _("   usage: gnokii [--help|--monitor [-noloop|-nl]|--version]\n"
+  fprintf(stdout, _("   usage: gnokii [--help] [--version]\n"
+  ));
+#ifndef UCLINUX
+"          gnokii --monitor [-noloop|-nl]\n"
+  ));
+#endif /* UCLINUX */
+
+  fprintf(stdout, _(
 "          gnokii --getmemory memory_type [start [end]] [-short|-v30|-v21|-v]\n"
 "          gnokii --writephonebook [-i]\n"
 "          gnokii --getmemory memory_type [start [end]] [-short|-v30|-v21|-v]\n"
 "          gnokii --writephonebook [-i]\n"
+  ));
+
+#ifndef UCLINUX
+  fprintf(stdout, _(
 "          gnokii --sendphonebookentry destination memory_type location\n"
 "                 [--smsc message_center_number] [--smscno message_center_index]\n"
 "                 [-s] [-v n] [-d]\n"
 "          gnokii --sendphonebookentry destination memory_type location\n"
 "                 [--smsc message_center_number] [--smscno message_center_index]\n"
 "                 [-s] [-v n] [-d]\n"
+  ));
+#endif /* UCLINUX */
+
+  fprintf(stdout, _(
 "          gnokii --savephonebookentry memory_type location\n"
 "                 [--smsc message_center_number] [--smscno message_center_index]\n"
 "                 [-r] [-i] [-s] [-a] [--name name]\n"
 "          gnokii --savephonebookentry memory_type location\n"
 "                 [--smsc message_center_number] [--smscno message_center_index]\n"
 "                 [-r] [-i] [-s] [-a] [--name name]\n"
+  ));
+
+#ifndef UCLINUX
+  fprintf(stdout, _(
 "          gnokii --getvoicemailbox\n"
 "          gnokii --getvoicemailbox\n"
+  ));
+#endif /* UCLINUX */
+
+  fprintf(stdout, _(
 "          gnokii --getspeeddial number\n"
 "          gnokii --setspeeddial number memory_type location\n\n"
 "          gnokii --getspeeddial number\n"
 "          gnokii --setspeeddial number memory_type location\n\n"
+  ));
 
 
+#ifndef UCLINUX
+  fprintf(stdout, _(
 "          gnokii --getsms memory_type start [end] [-f file]\n"
 "          gnokii --getsmsstatus\n"
 "          gnokii --getsmsfolders\n"
 "          gnokii --getsms memory_type start [end] [-f file]\n"
 "          gnokii --getsmsstatus\n"
 "          gnokii --getsmsfolders\n"
@@ -814,10 +869,25 @@ int usage(void)
 "          gnokii --sendprofile destination profile_name ringtonefile\n"
 "                 picturefile [--smsc message_center_number]\n"
 "                 [--smscno message_center_index] [-s] [-v n] [-d] [--scale]\n\n"
 "          gnokii --sendprofile destination profile_name ringtonefile\n"
 "                 picturefile [--smsc message_center_number]\n"
 "                 [--smscno message_center_index] [-s] [-v n] [-d] [--scale]\n\n"
+  ));
+#endif /* UCLINUX */
 
 
+  fprintf(stdout, _(
 "          gnokii --reset [soft|hard]\n"
 "          gnokii --reset [soft|hard]\n"
+  ));
+
+#ifndef UCLINUX
+  fprintf(stdout, _(
 "          gnokii --dialvoice number\n"
 "          gnokii --dialvoice number\n"
+  ));
+#endif /* UCLINUX */
+
+  fprintf(stdout, _(
 "          gnokii --cancelcall\n"
 "          gnokii --cancelcall\n"
+  ));
+
+#ifndef UCLINUX
+  fprintf(stdout, _(
 "          gnokii --displayoutput\n"
 "          gnokii --presskeysequence sequence\n"
 "          gnokii --backupsettings file\n"
 "          gnokii --displayoutput\n"
 "          gnokii --presskeysequence sequence\n"
 "          gnokii --backupsettings file\n"
@@ -834,8 +904,15 @@ int usage(void)
 "          gnokii --phonetests\n"
 "          gnokii --simlock\n"
 "          gnokii --getdisplaystatus\n"
 "          gnokii --phonetests\n"
 "          gnokii --simlock\n"
 "          gnokii --getdisplaystatus\n"
+  ));
+#endif /* UCLINUX */
+
+  fprintf(stdout, _(
 "          gnokii --identify\n\n"
 "          gnokii --identify\n\n"
+  ));
 
 
+#ifndef UCLINUX
+  fprintf(stdout, _(
 "          gnokii --getwapbookmark location\n"
 "          gnokii --setwapbookmark title url [location]\n"
 "          gnokii --sendwapbookmark location destination\n"
 "          gnokii --getwapbookmark location\n"
 "          gnokii --setwapbookmark title url [location]\n"
 "          gnokii --sendwapbookmark location destination\n"
@@ -870,13 +947,21 @@ int usage(void)
   ));
 #endif
 
   ));
 #endif
 
+#endif /* UCLINUX */
+
+#ifdef UCLINUX
+  fprintf(stdout, _(
+"          gnokii --gnokiid [--debug]\n"
+  ));
+#endif
+
   return 0;
 }
 
 /* fbusinit is the generic function which waits for the FBUS link. The limit
    is 10 seconds. After 10 seconds we quit. */
 
   return 0;
 }
 
 /* fbusinit is the generic function which waits for the FBUS link. The limit
    is 10 seconds. After 10 seconds we quit. */
 
-void fbusinit(void (*rlp_handler)(RLP_F96Frame *frame))
+static void fbusinit(void (*rlp_handler)(RLP_F96Frame *frame))
 {
 
   int count=0;
 {
 
   int count=0;
@@ -888,7 +973,7 @@ void fbusinit(void (*rlp_handler)(RLP_F96Frame *frame))
 #endif
 
   /* Initialise the code for the GSM interface. */     
 #endif
 
   /* Initialise the code for the GSM interface. */     
-  error = GSM_Initialise(model, Port, Initlength, GetConnectionTypeFromString(Connection), rlp_handler, SynchronizeTime);
+  error = GSM_Initialise(model, Port, Initlength, GetConnectionTypeFromString(Connection), rlp_handler, ""/*SynchronizeTime*/);
 
   if (error != GE_NONE) {
     fprintf(stderr, _("GSM/FBUS init failed! (Unknown model ?). Quitting.\n"));
 
   if (error != GE_NONE) {
     fprintf(stderr, _("GSM/FBUS init failed! (Unknown model ?). Quitting.\n"));
@@ -909,7 +994,7 @@ void fbusinit(void (*rlp_handler)(RLP_F96Frame *frame))
 /* This function checks that the argument count for a given options is withing
    an allowed range. */
 
 /* This function checks that the argument count for a given options is withing
    an allowed range. */
 
-int checkargs(int opt, struct gnokii_arg_len gals[], int argc)
+static int checkargs(int opt, struct gnokii_arg_len gals[], int argc)
 {
 
   int i;
 {
 
   int i;
@@ -943,6 +1028,8 @@ int checkargs(int opt, struct gnokii_arg_len gals[], int argc)
           else return 1;
 }
 
           else return 1;
 }
 
+static int gnokiid(int argc, char *argv[]);
+
 /* Main function - handles command line arguments, passes them to separate
    functions accordingly. */
 
 /* Main function - handles command line arguments, passes them to separate
    functions accordingly. */
 
@@ -960,14 +1047,19 @@ int main(int argc, char *argv[])
 
     { "help",               no_argument,       NULL, OPT_HELP             },// Display usage.
     { "version",            no_argument,       NULL, OPT_VERSION          },// Display version and build information.
 
     { "help",               no_argument,       NULL, OPT_HELP             },// Display usage.
     { "version",            no_argument,       NULL, OPT_VERSION          },// Display version and build information.
+#ifndef UCLINUX
     { "getsmsfolders",      no_argument,       NULL, OPT_GETSMSFOLDERS    },// Gets SMS folders
     { "getsmsstatus",       no_argument,       NULL, OPT_GETSMSSTATUS     },// Get SMS Folder Status
     { "getsmsfolders",      no_argument,       NULL, OPT_GETSMSFOLDERS    },// Gets SMS folders
     { "getsmsstatus",       no_argument,       NULL, OPT_GETSMSSTATUS     },// Get SMS Folder Status
+#endif /* UCLINUX */
     { "identify",           no_argument,       NULL, OPT_IDENTIFY         },// Identify
     { "identify",           no_argument,       NULL, OPT_IDENTIFY         },// Identify
+#ifndef UCLINUX
     { "pmon",               no_argument,       NULL, OPT_PMON             },// For development purposes: run in passive monitoring mode
     { "foogle",             no_argument,       NULL, OPT_FOOGLE           },// For development purposes: insert you function calls here
     { "getdatetime",        no_argument,       NULL, OPT_GETDATETIME      },// Get date and time mode    
     { "getalarm",           no_argument,       NULL, OPT_GETALARM         },// Get alarm    
     { "pmon",               no_argument,       NULL, OPT_PMON             },// For development purposes: run in passive monitoring mode
     { "foogle",             no_argument,       NULL, OPT_FOOGLE           },// For development purposes: insert you function calls here
     { "getdatetime",        no_argument,       NULL, OPT_GETDATETIME      },// Get date and time mode    
     { "getalarm",           no_argument,       NULL, OPT_GETALARM         },// Get alarm    
+#endif /* UCLINUX */
     { "cancelcall",         no_argument,       NULL, OPT_CANCELCALL       },// Cancel Call    
     { "cancelcall",         no_argument,       NULL, OPT_CANCELCALL       },// Cancel Call    
+#ifndef UCLINUX
     { "getdisplaystatus",   no_argument,       NULL, OPT_GETDISPLAYSTATUS },// Get display status mode    
     { "allringtones",       no_argument,       NULL, OPT_ALLRINGTONES     },/* Displays names of available ringtones */    
     { "displayoutput",      no_argument,       NULL, OPT_DISPLAYOUTPUT    },/* Show texts from phone's display */
     { "getdisplaystatus",   no_argument,       NULL, OPT_GETDISPLAYSTATUS },// Get display status mode    
     { "allringtones",       no_argument,       NULL, OPT_ALLRINGTONES     },/* Displays names of available ringtones */    
     { "displayoutput",      no_argument,       NULL, OPT_DISPLAYOUTPUT    },/* Show texts from phone's display */
@@ -979,8 +1071,10 @@ int main(int argc, char *argv[])
     { "receivesms",         no_argument,       NULL, OPT_RECEIVESMS       },    
     { "setoperatorname",    optional_argument, NULL, OPT_SETOPERATORNAME  },/* Set downloaded operator name */    
     { "setdatetime",        optional_argument, NULL, OPT_SETDATETIME      },// Set date and time    
     { "receivesms",         no_argument,       NULL, OPT_RECEIVESMS       },    
     { "setoperatorname",    optional_argument, NULL, OPT_SETOPERATORNAME  },/* Set downloaded operator name */    
     { "setdatetime",        optional_argument, NULL, OPT_SETDATETIME      },// Set date and time    
+#endif /* UCLINUX */
     { "writephonebook",     optional_argument, NULL, OPT_WRITEPHONEBOOK   },// Write phonebook (memory) mode
     { "reset",              optional_argument, NULL, OPT_RESET            },// Resets the phone
     { "writephonebook",     optional_argument, NULL, OPT_WRITEPHONEBOOK   },// Write phonebook (memory) mode
     { "reset",              optional_argument, NULL, OPT_RESET            },// Resets the phone
+#ifndef UCLINUX
     { "monitor",            optional_argument, NULL, OPT_MONITOR          },// Monitor mode
     { "setlogo",            optional_argument, NULL, OPT_SETLOGO          },// Set logo
     { "getprofile",         optional_argument, NULL, OPT_GETPROFILE       },// Show profile
     { "monitor",            optional_argument, NULL, OPT_MONITOR          },// Monitor mode
     { "setlogo",            optional_argument, NULL, OPT_SETLOGO          },// Set logo
     { "getprofile",         optional_argument, NULL, OPT_GETPROFILE       },// Show profile
@@ -991,11 +1085,15 @@ int main(int argc, char *argv[])
     { "sendcalendarnote",   required_argument, NULL, OPT_SENDCALENDARNOTE },
     { "savecalendarnote",   required_argument, NULL, OPT_SAVECALENDARNOTE },
     { "sendphonebookentry", required_argument, NULL, OPT_SENDPHONEBOOKENTRY},
     { "sendcalendarnote",   required_argument, NULL, OPT_SENDCALENDARNOTE },
     { "savecalendarnote",   required_argument, NULL, OPT_SAVECALENDARNOTE },
     { "sendphonebookentry", required_argument, NULL, OPT_SENDPHONEBOOKENTRY},
+#endif /* UCLINUX */
     { "savephonebookentry", required_argument, NULL, OPT_SAVEPHONEBOOKENTRY},
     { "savephonebookentry", required_argument, NULL, OPT_SAVEPHONEBOOKENTRY},
+#ifndef UCLINUX
     { "deletecalendarnote", required_argument, NULL, OPT_DELCALENDARNOTE  },// Delete calendar note mode    
     { "deletecalendarnote", required_argument, NULL, OPT_DELCALENDARNOTE  },// Delete calendar note mode    
+#endif /* UCLINUX */
     { "getmemory",          required_argument, NULL, OPT_GETMEMORY        },// Get memory mode
     { "getspeeddial",       required_argument, NULL, OPT_GETSPEEDDIAL     },// Get speed dial mode
     { "setspeeddial",       required_argument, NULL, OPT_SETSPEEDDIAL     },// Set speed dial mode
     { "getmemory",          required_argument, NULL, OPT_GETMEMORY        },// Get memory mode
     { "getspeeddial",       required_argument, NULL, OPT_GETSPEEDDIAL     },// Get speed dial mode
     { "setspeeddial",       required_argument, NULL, OPT_SETSPEEDDIAL     },// Set speed dial mode
+#ifndef UCLINUX
     { "getsms",             required_argument, NULL, OPT_GETSMS           },// Get SMS message mode
     { "deletesms",          required_argument, NULL, OPT_DELETESMS        },// Delete SMS message mode
     { "sendsms",            required_argument, NULL, OPT_SENDSMS          },// Send SMS message mode
     { "getsms",             required_argument, NULL, OPT_GETSMS           },// Get SMS message mode
     { "deletesms",          required_argument, NULL, OPT_DELETESMS        },// Delete SMS message mode
     { "sendsms",            required_argument, NULL, OPT_SENDSMS          },// Send SMS message mode
@@ -1047,6 +1145,11 @@ int main(int argc, char *argv[])
     { "sniff",              optional_argument, NULL, OPT_SNIFFER    },// Will show datas from port
     { "decodefile",         required_argument, NULL, OPT_DECODEFILE },//decode input file
 #endif
     { "sniff",              optional_argument, NULL, OPT_SNIFFER    },// Will show datas from port
     { "decodefile",         required_argument, NULL, OPT_DECODEFILE },//decode input file
 #endif
+#endif /* UCLINUX */
+
+#ifdef UCLINUX
+    { "gnokiid",            optional_argument, NULL, OPT_GNOKIID          },// gnokiid mode
+#endif /* UCLINUX */
 
     { 0, 0, 0, 0},
   };
 
     { 0, 0, 0, 0},
   };
@@ -1057,6 +1160,7 @@ int main(int argc, char *argv[])
   struct gnokii_arg_len gals[] =
   {
 
   struct gnokii_arg_len gals[] =
   {
 
+#ifndef UCLINUX
     { OPT_MONITOR,           0, 1, 0 },
 
 #ifdef SECURITY
     { OPT_MONITOR,           0, 1, 0 },
 
 #ifdef SECURITY
@@ -1081,9 +1185,11 @@ int main(int argc, char *argv[])
     { OPT_SAVEPHONEBOOKENTRY,2, 9, 0 },
     { OPT_SENDPHONEBOOKENTRY,3, 9, 0 },
     { OPT_DELCALENDARNOTE,   1, 1, 0 },
     { OPT_SAVEPHONEBOOKENTRY,2, 9, 0 },
     { OPT_SENDPHONEBOOKENTRY,3, 9, 0 },
     { OPT_DELCALENDARNOTE,   1, 1, 0 },
+#endif /* UCLINUX */
     { OPT_GETMEMORY,         2, 4, 0 },
     { OPT_GETSPEEDDIAL,      1, 1, 0 },
     { OPT_SETSPEEDDIAL,      3, 3, 0 },
     { OPT_GETMEMORY,         2, 4, 0 },
     { OPT_GETSPEEDDIAL,      1, 1, 0 },
     { OPT_SETSPEEDDIAL,      3, 3, 0 },
+#ifndef UCLINUX
     { OPT_GETSMS,            2, 5, 0 },
     { OPT_DELETESMS,         2, 3, 0 },
     { OPT_SENDSMS,           1,10, 0 },
     { OPT_GETSMS,            2, 5, 0 },
     { OPT_DELETESMS,         2, 3, 0 },
     { OPT_SENDSMS,           1,10, 0 },
@@ -1101,11 +1207,15 @@ int main(int argc, char *argv[])
     { OPT_SETRINGTONE,       1, 3, 0 },
     { OPT_GETRINGTONE,       1, 2, 0 },
     { OPT_PRESSKEYSEQUENCE,  1, 1, 0 },
     { OPT_SETRINGTONE,       1, 3, 0 },
     { OPT_GETRINGTONE,       1, 2, 0 },
     { OPT_PRESSKEYSEQUENCE,  1, 1, 0 },
+#endif /* UCLINUX */
     { OPT_RESET,             0, 1, 0 },
     { OPT_RESET,             0, 1, 0 },
+#ifndef UCLINUX
     { OPT_GETPROFILE,        0, 1, 0 },
     { OPT_SETPROFILE,        3, 3, 0 },
     { OPT_SENDPROFILE,       4,10, 0 },
     { OPT_GETPROFILE,        0, 1, 0 },
     { OPT_SETPROFILE,        3, 3, 0 },
     { OPT_SENDPROFILE,       4,10, 0 },
+#endif /* UCLINUX */
     { OPT_WRITEPHONEBOOK,    0, 1, 0 },
     { OPT_WRITEPHONEBOOK,    0, 1, 0 },
+#ifndef UCLINUX
     { OPT_PLAYRINGTONE,      1, 1, 0 },
     { OPT_COMPOSER,          1, 1, 0 },
     { OPT_RINGTONECONVERT,   2, 2, 0 },
     { OPT_PLAYRINGTONE,      1, 1, 0 },
     { OPT_COMPOSER,          1, 1, 0 },
     { OPT_RINGTONECONVERT,   2, 2, 0 },
@@ -1124,6 +1234,11 @@ int main(int argc, char *argv[])
     { OPT_SAVEWAPSETTINGS,   1, 9, 0 },
     { OPT_SENDWAPSETTINGS,   2, 9, 0 },
     { OPT_DIVERT,            3, 5, 0 },    
     { OPT_SAVEWAPSETTINGS,   1, 9, 0 },
     { OPT_SENDWAPSETTINGS,   2, 9, 0 },
     { OPT_DIVERT,            3, 5, 0 },    
+#endif /* UCLINUX */
+
+#ifdef UCLINUX
+    { OPT_GNOKIID,           0, 1, 0 },
+#endif /* UCLINUX */
 
     { 0, 0, 0, 0 },
   };
 
     { 0, 0, 0, 0 },
   };
@@ -1143,7 +1258,7 @@ int main(int argc, char *argv[])
 #endif
 
     /* Read config file */
 #endif
 
     /* Read config file */
-    if (CFG_ReadConfig(&model, &Port, &Initlength, &Connection, &BinDir, &SynchronizeTime,false) < 0) {
+    if (CFG_ReadConfig(&model, &Port, &Initlength, &Connection, &BinDir, false) < 0) {
        exit(-1);
     }
 
        exit(-1);
     }
 
@@ -1195,14 +1310,17 @@ int main(int argc, char *argv[])
     // Then, options with no arguments
     case OPT_HELP:                  rc = usage();                   break;
     case OPT_VERSION:               rc = version();                 break;
     // Then, options with no arguments
     case OPT_HELP:                  rc = usage();                   break;
     case OPT_VERSION:               rc = version();                 break;
+#ifndef UCLINUX
     case OPT_MONITOR:               rc = monitormode(nargc, nargv); break;
     case OPT_GETSMSFOLDERS:         rc = getsmsfolders();           break;
     case OPT_GETDATETIME:           rc = getdatetime();             break;
     case OPT_GETALARM:              rc = getalarm();                break;
     case OPT_GETDISPLAYSTATUS:      rc = getdisplaystatus();        break;
     case OPT_PMON:                  rc = pmon();                    break;
     case OPT_MONITOR:               rc = monitormode(nargc, nargv); break;
     case OPT_GETSMSFOLDERS:         rc = getsmsfolders();           break;
     case OPT_GETDATETIME:           rc = getdatetime();             break;
     case OPT_GETALARM:              rc = getalarm();                break;
     case OPT_GETDISPLAYSTATUS:      rc = getdisplaystatus();        break;
     case OPT_PMON:                  rc = pmon();                    break;
+#endif /* UCLINUX */
     case OPT_WRITEPHONEBOOK:        rc = writephonebook(nargc, nargv);break;
 
     case OPT_WRITEPHONEBOOK:        rc = writephonebook(nargc, nargv);break;
 
+#ifndef UCLINUX
 #ifdef SECURITY
     case OPT_ENTERSECURITYCODE:     rc = entersecuritycode(optarg); break;
     case OPT_GETSECURITYCODESTATUS: rc = getsecuritycodestatus();   break;
 #ifdef SECURITY
     case OPT_ENTERSECURITYCODE:     rc = entersecuritycode(optarg); break;
     case OPT_GETSECURITYCODESTATUS: rc = getsecuritycodestatus();   break;
@@ -1221,17 +1339,23 @@ int main(int argc, char *argv[])
     case OPT_SETDATETIME:           rc = setdatetime(nargc, nargv); break;
     case OPT_SETALARM:              rc = setalarm(nargv);           break;
     case OPT_DIALVOICE:             rc = dialvoice(optarg);         break;
     case OPT_SETDATETIME:           rc = setdatetime(nargc, nargv); break;
     case OPT_SETALARM:              rc = setalarm(nargv);           break;
     case OPT_DIALVOICE:             rc = dialvoice(optarg);         break;
+#endif /* UCLINUX */
     case OPT_CANCELCALL:            rc = cancelcall();              break;
     case OPT_CANCELCALL:            rc = cancelcall();              break;
+#ifndef UCLINUX
     case OPT_GETCALENDARNOTE:       rc = getcalendarnote(nargc, nargv);break;
     case OPT_DELCALENDARNOTE:       rc = deletecalendarnote(optarg);break;
     case OPT_SAVECALENDARNOTE:      rc = savecalendarnote(nargc, nargv);break;
     case OPT_SENDCALENDARNOTE:      rc = sendcalendarnote(nargc, nargv);break;
     case OPT_GETCALENDARNOTE:       rc = getcalendarnote(nargc, nargv);break;
     case OPT_DELCALENDARNOTE:       rc = deletecalendarnote(optarg);break;
     case OPT_SAVECALENDARNOTE:      rc = savecalendarnote(nargc, nargv);break;
     case OPT_SENDCALENDARNOTE:      rc = sendcalendarnote(nargc, nargv);break;
+#endif /* UCLINUX */
     case OPT_SAVEPHONEBOOKENTRY:    rc = savephonebookentry(nargc, nargv);break;
     case OPT_SAVEPHONEBOOKENTRY:    rc = savephonebookentry(nargc, nargv);break;
+#ifndef UCLINUX
     case OPT_SENDPHONEBOOKENTRY:    rc = sendphonebookentry(nargc, nargv);break;
     case OPT_WRITECALENDARNOTE:     rc = writecalendarnote(nargv);  break;
     case OPT_SENDPHONEBOOKENTRY:    rc = sendphonebookentry(nargc, nargv);break;
     case OPT_WRITECALENDARNOTE:     rc = writecalendarnote(nargv);  break;
+#endif /* UCLINUX */
     case OPT_GETMEMORY:             rc = getmemory(nargc, nargv);   break;
     case OPT_GETSPEEDDIAL:          rc = getspeeddial(optarg);      break;
     case OPT_SETSPEEDDIAL:          rc = setspeeddial(nargv);       break;
     case OPT_GETMEMORY:             rc = getmemory(nargc, nargv);   break;
     case OPT_GETSPEEDDIAL:          rc = getspeeddial(optarg);      break;
     case OPT_SETSPEEDDIAL:          rc = setspeeddial(nargv);       break;
+#ifndef UCLINUX
     case OPT_GETSMS:                rc = getsms(argc, argv);        break;
     case OPT_GETSMSSTATUS:          rc = getsmsstatus(argc, argv);  break;
     case OPT_DELETESMS:             rc = deletesms(nargc, nargv);   break;
     case OPT_GETSMS:                rc = getsms(argc, argv);        break;
     case OPT_GETSMSSTATUS:          rc = getsmsstatus(argc, argv);  break;
     case OPT_DELETESMS:             rc = deletesms(nargc, nargv);   break;
@@ -1243,7 +1367,9 @@ int main(int argc, char *argv[])
     case OPT_GETSMSC:               rc = getsmsc(optarg);           break;
     case OPT_RENAMESMSC:            rc = renamesmsc(nargc,nargv);   break;
     case OPT_NETMONITOR:            rc = netmonitor(optarg);        break;
     case OPT_GETSMSC:               rc = getsmsc(optarg);           break;
     case OPT_RENAMESMSC:            rc = renamesmsc(nargc,nargv);   break;
     case OPT_NETMONITOR:            rc = netmonitor(optarg);        break;
+#endif /* UCLINUX */
     case OPT_IDENTIFY:              rc = identify();                break;
     case OPT_IDENTIFY:              rc = identify();                break;
+#ifndef UCLINUX
     case OPT_SETLOGO:               rc = setlogo(nargc, nargv);     break;
     case OPT_GETLOGO:               rc = getlogo(nargc, nargv);     break;
     case OPT_RECEIVESMS:            rc = receivesms(nargc, nargv);  break;
     case OPT_SETLOGO:               rc = setlogo(nargc, nargv);     break;
     case OPT_GETLOGO:               rc = getlogo(nargc, nargv);     break;
     case OPT_RECEIVESMS:            rc = receivesms(nargc, nargv);  break;
@@ -1268,7 +1394,9 @@ int main(int argc, char *argv[])
     case OPT_PHONETESTS:            rc = phonetests();              break;
     case OPT_SIMLOCKINFO:           rc = simlockinfo();             break;
     case OPT_SENDDTMF:              rc = senddtmf(optarg);          break;
     case OPT_PHONETESTS:            rc = phonetests();              break;
     case OPT_SIMLOCKINFO:           rc = simlockinfo();             break;
     case OPT_SENDDTMF:              rc = senddtmf(optarg);          break;
+#endif /* UCLINUX */
     case OPT_RESET:                 rc = reset(nargc,nargv);        break;
     case OPT_RESET:                 rc = reset(nargc,nargv);        break;
+#ifndef UCLINUX
     case OPT_GETOPERATORNAME:       rc = getoperatorname();         break;
     case OPT_SETOPERATORNAME:       rc = setoperatorname(nargc,nargv);break;
     case OPT_GETWAPBOOKMARK:        rc = getwapbookmark(nargc,nargv);break;
     case OPT_GETOPERATORNAME:       rc = getoperatorname();         break;
     case OPT_SETOPERATORNAME:       rc = setoperatorname(nargc,nargv);break;
     case OPT_GETWAPBOOKMARK:        rc = getwapbookmark(nargc,nargv);break;
@@ -1284,7 +1412,11 @@ int main(int argc, char *argv[])
     case OPT_GETVOICEMAILBOX:       rc = getvoicemailbox();         break;
     case OPT_NM_COLLECT:            rc = nm_collect(nargc, nargv);  break;
     case OPT_NETMONITORDATA:        rc = netmonitordata(nargc, nargv);break;
     case OPT_GETVOICEMAILBOX:       rc = getvoicemailbox();         break;
     case OPT_NM_COLLECT:            rc = nm_collect(nargc, nargv);  break;
     case OPT_NETMONITORDATA:        rc = netmonitordata(nargc, nargv);break;
+#endif /* UCLINUX */
 
 
+#ifdef UCLINUX
+    case OPT_GNOKIID:               rc = gnokiid(nargc, nargv);     break;
+#endif /* UCLINUX */
     default:         fprintf(stderr, _("Unknown option: %d\n"), c); break;
 
     }
     default:         fprintf(stderr, _("Unknown option: %d\n"), c); break;
 
     }
@@ -1299,6 +1431,8 @@ int main(int argc, char *argv[])
   exit(-1);
 }
 
   exit(-1);
 }
 
+#ifndef UCLINUX
+
 /* Restores various phone settings from one file */
 int restoresettings(char *argv[])
 {
 /* Restores various phone settings from one file */
 int restoresettings(char *argv[])
 {
@@ -1651,7 +1785,7 @@ int sendsms(int argc, char *argv[])
     case GSM_DisableFax:
     case GSM_EnableEmail:
     case GSM_DisableEmail:
     case GSM_DisableFax:
     case GSM_EnableEmail:
     case GSM_DisableEmail:
-      fprintf(stdout,_("Warning: saving %i chars\n"),strlen(MultiSMS.SMS[0].MessageText));
+      fprintf(stdout,_("Warning: saving %ld chars\n"),(long)strlen(MultiSMS.SMS[0].MessageText));
       msgnum=1;
       break;
     default:
       msgnum=1;
       break;
     default:
@@ -1856,7 +1990,7 @@ int savesms(int argc, char *argv[])
     case GSM_DisableFax:
     case GSM_EnableEmail:
     case GSM_DisableEmail:
     case GSM_DisableFax:
     case GSM_EnableEmail:
     case GSM_DisableEmail:
-      fprintf(stdout,_("Warning: saving %i chars\n"),strlen(MultiSMS.SMS[0].MessageText));
+      fprintf(stdout,_("Warning: saving %ld chars\n"),(long)strlen(MultiSMS.SMS[0].MessageText));
       msgnum=1;
       break;
     default:
       msgnum=1;
       break;
     default:
@@ -2705,8 +2839,10 @@ int dialvoice(char *Number)
   return 0;
 }
 
   return 0;
 }
 
+#endif /* UCLINUX */
+
 /* Cancel a call */
 /* Cancel a call */
-int cancelcall(void)
+static int cancelcall(void)
 {
   fbusinit(NULL);
 
 {
   fbusinit(NULL);
 
@@ -2717,6 +2853,8 @@ int cancelcall(void)
   return 0;
 }
 
   return 0;
 }
 
+#ifndef UCLINUX
+
 int savelogo(int argc, char *argv[])
 {
   GSM_Bitmap bitmap;
 int savelogo(int argc, char *argv[])
 {
   GSM_Bitmap bitmap;
@@ -3325,7 +3463,7 @@ int setlogo(int argc, char *argv[])
                        } else {
                          GSM->SetBitmap(&bitmap);
                          GSM->GetBitmap(&oldbit);
                        } else {
                          GSM->SetBitmap(&bitmap);
                          GSM->GetBitmap(&oldbit);
-                         fprintf(stderr, _("too long, truncated to \"%s\" (length %i)\n"),oldbit.text,strlen(oldbit.text));
+                         fprintf(stderr, _("too long, truncated to \"%s\" (length %ld)\n"),oldbit.text,(long)strlen(oldbit.text));
                        }
                         ok=false;
                      }
                        }
                         ok=false;
                      }
@@ -3977,6 +4115,53 @@ int monitormode(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
+#endif /* UCLINUX */
+
+/* Emulation of separate gnokiid binary for uClinux */
+
+#ifdef UCLINUX
+
+static int gnokiid(int argc, char *argv[])
+{
+       bool    DebugMode;  /* When true, run in debug mode */
+       char    *Model;   /* Model from .gnokiirc file. */
+       char    *Port;    /* Port from .gnokiirc file */
+       char    *Initlength;  /* Init length from .gnokiirc file */
+       char    *Connection;  /* Connection type from .gnokiirc file */
+       char    *BinDir;  /* Directory of the mgnokiidev command */
+
+       /* evaluate for presence of "--debug" argument in parameter */
+       DebugMode = false;
+       if(argc>0)
+       {
+               if( strcmp(argv[0],"--debug" ))
+               {
+                       usage();
+                       return -1;
+               }
+               else
+                       DebugMode = true;
+       }
+
+#ifdef DEBUG
+  fprintf (stderr, _("Entering gnokiid mode...\n"));
+#endif
+
+       if (CFG_ReadConfig(&Model, &Port, &Initlength, &Connection, &BinDir, true) < 0)
+               return(-1);
+
+  if (VM_Initialise(Model, Port, Initlength, GCT_FBUS, BinDir, DebugMode, true, ""/*SynchronizeTime*/) == false)
+               return (-1);
+
+       VM_Terminate();
+
+  return 0;
+}
+
+#endif /* UCLINUX */
+
+#ifndef UCLINUX
+
 /* Shows texts from phone's display */
 
 int displayoutput()
 /* Shows texts from phone's display */
 
 int displayoutput()
@@ -4461,10 +4646,12 @@ int setprofile(int argc, char *argv[])
 
 }
 
 
 }
 
+#endif /* UCLINUX */
+
 /* Get requested range of memory storage entries and output to stdout in
    easy-to-parse format */
 
 /* Get requested range of memory storage entries and output to stdout in
    easy-to-parse format */
 
-int getmemory(int argc, char *argv[])
+static int getmemory(int argc, char *argv[])
 {
 
   GSM_PhonebookEntry entry;
 {
 
   GSM_PhonebookEntry entry;
@@ -4696,7 +4883,7 @@ int getmemory(int argc, char *argv[])
 /* Read data from stdin, parse and write to phone.  The parsing is relatively
    crude and doesn't allow for much variation from the stipulated format. */
 
 /* Read data from stdin, parse and write to phone.  The parsing is relatively
    crude and doesn't allow for much variation from the stipulated format. */
 
-int writephonebook(int argc, char *args[])
+static int writephonebook(int argc, char *args[])
 {
 
   GSM_PhonebookEntry entry;
 {
 
   GSM_PhonebookEntry entry;
@@ -4912,7 +5099,7 @@ int writephonebook(int argc, char *args[])
 
 /* Getting speed dials. */
 
 
 /* Getting speed dials. */
 
-int getspeeddial(char *Number) {
+static int getspeeddial(char *Number) {
 
   GSM_SpeedDial entry;
   GSM_Error error;
 
   GSM_SpeedDial entry;
   GSM_Error error;
@@ -4945,7 +5132,7 @@ int getspeeddial(char *Number) {
 
 /* Setting speed dials. */
 
 
 /* Setting speed dials. */
 
-int setspeeddial(char *argv[]) {
+static int setspeeddial(char *argv[]) {
 
   GSM_SpeedDial entry;
 
 
   GSM_SpeedDial entry;
 
@@ -4981,6 +5168,8 @@ int setspeeddial(char *argv[]) {
   return 0;
 }
 
   return 0;
 }
 
+#ifndef UCLINUX
+
 /* Getting the status of the display. */
 
 int getdisplaystatus()
 /* Getting the status of the display. */
 
 int getdisplaystatus()
@@ -5040,7 +5229,9 @@ int netmonitor(char *Mode)
   return 0;
 }
 
   return 0;
 }
 
-int identify( void )
+#endif /* UCLINUX */
+
+static int identify( void )
 {
   /* Hopefully is 64 larger as FB38_MAX* / FB61_MAX* */
   char imei[64], model[64], rev[64], manufacturer[64];
 {
   /* Hopefully is 64 larger as FB38_MAX* / FB61_MAX* */
   char imei[64], model[64], rev[64], manufacturer[64];
@@ -5063,6 +5254,8 @@ int identify( void )
   return 0;
 }
 
   return 0;
 }
 
+#ifndef UCLINUX
+
 int senddtmf(char *String)
 {
 
 int senddtmf(char *String)
 {
 
@@ -5075,8 +5268,10 @@ int senddtmf(char *String)
   return 0;
 }
 
   return 0;
 }
 
+#endif /* UCLINUX */
+
 /* Resets the phone */
 /* Resets the phone */
-int reset(int argc, char *argv[])
+static int reset(int argc, char *argv[])
 {
 
   unsigned char _type=0x03;
 {
 
   unsigned char _type=0x03;
@@ -5104,6 +5299,8 @@ int reset(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
+#ifndef UCLINUX
+
 /* This is a "convenience" function to allow quick test of new API stuff which
    doesn't warrant a "proper" command line function. */
 
 /* This is a "convenience" function to allow quick test of new API stuff which
    doesn't warrant a "proper" command line function. */
 
@@ -5147,7 +5344,7 @@ int pmon()
 
   /* Initialise the code for the GSM interface. */     
 
 
   /* Initialise the code for the GSM interface. */     
 
-  error = GSM_Initialise(model, Port, Initlength, connection, RLP_DisplayF96Frame, SynchronizeTime);
+  error = GSM_Initialise(model, Port, Initlength, connection, RLP_DisplayF96Frame, ""/*SynchronizeTime*/);
 
   if (error != GE_NONE) {
     fprintf(stderr, _("GSM/FBUS init failed! (Unknown model ?). Quitting.\n"));
 
   if (error != GE_NONE) {
     fprintf(stderr, _("GSM/FBUS init failed! (Unknown model ?). Quitting.\n"));
@@ -7643,11 +7840,13 @@ int renamesmsc(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
+#endif /* UCLINUX */
+
 /*
  * Returns number of sostituited characters.
  * ... may be useful one day ??
  */
 /*
  * Returns number of sostituited characters.
  * ... may be useful one day ??
  */
-int semicolon_pipe_substitution( GSM_PhonebookEntry *pentry, unsigned int direction )
+static int semicolon_pipe_substitution( GSM_PhonebookEntry *pentry, unsigned int direction )
        /* direction = 0 : after reading phone memory (
         *             1 : writing phone memory
         */
        /* direction = 0 : after reading phone memory (
         *             1 : writing phone memory
         */
@@ -7683,6 +7882,10 @@ int str_substch( char *str, const char toric, const char sost )
        return( i_sost );
 }                                                                               
 
        return( i_sost );
 }                                                                               
 
+#ifndef UCLINUX
+
+extern GSM_Error N6110_EnableExtendedCommands (unsigned char status);
+
 /* Allows to set simlock state.
    With older phone (older 51xx, 61xx) can open them, with older
    and newer should be able to close them */
 /* Allows to set simlock state.
    With older phone (older 51xx, 61xx) can open them, with older
    and newer should be able to close them */
@@ -8656,7 +8859,9 @@ int divert(int argc, char *argv[])
        return 0;
 }
 
        return 0;
 }
 
-int savephonebookentry(int argc, char *argv[])
+#endif /* UCLINUX */
+
+static int savephonebookentry(int argc, char *argv[])
 {
   GSM_MultiSMSMessage MultiSMS;
   GSM_PhonebookEntry entry;
 {
   GSM_MultiSMSMessage MultiSMS;
   GSM_PhonebookEntry entry;
@@ -8682,9 +8887,12 @@ int savephonebookentry(int argc, char *argv[])
     case GE_NONE:
 
       /* Put entry into SMS structure */
     case GE_NONE:
 
       /* Put entry into SMS structure */
+#ifndef UCLINUX
       if (GetModelFeature(FN_PHONEBOOK)==F_PBK71) {
         GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,21);
       if (GetModelFeature(FN_PHONEBOOK)==F_PBK71) {
         GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,21);
-      } else {
+      } else
+#endif /* UCLINUX */
+                               {
         GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,10);
       }
 
         GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,10);
       }
 
@@ -8701,6 +8909,8 @@ int savephonebookentry(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
+#ifndef UCLINUX
+
 int sendphonebookentry(int argc, char *argv[])
 {
   GSM_MultiSMSMessage MultiSMS;
 int sendphonebookentry(int argc, char *argv[])
 {
   GSM_MultiSMSMessage MultiSMS;
@@ -8746,3 +8956,5 @@ int sendphonebookentry(int argc, char *argv[])
 
   return 0;
 }
 
   return 0;
 }
+
+#endif /* UCLINUX */
index dbcf972..2c0e921 100644 (file)
@@ -12,6 +12,8 @@
 
 /* Prototypes */
 
 
 /* Prototypes */
 
+#ifndef UCLINUX
+
 int monitormode(int argc, char *argv[]);
 
 #ifdef SECURITY
 int monitormode(int argc, char *argv[]);
 
 #ifdef SECURITY
@@ -25,10 +27,13 @@ int monitormode(int argc, char *argv[]);
   int decodefile(int nargc, char *nargv[]); 
 #endif
 
   int decodefile(int nargc, char *nargv[]); 
 #endif
 
-int getmemory(int argc, char *argv[]);
-int writephonebook(int argc, char *argv[]);
-int getspeeddial(char *number);
-int setspeeddial(char *argv[]);
+#endif /* UCLINUX */
+
+static int getmemory(int argc, char *argv[]);
+static int writephonebook(int argc, char *argv[]);
+static int getspeeddial(char *number);
+static int setspeeddial(char *argv[]);
+#ifndef UCLINUX
 int getsms(int argc, char *argv[]);
 int renamesmsc(int argc, char *argv[]);
 int deletesms(int argc, char *argv[]);
 int getsms(int argc, char *argv[]);
 int renamesmsc(int argc, char *argv[]);
 int deletesms(int argc, char *argv[]);
@@ -44,13 +49,17 @@ int getdatetime(void);
 int setalarm(char *argv[]);
 int getalarm(void);
 int dialvoice(char *number);
 int setalarm(char *argv[]);
 int getalarm(void);
 int dialvoice(char *number);
-int cancelcall(void);
+#endif /* UCLINUX */
+static int cancelcall(void);
+#ifndef UCLINUX
 int getcalendarnote(int argc, char *argv[]);
 int writecalendarnote(char *argv[]);
 int deletecalendarnote(char *index);
 int getdisplaystatus();
 int netmonitor(char *_mode);
 int getcalendarnote(int argc, char *argv[]);
 int writecalendarnote(char *argv[]);
 int deletecalendarnote(char *index);
 int getdisplaystatus();
 int netmonitor(char *_mode);
-int identify(void);
+#endif /* UCLINUX */
+static int identify(void);
+#ifndef UCLINUX
 int senddtmf(char *String);
 int foogle(char *argv[]);
 int pmon(void);
 int senddtmf(char *String);
 int foogle(char *argv[]);
 int pmon(void);
@@ -59,7 +68,9 @@ int getlogo(int argc, char *argv[]);
 int binringtoneconvert(int argc, char *argv[]);
 int setringtone(int argc, char *argv[]);
 int getringtone(int argc, char *argv[]);
 int binringtoneconvert(int argc, char *argv[]);
 int setringtone(int argc, char *argv[]);
 int getringtone(int argc, char *argv[]);
-int reset(int argc, char *argv[]);
+#endif /* UCLINUX */
+static int reset(int argc, char *argv[]);
+#ifndef UCLINUX
 int getprofile(int argc, char *argv[]);
 int setprofile(int argc, char *argv[]);
 int allringtones();
 int getprofile(int argc, char *argv[]);
 int setprofile(int argc, char *argv[]);
 int allringtones();
@@ -98,8 +109,11 @@ int sendcalendarnote(int argc, char *argv[]);
 int receivesms(int argc, char *argv[]);
 int getsmsstatus(int argc, char *argv[]);
 int divert(int argc, char *argv[]);
 int receivesms(int argc, char *argv[]);
 int getsmsstatus(int argc, char *argv[]);
 int divert(int argc, char *argv[]);
-int savephonebookentry(int argc, char *argv[]);
+#endif /* UCLINUX */
+static int savephonebookentry(int argc, char *argv[]);
+#ifndef UCLINUX
 int sendphonebookentry(int argc, char *argv[]);
 int sendphonebookentry(int argc, char *argv[]);
+#endif /* UCLINUX */
 
 typedef enum {
   OPT_HELP,
 
 typedef enum {
   OPT_HELP,
@@ -184,7 +198,8 @@ typedef enum {
   OPT_GETSMSSTATUS=145,
   OPT_DIVERT=146,
   OPT_SENDWAPSETTINGS=147,
   OPT_GETSMSSTATUS=145,
   OPT_DIVERT=146,
   OPT_SENDWAPSETTINGS=147,
-  OPT_SETWAPBOOKMARK=148
+  OPT_SETWAPBOOKMARK=148,
+  OPT_GNOKIID=149,
 } opt_index;
 
 struct gnokii_arg_len {
 } opt_index;
 
 struct gnokii_arg_len {
@@ -206,8 +221,10 @@ struct keys_table_position {
   int whatcode;
 };
 
   int whatcode;
 };
 
+#ifndef UCLINUX
+
 /* for --presskeysequence */
 /* for --presskeysequence */
-struct keys_table_position Keys[] = {
+static struct keys_table_position Keys[] = {
 {'m',PHONEKEY_MENU},
 {'M',PHONEKEY_MENU},
 {'n',PHONEKEY_NAMES},
 {'m',PHONEKEY_MENU},
 {'M',PHONEKEY_MENU},
 {'n',PHONEKEY_NAMES},
@@ -239,6 +256,8 @@ struct keys_table_position Keys[] = {
 {' ',0}
 };
 
 {' ',0}
 };
 
+#endif /* UCLINUX */
+
 /* for NETMONITOR */
 
 //maximal number of screens for --nm_collect
 /* for NETMONITOR */
 
 //maximal number of screens for --nm_collect
@@ -274,5 +293,5 @@ typedef struct {
        unsigned char req_screen[NM_MAX_SCREEN];
 } OUT_INFO_MON;
 
        unsigned char req_screen[NM_MAX_SCREEN];
 } OUT_INFO_MON;
 
-int semicolon_pipe_substitution( GSM_PhonebookEntry *pentry, unsigned int direction );
-int str_substch( char *str, const char toric, const char sost );
+static int semicolon_pipe_substitution( GSM_PhonebookEntry *pentry, unsigned int direction );
+static int str_substch( char *str, const char toric, const char sost );
index 3f95297..2edfb23 100644 (file)
        /* Prototypes */
 bool   ATEM_Initialise(int read_fd, int write_fd, char *model, char *port);
 void   ATEM_HandleIncomingData(char *buffer, int length);
        /* Prototypes */
 bool   ATEM_Initialise(int read_fd, int write_fd, char *model, char *port);
 void   ATEM_HandleIncomingData(char *buffer, int length);
-void   ATEM_InitRegisters(void);
-void   ATEM_StringOut(char *buffer);
-void   ATEM_ParseAT(char *cmd_buffer);
-void   ATEM_ParseSMS(char *cmd_buffer);
-void   ATEM_ParseDIR(char *cmd_buffer);
-bool   ATEM_CommandPlusC(char **buf);
-bool   ATEM_CommandPlusG(char **buf);
-int            ATEM_GetNum(char **p);
 void   ATEM_ModemResult(int code);
 void    ATEM_CallPassup(char c);
 
        /* Global variables */
 void   ATEM_ModemResult(int code);
 void    ATEM_CallPassup(char c);
 
        /* Global variables */
-bool   ATEM_Initialised;
+extern bool    ATEM_Initialised;
 
        /* Definition of modem result codes - these are returned to "terminal"
        numerically or as a string depending on the setting of S12 */
 
        /* Definition of modem result codes - these are returned to "terminal"
        numerically or as a string depending on the setting of S12 */
index c1e48d1..921610d 100644 (file)
@@ -19,7 +19,6 @@
 
 void    DP_CallFinished(void);
 bool   DP_Initialise(int read_fd, int write_fd);
 
 void    DP_CallFinished(void);
 bool   DP_Initialise(int read_fd, int write_fd);
-int     DP_CallBack(RLP_UserInds ind, u8 *buffer, int length);
 void    DP_CallPassup(char c);
 
        /* All defines and prototypes from here down are specific to 
 void    DP_CallPassup(char c);
 
        /* All defines and prototypes from here down are specific to 
index a03a497..db0dc0f 100644 (file)
@@ -172,10 +172,7 @@ typedef struct {
 /* Prototypes for functions. */
 
 void RLP_DisplayF96Frame(RLP_F96Frame *frame);
 /* Prototypes for functions. */
 
 void RLP_DisplayF96Frame(RLP_F96Frame *frame);
-void RLP_DecodeF96Header(RLP_F96Frame *frame, RLP_F96Header *header);
-void RLP_DisplayXID(u8 *frame);
 void RLP_Initialise(bool (*rlp_send_function)(RLP_F96Frame *frame, bool out_dtx), int (*rlp_passup)(RLP_UserInds ind, u8 *buffer, int length));
 void RLP_Initialise(bool (*rlp_send_function)(RLP_F96Frame *frame, bool out_dtx), int (*rlp_passup)(RLP_UserInds ind, u8 *buffer, int length));
-void RLP_Init_link_vars(void);
 void RLP_SetUserRequest(RLP_UserRequests type, bool value);
 void RLP_Send(char *buffer, int length);
 
 void RLP_SetUserRequest(RLP_UserRequests type, bool value);
 void RLP_Send(char *buffer, int length);
 
index 6fe838d..a619e54 100644 (file)
@@ -15,7 +15,7 @@
 
 /* Prototypes */
 
 
 /* Prototypes */
 
-bool VM_Initialise(char *model,
+extern bool VM_Initialise(char *model,
                   char *port,
                   char *initlength,
                   GSM_ConnectionType connection,
                   char *port,
                   char *initlength,
                   GSM_ConnectionType connection,
@@ -23,15 +23,6 @@ bool VM_Initialise(char *model,
                   bool debug_mode,
                   bool GSM_Init,
                   char *synchronizetime);
                   bool debug_mode,
                   bool GSM_Init,
                   char *synchronizetime);
-int  VM_PtySetup(char *bindir);
-void VM_ThreadLoop(void);
-void VM_CharHandler(void);
-int  VM_GetMasterPty(char **name);
-void VM_Terminate(void);
-GSM_Error VM_GSMInitialise(char *model,
-                          char *port,
-                          char *initlength,
-                          GSM_ConnectionType connection,
-                          char *synchronizetime);
+extern void VM_Terminate(void);
 
 #endif /* __virtmodem_h */
 
 #endif /* __virtmodem_h */
index 5ad2dd3..fabe975 100644 (file)
@@ -22,6 +22,7 @@
    IR (only with 61x0 models) and MBUS (61x0, 640, 6160) */
 typedef enum {
   GCT_FBUS,     /* FBUS connection. */
    IR (only with 61x0 models) and MBUS (61x0, 640, 6160) */
 typedef enum {
   GCT_FBUS,     /* FBUS connection. */
+#ifndef UCLINUX
   GCT_Infrared, /* FBUS over direct infrared connection - 61xx. */
   GCT_Irda,     /* FBUS over Irda sockets - 7110, 6210, etc. */
   GCT_MBUS,     /* MBUS */
   GCT_Infrared, /* FBUS over direct infrared connection - 61xx. */
   GCT_Irda,     /* FBUS over Irda sockets - 7110, 6210, etc. */
   GCT_MBUS,     /* MBUS */
@@ -29,23 +30,14 @@ typedef enum {
   GCT_Tekram,   /* FBUS over direct infrared connection (Tekram device) - 61xx. */
   GCT_AT,       /* AT commands */
   GCT_Default   /* Old style module */
   GCT_Tekram,   /* FBUS over direct infrared connection (Tekram device) - 61xx. */
   GCT_AT,       /* AT commands */
   GCT_Default   /* Old style module */
+#endif /* UCLINUX */
 } GSM_ConnectionType;
 
 #ifndef WIN32
   #include <unistd.h>
   #include "misc.h"
 
 } GSM_ConnectionType;
 
 #ifndef WIN32
   #include <unistd.h>
   #include "misc.h"
 
-  int device_getfd(void);
-
-  int device_open(__const char *__file, int __with_odd_parity);
-  void device_reset(void);
-
-  size_t device_read(__ptr_t __buf, size_t __nbytes);
   size_t device_write(__const __ptr_t __buf, size_t __n);
   size_t device_write(__const __ptr_t __buf, size_t __n);
-
-  #ifdef DEBUG
-    void device_dumpserial(void);
-  #endif
 #else
   size_t device_write(const __ptr_t __buf, size_t __n);
 #endif
 #else
   size_t device_write(const __ptr_t __buf, size_t __n);
 #endif
index b044d43..c9be583 100644 (file)
 
 #include "misc.h"
 
 
 #include "misc.h"
 
-int serial_open(__const char *__file, int __oflag);
-int serial_close(int __fd);
+#ifndef UCLINUX
+extern int serial_open(__const char *__file, int __oflag);
+#endif /* UCLINUX */
+extern int serial_close(int __fd);
 
 
-int serial_opendevice(__const char *__file, int __with_odd_parity, int __with_async, int __with_hw_handshake);
+extern int serial_opendevice(__const char *__file, int __with_odd_parity, int __with_async, int __with_hw_handshake);
 
 
-void serial_setdtrrts(int __fd, int __dtr, int __rts);
-void serial_changespeed(int __fd, int __speed);
+extern void serial_setdtrrts(int __fd, int __dtr, int __rts);
+extern void serial_changespeed(int __fd, int __speed);
 
 
-size_t serial_read(int __fd, __ptr_t __buf, size_t __nbytes);
-size_t serial_write(int __fd, __const __ptr_t __buf, size_t __n);
+extern size_t serial_read(int __fd, __ptr_t __buf, size_t __nbytes);
+extern size_t serial_write(int __fd, __const __ptr_t __buf, size_t __n);
 
 
-int serial_select(int fd, struct timeval *timeout);
+extern int serial_select(int fd, struct timeval *timeout);
 
 #endif  /* __devices_unixserial_h */
 
 
 #endif  /* __devices_unixserial_h */
 
index 15513d7..7c0ebba 100644 (file)
@@ -35,6 +35,8 @@ struct CFG_Header {
         char *section;
 };
 
         char *section;
 };
 
+#ifndef UCLINUX
+
 /* Function prototypes */
 
 struct CFG_Header *CFG_ReadFile(char *filename);
 /* Function prototypes */
 
 struct CFG_Header *CFG_ReadFile(char *filename);
@@ -43,10 +45,16 @@ char              *CFG_Set(struct CFG_Header *cfg, char *section, char *key,
                            char *value);
 int                CFG_WriteFile(struct CFG_Header *cfg, char *filename);
 
                            char *value);
 int                CFG_WriteFile(struct CFG_Header *cfg, char *filename);
 
+#endif /* UCLINUX */
+
 int              CFG_ReadConfig(char **model, char **port, char **initlength,
 int              CFG_ReadConfig(char **model, char **port, char **initlength,
-                                 char **connection, char **bindir, char **synchronizetime,
+                                 char **connection, char **bindir,
                                  bool isgnokiid);
 
                                  bool isgnokiid);
 
+#ifndef UCLINUX
+
 struct CFG_Header *CFG_FindGnokiirc();
 
 struct CFG_Header *CFG_FindGnokiirc();
 
+#endif /* UCLINUX */
+
 #endif /* _CFGREADER_H */
 #endif /* _CFGREADER_H */
index 0ab7718..10cb4b0 100644 (file)
 #include "gsm-ringtones.h"
 #include "gsm-wap.h"
 
 #include "gsm-ringtones.h"
 #include "gsm-wap.h"
 
+#ifndef UCLINUX
+
 /* Undefined functions in fbus/mbus files */
 extern GSM_Error Unimplemented(void);
 #define UNIMPLEMENTED (void *) Unimplemented
 extern GSM_Error NotSupported(void);
 #define NOTSUPPORTED (void *) NotSupported
 
 /* Undefined functions in fbus/mbus files */
 extern GSM_Error Unimplemented(void);
 #define UNIMPLEMENTED (void *) Unimplemented
 extern GSM_Error NotSupported(void);
 #define NOTSUPPORTED (void *) NotSupported
 
+#endif /* UCLINUX */
+
 /* Define the structure used to hold pointers to the various API functions.
    This is in effect the master list of functions provided by the gnokii API.
    Modules containing the model specific code each contain one of these
 /* Define the structure used to hold pointers to the various API functions.
    This is in effect the master list of functions provided by the gnokii API.
    Modules containing the model specific code each contain one of these
@@ -288,160 +292,178 @@ extern GSM_Information *GSM_Info;
 extern GSM_Functions *GSM;
 extern GSM_Protocol *Protocol;
 
 extern GSM_Functions *GSM;
 extern GSM_Protocol *Protocol;
 
-GSM_PhonebookEntry *CurrentPhonebookEntry;
-GSM_Error          CurrentPhonebookError;
+extern GSM_PhonebookEntry *CurrentPhonebookEntry;
+extern GSM_Error          CurrentPhonebookError;
 
 
-GSM_SpeedDial      *CurrentSpeedDialEntry;
-GSM_Error          CurrentSpeedDialError;
+#ifndef UCLINUX
+extern GSM_SpeedDial      *CurrentSpeedDialEntry;
+extern GSM_Error          CurrentSpeedDialError;
+#endif /* UCLINUX */
 
 
-unsigned char      Current_IMEI[GSM_MAX_IMEI_LENGTH];
-unsigned char      Current_Revision[GSM_MAX_REVISION_LENGTH];
-unsigned char      Current_Model[GSM_MAX_MODEL_LENGTH];
+extern unsigned char      Current_IMEI[GSM_MAX_IMEI_LENGTH];
+extern unsigned char      Current_Revision[GSM_MAX_REVISION_LENGTH];
+extern unsigned char      Current_Model[GSM_MAX_MODEL_LENGTH];
 
 
-GSM_SMSMessage     *CurrentSMSMessage;
-GSM_Error          CurrentSMSMessageError;
-int                CurrentSMSPointer;
+#ifndef UCLINUX
+extern GSM_SMSMessage     *CurrentSMSMessage;
+extern GSM_Error          CurrentSMSMessageError;
+extern int                CurrentSMSPointer;
 
 
-GSM_SMSFolders      *CurrentSMSFolders;
-GSM_Error          CurrentSMSFoldersError;
-int                CurrentSMSFoldersCount;
+extern GSM_SMSFolders      *CurrentSMSFolders;
+extern GSM_Error          CurrentSMSFoldersError;
+extern int                CurrentSMSFoldersCount;
 
 
-GSM_OneSMSFolder   CurrentSMSFolder;
-GSM_Error          CurrentSMSFolderError;
-int                CurrentSMSFolderID;
+extern GSM_OneSMSFolder   CurrentSMSFolder;
+extern GSM_Error          CurrentSMSFolderError;
+extern int                CurrentSMSFolderID;
+#endif /* UCLINUX */
 
 
-GSM_MemoryStatus   *CurrentMemoryStatus;
-GSM_Error          CurrentMemoryStatusError;
+extern GSM_MemoryStatus   *CurrentMemoryStatus;
+extern GSM_Error          CurrentMemoryStatusError;
 
 
-GSM_NetworkInfo    *CurrentNetworkInfo;
-GSM_Error          CurrentNetworkInfoError;
+#ifndef UCLINUX
+extern GSM_NetworkInfo    *CurrentNetworkInfo;
+extern GSM_Error          CurrentNetworkInfoError;
 
 
-GSM_SMSStatus      *CurrentSMSStatus;
-GSM_Error          CurrentSMSStatusError;
+extern GSM_SMSStatus      *CurrentSMSStatus;
+extern GSM_Error          CurrentSMSStatusError;
 
 
-GSM_MessageCenter  *CurrentMessageCenter;
-GSM_Error          CurrentMessageCenterError;
+extern GSM_MessageCenter  *CurrentMessageCenter;
+extern GSM_Error          CurrentMessageCenterError;
 
 
-int                *CurrentSecurityCodeStatus;
-GSM_Error          CurrentSecurityCodeError;
-GSM_SecurityCode   *CurrentSecurityCode;
+extern int                *CurrentSecurityCodeStatus;
+extern GSM_Error          CurrentSecurityCodeError;
+extern GSM_SecurityCode   *CurrentSecurityCode;
 
 
-GSM_DateTime       *CurrentDateTime;
-GSM_Error          CurrentDateTimeError;
+extern GSM_DateTime       *CurrentDateTime;
+extern GSM_Error          CurrentDateTimeError;
 
 
-GSM_Error          CurrentResetPhoneSettingsError;
+extern GSM_Error          CurrentResetPhoneSettingsError;
 
 
-GSM_DateTime       *CurrentAlarm;
-GSM_Error          CurrentAlarmError;
+extern GSM_DateTime       *CurrentAlarm;
+extern GSM_Error          CurrentAlarmError;
 
 
-GSM_CalendarNote   *CurrentCalendarNote;
-GSM_Error          CurrentCalendarNoteError;
+extern GSM_CalendarNote   *CurrentCalendarNote;
+extern GSM_Error          CurrentCalendarNoteError;
 
 
-GSM_NotesInfo      CurrentCalendarNotesInfo,*CurrentCalendarNotesInfo2;
-GSM_Error          CurrentCalendarNotesInfoError;
+extern GSM_NotesInfo      CurrentCalendarNotesInfo,*CurrentCalendarNotesInfo2;
+extern GSM_Error          CurrentCalendarNotesInfoError;
 
 
-int                *CurrentFirstCalendarFreePos;
-GSM_Error          CurrentFirstCalendarFreePosError;
+extern GSM_Error          CurrentSetDateTimeError;
+extern GSM_Error          CurrentSetAlarmError;
 
 
-GSM_Error          CurrentSetDateTimeError;
-GSM_Error          CurrentSetAlarmError;
+extern int                *CurrentFirstCalendarFreePos;
+extern GSM_Error          CurrentFirstCalendarFreePosError;
+#endif /* UCLINUX */
 
 
-GSM_Error          CurrentEnableExtendedCommandsError;
+extern GSM_Error          CurrentEnableExtendedCommandsError;
 
 
-int                CurrentRFLevel,
+extern int                CurrentRFLevel,
                    CurrentBatteryLevel,
                    CurrentPowerSource;
 
                    CurrentBatteryLevel,
                    CurrentPowerSource;
 
-int                CurrentDisplayStatus;
-GSM_Error          CurrentDisplayStatusError;
+#ifndef UCLINUX
+extern int                CurrentDisplayStatus;
+extern GSM_Error          CurrentDisplayStatusError;
 
 
-char               *CurrentNetmonitor;
-GSM_Error          CurrentNetmonitorError;
+extern char               *CurrentNetmonitor;
+extern GSM_Error          CurrentNetmonitorError;
 
 
-GSM_Bitmap         *CurrentGetBitmap;
-GSM_Error          CurrentGetBitmapError;
+extern GSM_Bitmap         *CurrentGetBitmap;
+extern GSM_Error          CurrentGetBitmapError;
 
 
-GSM_Error          CurrentSetBitmapError;
+extern GSM_Error          CurrentSetBitmapError;
 
 
-GSM_Error          CurrentSendDTMFError;
+extern GSM_Error          CurrentSendDTMFError;
 
 
-GSM_Profile        *CurrentProfile;
-GSM_Error          CurrentProfileError;
+extern GSM_Profile        *CurrentProfile;
+extern GSM_Error          CurrentProfileError;
 
 
-GSM_Error          CurrentDisplayOutputError;
+extern GSM_Error          CurrentDisplayOutputError;
 
 
-GSM_CBMessage      *CurrentCBMessage;
-GSM_Error          CurrentCBError;
+extern GSM_CBMessage      *CurrentCBMessage;
+extern GSM_Error          CurrentCBError;
 
 
-int                CurrentPressKeyEvent;
-GSM_Error          CurrentPressKeyError;
+extern int                CurrentPressKeyEvent;
+extern GSM_Error          CurrentPressKeyError;
 
 
-GSM_Error          CurrentPlayToneError;
+extern GSM_Error          CurrentPlayToneError;
+#endif /* UCLINUX */
 
 
-GSM_Error          CurrentDialVoiceError;
+extern GSM_Error          CurrentDialVoiceError;
 
 
-GSM_Error          CurrentGetOperatorNameError;
-GSM_Network        *CurrentGetOperatorNameNetwork;
-GSM_Error          CurrentSetOperatorNameError;
+#ifndef UCLINUX
+extern GSM_Error          CurrentGetOperatorNameError;
+extern GSM_Network        *CurrentGetOperatorNameNetwork;
+extern GSM_Error          CurrentSetOperatorNameError;
+#endif /* UCLINUX */
 
 
-GSM_Error          CurrentGetIMEIError;
+extern GSM_Error          CurrentGetIMEIError;
 
 
-GSM_Error          CurrentGetHWError;
+extern GSM_Error          CurrentGetHWError;
 
 
-unsigned char      CurrentPPS[4];
-GSM_Error          CurrentProductProfileSettingsError;
+#ifndef UCLINUX
+extern unsigned char      CurrentPPS[4];
+extern GSM_Error          CurrentProductProfileSettingsError;
 
 
-char               CurrentIncomingCall[20];
+extern char               CurrentIncomingCall[20];
 
 
-GSM_Error          CurrentBinRingtoneError;
-GSM_BinRingtone    *CurrentGetBinRingtone;
+extern GSM_Error          CurrentBinRingtoneError;
+extern GSM_BinRingtone    *CurrentGetBinRingtone;
 
 
-GSM_Error          CurrentRingtoneError; 
+extern GSM_Error          CurrentRingtoneError; 
+#endif /* UCLINUX */
 
 
-GSM_Error          CurrentMagicError;
+extern GSM_Error          CurrentMagicError;
 
 
-GSM_Error          CurrentSimlockInfoError;
-GSM_AllSimlocks    *CurrentSimLock;
+#ifndef UCLINUX
+extern GSM_Error          CurrentSimlockInfoError;
+extern GSM_AllSimlocks    *CurrentSimLock;
 
 
-GSM_Error          CurrentGetWAPBookmarkError;
-GSM_Error          CurrentSetWAPBookmarkError;
-GSM_WAPBookmark    *WAPBookmark;
+extern GSM_Error          CurrentGetWAPBookmarkError;
+extern GSM_Error          CurrentSetWAPBookmarkError;
+extern GSM_WAPBookmark    *WAPBookmark;
 
 
-GSM_Error          CurrentGetWAPSettingsError;
-GSM_WAPSettings    *WAPSettings;
+extern GSM_Error          CurrentGetWAPSettingsError;
+extern GSM_WAPSettings    *WAPSettings;
 
 
-GSM_Error          CurrentCallDivertError;
-GSM_CallDivert    *CurrentCallDivert;
+extern GSM_Error          CurrentCallDivertError;
+extern GSM_CallDivert    *CurrentCallDivert;
 
 
-char              *CurrentManufacturer;
+extern char              *CurrentManufacturer;
+#endif /* UCLINUX */
 
 /* This is the connection type used in gnokii. */
 
 /* This is the connection type used in gnokii. */
-GSM_ConnectionType CurrentConnectionType;
+extern GSM_ConnectionType CurrentConnectionType;
 
 /* Pointer to a callback function used to return changes to a calls status */
 /* This saves unreliable polling */
 
 /* Pointer to a callback function used to return changes to a calls status */
 /* This saves unreliable polling */
-void (*CurrentCallPassup)(char c);
+extern void (*CurrentCallPassup)(char c);
 
 /* Pointer to callback function in user code to be called when RLP frames
    are received. */
 
 /* Pointer to callback function in user code to be called when RLP frames
    are received. */
-void (*CurrentRLP_RXCallback)(RLP_F96Frame *frame);
+extern void (*CurrentRLP_RXCallback)(RLP_F96Frame *frame);
 
 /* Used to disconnect the call */
 
 /* Used to disconnect the call */
-u8 CurrentCallSequenceNumber;
+extern u8 CurrentCallSequenceNumber;
 
 
-bool CurrentLinkOK;
+extern bool CurrentLinkOK;
 
 
-bool CurrentRequestTerminate;
+extern bool CurrentRequestTerminate;
 
 
-bool CurrentDisableKeepAlive;
+#ifndef UCLINUX
+extern bool CurrentDisableKeepAlive;
+#endif /* UCLINUX */
 
 /* Prototype for the functions actually provided by gsm-api.c. */
 
 
 /* Prototype for the functions actually provided by gsm-api.c. */
 
-GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), char* SynchronizeTime);
+extern GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), char* SynchronizeTime);
 
 
-bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType connection);
+#ifndef UCLINUX
+extern bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType connection);
+#endif /* UCLINUX */
 
 
-char *GetMygnokiiVersion();
+extern char *GetMygnokiiVersion();
 
 typedef enum {
   F_CAL61=0,/*Calendar in 6110 style - 4 types,...*/
 
 typedef enum {
   F_CAL61=0,/*Calendar in 6110 style - 4 types,...*/
@@ -510,10 +532,15 @@ typedef struct {
 } OnePhoneModel;
 
 extern char *GetModelName ();
 } OnePhoneModel;
 
 extern char *GetModelName ();
-int GetModelFeature (featnum_index num);
+extern int GetModelFeature (featnum_index num);
 
 
+#ifndef UCLINUX
 extern bool AppendLog(u8 *buffer, int length,bool format);
 extern bool AppendLogText(u8 *buffer,bool format);
 extern bool AppendLog(u8 *buffer, int length,bool format);
 extern bool AppendLogText(u8 *buffer,bool format);
+#else /* UCLINUX */
+#define AppendLog(buffer,length,format)
+#define AppendLogText(buffer,format)
+#endif /* UCLINUX */
 
 typedef struct {
   int                SIMPhonebookUsed;
 
 typedef struct {
   int                SIMPhonebookUsed;
index 3414f1f..6b802e6 100644 (file)
 #ifndef __gsm_coding_h
 #define __gsm_coding_h    
 
 #ifndef __gsm_coding_h
 #define __gsm_coding_h    
 
+#ifndef UCLINUX
 extern void EncodeDefault (unsigned char* dest, const unsigned char* src, int len);
 extern void DecodeDefault (unsigned char* dest, const unsigned char* src, int len);
 extern void EncodeDefault (unsigned char* dest, const unsigned char* src, int len);
 extern void DecodeDefault (unsigned char* dest, const unsigned char* src, int len);
+#endif /* UCLINUX */
 extern void EncodeUnicode (unsigned char* dest, const unsigned char* src, int len);
 extern void DecodeUnicode (unsigned char* dest, const unsigned char* src, int len);
 extern void EncodeUTF8    (unsigned char* dest, const unsigned char* src, int len);
 extern void EncodeUnicode (unsigned char* dest, const unsigned char* src, int len);
 extern void DecodeUnicode (unsigned char* dest, const unsigned char* src, int len);
 extern void EncodeUTF8    (unsigned char* dest, const unsigned char* src, int len);
+#ifndef UCLINUX
 extern void DecodeUTF8    (unsigned char* dest, const unsigned char* src, int len);
 extern void DecodeHexBin  (unsigned char* dest, const unsigned char* src, int len);
 extern void EncodeHexBin  (unsigned char* dest, const unsigned char* src, int len);
 extern void DecodeUTF8    (unsigned char* dest, const unsigned char* src, int len);
 extern void DecodeHexBin  (unsigned char* dest, const unsigned char* src, int len);
 extern void EncodeHexBin  (unsigned char* dest, const unsigned char* src, int len);
@@ -32,5 +35,6 @@ extern int           DecodeWithHexBinAlphabet (unsigned char mychar);
 extern unsigned char EncodeWithHexBinAlphabet (int digit);
 extern unsigned char EncodeWithBCDAlphabet    (int value);
 extern int           DecodeWithBCDAlphabet    (unsigned char value);
 extern unsigned char EncodeWithHexBinAlphabet (int digit);
 extern unsigned char EncodeWithBCDAlphabet    (int value);
 extern int           DecodeWithBCDAlphabet    (unsigned char value);
+#endif /* UCLINUX */
 
 #endif
 
 #endif
index 367a964..177dd67 100644 (file)
@@ -48,10 +48,12 @@ typedef struct {
 
 /* These functions are used to search the structure defined above.*/
 char *GSM_GetNetworkName(char *NetworkCode);
 
 /* These functions are used to search the structure defined above.*/
 char *GSM_GetNetworkName(char *NetworkCode);
+#ifndef UCLINUX
 char *GSM_GetNetworkCode(char *NetworkName);
 
 char *GSM_GetCountryName(char *CountryCode);
 char *GSM_GetCountryCode(char *CountryName);
 char *GSM_GetNetworkCode(char *NetworkName);
 
 char *GSM_GetCountryName(char *CountryCode);
 char *GSM_GetCountryCode(char *CountryName);
+#endif /* UCLINUX */
 
 void EncodeNetworkCode(unsigned char* buffer, unsigned char* output);
 void DecodeNetworkCode(unsigned char* buffer, unsigned char* output);
 
 void EncodeNetworkCode(unsigned char* buffer, unsigned char* output);
 void DecodeNetworkCode(unsigned char* buffer, unsigned char* output);
index fac18b9..6870150 100644 (file)
@@ -266,27 +266,35 @@ typedef struct {
        TP-Status-Report-Request      (1 bit). See GSM 03.40 section 9.2.3.5 */
 } GSM_ETSISMSMessage;
 
        TP-Status-Report-Request      (1 bit). See GSM 03.40 section 9.2.3.5 */
 } GSM_ETSISMSMessage;
 
-int   GSM_PackSemiOctetNumber  (u8 *Number, u8 *Output, bool semioctet);
-char *GSM_UnpackSemiOctetNumber(u8 *Number, bool semioctet);
+#ifndef UCLINUX
+extern int   GSM_PackSemiOctetNumber  (u8 *Number, u8 *Output, bool semioctet);
+extern char *GSM_UnpackSemiOctetNumber(u8 *Number, bool semioctet);
 
 
-int GSM_UnpackEightBitsToSeven(int fillbits, int in_length, int out_length, unsigned char *input, unsigned char *output);
-int GSM_PackSevenBitsToEight  (int offset, unsigned char *input, unsigned char *output);
+extern int GSM_UnpackEightBitsToSeven(int fillbits, int in_length, int out_length, unsigned char *input, unsigned char *output);
+extern int GSM_PackSevenBitsToEight  (int offset, unsigned char *input, unsigned char *output);
+#endif /* UCLINUX */
 
 
-GSM_Error GSM_EncodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI, SMS_MessageType PDU, int *length);
-GSM_Error GSM_DecodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI);
+extern GSM_Error GSM_EncodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI, SMS_MessageType PDU, int *length);
+extern GSM_Error GSM_DecodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI);
 
 
-GSM_Error GSM_EncodeSMSDateTime(GSM_DateTime *DT, unsigned char *req);
+#ifndef UCLINUX
+extern GSM_Error GSM_EncodeSMSDateTime(GSM_DateTime *DT, unsigned char *req);
+#endif /* UCLINUX */
 
 
-GSM_Error GSM_DecodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI);
+extern GSM_Error GSM_DecodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI);
 
 
-GSM_Error GSM_DecodeETSISMSStatusReportData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI);
+extern GSM_Error GSM_DecodeETSISMSStatusReportData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI);
 
 
-void GSM_SetDefaultSMSData(GSM_SMSMessage *SMS);
-GSM_Error EncodeUDHHeader(char *text, GSM_UDH UDHType);
+#ifndef UCLINUX
+extern void GSM_SetDefaultSMSData(GSM_SMSMessage *SMS);
+extern GSM_Error EncodeUDHHeader(char *text, GSM_UDH UDHType);
+#endif /* UCLINUX */
 
 
-int GSM_MakeSinglePartSMS2(GSM_SMSMessage *SMS,
+#ifndef UCLINUX
+extern int GSM_MakeSinglePartSMS2(GSM_SMSMessage *SMS,
     unsigned char *MessageBuffer,int cur, GSM_UDH UDHType, GSM_Coding_Type Coding);
     unsigned char *MessageBuffer,int cur, GSM_UDH UDHType, GSM_Coding_Type Coding);
-void GSM_MakeMultiPartSMS2(GSM_MultiSMSMessage *SMS,
+#endif /* UCLINUX */
+extern void GSM_MakeMultiPartSMS2(GSM_MultiSMSMessage *SMS,
     unsigned char *MessageBuffer,int MessageLength, GSM_UDH UDHType, GSM_Coding_Type Coding);
 
 #endif /* __gsm_sms_h */
     unsigned char *MessageBuffer,int MessageLength, GSM_UDH UDHType, GSM_Coding_Type Coding);
 
 #endif /* __gsm_sms_h */
index 34a3988..cbce246 100644 (file)
@@ -51,168 +51,194 @@ extern GSM_Functions   N6110_Functions;
 extern GSM_Information N6110_Information;
 
 /* Prototypes for the functions designed to be used externally. */
 extern GSM_Information N6110_Information;
 
 /* Prototypes for the functions designed to be used externally. */
-GSM_Error N6110_Initialise(char *port_device, char *initlength,
+static GSM_Error N6110_Initialise(char *port_device, char *initlength,
                           GSM_ConnectionType connection,
                           void (*rlp_callback)(RLP_F96Frame *frame));
 
                           GSM_ConnectionType connection,
                           void (*rlp_callback)(RLP_F96Frame *frame));
 
-void      N6110_DispatchMessage(u16 MessageLength, u8 *MessageBuffer,
+static void      N6110_DispatchMessage(u16 MessageLength, u8 *MessageBuffer,
                               u8 MessageType);
 
                               u8 MessageType);
 
-GSM_Error N6110_SendStatusRequest(void);
+static GSM_Error N6110_SendStatusRequest(void);
 
 
-int       N6110_GetMemoryType(GSM_MemoryType memory_type);
+static int       N6110_GetMemoryType(GSM_MemoryType memory_type);
 
 
-GSM_Error N6110_GetVoiceMailbox ( GSM_PhonebookEntry *entry);  
+#ifndef UCLINUX
+static GSM_Error N6110_GetVoiceMailbox ( GSM_PhonebookEntry *entry);  
 
 
-GSM_Error N6110_GetOperatorName ( GSM_Network *operator);  
-GSM_Error N6110_SetOperatorName ( GSM_Network *operator);    
+static GSM_Error N6110_GetOperatorName ( GSM_Network *operator);  
+static GSM_Error N6110_SetOperatorName ( GSM_Network *operator);    
+#endif /* UCLINUX */
 
 
-GSM_Error N6110_GetMemoryLocation(GSM_PhonebookEntry *entry);
-GSM_Error N6110_WritePhonebookLocation(GSM_PhonebookEntry *entry);
+static GSM_Error N6110_GetMemoryLocation(GSM_PhonebookEntry *entry);
+static GSM_Error N6110_WritePhonebookLocation(GSM_PhonebookEntry *entry);
 
 
-GSM_Error N6110_GetSpeedDial(GSM_SpeedDial *entry);
-GSM_Error N6110_SetSpeedDial(GSM_SpeedDial *entry);
+#ifndef UCLINUX
+static GSM_Error N6110_GetSpeedDial(GSM_SpeedDial *entry);
+static GSM_Error N6110_SetSpeedDial(GSM_SpeedDial *entry);
+#endif /* UCLINUX */
 
 
-GSM_Error N6110_GetMemoryStatus(GSM_MemoryStatus *Status);
-GSM_Error N6110_GetSMSStatus(GSM_SMSStatus *Status);
-GSM_Error N6110_GetSMSCenter(GSM_MessageCenter *MessageCenter);
+static GSM_Error N6110_GetMemoryStatus(GSM_MemoryStatus *Status);
+#ifndef UCLINUX
+static GSM_Error N6110_GetSMSStatus(GSM_SMSStatus *Status);
+static GSM_Error N6110_GetSMSCenter(GSM_MessageCenter *MessageCenter);
   
   
-GSM_Error N6110_GetSMSMessage(GSM_SMSMessage *Message);
-GSM_Error N6110_DeleteSMSMessage(GSM_SMSMessage *Message);
-GSM_Error N6110_SendSMSMessage(GSM_SMSMessage *Message);
-GSM_Error N6110_SaveSMSMessage(GSM_SMSMessage *Message);
+static GSM_Error N6110_GetSMSMessage(GSM_SMSMessage *Message);
+static GSM_Error N6110_DeleteSMSMessage(GSM_SMSMessage *Message);
+static GSM_Error N6110_SendSMSMessage(GSM_SMSMessage *Message);
+static GSM_Error N6110_SaveSMSMessage(GSM_SMSMessage *Message);
+#endif /* UCLINUX */
 
 
-GSM_Error N6110_GetRFLevel(GSM_RFUnits *units, float *level);
-GSM_Error N6110_GetBatteryLevel(GSM_BatteryUnits *units, float *level);
-GSM_Error N6110_GetPowerSource(GSM_PowerSource *source);
-GSM_Error N6110_GetDisplayStatus(int *Status);
+static GSM_Error N6110_GetRFLevel(GSM_RFUnits *units, float *level);
+static GSM_Error N6110_GetBatteryLevel(GSM_BatteryUnits *units, float *level);
+static GSM_Error N6110_GetPowerSource(GSM_PowerSource *source);
+#ifndef UCLINUX
+static GSM_Error N6110_GetDisplayStatus(int *Status);
 
 
-GSM_Error N6110_EnterSecurityCode(GSM_SecurityCode SecurityCode);
-GSM_Error N6110_GetSecurityCodeStatus(int *Status);
-GSM_Error N6110_GetSecurityCode(GSM_SecurityCode *SecurityCode);
+static GSM_Error N6110_EnterSecurityCode(GSM_SecurityCode SecurityCode);
+static GSM_Error N6110_GetSecurityCodeStatus(int *Status);
+static GSM_Error N6110_GetSecurityCode(GSM_SecurityCode *SecurityCode);
 
 
-GSM_Error N6110_GetSMSCenter(GSM_MessageCenter *MessageCenter);
-GSM_Error N6110_SetSMSCenter(GSM_MessageCenter *MessageCenter);
+static GSM_Error N6110_GetSMSCenter(GSM_MessageCenter *MessageCenter);
+static GSM_Error N6110_SetSMSCenter(GSM_MessageCenter *MessageCenter);
 
 
-GSM_Error N6110_GetIMEI(char *imei);
-GSM_Error N6110_GetRevision(char *revision);
-GSM_Error N6110_GetModel(char *model);
-GSM_Error N6110_GetManufacturer(char *manufacturer);
+static GSM_Error N6110_GetIMEI(char *imei);
+static GSM_Error N6110_GetRevision(char *revision);
+static GSM_Error N6110_GetModel(char *model);
+#endif /* UCLINUX */
+static GSM_Error N6110_GetManufacturer(char *manufacturer);
 
 
-GSM_Error N6110_GetDateTime(GSM_DateTime *date_time);
-GSM_Error N6110_SetDateTime(GSM_DateTime *date_time);
+#ifndef UCLINUX
+static GSM_Error N6110_GetDateTime(GSM_DateTime *date_time);
+static GSM_Error N6110_SetDateTime(GSM_DateTime *date_time);
 
 
-GSM_Error N6110_PrivGetDateTime(GSM_DateTime *date_time, int msgtype);
-GSM_Error N6110_PrivSetDateTime(GSM_DateTime *date_time, int msgtype);
+static GSM_Error N6110_PrivGetDateTime(GSM_DateTime *date_time, int msgtype);
+static GSM_Error N6110_PrivSetDateTime(GSM_DateTime *date_time, int msgtype);
 
 
-GSM_Error N6110_GetAlarm(int alarm_number, GSM_DateTime *date_time);
-GSM_Error N6110_SetAlarm(int alarm_number, GSM_DateTime *date_time);
+static GSM_Error N6110_GetAlarm(int alarm_number, GSM_DateTime *date_time);
+static GSM_Error N6110_SetAlarm(int alarm_number, GSM_DateTime *date_time);
 
 
-GSM_Error N6110_PrivGetAlarm(int alarm_number, GSM_DateTime *date_time, int msgtype);
-GSM_Error N6110_PrivSetAlarm(int alarm_number, GSM_DateTime *date_time, int msgtype);
+static GSM_Error N6110_PrivGetAlarm(int alarm_number, GSM_DateTime *date_time, int msgtype);
+static GSM_Error N6110_PrivSetAlarm(int alarm_number, GSM_DateTime *date_time, int msgtype);
 
 
-GSM_Error N6110_DialVoice(char *Number);
-GSM_Error N6110_DialData(char *Number, char type,  void (* callpassup)(char c));
-GSM_Error N6110_AnswerCall(char s);
+static GSM_Error N6110_DialVoice(char *Number);
+#endif /* UCLINUX */
+static GSM_Error N6110_DialData(char *Number, char type,  void (* callpassup)(char c));
+#ifndef UCLINUX
+static GSM_Error N6110_AnswerCall(char s);
 
 
-GSM_Error N6110_GetIncomingCallNr(char *Number);
+static GSM_Error N6110_GetIncomingCallNr(char *Number);
 
 
-GSM_Error N6110_SendBitmap(char *NetworkCode, int width, int height,
-                          unsigned char *bitmap);
-GSM_Error N6110_GetNetworkInfo(GSM_NetworkInfo *NetworkInfo);
+static GSM_Error N6110_GetNetworkInfo(GSM_NetworkInfo *NetworkInfo);
 
 
-GSM_Error N6110_GetCalendarNote(GSM_CalendarNote *CalendarNote);
-GSM_Error N6110_WriteCalendarNote(GSM_CalendarNote *CalendarNote);
-GSM_Error N6110_DeleteCalendarNote(GSM_CalendarNote *CalendarNote);
+static GSM_Error N6110_GetCalendarNote(GSM_CalendarNote *CalendarNote);
+static GSM_Error N6110_WriteCalendarNote(GSM_CalendarNote *CalendarNote);
+static GSM_Error N6110_DeleteCalendarNote(GSM_CalendarNote *CalendarNote);
 
 
-GSM_Error N6110_NetMonitor(unsigned char mode, char *Screen);
+static GSM_Error N6110_NetMonitor(unsigned char mode, char *Screen);
 
 
-GSM_Error N6110_PlayTone(int Herz, u8 Volume);
+static GSM_Error N6110_PlayTone(int Herz, u8 Volume);
 
 
-GSM_Error N6110_SetBitmap( GSM_Bitmap *Bitmap );
-GSM_Error N6110_GetBitmap( GSM_Bitmap *Bitmap );
+static GSM_Error N6110_SetBitmap( GSM_Bitmap *Bitmap );
+static GSM_Error N6110_GetBitmap( GSM_Bitmap *Bitmap );
 
 
-GSM_Error N6110_SetRingTone(GSM_Ringtone *ringtone, int *maxlength);
-GSM_Error N6110_SetBinRingTone(GSM_BinRingtone *ringtone);
-GSM_Error N6110_GetBinRingTone(GSM_BinRingtone *ringtone);
+static GSM_Error N6110_SetRingTone(GSM_Ringtone *ringtone, int *maxlength);
+static GSM_Error N6110_SetBinRingTone(GSM_BinRingtone *ringtone);
+static GSM_Error N6110_GetBinRingTone(GSM_BinRingtone *ringtone);
 
 
-GSM_Error N6110_EnableDisplayOutput();
-GSM_Error N6110_DisableDisplayOutput();
+static GSM_Error N6110_EnableDisplayOutput();
+static GSM_Error N6110_DisableDisplayOutput();
 
 
-GSM_Error N6110_EnableCellBroadcast ();
-GSM_Error N6110_DisableCellBroadcast(void);
-GSM_Error N6110_ReadCellBroadcast (GSM_CBMessage *Message);
+static GSM_Error N6110_EnableCellBroadcast ();
+static GSM_Error N6110_DisableCellBroadcast(void);
+static GSM_Error N6110_ReadCellBroadcast (GSM_CBMessage *Message);
 
 
-GSM_Error N6110_SendDTMF(char *String);
+static GSM_Error N6110_SendDTMF(char *String);
+#endif /* UCLINUX */
 
 
-GSM_Error N6110_Reset(unsigned char type);
+static GSM_Error N6110_Reset(unsigned char type);
 
 
-GSM_Error N6110_GetProfile(GSM_Profile *Profile);
-GSM_Error N6110_SetProfile(GSM_Profile *Profile);
-bool      N6110_SendRLPFrame(RLP_F96Frame *frame, bool out_dtx);
+#ifndef UCLINUX
+static GSM_Error N6110_GetProfile(GSM_Profile *Profile);
+static GSM_Error N6110_SetProfile(GSM_Profile *Profile);
+static bool      N6110_SendRLPFrame(RLP_F96Frame *frame, bool out_dtx);
+#endif /* UCLINUX */
 
 
-GSM_Error N6110_CancelCall(void);
+static GSM_Error N6110_CancelCall(void);
 
 
-GSM_Error N6110_PressKey(int key, int event);
+#ifndef UCLINUX
+static GSM_Error N6110_PressKey(int key, int event);
 
 
-GSM_Error N6110_GetProductProfileSetting (GSM_PPS *PPS);
-GSM_Error N6110_SetProductProfileSetting (GSM_PPS *PPS);
+static GSM_Error N6110_GetProductProfileSetting (GSM_PPS *PPS);
+static GSM_Error N6110_SetProductProfileSetting (GSM_PPS *PPS);
 
 
-GSM_Error N6110_CallDivert(GSM_CallDivert *cd);
+static GSM_Error N6110_CallDivert(GSM_CallDivert *cd);
+#endif /* UCLINUX */
 
 
-void N6110_RX_HandleRLPMessage(u8 *MessageBuffer);
+static void N6110_RX_HandleRLPMessage(u8 *MessageBuffer);
 
 
-GSM_Error N6110_SendIMEIFrame();
-GSM_Error N6110_SendIDFrame();
-GSM_Error N6110_SendHWFrame();
+static GSM_Error N6110_SendIMEIFrame();
+static GSM_Error N6110_SendIDFrame();
+static GSM_Error N6110_SendHWFrame();
 
 
-GSM_Error N6110_EnableExtendedCommands (unsigned char status);
+static GSM_Error N6110_EnableExtendedCommands (unsigned char status);
 
 
-GSM_Error N6110_Tests();
+#ifndef UCLINUX
+static GSM_Error N6110_Tests();
 
 
-void N6110_DisplayTestsInfo(u8 *MessageBuffer);
+static void N6110_DisplayTestsInfo(u8 *MessageBuffer);
 
 
-GSM_Error N6110_SimlockInfo(GSM_AllSimlocks *siml);\r
-GSM_Error N6110_GetSMSFolders ( GSM_SMSFolders *folders);
+static GSM_Error N6110_SimlockInfo(GSM_AllSimlocks *siml);\r
+static GSM_Error N6110_GetSMSFolders ( GSM_SMSFolders *folders);
 
 
-GSM_Error N6110_ResetPhoneSettings();
+static GSM_Error N6110_ResetPhoneSettings();
+#endif /* UCLINUX */
 
 
-void N6110_Dispatch0x01Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
+static void N6110_Dispatch0x01Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
 
 
-void N6110_ReplySendSMSMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
-void N6110_ReplySetSMSCenter  (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
-void N6110_ReplyGetSMSCenter  (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
-void N6110_Dispatch0x02Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
-void N6110_ReplySetCellBroadcast (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
-void N6110_ReplyReadCellBroadcast(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
+#ifndef UCLINUX
+static void N6110_ReplySendSMSMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
+static void N6110_ReplySetSMSCenter  (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
+static void N6110_ReplyGetSMSCenter  (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
+static void N6110_Dispatch0x02Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
+static void N6110_ReplySetCellBroadcast (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
+static void N6110_ReplyReadCellBroadcast(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
 
 
-void N6110_ReplyCallDivert    (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
-void N6110_Dispatch0x06Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
+static void N6110_ReplyCallDivert    (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
+static void N6110_Dispatch0x06Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
+#endif /* UCLINUX */
 
 
-void N6110_ReplySetDateTime(u16 MessageLength,u8 *MessageBuffer, u8 MessageType);
-void N6110_ReplyGetDateTime(u16 MessageLength,u8 *MessageBuffer, u8 MessageType);
-void N6110_ReplySetAlarm   (u16 MessageLength,u8 *MessageBuffer, u8 MessageType);
-void N6110_ReplyGetAlarm   (u16 MessageLength,u8 *MessageBuffer, u8 MessageType);
+#ifndef UCLINUX
+static void N6110_ReplySetDateTime(u16 MessageLength,u8 *MessageBuffer, u8 MessageType);
+static void N6110_ReplyGetDateTime(u16 MessageLength,u8 *MessageBuffer, u8 MessageType);
+static void N6110_ReplySetAlarm   (u16 MessageLength,u8 *MessageBuffer, u8 MessageType);
+static void N6110_ReplyGetAlarm   (u16 MessageLength,u8 *MessageBuffer, u8 MessageType);
+#endif /* UCLINUX */
 
 
-void N6110_ReplyEnableExtendedCommands  (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
-void N6110_ReplyResetPhoneSettings      (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
-void N6110_ReplyIMEI                    (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
-void N6110_ReplyGetProductProfileSetting(u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
-void N6110_ReplySetProductProfileSetting(u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
-void N6110_ReplyNetmonitor              (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
-void N6110_ReplySimlockInfo             (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
-void N6110_ReplyPlayTone                (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
-void N6110_ReplyHW                      (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
-void N6110_Dispatch0x40Message          (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
+static void N6110_ReplyEnableExtendedCommands  (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
+#ifndef UCLINUX
+static void N6110_ReplyResetPhoneSettings      (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
+#endif /* UCLINUX */
+static void N6110_ReplyIMEI                    (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
+#ifndef UCLINUX
+static void N6110_ReplyGetProductProfileSetting(u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
+static void N6110_ReplySetProductProfileSetting(u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
+static void N6110_ReplyNetmonitor              (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
+static void N6110_ReplySimlockInfo             (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
+static void N6110_ReplyPlayTone                (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
+#endif /* UCLINUX */
+static void N6110_ReplyHW                      (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
+static void N6110_Dispatch0x40Message          (u16 MessageLength,u8 *MessageBuffer,u8 MessageType);
 
 
-void N6110_DispatchACKMessage (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
-void N6110_ReplyID(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
+static void N6110_DispatchACKMessage (u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
+static void N6110_ReplyID(u16 MessageLength, u8 *MessageBuffer, u8 MessageType);
 
 
-GSM_Error GSM_EncodeNokiaSMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int *length, SMS_MessageType PDU);
-GSM_Error GSM_DecodeNokiaSMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int length);
+#ifndef UCLINUX
+static GSM_Error GSM_EncodeNokiaSMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int *length, SMS_MessageType PDU);
+static GSM_Error GSM_DecodeNokiaSMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int length);
 
 
-int N6110_MakeCallerGroupFrame (unsigned char *req,GSM_Bitmap Bitmap);
-int N6110_MakeOperatorLogoFrame(unsigned char *req,GSM_Bitmap Bitmap);
-int N6110_MakeStartupLogoFrame (unsigned char *req,GSM_Bitmap Bitmap);
+static int N6110_MakeCallerGroupFrame (unsigned char *req,GSM_Bitmap Bitmap);
+static int N6110_MakeOperatorLogoFrame(unsigned char *req,GSM_Bitmap Bitmap);
+static int N6110_MakeStartupLogoFrame (unsigned char *req,GSM_Bitmap Bitmap);
+#endif /* UCLINUX */
 
 #endif /* __n_6110_h */
 
 #endif /* __n_6110_h */
index 1340262..a42a7fa 100644 (file)
@@ -49,13 +49,4 @@ enum FBUS_RX_States {
   FBUS_RX_GetMessage
 };
 
   FBUS_RX_GetMessage
 };
 
-GSM_Error FBUS_Initialise(char *port_device, char *initlength,
-                          GSM_ConnectionType connection,
-                          void (*rlp_callback)(RLP_F96Frame *frame));
-
-int FBUS_SendMessage(u16 message_length, u8 message_type, u8 *buffer);
-int FBUS_SendFrame(u16 message_length, u8 message_type, u8 *buffer);
-void FBUS_Terminate(void);
-void FBUS_RX_StateMachine(unsigned char rx_byte);
-
 #endif /* __fbus_h */
 #endif /* __fbus_h */
diff --git a/include/uccompat.h b/include/uccompat.h
new file mode 100644 (file)
index 0000000..807e74f
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+
+  $Id$
+
+  G N O K I I
+
+  A Linux/Unix toolset and driver for Nokia mobile phones.
+
+  Released under the terms of the GNU GPL, see file COPYING for more details.
+
+*/
+
+#ifndef __UCCOMPAT_H__
+#define __UCCOMPAT_H__
+
+#ifdef UCCOMPAT
+
+
+/* Handle non-existing atoi() */
+#include <limits.h>
+#define atoi(s) ({ \
+               long _atoi_l=strtol((s), (char **)NULL, 10); \
+               /**/ if (_atoi_l<INT_MIN) _atoi_l=INT_MIN; \
+               else if (_atoi_l>INT_MAX) _atoi_l=INT_MAX; \
+               _atoi_l; \
+               })
+
+#define strchr _Xstrchr
+#define strrchr _Xstrrchr
+#include <string.h>
+#undef strchr
+#undef strrchr
+extern char * strchr __P ((const char *, int));
+extern char * strrchr __P ((const char *, int));
+
+#define getpid() (2)
+
+
+#endif /* UCCOMPAT */
+
+#endif /* __UCCOMPAT_H__ */
index 04af119..e724eac 100644 (file)
@@ -11,7 +11,7 @@ include $(TOPDIR)/Makefile.global
 
 OBJS = mgnokiidev.o
 
 
 OBJS = mgnokiidev.o
 
-all: mgnokiidev
+all: #mgnokiidev
 
 mgnokiidev: $(OBJS) 
 
 
 mgnokiidev: $(OBJS)