summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone/pfunc.c
Unidiff
Diffstat (limited to 'gammu/emb/common/phone/pfunc.c') (more/less context) (show whitespace changes)
-rw-r--r--gammu/emb/common/phone/pfunc.c138
1 files changed, 138 insertions, 0 deletions
diff --git a/gammu/emb/common/phone/pfunc.c b/gammu/emb/common/phone/pfunc.c
new file mode 100644
index 0000000..a03a81d
--- a/dev/null
+++ b/gammu/emb/common/phone/pfunc.c
@@ -0,0 +1,138 @@
1/* (c) 2002-2003 by Marcin Wiacek */
2
3#include <string.h>
4#include <ctype.h>
5
6#include "../gsmstate.h"
7#include "../service/sms/gsmsms.h"
8#include "../misc/coding/coding.h"
9
10/* These SMS layouts are used exactly as written in Nokia DCT3 phones.
11 * In AT module(s) we have to use some layouts to convert AT frame to format
12 * understod by SMS module. To share source the same layouts are used */
13GSM_SMSMessageLayout PHONE_SMSDeliver = {
14 35 /* SMS Text */, 16 /* Phone number*/,
15 0 /* SMSC Number */, 14 /* TPDCS */,
16 28 /* SendingDateTime */, 255 /* SMSCDateTime*/,
17 255 /* TPStatus */, 15 /* TPUDL */,
18 255 /* TPVP */, 12 /* firstbyte*/,
19 255 /* TPMR */, 13 /* TPPID */};
20GSM_SMSMessageLayout PHONE_SMSSubmit = {
21 36 /* SMS Text */, 17 /* Phone number*/,
22 0 /* SMSC Number */, 15 /* TPDCS */,
23 255 /* SendingDateTime */, 255 /* SMSCDateTime*/,
24 255 /* TPStatus */, 16 /* TPUDL */,
25 29 /* TPVP */, 12 /* firstbyte*/,
26 13 /* TPMR */, 14 /* TPPID */};
27GSM_SMSMessageLayout PHONE_SMSStatusReport = {
28 255 /* SMS Text */, 15 /* Phone number*/,
29 0 /* SMSC Number */, 255 /* TPDCS */,
30 27 /* SendingDateTime */, 34 /* SMSCDateTime*/,
31 14 /* TPStatus */, 255 /* TPUDL */,
32 255 /* TPVP */, 12 /* firstbyte*/,
33 13 /* TPMR */, 255 /* TPPID?? */};
34
35GSM_Error PHONE_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders)
36{
37 folders->Number=2;
38 EncodeUnicode(folders->Folder[0].Name,GetMsg(s->msg,"Inbox"),strlen(GetMsg(s->msg,"Inbox")));
39 EncodeUnicode(folders->Folder[1].Name,GetMsg(s->msg,"Outbox"),strlen(GetMsg(s->msg,"Outbox")));
40 folders->Folder[0].InboxFolder = true;
41 folders->Folder[1].InboxFolder = false;
42 folders->Folder[0].Memory = MEM_SM;
43 folders->Folder[1].Memory = MEM_SM;
44 return ERR_NONE;
45}
46
47void GSM_CreateFirmwareNumber(GSM_StateMachine *s)
48{
49 StringToDouble(s->Phone.Data.Version, &s->Phone.Data.VerNum);
50 dbgprintf("Number version is \"%f\"\n", s->Phone.Data.VerNum);
51}
52
53GSM_Error PHONE_EncodeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout, int *length, bool clear)
54{
55 GSM_Error error;
56
57 if (SMS->SMSC.Location!=0) {
58 error = s->Phone.Functions->GetSMSC(s, &SMS->SMSC);
59 if (error != ERR_NONE) return error;
60 SMS->SMSC.Location = 0;
61 }
62 if (SMS->PDU == SMS_Deliver) {
63 if (SMS->SMSC.Number[0] == 0x00 && SMS->SMSC.Number[1] == 0x00) {
64 return ERR_EMPTYSMSC;
65 }
66 }
67 return GSM_EncodeSMSFrame(SMS, buffer, Layout, length, clear);
68}
69
70GSM_Error PHONE_Terminate(GSM_StateMachine *s)
71{
72 GSM_Error error;
73
74 if (s->Phone.Data.EnableIncomingCB==true) {
75 error=s->Phone.Functions->SetIncomingCB(s,false);
76 if (error!=ERR_NONE) return error;
77 }
78 if (s->Phone.Data.EnableIncomingSMS==true) {
79 error=s->Phone.Functions->SetIncomingSMS(s,false);
80 if (error!=ERR_NONE) return error;
81 }
82 return ERR_NONE;
83}
84
85GSM_Error PHONE_RTTLPlayOneNote(GSM_StateMachine *s, GSM_RingNote note, bool first)
86{
87 int duration, Hz;
88 GSM_Error error;
89
90 Hz=GSM_RingNoteGetFrequency(note);
91
92 error=s->Phone.Functions->PlayTone(s,Hz,5,first);
93 if (error!=ERR_NONE) return error;
94
95 duration = GSM_RingNoteGetFullDuration(note);
96
97 /* Is it correct ? Experimental values here */
98 switch (note.Style) {
99 case StaccatoStyle:
100 my_sleep (7500);
101 error=s->Phone.Functions->PlayTone(s,0,0,false);
102 if (error != ERR_NONE) return error;
103 my_sleep ((1400000/note.Tempo*duration)-(7500));
104 break;
105 case ContinuousStyle:
106 my_sleep (1400000/note.Tempo*duration);
107 break;
108 case NaturalStyle:
109 my_sleep (1400000/note.Tempo*duration-50);
110 error=s->Phone.Functions->PlayTone(s,0,0,false);
111 if (error != ERR_NONE) return error;
112 my_sleep (50);
113 break;
114 }
115 return ERR_NONE;
116}
117
118GSM_Error PHONE_Beep(GSM_StateMachine *s)
119{
120 GSM_Error error;
121
122 error=s->Phone.Functions->PlayTone(s, 4000, 5,true);
123 if (error!=ERR_NONE) return error;
124
125 my_sleep(500);
126
127 return s->Phone.Functions->PlayTone(s,255*255,0,false);
128}
129
130GSM_Error NoneReply(GSM_Protocol_Message msg, GSM_StateMachine *s)
131{
132 smprintf(s,"None answer\n");
133 return ERR_NONE;
134}
135
136/* How should editor hadle tabs in this file? Add editor commands here.
137 * vim: noexpandtab sw=8 ts=8 sts=8:
138 */