X-Git-Url: http://git.jankratochvil.net/?a=blobdiff_plain;f=common%2Fphones%2Fnk2110.c;h=bcf6e1b48a90fb51840b98f21e8ab6b0e2e547c0;hb=7752f472c7fca5f6486e67332e3b8b33bdd78f5a;hp=bee7093815630927c5d64857b079b9b34619ccae;hpb=4ee1266711b695852ec88f06784fd84400cd70bb;p=gnokii.git diff --git a/common/phones/nk2110.c b/common/phones/nk2110.c index bee7093..bcf6e1b 100644 --- a/common/phones/nk2110.c +++ b/common/phones/nk2110.c @@ -11,21 +11,8 @@ Released under the terms of the GNU GPL, see file COPYING for more details. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:11 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 - - Revision 1.16 2001/11/23 22:07:44 machek - Fix SMS receiving to work, again. Unfortunately, it is not possible to - reuse much of gsm-sms.c... - - Revision 1.15 2001/11/15 12:10:57 pkot - Removed a warning from 2110 compilation - - Revision 1.14 2001/11/09 13:49:12 pkot - Pavel! You haven't implemented slave_process() function! - - Revision 1.13 2001/11/09 13:17:11 pkot - Update 2110 to a new libsms api + Revision 1.1.1.3 2002/04/03 00:08:09 short + Found in "gnokii-working" directory, some November-patches version Revision 1.12 2001/10/21 22:23:56 machek Use symbolic constants instead of numbers @@ -100,7 +87,6 @@ #include "mbus-2110.h" #include "phones/nokia.h" #include "device.h" -#include "gsm-sms.h" #include #include @@ -371,7 +357,8 @@ SMS(GSM_SMSMessage *message, int command) PacketOK = false; pkt[1] = command; pkt[2] = 1; /* == LM_SMS_MEM_TYPE_DEFAULT or LM_SMS_MEM_TYPE_SIM or LM_SMS_MEM_TYPE_ME */ - pkt[3] = message->Number; + pkt[3] = message->Location; + message->MessageNumber = message->Location; SendCommand(pkt, LM_SMS_COMMAND, sizeof(pkt)); msleep_poll(300); /* We have to keep acknowledning phone's data */ @@ -383,8 +370,8 @@ SMS(GSM_SMSMessage *message, int command) eprintf("Something is very wrong with SMS\n"); return GE_BUSY; /* FIXME */ } - if ((SMSData[2]) && (SMSData[2] != message->Number)) { - eprintf("Wanted message @%d, got message at @%d!\n", message->Number, SMSData[2]); + if ((SMSData[2]) && (SMSData[2] != message->Location)) { + eprintf("Wanted message @%d, got message at @%d!\n", message->Location, SMSData[2]); return GE_BUSY; } return (GE_NONE); @@ -394,23 +381,28 @@ SMS(GSM_SMSMessage *message, int command) static GSM_Error DecodeIncomingSMS(GSM_SMSMessage *m) { - GSM_Error error; - int len, i; - - error = GE_NONE; -/* Should be moved to gsm-sms.c */ - + int i, len; ddprintf("Status: " ); switch (SMSData[3]) { - case 7: m->Type = SMS_Submit; /* m->Status = GSS_NOTSENTREAD; */ ddprintf("not sent\n"); break; - case 5: m->Type = SMS_Submit; /* m->Status = GSS_SENTREAD; */ ddprintf("sent\n"); break; - case 3: m->Type = SMS_Deliver; /* m->Status = GSS_NOTSENTREAD; */ ddprintf("not read\n"); break; - case 1: m->Type = SMS_Deliver; /* m->Status = GSS_SENTREAD; */ ddprintf("read\n"); break; + case 7: m->Type = GST_MO; m->Status = GSS_NOTSENTREAD; ddprintf("not sent\n"); break; + case 5: m->Type = GST_MO; m->Status = GSS_SENTREAD; ddprintf("sent\n"); break; + case 3: m->Type = GST_MT; m->Status = GSS_NOTSENTREAD; ddprintf("not read\n"); break; + case 1: m->Type = GST_MT; m->Status = GSS_SENTREAD; ddprintf("read\n"); break; } - UnpackDateTime(SMSData+7, &m->Time); + /* Date is at SMSData[7]; this code is copied from fbus-6110.c*/ + { + int offset = -32 + 7; + m->Time.Year=10*(SMSData[32+offset]&0x0f)+(SMSData[32+offset]>>4); + m->Time.Month=10*(SMSData[33+offset]&0x0f)+(SMSData[33+offset]>>4); + m->Time.Day=10*(SMSData[34+offset]&0x0f)+(SMSData[34+offset]>>4); + m->Time.Hour=10*(SMSData[35+offset]&0x0f)+(SMSData[35+offset]>>4); + m->Time.Minute=10*(SMSData[36+offset]&0x0f)+(SMSData[36+offset]>>4); + m->Time.Second=10*(SMSData[37+offset]&0x0f)+(SMSData[37+offset]>>4); + m->Time.Timezone=(10*(SMSData[38+offset]&0x07)+(SMSData[38+offset]>>4))/4; + } - m->Length = len = SMSData[14]; + len = SMSData[14]; ddprintf("%d bytes: ", len ); for (i = 0; i160) eprintf("Magic not allowed\n"); - memset(m->MessageText, 0, 161); + memset(m->MessageText, 0, sizeof(m->MessageText)); strncpy(m->MessageText, (void *) &SMSData[15], len); - + m->MessageTextLength = len; /* we currently do not support UDH & 8-bit so it is simple */ + m->EightBit = false; ddprintf("Text is %s\n", m->MessageText); - /* - Originator address is at 15+i, - followed by message center addres (?) - */ + /* Originator address is at 15+i, + followed by message center addres (?) */ { char *s = (char *) &SMSData[15+i]; /* We discard volatile. Make compiler quiet. */ - strcpy(m->RemoteNumber.number, s); + strcpy(m->Sender, s); s+=strlen(s)+1; strcpy(m->MessageCenter.Number, s); ddprintf("Sender = %s, MessageCenter = %s\n", m->Sender, m->MessageCenter.Name); @@ -437,15 +428,14 @@ DecodeIncomingSMS(GSM_SMSMessage *m) m->MessageCenter.No = 0; strcpy(m->MessageCenter.Name, "(unknown)"); - m->UDH_No = 0; - - return error; + m->UDHPresent = false; + return GE_NONE; } static GSM_Error GetSMSMessage(GSM_SMSMessage *m) { - if (m->Number > 10) + if (m->Location > 10) return GE_INVALIDSMSLOCATION; if (SMS(m, LM_SMS_READ_STORED_DATA) != GE_NONE) @@ -467,7 +457,7 @@ GetSMSMessage(GSM_SMSMessage *m) static GSM_Error SendSMSMessage(GSM_SMSMessage *m) { - if (m->Number > 10) + if (m->Location > 10) return GE_INVALIDSMSLOCATION; if (SMSData[0] != 0x0b) { @@ -671,7 +661,7 @@ HandlePacket(void) return ((PacketData[4] & 0xf) != 0); /* Make all but last fragment "secret" */ - default: dprintf("Unknown response %dx\n", PacketData[3]); + default: dprintf("Unknown response %x\n", (unsigned int)PacketData[3]); return 0; } } @@ -1020,7 +1010,7 @@ static GSM_Error SMS_Reserve(GSM_Statemachine *sm) eprintf("Bad reply trying to reserve SMS-es\n"); if (SMSData[0] != LM_SMS_PP_RESERVE_COMPLETE) eprintf("Not okay trying to reserve SMS-es (%d)\n", SMSData[0]); - return GE_NONE; + } static GSM_Error SMS_Slave(GSM_Statemachine *sm) @@ -1047,14 +1037,12 @@ static GSM_Error SMS_Slave(GSM_Statemachine *sm) eprintf("New message indicated @%d\n", SMSData[2]); msleep_poll(200); memset(&m, 0, sizeof(m)); - m.Number = SMSData[2]; + m.Location = SMSData[2]; m.MemoryType = GMT_ME; if (GetSMSMessage(&m) != GE_NONE) eprintf("Could not find promissed message?\n"); -#if 0 else - slave_process(&m, SMSData[2]); -#endif + /*slave_process(&m, SMSData[2])*/; } break; default: @@ -1180,10 +1168,11 @@ WritePhonebookLocation(GSM_PhonebookEntry *entry) } static GSM_Error -GetSMSStatus(GSM_SMSMemoryStatus *Status) +GetSMSStatus(GSM_SMSStatus *Status) { - Status->Unread = 0; - Status->Number = 5; + Status->UnRead = 0; + Status->Used = 0; + Status->Slots = 5; return GE_NONE; } @@ -1232,7 +1221,6 @@ GSM_Functions N2110_Functions = { NULL, NULL, NULL, - NULL, SendRLPFrame, NULL, EnableDisplayOutput,