1 /* Test for reading model on AT driver */
7 #include "../libgammu/protocol/protocol.h" /* Needed for GSM_Protocol_Message */
8 #include "../libgammu/gsmstate.h" /* Needed for state machine internals */
9 #include "../libgammu/gsmphones.h" /* Phone data */
13 #define BUFFER_SIZE 16384
15 extern GSM_Error
ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message
*msg
, GSM_StateMachine
* s
);
17 int main(int argc
, char **argv
)
19 GSM_Debug_Info
*debug_info
;
20 GSM_Phone_ATGENData
*Priv
;
22 unsigned char buffer
[BUFFER_SIZE
];
26 GSM_Protocol_Message msg
;
29 /* Check parameters */
31 printf("Not enough parameters!\nUsage: at-cnmi-reply comm.dump\n");
36 f
= fopen(argv
[1], "r");
38 printf("Could not open %s\n", argv
[1]);
43 len
= fread(buffer
, 1, sizeof(buffer
) - 1, f
);
45 printf("Could not read whole file %s\n", argv
[1]);
49 /* Zero terminate data */
55 /* Configure state machine */
56 debug_info
= GSM_GetGlobalDebug();
57 GSM_SetDebugFileDescriptor(stderr
, FALSE
, debug_info
);
58 GSM_SetDebugLevel("textall", debug_info
);
60 /* Allocates state machine */
61 s
= GSM_AllocStateMachine();
62 test_result(s
!= NULL
);
63 debug_info
= GSM_GetDebug(s
);
64 GSM_SetDebugGlobal(TRUE
, debug_info
);
66 /* Initialize AT engine */
67 Data
= &s
->Phone
.Data
;
68 Data
->ModelInfo
= GetModelData(NULL
, NULL
, "unknown", NULL
);
69 Priv
= &s
->Phone
.Data
.Priv
.ATGEN
;
70 Priv
->ReplyState
= AT_Reply_OK
;
71 Priv
->SMSMode
= SMS_AT_PDU
;
72 Priv
->Charset
= AT_CHARSET_UCS2
;
73 Priv
->Manufacturer
= AT_Samsung
;
79 SplitLines(msg
.Buffer
, msg
.Length
, &Priv
->Lines
, "\x0D\x0A", 2, "\"", 1, TRUE
);
82 error
= ATGEN_ReplyGetSMSMemories(&msg
, s
);
84 /* This is normally done by ATGEN_Terminate */
85 FreeLines(&Priv
->Lines
);
86 GetLineString(NULL
, NULL
, 0);
88 /* Free state machine */
89 GSM_FreeStateMachine(s
);
91 gammu_test_result(error
, "ATGEN_ReplyGetSMSMemories");
96 /* Editor configuration
97 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: