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 */
12 #include "../libgammu/gsmphones.h" /* Phone data */
14 #include "../helper/message-display.h"
16 unsigned char data
[] = {
17 0x01, 0x6B, 0x00, 0x03, 0x00, 0x01, 0x02, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x80,
18 0x00, 0x00, 0x08, 0x66, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x82, 0x0C,
19 0x01, 0x08, 0x0B, 0x91, 0x97, 0x60, 0x60, 0x82, 0x87, 0xF0, 0x82, 0x08, 0x02, 0x01, 0x00, 0x00,
20 0x00, 0x00, 0x80, 0x5C, 0x56, 0x2B, 0x04, 0x23, 0x00, 0x20, 0x04, 0x3C, 0x04, 0x35, 0x04, 0x3D,
21 0x04, 0x4F, 0x00, 0x20, 0x04, 0x38, 0x04, 0x41, 0x04, 0x42, 0x04, 0x35, 0x04, 0x40, 0x04, 0x38,
22 0x04, 0x3A, 0x04, 0x30, 0x00, 0x2E, 0x04, 0x1E, 0x04, 0x42, 0x04, 0x3F, 0x04, 0x38, 0x04, 0x48,
23 0x04, 0x38, 0x04, 0x42, 0x04, 0x35, 0x04, 0x41, 0x04, 0x4C, 0x00, 0x2C, 0x04, 0x3A, 0x04, 0x30,
24 0x04, 0x3A, 0x00, 0x20, 0x04, 0x34, 0x04, 0x3E, 0x04, 0x3B, 0x04, 0x35, 0x04, 0x42, 0x04, 0x38,
25 0x04, 0x42, 0x04, 0x35, 0x00, 0x2C, 0x04, 0x3E, 0x04, 0x3A, 0x00, 0x3F, 0x00, 0x00
28 const char text
[] = "У меня истерика.Отпишитесь,как долетите,ок?";
29 char decoded_text
[200];
31 /* This is not part of API! */
32 extern GSM_Error
N6510_ReplyGetSMSMessage(GSM_Protocol_Message
*msg
, GSM_StateMachine
* s
);
34 int main(int argc UNUSED
, char **argv UNUSED
)
36 GSM_Debug_Info
*debug_info
;
38 GSM_Protocol_Message msg
;
40 GSM_MultiSMSMessage sms
;
42 /* Init locales for proper output */
43 GSM_InitLocales(NULL
);
45 debug_info
= GSM_GetGlobalDebug();
46 GSM_SetDebugFileDescriptor(stderr
, FALSE
, debug_info
);
47 GSM_SetDebugLevel("textall", debug_info
);
49 /* Allocates state machine */
50 s
= GSM_AllocStateMachine();
51 test_result(s
!= NULL
);
53 debug_info
= GSM_GetDebug(s
);
54 GSM_SetDebugGlobal(TRUE
, debug_info
);
55 GSM_SetDebugFileDescriptor(stderr
, FALSE
, debug_info
);
56 GSM_SetDebugLevel("textall", debug_info
);
58 s
->Phone
.Data
.ModelInfo
= GetModelData(NULL
, NULL
, "unknown", NULL
);
62 msg
.Length
= sizeof(data
);
65 s
->Phone
.Data
.GetSMSMessage
= &sms
;
68 error
= N6510_ReplyGetSMSMessage(&msg
, s
);
71 DisplayMultiSMSInfo(&sms
, FALSE
, TRUE
, NULL
, NULL
);
72 DisplayMultiSMSInfo(&sms
, TRUE
, TRUE
, NULL
, NULL
);
74 /* Free state machine */
75 GSM_FreeStateMachine(s
);
77 /* Check expected text */
78 /* We do not compare full text due to locales problem */
79 EncodeUTF8(decoded_text
, sms
.SMS
[0].Text
);
80 test_result(strcmp(text
, decoded_text
) == 0);
82 test_result(sms
.SMS
[0].DateTime
.Year
== 0);
84 gammu_test_result(error
, "N6510_ReplyGetSMSMessage");
89 /* Editor configuration
90 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: