1 /* Test for reading SMSC on AT 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 #define BUFFER_SIZE 16384
16 extern GSM_Error
ATGEN_ReplyGetSMSC(GSM_Protocol_Message
*msg
, GSM_StateMachine
* s
);
18 int main(int argc
, char **argv
)
20 GSM_Debug_Info
*debug_info
;
21 GSM_Phone_ATGENData
*Priv
;
23 unsigned char buffer
[BUFFER_SIZE
];
27 GSM_Protocol_Message msg
;
31 /* Check parameters */
33 printf("Not enough parameters!\nUsage: get-smsc-at comm.dump\n");
38 f
= fopen(argv
[1], "r");
39 test_result(f
!= NULL
);
42 len
= fread(buffer
, 1, sizeof(buffer
) - 1, f
);
45 /* Zero terminate data */
51 /* Configure state machine */
52 debug_info
= GSM_GetGlobalDebug();
53 GSM_SetDebugFileDescriptor(stderr
, FALSE
, debug_info
);
54 GSM_SetDebugLevel("textall", debug_info
);
56 /* Allocates state machine */
57 s
= GSM_AllocStateMachine();
58 test_result(s
!= NULL
);
59 debug_info
= GSM_GetDebug(s
);
60 GSM_SetDebugGlobal(TRUE
, debug_info
);
61 GSM_SetDebugFileDescriptor(stderr
, FALSE
, debug_info
);
62 GSM_SetDebugLevel("textall", debug_info
);
64 /* Initialize AT engine */
65 Data
= &s
->Phone
.Data
;
66 Data
->ModelInfo
= GetModelData(NULL
, NULL
, "unknown", NULL
);
67 Priv
= &s
->Phone
.Data
.Priv
.ATGEN
;
68 Priv
->ReplyState
= AT_Reply_OK
;
69 Priv
->SMSMode
= SMS_AT_PDU
;
70 Priv
->Charset
= AT_CHARSET_UCS2
;
76 SplitLines(msg
.Buffer
, msg
.Length
, &Priv
->Lines
, "\x0D\x0A", 2, "\"", 1, TRUE
);
78 /* Pointer to store message */
79 s
->Phone
.Data
.SMSC
= &SMSC
;
82 error
= ATGEN_ReplyGetSMSC(&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 printf("%s\n", GSM_ErrorString(error
));
93 return (error
== ERR_NONE
) ? 0 : 1;
96 /* Editor configuration
97 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: