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)
#include "phones/nokia.h"
#ifndef WIN32
-# include <unistd.h>
+ #include <unistd.h>
+ #include <pthread.h>
#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 */
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)
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;
}
if (P3110_MEMORY_SIZE_ME == 0) return GE_NOTREADY;
return P3110_GetSMSInfo(data, state);
default:
- break;
}
return GE_NOTREADY;
}
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;
}
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;
}
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;
}
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(' ');
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) {
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) {
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;
}
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;
break;
default:
data->SMSMessage->MemoryType = GMT_XX;
- break;
}
Set location in memory
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);
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;
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",
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;
}
{
u8 center_number_length;
u8 option_number_length;
+#ifdef DEBUG
int count;
+#endif
if (!data) return GE_INTERNALERROR;
/* 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]);
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) {
data->MemoryStatus->Free = P3110_MEMORY_SIZE_ME - message[3];
break;
default:
- break;
}
}
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;
}
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",
"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.
*(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;
}
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;
}