Diffstat (limited to 'gammu/emb/common/service/sms/gsmsms.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/service/sms/gsmsms.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gammu/emb/common/service/sms/gsmsms.c b/gammu/emb/common/service/sms/gsmsms.c index 9920835..feceba4 100644 --- a/gammu/emb/common/service/sms/gsmsms.c +++ b/gammu/emb/common/service/sms/gsmsms.c | |||
@@ -1,98 +1,101 @@ | |||
1 | /* (c) 2001-2004 by Marcin Wiacek */ | 1 | /* (c) 2001-2004 by Marcin Wiacek */ |
2 | /* based on some work from Pawel Kot, others and Gnokii */ | 2 | /* Based on some Pawel Kot and others work from Gnokii (www.gnokii.org) |
3 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
4 | * GNU GPL version 2 or later | ||
5 | */ | ||
3 | 6 | ||
4 | #include <ctype.h> | 7 | #include <ctype.h> |
5 | #include <string.h> | 8 | #include <string.h> |
6 | #include <time.h> | 9 | #include <time.h> |
7 | 10 | ||
8 | #include "../../gsmcomon.h" | 11 | #include "../../gsmcomon.h" |
9 | #include "../../misc/coding/coding.h" | 12 | #include "../../misc/coding/coding.h" |
10 | #include "../gsmcal.h" | 13 | #include "../gsmcal.h" |
11 | #include "../gsmpbk.h" | 14 | #include "../gsmpbk.h" |
12 | #include "../gsmlogo.h" | 15 | #include "../gsmlogo.h" |
13 | #include "../gsmring.h" | 16 | #include "../gsmring.h" |
14 | #include "../gsmdata.h" | 17 | #include "../gsmdata.h" |
15 | #include "../gsmnet.h" | 18 | #include "../gsmnet.h" |
16 | #include "gsmsms.h" | 19 | #include "gsmsms.h" |
17 | 20 | ||
18 | /* User data headers */ | 21 | /* User data headers */ |
19 | static GSM_UDHHeader UDHHeaders[] = { | 22 | static GSM_UDHHeader UDHHeaders[] = { |
20 | /* See GSM 03.40 section 9.2.3.24.1 | 23 | /* See GSM 03.40 section 9.2.3.24.1 |
21 | * 1 byte 0x00 | 24 | * 1 byte 0x00 |
22 | * 1 byte 0x03 | 25 | * 1 byte 0x03 |
23 | * 1 byte 0x01: unique ID for message series | 26 | * 1 byte 0x01: unique ID for message series |
24 | * 1 byte 0x00: how many SMS in sequence | 27 | * 1 byte 0x00: how many SMS in sequence |
25 | * 1 byte 0x00: number of current SMS in sequence */ | 28 | * 1 byte 0x00: number of current SMS in sequence */ |
26 | { UDH_ConcatenatedMessages, 0x05, "\x00\x03\x01\x00\x00",2,-1,4,3}, | 29 | { UDH_ConcatenatedMessages, 0x05, "\x00\x03\x01\x00\x00",2,-1,4,3}, |
27 | 30 | ||
28 | /* See GSM 03.40 section 9.2.3.24.2 for voice, fax and email messages */ | 31 | /* See GSM 03.40 section 9.2.3.24.2 for voice, fax and email messages */ |
29 | { UDH_DisableVoice, 0x04, "\x01\x02\x00\x00",-1,-1,-1,-1}, | 32 | { UDH_DisableVoice, 0x04, "\x01\x02\x00\x00",-1,-1,-1,-1}, |
30 | { UDH_DisableFax, 0x04, "\x01\x02\x01\x00",-1,-1,-1,-1}, | 33 | { UDH_DisableFax, 0x04, "\x01\x02\x01\x00",-1,-1,-1,-1}, |
31 | { UDH_DisableEmail, 0x04, "\x01\x02\x02\x00",-1,-1,-1,-1}, | 34 | { UDH_DisableEmail, 0x04, "\x01\x02\x02\x00",-1,-1,-1,-1}, |
32 | { UDH_EnableVoice, 0x04, "\x01\x02\x00\x01",-1,-1,-1,-1}, | 35 | { UDH_EnableVoice, 0x04, "\x01\x02\x00\x01",-1,-1,-1,-1}, |
33 | { UDH_EnableFax, 0x04, "\x01\x02\x01\x01",-1,-1,-1,-1}, | 36 | { UDH_EnableFax, 0x04, "\x01\x02\x01\x01",-1,-1,-1,-1}, |
34 | { UDH_EnableEmail, 0x04, "\x01\x02\x02\x01",-1,-1,-1,-1}, | 37 | { UDH_EnableEmail, 0x04, "\x01\x02\x02\x01",-1,-1,-1,-1}, |
35 | 38 | ||
36 | /* When send such SMS to some phones, they don't display anything, | 39 | /* When send such SMS to some phones, they don't display anything, |
37 | * only beep and enable vibra/light | 40 | * only beep and enable vibra/light |
38 | */ | 41 | */ |
39 | { UDH_VoidSMS, 0x08, "\x01\x02\x02\x01\x01\x02\x02\x00",-1,-1,-1,-1}, | 42 | { UDH_VoidSMS, 0x08, "\x01\x02\x02\x01\x01\x02\x02\x00",-1,-1,-1,-1}, |
40 | 43 | ||
41 | /* Nokia Smart Messaging (short version) UDH | 44 | /* Nokia Smart Messaging (short version) UDH |
42 | * General format : | 45 | * General format : |
43 | * 1 byte 0x05 : IEI application port addressing scheme, 16 bit address | 46 | * 1 byte 0x05 : IEI application port addressing scheme, 16 bit address |
44 | * 1 byte 0x04 : IEI length | 47 | * 1 byte 0x04 : IEI length |
45 | * 2 bytes : destination address : high & low byte | 48 | * 2 bytes : destination address : high & low byte |
46 | * 2 bytes 0x00 0x00 : originator address : high & low byte */ | 49 | * 2 bytes 0x00 0x00 : originator address : high & low byte */ |
47 | { UDH_NokiaRingtone, 0x06, "\x05\x04\x15\x81\x00\x00",-1,-1,-1,-1}, | 50 | { UDH_NokiaRingtone, 0x06, "\x05\x04\x15\x81\x00\x00",-1,-1,-1,-1}, |
48 | { UDH_NokiaOperatorLogo, 0x06, "\x05\x04\x15\x82\x00\x00",-1,-1,-1,-1}, | 51 | { UDH_NokiaOperatorLogo, 0x06, "\x05\x04\x15\x82\x00\x00",-1,-1,-1,-1}, |
49 | { UDH_NokiaCallerLogo, 0x06, "\x05\x04\x15\x83\x00\x00",-1,-1,-1,-1}, | 52 | { UDH_NokiaCallerLogo, 0x06, "\x05\x04\x15\x83\x00\x00",-1,-1,-1,-1}, |
50 | { UDH_NokiaWAP, 0x06, "\x05\x04\xc3\x4f\x00\x00",-1,-1,-1,-1}, | 53 | { UDH_NokiaWAP, 0x06, "\x05\x04\xc3\x4f\x00\x00",-1,-1,-1,-1}, |
51 | 54 | ||
52 | /* Nokia Smart Messaging (long version) UDH and other | 55 | /* Nokia Smart Messaging (long version) UDH and other |
53 | * General format: | 56 | * General format: |
54 | * 1 byte 0x05 : IEI application port addressing scheme, 16 bit address | 57 | * 1 byte 0x05 : IEI application port addressing scheme, 16 bit address |
55 | * 1 byte 0x04 : IEI length | 58 | * 1 byte 0x04 : IEI length |
56 | * 2 bytes 0x00 0x00 : destination address : high & low byte | 59 | * 2 bytes 0x00 0x00 : destination address : high & low byte |
57 | * 2 bytes 0x00 0x00 : originator address : high & low byte | 60 | * 2 bytes 0x00 0x00 : originator address : high & low byte |
58 | * 1 byte 0x00 : SAR | 61 | * 1 byte 0x00 : SAR |
59 | * 1 byte 0x03 : SAR length | 62 | * 1 byte 0x03 : SAR length |
60 | * 1 byte : diagram reference number (unique ID for message series) | 63 | * 1 byte : diagram reference number (unique ID for message series) |
61 | * 1 byte : number of all SMS | 64 | * 1 byte : number of all SMS |
62 | * 1 byte : number of current SMS */ | 65 | * 1 byte : number of current SMS */ |
63 | { UDH_NokiaCalendarLong, 0x0b, "\x05\x04\x00\xe4\x00\x00\x00\x03\xc7\x00\x00",8,-1,10,9}, | 66 | { UDH_NokiaCalendarLong, 0x0b, "\x05\x04\x00\xe4\x00\x00\x00\x03\xc7\x00\x00",8,-1,10,9}, |
64 | { UDH_MMSIndicatorLong, 0x0b, "\x05\x04\x0b\x84\x23\xf0\x00\x03\xe5\x00\x00",8,-1,10,9}, | 67 | { UDH_MMSIndicatorLong, 0x0b, "\x05\x04\x0b\x84\x23\xf0\x00\x03\xe5\x00\x00",8,-1,10,9}, |
65 | { UDH_NokiaRingtoneLong, 0x0b, "\x05\x04\x15\x81\x00\x00\x00\x03\x01\x00\x00",8,-1,10,9}, | 68 | { UDH_NokiaRingtoneLong, 0x0b, "\x05\x04\x15\x81\x00\x00\x00\x03\x01\x00\x00",8,-1,10,9}, |
66 | { UDH_NokiaOperatorLogoLong, 0x0b, "\x05\x04\x15\x82\x00\x00\x00\x03\x02\x00\x00",8,-1,10,9}, | 69 | { UDH_NokiaOperatorLogoLong, 0x0b, "\x05\x04\x15\x82\x00\x00\x00\x03\x02\x00\x00",8,-1,10,9}, |
67 | { UDH_NokiaProfileLong, 0x0b, "\x05\x04\x15\x8a\x00\x00\x00\x03\xce\x00\x00",8,-1,10,9}, | 70 | { UDH_NokiaProfileLong, 0x0b, "\x05\x04\x15\x8a\x00\x00\x00\x03\xce\x00\x00",8,-1,10,9}, |
68 | { UDH_NokiaPhonebookLong, 0x0b, "\x05\x04\x23\xf4\x00\x00\x00\x03\x01\x00\x00",8,-1,10,9}, | 71 | { UDH_NokiaPhonebookLong, 0x0b, "\x05\x04\x23\xf4\x00\x00\x00\x03\x01\x00\x00",8,-1,10,9}, |
69 | { UDH_NokiaWAPLong, 0x0b, "\x05\x04\xc3\x4f\x00\x00\x00\x03\x7f\x00\x00",8,-1,10,9}, | 72 | { UDH_NokiaWAPLong, 0x0b, "\x05\x04\xc3\x4f\x00\x00\x00\x03\x7f\x00\x00",8,-1,10,9}, |
70 | 73 | ||
71 | { UDH_ConcatenatedMessages16bit,0x06, "\x08\x04\x00\x00\x00\x00",-1,2,5,4}, | 74 | { UDH_ConcatenatedMessages16bit,0x06, "\x08\x04\x00\x00\x00\x00",-1,2,5,4}, |
72 | 75 | ||
73 | { UDH_NoUDH, 0x00, "",-1,-1,-1,-1} | 76 | { UDH_NoUDH, 0x00, "",-1,-1,-1,-1} |
74 | }; | 77 | }; |
75 | 78 | ||
76 | /* --------------------------- Unpacking SMS ------------------------------- */ | 79 | /* --------------------------- Unpacking SMS ------------------------------- */ |
77 | 80 | ||
78 | /* See GSM 03.40 section 9.2.3.11 */ | 81 | /* See GSM 03.40 section 9.2.3.11 */ |
79 | static GSM_Error GSM_DecodeSMSDateTime(GSM_DateTime *DT, unsigned char *req) | 82 | static GSM_Error GSM_DecodeSMSDateTime(GSM_DateTime *DT, unsigned char *req) |
80 | { | 83 | { |
81 | DT->Year = DecodeWithBCDAlphabet(req[0]); | 84 | DT->Year = DecodeWithBCDAlphabet(req[0]); |
82 | if (DT->Year<90) DT->Year=DT->Year+2000; else DT->Year=DT->Year+1990; | 85 | if (DT->Year<90) DT->Year=DT->Year+2000; else DT->Year=DT->Year+1990; |
83 | DT->Month = DecodeWithBCDAlphabet(req[1]); | 86 | DT->Month = DecodeWithBCDAlphabet(req[1]); |
84 | DT->Day = DecodeWithBCDAlphabet(req[2]); | 87 | DT->Day = DecodeWithBCDAlphabet(req[2]); |
85 | DT->Hour = DecodeWithBCDAlphabet(req[3]); | 88 | DT->Hour = DecodeWithBCDAlphabet(req[3]); |
86 | DT->Minute = DecodeWithBCDAlphabet(req[4]); | 89 | DT->Minute = DecodeWithBCDAlphabet(req[4]); |
87 | DT->Second = DecodeWithBCDAlphabet(req[5]); | 90 | DT->Second = DecodeWithBCDAlphabet(req[5]); |
88 | 91 | ||
89 | /* Base for timezone is GMT. It's in quarters */ | 92 | /* Base for timezone is GMT. It's in quarters */ |
90 | DT->Timezone=(10*(req[6]&0x07)+(req[6]>>4))/4; | 93 | DT->Timezone=(10*(req[6]&0x07)+(req[6]>>4))/4; |
91 | 94 | ||
92 | if (req[6]&0x08) DT->Timezone = -DT->Timezone; | 95 | if (req[6]&0x08) DT->Timezone = -DT->Timezone; |
93 | 96 | ||
94 | dbgprintf("Decoding date & time: "); | 97 | dbgprintf("Decoding date & time: "); |
95 | dbgprintf("%s %4d/%02d/%02d ", DayOfWeek(DT->Year, DT->Month, DT->Day), | 98 | dbgprintf("%s %4d/%02d/%02d ", DayOfWeek(DT->Year, DT->Month, DT->Day), |
96 | DT->Year, DT->Month, DT->Day); | 99 | DT->Year, DT->Month, DT->Day); |
97 | dbgprintf("%02d:%02d:%02d %02d00\n", DT->Hour, DT->Minute, DT->Second, DT->Timezone); | 100 | dbgprintf("%02d:%02d:%02d %02d00\n", DT->Hour, DT->Minute, DT->Second, DT->Timezone); |
98 | 101 | ||