1 /* Test for decoding SMS on Nokia 6510 driver */
10 #include "../libgammu/protocol/protocol.h" /* Needed for GSM_Protocol_Message */
11 #include "../libgammu/gsmstate.h" /* Needed for state machine internals */
13 #include "../helper/message-display.h"
15 unsigned char data
[] = {
16 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x9F, 0x00, 0x00, 0x02, 0xE0, 0x00, 0x00, 0x00, 0x00,
17 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B,
22 0x00, 0x34, 0x00, 0x38, 0x00, 0x36, 0x00, 0x36, 0x00, 0x38, 0x00, 0x38, 0x00, 0x35, 0x00, 0x31,
23 0x00, 0x36, 0x00, 0x33, 0x00, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 0x40, 0x0B, 0x91, 0x84, 0x66, 0x88, 0x15, 0x36, 0xF9, 0x00, 0x08, 0x90, 0x80, 0x72, 0x41, 0x03,
28 0x91, 0x80, 0x8C, 0x05, 0x00, 0x03, 0xCE, 0x03, 0x01, 0x00, 0x41, 0x00, 0x20, 0x00, 0x6B, 0x00,
29 0x69, 0x00, 0x65, 0x00, 0x64, 0x00, 0x79, 0x00, 0x20, 0x00, 0x73, 0x00, 0x61, 0x00, 0x6D, 0x00,
30 0x65, 0x00, 0x6D, 0x00, 0x75, 0x00, 0x20, 0x00, 0x64, 0x00, 0x6F, 0x00, 0x62, 0x00, 0x72, 0x00,
31 0x7A, 0x00, 0x65, 0x00, 0x20, 0x00, 0x2D, 0x00, 0x20, 0x00, 0x73, 0x00, 0x61, 0x00, 0x6D, 0x00,
32 0x20, 0x00, 0x77, 0x00, 0x69, 0x00, 0x65, 0x00, 0x73, 0x00, 0x7A, 0x00, 0x20, 0x00, 0x64, 0x00,
33 0x6F, 0x00, 0x73, 0x00, 0x6B, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x65, 0x00,
34 0x2E, 0x00, 0x20, 0x00, 0x43, 0x00, 0x68, 0x00, 0x63, 0x00, 0x65, 0x00, 0x73, 0x00, 0x7A, 0x00,
35 0x20, 0x00, 0x6D, 0x00, 0x6E, 0x00, 0x69, 0x00, 0x65, 0x00, 0x20, 0x00, 0x7A, 0x00, 0x61, 0x00,
36 0x6D, 0x00, 0x69, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x69, 0x01, 0x07, 0x00, 0x20, 0x00, 0x77, 0x01,
37 0x01, 0x8E, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x0D, 0x2B, 0x34, 0x38, 0x36, 0x30, 0x32, 0x30,
38 0x30, 0x36, 0x30, 0x37, 0x31, 0x00, 0x03, 0x01, 0x38, 0x00, 0x41, 0x00, 0x20, 0x00, 0x6B, 0x00,
39 0x69, 0x00, 0x65, 0x00, 0x64, 0x00, 0x79, 0x00, 0x20, 0x00, 0x73, 0x00, 0x61, 0x00, 0x6D, 0x00,
40 0x65, 0x00, 0x6D, 0x00, 0x75, 0x00, 0x20, 0x00, 0x64, 0x00, 0x6F, 0x00, 0x62, 0x00, 0x72, 0x00,
41 0x7A, 0x00, 0x65, 0x00, 0x20, 0x00, 0x2D, 0x00, 0x20, 0x00, 0x73, 0x00, 0x61, 0x00, 0x6D, 0x00,
42 0x20, 0x00, 0x77, 0x00, 0x69, 0x00, 0x65, 0x00, 0x73, 0x00, 0x7A, 0x00, 0x20, 0x00, 0x64, 0x00,
43 0x6F, 0x00, 0x73, 0x00, 0x6B, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x65, 0x00,
44 0x2E, 0x00, 0x20, 0x00, 0x43, 0x00, 0x68, 0x00, 0x63, 0x00, 0x65, 0x00, 0x73, 0x00, 0x7A, 0x00,
45 0x20, 0x00, 0x6D, 0x00, 0x6E, 0x00, 0x69, 0x00, 0x65, 0x00, 0x20, 0x00, 0x7A, 0x00, 0x61, 0x00,
46 0x6D, 0x00, 0x69, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x69, 0x01, 0x07, 0x00, 0x20, 0x00, 0x77, 0x00,
47 0x20, 0x00, 0x68, 0x00, 0x69, 0x00, 0x70, 0x00, 0x6F, 0x00, 0x70, 0x00, 0x6F, 0x00, 0x74, 0x00,
48 0x61, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x3F, 0x00, 0x20, 0x00, 0x49, 0x00, 0x3A, 0x00, 0x20, 0x00,
49 0x73, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x61, 0x00, 0x6E, 0x00, 0x69, 0x00,
50 0x6E, 0x00, 0x79, 0x00, 0x20, 0x00, 0x77, 0x01, 0x42, 0x00, 0x61, 0x01, 0x5B, 0x00, 0x63, 0x00,
51 0x69, 0x00, 0x77, 0x00, 0x79, 0x00, 0x20, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6B, 0x00, 0x69, 0x00,
52 0x2E, 0x00, 0x20, 0x00, 0x44, 0x00, 0x6F, 0x00, 0x62, 0x00, 0x72, 0x00, 0x7A, 0x00, 0x65, 0x00,
53 0x20, 0x00, 0x6A, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x2C, 0x00, 0x20, 0x00, 0x6D, 0x00,
54 0x61, 0x00, 0x6D, 0x00, 0x20, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x64, 0x00, 0x7A, 0x00, 0x69, 0x00,
55 0x65, 0x00, 0x6A, 0x01, 0x19, 0x00, 0x2C, 0x00, 0x20, 0x01, 0x7C, 0x00, 0x65, 0x00, 0x20, 0x00,
56 0x6E, 0x00, 0x69, 0x00, 0x65, 0x00, 0x20, 0x00, 0x74, 0x00, 0x79, 0x00, 0x6C, 0x00, 0x6B, 0x00,
57 0x6F, 0x00, 0x20, 0x00, 0x74, 0x00, 0x75, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6A, 0x00, 0x2E, 0x00,
58 0x00, 0x04, 0x00, 0x1A, 0x00, 0x2B, 0x00, 0x34, 0x00, 0x38, 0x00, 0x36, 0x00, 0x36, 0x00, 0x38,
59 0x00, 0x38, 0x00, 0x35, 0x00, 0x31, 0x00, 0x36, 0x00, 0x33, 0x00, 0x39, 0x00, 0x00, 0x0C, 0x00,
60 0x01, 0x00, 0x07, 0x00, 0x01, 0x00, 0x05, 0x00, 0x01, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00,
61 0x00, 0x08, 0x00, 0x01, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x09, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
65 const char text
[] = "A kiedy samemu dobrze - sam wiesz doskonale. Chcesz mnie zamienić w";
66 char decoded_text
[200];
68 /* This is not part of API! */
69 extern GSM_Error
N6510_DecodeFilesystemSMS(GSM_StateMachine
* s
, GSM_MultiSMSMessage
* sms
, GSM_File
* FFF
, int location
);
71 int main(int argc UNUSED
, char **argv UNUSED
)
73 GSM_Debug_Info
*debug_info
;
77 GSM_MultiSMSMessage sms
;
79 /* Init locales for proper output */
80 GSM_InitLocales(NULL
);
82 debug_info
= GSM_GetGlobalDebug();
83 GSM_SetDebugFileDescriptor(stderr
, FALSE
, debug_info
);
84 GSM_SetDebugLevel("textall", debug_info
);
86 /* Allocates state machine */
87 s
= GSM_AllocStateMachine();
88 test_result(s
!= NULL
);
90 debug_info
= GSM_GetDebug(s
);
91 GSM_SetDebugGlobal(TRUE
, debug_info
);
94 file
.Buffer
= malloc(sizeof(data
));
95 memcpy(file
.Buffer
, data
, sizeof(data
));
96 file
.Used
= sizeof(data
);
97 file
.ID_FullName
[0] = 0;
98 file
.ID_FullName
[1] = 0;
99 GSM_GetCurrentDateTime(&(file
.Modified
));
102 error
= N6510_DecodeFilesystemSMS(s
, &sms
, &file
, 0);
104 /* Display message */
105 DisplayMultiSMSInfo(&sms
, FALSE
, TRUE
, NULL
, NULL
);
106 DisplayMultiSMSInfo(&sms
, TRUE
, TRUE
, NULL
, NULL
);
108 /* Free state machine */
109 GSM_FreeStateMachine(s
);
111 /* Check expected text */
112 /* We do not compare full text due to locales problem */
113 EncodeUTF8(decoded_text
, sms
.SMS
[0].Text
);
114 test_result(strcmp(text
, decoded_text
) == 0);
116 gammu_test_result(error
, "N6510_DecodeFilesystemSMS");
121 /* Editor configuration
122 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: