Translation update done using Pootle.
[gammu.git] / tests / sms-nokia-06.c
blobd9039c41cd22293ab0506312f59ee95dcbb2a9b0
1 /* Test for decoding SMS on Nokia 6510 driver */
3 #include <gammu.h>
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <string.h>
8 #include "common.h"
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,
17 0x00, 0x16, 0x00, 0x00, 0x01, 0x20, 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, 0x00,
22 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x32, 0x00, 0x30, 0x00, 0x32,
23 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 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 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x05, 0x81, 0x24, 0x20, 0xF2,
28 0x00, 0x00, 0x80, 0x21, 0x02, 0x02, 0x00, 0x32, 0x40, 0x06, 0xB4, 0x5A, 0xAD, 0x56, 0x53, 0x00,
29 0x01, 0x00, 0x57, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x0E, 0x2B, 0x33, 0x39, 0x33, 0x34, 0x39,
30 0x32, 0x30, 0x30, 0x30, 0x32, 0x30, 0x30, 0x00, 0x03, 0x00, 0x0E, 0x00, 0x34, 0x00, 0x35, 0x00,
31 0x35, 0x00, 0x35, 0x00, 0x35, 0x00, 0x0A, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x00, 0x34, 0x00, 0x32,
32 0x00, 0x30, 0x00, 0x32, 0x00, 0x32, 0x00, 0x00, 0x0C, 0x00, 0x01, 0x00, 0x07, 0x00, 0x01, 0x00,
33 0x05, 0x00, 0x01, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x02, 0x0B,
34 0x00, 0x01, 0x00, 0x09, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00
37 unsigned char message[] = {
38 0x00, 0x34, 0x00, 0x35, 0x00, 0x35, 0x00, 0x35, 0x00, 0x35, 0x00, 0x0A
41 /* This is not part of API! */
42 extern GSM_Error N6510_DecodeFilesystemSMS(GSM_StateMachine * s, GSM_MultiSMSMessage * sms, GSM_File * FFF, int location);
44 int main(int argc UNUSED, char **argv UNUSED)
46 GSM_Debug_Info *debug_info;
47 GSM_StateMachine *s;
48 GSM_File file;
49 GSM_Error error;
50 GSM_MultiSMSMessage sms;
51 size_t len;
53 debug_info = GSM_GetGlobalDebug();
54 GSM_SetDebugFileDescriptor(stderr, FALSE, debug_info);
55 GSM_SetDebugLevel("textall", debug_info);
57 /* Allocates state machine */
58 s = GSM_AllocStateMachine();
59 test_result(s != NULL);
61 debug_info = GSM_GetDebug(s);
62 GSM_SetDebugGlobal(TRUE, debug_info);
63 GSM_SetDebugFileDescriptor(stderr, FALSE, debug_info);
64 GSM_SetDebugLevel("textall", debug_info);
66 /* Init file */
67 file.Buffer = malloc(sizeof(data));
68 memcpy(file.Buffer, data, sizeof(data));
69 file.Used = sizeof(data);
70 file.ID_FullName[0] = 0;
71 file.ID_FullName[1] = 0;
72 GSM_GetCurrentDateTime(&(file.Modified));
74 /* Parse it */
75 error = N6510_DecodeFilesystemSMS(s, &sms, &file, 0);
77 /* Check expected text */
78 len = UnicodeLength(sms.SMS[0].Text);
79 if (len > (sizeof(message) / 2) - 1)
80 len = (sizeof(message) / 2) - 1;
81 test_result(mywstrncmp(sms.SMS[0].Text, message, len) == TRUE);
83 /* Display message */
84 DisplayMultiSMSInfo(&sms, FALSE, TRUE, NULL, NULL);
85 DisplayMultiSMSInfo(&sms, TRUE, TRUE, NULL, NULL);
87 /* Free state machine */
88 GSM_FreeStateMachine(s);
90 gammu_test_result(error, "N6510_DecodeFilesystemSMS");
92 return 0;
95 /* Editor configuration
96 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: