X-Git-Url: https://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=common%2Fphones%2Fnk3110.c;fp=common%2Fphones%2Fnk3110.c;h=9c74f3444254d0c8c925044a88d8ae8d5215721b;hp=df302041cfc41b2e9c70d84b53b785859127368b;hb=49dd905279a8e62936e3713510ab0fd738e20ecb;hpb=2f2703c9133032c12671ca5c77ae626b8fb178d4 diff --git a/common/phones/nk3110.c b/common/phones/nk3110.c index df30204..9c74f34 100644 --- a/common/phones/nk3110.c +++ b/common/phones/nk3110.c @@ -15,26 +15,8 @@ See README for more details on supported mobile phones. $Log$ - Revision 1.1.1.2 2001/11/27 22:01:20 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Tue Nov 27 22:58 CET 2001 - - Revision 1.7 2001/11/27 12:19:01 pkot - Cleanup, indentation, ANSI complaint preprocesor symbols (Jan Kratochvil, me) - - Revision 1.6 2001/11/20 16:22:22 pkot - First attempt to read Picture Messages. They should appear when you enable DEBUG. Nokia seems to break own standards. :/ (Markus Plail) - - Revision 1.5 2001/11/19 13:03:18 pkot - nk3110.c cleanup - - Revision 1.4 2001/11/17 16:42:47 pkot - Cleanup - - Revision 1.3 2001/11/09 14:25:04 pkot - DEBUG cleanups - - Revision 1.2 2001/11/09 13:47:58 pkot - Removed pthreads from 3110 support. It may break it. + Revision 1.1.1.3 2002/04/03 00:08:11 short + Found in "gnokii-working" directory, some November-patches version Revision 1.1 2001/11/08 16:39:09 pkot 3810/3110 support for the new structure (Tamas Bondar) @@ -55,10 +37,11 @@ #include "phones/nokia.h" #ifndef WIN32 -# include + #include + #include #else -# define snprintf _snprintf -# define usleep(x) Sleep(((x) < 1000) ? 1 : ((x) / 1000)) + #define snprintf _snprintf + #define usleep(x) Sleep(((x) < 1000) ? 1 : ((x) / 1000)) #endif /* Some globals */ @@ -173,6 +156,9 @@ static bool SimAvailable = false; static bool RequestTerminate; static bool DisableKeepAlive; static int KeepAliveTimer; +#ifndef WIN32 +pthread_t Thread; +#endif /* Initialise is the only function allowed to 'use' state */ static GSM_Error P3110_Initialise(GSM_Statemachine *state) @@ -213,6 +199,10 @@ static GSM_Error P3110_Initialise(GSM_Statemachine *state) KeepAliveTimer = P3110_KEEPALIVE_TIMEOUT; RequestTerminate = false; DisableKeepAlive = false; +#ifndef WIN32 + if (pthread_create(&Thread, NULL, (void *) P3110_KeepAliveLoop, state) != 0) + return (GE_INTERNALERROR); +#endif return GE_NONE; } @@ -253,7 +243,6 @@ static GSM_Error P3110_GetMemoryStatus(GSM_Data *data, GSM_Statemachine *state) if (P3110_MEMORY_SIZE_ME == 0) return GE_NOTREADY; return P3110_GetSMSInfo(data, state); default: - break; } return GE_NOTREADY; } @@ -568,7 +557,7 @@ static GSM_Error P3110_SendSMSMessage(GSM_Data *data, GSM_Statemachine *state) case 0x29: /* Got a retry response so try again! */ dprintf("SMS send attempt failed, trying again...\n"); - retry_count--; + retry_count --; /* After an empirically determined pause... */ usleep(500000); /* 0.5 seconds. */ break; @@ -602,16 +591,20 @@ static GSM_Error P3110_IncomingCall(int messagetype, unsigned char *message, int } buffer[count] = 0x00; +#ifdef DEBUG /* Now display incoming call message. */ dprintf("Incoming call - Type: %s. %02x, Number %s.\n", (message[2] == 0x05 ? "Voice":"Data?"), message[3], buffer); +#endif return GE_NONE; } static GSM_Error P3110_IncomingCallAnswered(int messagetype, unsigned char *message, int length, GSM_Data *data) { +#ifdef DEBUG dprintf("Incoming call answered from phone.\n"); +#endif return GE_NONE; } @@ -620,8 +613,10 @@ static GSM_Error P3110_IncomingCallAnswered(int messagetype, unsigned char *mess call message has three (unexplained) data bytes. */ static GSM_Error P3110_IncomingCallEstablished(int messagetype, unsigned char *message, int length, GSM_Data *data) { +#ifdef DEBUG dprintf("%s call established - status bytes %02x %02x.\n", (message[2] == 0x05 ? "voice":"data(?)"), message[3], message[4]); +#endif return GE_NONE; } @@ -630,7 +625,9 @@ static GSM_Error P3110_IncomingCallEstablished(int messagetype, unsigned char *m call terminates. */ static GSM_Error P3110_IncomingEndOfOutgoingCall(int messagetype, unsigned char *message, int length, GSM_Data *data) { +#ifdef DEBUG dprintf("Call terminated from phone (0x10 message).\n"); +#endif /* FIXME: Tell datapump code that the call has terminated. */ /*if (CallPassup) { CallPassup(' '); @@ -644,7 +641,9 @@ static GSM_Error P3110_IncomingEndOfOutgoingCall(int messagetype, unsigned char purpose as yet undertermined. */ static GSM_Error P3110_IncomingEndOfIncomingCall(int messagetype, unsigned char *message, int length, GSM_Data *data) { +#ifdef DEBUG dprintf("Call terminated from opposite end of line (or from network).\n"); +#endif /* FIXME: Tell datapump code that the call has terminated. */ /*if (CallPassup) { @@ -660,7 +659,9 @@ static GSM_Error P3110_IncomingEndOfIncomingCall(int messagetype, unsigned char yet undertermined. */ static GSM_Error P3110_IncomingEndOfOutgoingCall2(int messagetype, unsigned char *message, int length, GSM_Data *data) { +#ifdef DEBUG dprintf("Call terminated from phone (0x12 message).\n"); +#endif /* FIXME: Tell datapump code that the call has terminated. */ /*if (CallPassup) { @@ -701,7 +702,9 @@ static GSM_Error P3110_IncomingInitFrame_0x15(int messagetype, unsigned char *me static GSM_Error P3110_IncomingInitFrame_0x16(int messagetype, unsigned char *message, int length, GSM_Data *data) { SimAvailable = (message[2] == 0x02); +#ifdef DEBUG dprintf("SIM available: %s.\n", (SimAvailable ? "Yes" : "No")); +#endif return GE_NONE; } @@ -776,7 +779,7 @@ static GSM_Error P3110_IncomingSMSSendError(int messagetype, unsigned char *mess static GSM_Error P3110_IncomingSMSHeader(int messagetype, unsigned char *message, int length, GSM_Data *data) { - /* u8 sender_length, smsc_length, l; */ + u8 sender_length, smsc_length, l; if (!data->SMSMessage) return GE_INTERNALERROR; @@ -795,7 +798,6 @@ static GSM_Error P3110_IncomingSMSHeader(int messagetype, unsigned char *message break; default: data->SMSMessage->MemoryType = GMT_XX; - break; } Set location in memory @@ -870,8 +872,8 @@ static GSM_Error P3110_IncomingSMSHeader(int messagetype, unsigned char *message message[6], message[7], message[14], message[4], message[5]); dprintf("Message Read:\n"); - dprintf(" Location: %d. Type: %d Status: %d\n", data->SMSMessage->Number, data->SMSMessage->Type, data->SMSMessage->Status); - dprintf(" Sender: %s\n", data->SMSMessage->RemoteNumber.number); + dprintf(" Location: %d. Type: %d Status: %d\n", data->SMSMessage->Location, data->SMSMessage->Type, data->SMSMessage->Status); + dprintf(" Sender: %s\n", data->SMSMessage->Sender); dprintf(" Message Center: %s\n", data->SMSMessage->MessageCenter.Number); dprintf(" Time: %02d.%02d.%02d %02d:%02d:%02d\n", data->SMSMessage->Time.Day, data->SMSMessage->Time.Month, data->SMSMessage->Time.Year, data->SMSMessage->Time.Hour, data->SMSMessage->Time.Minute, data->SMSMessage->Time.Second); @@ -921,7 +923,7 @@ static GSM_Error P3110_IncomingSMSDeleteError(int messagetype, unsigned char *me static GSM_Error P3110_IncomingSMSDelivered(int messagetype, unsigned char *message, int length, GSM_Data *data) { static GSM_SMSMessage sms; -/* u8 dest_length, smsc_length, l;*/ + u8 dest_length, smsc_length, l; u8 U0, U1, U2; data->SMSMessage = &sms; @@ -957,8 +959,8 @@ static GSM_Error P3110_IncomingSMSDelivered(int messagetype, unsigned char *mess data->SMSMessage->MessageCenter.Number[l] = 0; */ - dprintf("Message [0x%02x] Delivered!\n", data->SMSMessage->Number); - dprintf(" Destination: %s\n", data->SMSMessage->RemoteNumber.number); + dprintf("Message [0x%02x] Delivered!\n", data->SMSMessage->MessageNumber); + dprintf(" Destination: %s\n", data->SMSMessage->Destination); dprintf(" Message Center: %s\n", data->SMSMessage->MessageCenter.Number); dprintf(" Unknowns: 0x%02x 0x%02x 0x%02x\n", U0, U1, U2); dprintf(" Discharge Time: %02d.%02d.%02d %02d:%02d:%02d\n", @@ -975,7 +977,9 @@ static GSM_Error P3110_IncomingSMSDelivered(int messagetype, unsigned char *mess static GSM_Error P3110_IncomingNoSMSInfo(int messagetype, unsigned char *message, int length, GSM_Data *data) { +#ifdef DEBUG dprintf("SMS Message Center Data not reachable.\n"); +#endif return GE_NOTREADY; } @@ -987,7 +991,9 @@ static GSM_Error P3110_IncomingSMSInfo(int messagetype, unsigned char *message, { u8 center_number_length; u8 option_number_length; +#ifdef DEBUG int count; +#endif if (!data) return GE_INTERNALERROR; @@ -997,6 +1003,8 @@ static GSM_Error P3110_IncomingSMSInfo(int messagetype, unsigned char *message, /* Get message center length */ center_number_length = message[13 + option_number_length]; + +#ifdef DEBUG dprintf("SMS Message Center Data:\n"); dprintf(" Selected memory: 0x%02x\n", message[2]); dprintf(" Messages in Phone: 0x%02x Unread: 0x%02x\n", message[3], message[4]); @@ -1017,6 +1025,7 @@ static GSM_Error P3110_IncomingSMSInfo(int messagetype, unsigned char *message, dprintf("%c", message[14 + option_number_length + count]); } dprintf("\n"); +#endif /* Get message center related info if upper layer wants to know */ if (data->MessageCenter) { @@ -1056,7 +1065,6 @@ static GSM_Error P3110_IncomingSMSInfo(int messagetype, unsigned char *message, data->MemoryStatus->Free = P3110_MEMORY_SIZE_ME - message[3]; break; default: - break; } } @@ -1071,7 +1079,9 @@ static GSM_Error P3110_IncomingSMSInfo(int messagetype, unsigned char *message, static GSM_Error P3110_IncomingPINEntered(int messagetype, unsigned char *message, int length, GSM_Data *data) { SimAvailable = true; +#ifdef DEBUG dprintf("PIN [possibly] entered.\n"); +#endif return GE_NONE; } @@ -1083,6 +1093,7 @@ static GSM_Error P3110_IncomingPINEntered(int messagetype, unsigned char *messag static GSM_Error P3110_IncomingStatusInfo(int messagetype, unsigned char *message, int length, GSM_Data *data) { /* Strings for the status byte received from phone. */ +#ifdef DEBUG char *StatusStr[] = { "Unknown", "Ready", @@ -1090,6 +1101,7 @@ static GSM_Error P3110_IncomingStatusInfo(int messagetype, unsigned char *messag "Call in progress", "No network access" }; +#endif /* There are three data bytes in the status message, two have been attributed to signal level, the third is presently unknown. @@ -1112,10 +1124,12 @@ static GSM_Error P3110_IncomingStatusInfo(int messagetype, unsigned char *messag *(data->BatteryLevel) = message[4]; } +#ifdef DEBUG /* Only output connection status byte now as the RF and Battery levels are displayed by the main gnokii code. */ dprintf("Status: %s, Battery level: %d, RF level: %d.\n", StatusStr[message[2]], message[4], message[3]); +#endif return GE_NONE; } @@ -1138,10 +1152,12 @@ static GSM_Error P3110_IncomingPhoneInfo(int messagetype, unsigned char *message if (data->Model) strcpy(data->Model, message + 4 + imei_length + rev_length); +#ifdef DEBUG dprintf("Mobile Phone Identification:\n"); dprintf(" IMEI: %s\n", message + 2); dprintf(" Model: %s\n", message + 4 + imei_length + rev_length); dprintf(" Revision: %s\n", message + 3 + imei_length); +#endif return GE_NONE; }