5 #include "../gsmstate.h"
6 #include "../service/sms/gsmsms.h"
7 #include "../misc/coding/coding.h"
9 /* These SMS layouts are used exactly as written in Nokia DCT3 phones.
10 * In AT module(s) we have to use some layouts to convert AT frame to format
11 * understod by SMS module. To share source the same layouts are used */
12 GSM_SMSMessageLayout PHONE_SMSDeliver
= {
13 35 /* SMS Text */, 16 /* Phone number */,
14 0 /* SMSC Number */, 14 /* TPDCS */,
15 28 /* SendingDateTime */, 255 /* SMSCDateTime */,
16 255 /* TPStatus */, 15 /* TPUDL */,
17 255 /* TPVP */, 12 /* firstbyte */,
18 255 /* TPMR */, 13 /* TPPID */};
19 GSM_SMSMessageLayout PHONE_SMSSubmit
= {
20 36 /* SMS Text */, 17 /* Phone number */,
21 0 /* SMSC Number */, 15 /* TPDCS */,
22 255 /* SendingDateTime */, 255 /* SMSCDateTime */,
23 255 /* TPStatus */, 16 /* TPUDL */,
24 29 /* TPVP */, 12 /* firstbyte */,
25 13 /* TPMR */, 14 /* TPPID */};
26 GSM_SMSMessageLayout PHONE_SMSStatusReport
= {
27 255 /* SMS Text */, 15 /* Phone number */,
28 0 /* SMSC Number */, 255 /* TPDCS */,
29 27 /* SendingDateTime */, 34 /* SMSCDateTime */,
30 14 /* TPStatus */, 255 /* TPUDL */,
31 255 /* TPVP */, 12 /* firstbyte */,
32 255 /* TPMR */, 255 /* TPPID?? */};
34 GSM_Error
PHONE_GetSMSFolders(GSM_StateMachine
*s
, GSM_SMSFolders
*folders
)
37 EncodeUnicode(folders
->Folder
[0].Name
,GetMsg(s
->msg
,"Inbox"),strlen(GetMsg(s
->msg
,"Inbox")));
38 EncodeUnicode(folders
->Folder
[1].Name
,GetMsg(s
->msg
,"Outbox"),strlen(GetMsg(s
->msg
,"Outbox")));
39 folders
->Folder
[0].InboxFolder
= true;
40 folders
->Folder
[1].InboxFolder
= false;
41 folders
->Folder
[0].Memory
= GMT_SM
;
42 folders
->Folder
[1].Memory
= GMT_SM
;
46 void GSM_CreateFirmwareNumber(GSM_StateMachine
*s
)
48 StringToDouble(s
->Phone
.Data
.Version
, &s
->Phone
.Data
.VerNum
);
49 dbgprintf("Number version is \"%f\"\n", s
->Phone
.Data
.VerNum
);
52 GSM_Error
PHONE_EncodeSMSFrame(GSM_StateMachine
*s
, GSM_SMSMessage
*SMS
, unsigned char *buffer
, GSM_SMSMessageLayout Layout
, int *length
, bool clear
)
56 if (SMS
->SMSC
.Location
!=0) {
57 error
= s
->Phone
.Functions
->GetSMSC(s
, &SMS
->SMSC
);
58 if (error
!= GE_NONE
) return error
;
59 SMS
->SMSC
.Location
= 0;
61 if (SMS
->PDU
== SMS_Deliver
) {
62 if (SMS
->SMSC
.Number
[0] == 0x00 && SMS
->SMSC
.Number
[1] == 0x00)
67 return GSM_EncodeSMSFrame(SMS
, buffer
, Layout
, length
, clear
);
70 GSM_Error
PHONE_Terminate(GSM_StateMachine
*s
)
74 if (s
->Phone
.Data
.EnableIncomingCB
==true) {
75 error
=s
->Phone
.Functions
->SetIncomingCB(s
,false);
76 if (error
!=GE_NONE
) return error
;
78 if (s
->Phone
.Data
.EnableIncomingSMS
==true) {
79 error
=s
->Phone
.Functions
->SetIncomingSMS(s
,false);
80 if (error
!=GE_NONE
) return error
;
85 GSM_Error
PHONE_RTTLPlayOneNote(GSM_StateMachine
*s
, GSM_RingNote note
, bool first
)
90 Hz
=GSM_RingNoteGetFrequency(note
);
92 error
=s
->Phone
.Functions
->PlayTone(s
,Hz
,5,first
);
93 if (error
!=GE_NONE
) return error
;
95 duration
= GSM_RingNoteGetFullDuration(note
);
97 /* Is it correct ? Experimental values here */
101 error
=s
->Phone
.Functions
->PlayTone(s
,0,0,false);
102 if (error
!= GE_NONE
) return error
;
103 my_sleep ((1400000/note
.Tempo
*duration
)-(7500));
105 case ContinuousStyle
:
106 my_sleep (1400000/note
.Tempo
*duration
);
109 my_sleep (1400000/note
.Tempo
*duration
-50);
110 error
=s
->Phone
.Functions
->PlayTone(s
,0,0,false);
111 if (error
!= GE_NONE
) return error
;
118 GSM_Error
PHONE_Beep(GSM_StateMachine
*s
)
122 error
=s
->Phone
.Functions
->PlayTone(s
, 4000, 5,true);
123 if (error
!=GE_NONE
) return error
;
127 return s
->Phone
.Functions
->PlayTone(s
,255*255,0,false);
130 GSM_Error
NoneReply(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
135 /* How should editor hadle tabs in this file? Add editor commands here.
136 * vim: noexpandtab sw=8 ts=8 sts=8: