summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone/nokia/dct4/dct4func.c
Unidiff
Diffstat (limited to 'gammu/emb/common/phone/nokia/dct4/dct4func.c') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/phone/nokia/dct4/dct4func.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/gammu/emb/common/phone/nokia/dct4/dct4func.c b/gammu/emb/common/phone/nokia/dct4/dct4func.c
new file mode 100644
index 0000000..9fa931f
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct4/dct4func.c
@@ -0,0 +1,115 @@
1/* (c) 2002-2003 by Marcin Wiacek */
2
3#include "../../../gsmstate.h"
4
5#include <string.h>
6#include <time.h>
7
8#include "../../../gsmcomon.h"
9#include "../../../misc/coding/coding.h"
10#include "../../../service/gsmlogo.h"
11#include "../nfunc.h"
12#include "../nfuncold.h"
13#include "../../pfunc.h"
14#include "dct4func.h"
15
16#ifdef GSM_ENABLE_NOKIA_DCT4
17
18GSM_Error DCT4_ReplyGetPhoneMode(GSM_Protocol_Message msg, GSM_StateMachine *s)
19{
20 s->Phone.Data.PhoneString[0] = msg.Buffer[4];
21 return ERR_NONE;
22}
23
24GSM_Error DCT4_GetPhoneMode(GSM_StateMachine *s)
25{
26 unsigned char req[] = {N6110_FRAME_HEADER, 0x02, 0x00, 0x00};
27
28 smprintf(s,"Getting phone mode\n");
29
30 return GSM_WaitFor (s, req, 6, 0x15, 4, ID_Reset);
31}
32
33GSM_Error DCT4_ReplySetPhoneMode(GSM_Protocol_Message msg, GSM_StateMachine *s)
34{
35 return ERR_NONE;
36}
37
38GSM_Error DCT4_SetPhoneMode(GSM_StateMachine *s, DCT4_PHONE_MODE mode)
39{
40 unsigned char PhoneMode[10];
41 int i;
42 GSM_Error error;
43 unsigned char req[] = {N6110_FRAME_HEADER, 0x01,
44 0x04, /* phone mode */
45 0x00};
46
47 if (s->ConnectionType != GCT_FBUS2) return ERR_OTHERCONNECTIONREQUIRED;
48
49 s->Phone.Data.PhoneString = PhoneMode;
50 req[4] = mode;
51
52 while (1) {
53 smprintf(s,"Going to phone mode %i\n",mode);
54 error = GSM_WaitFor (s, req, 6, 0x15, 4, ID_Reset);
55 if (error != ERR_NONE) return error;
56 for (i=0;i<20;i++) {
57 error=DCT4_GetPhoneMode(s);
58 if (error != ERR_NONE) return error;
59 if (PhoneMode[0] == mode) return ERR_NONE;
60 my_sleep(500);
61 }
62 }
63 return ERR_NONE;
64}
65
66GSM_Error DCT4_ReplyGetIMEI(GSM_Protocol_Message msg, GSM_StateMachine *s)
67{
68 memcpy(s->Phone.Data.IMEI,msg.Buffer + 10, 16);
69 smprintf(s, "Received IMEI %s\n",s->Phone.Data.IMEI);
70 return ERR_NONE;
71}
72
73GSM_Error DCT4_GetIMEI (GSM_StateMachine *s)
74{
75 unsigned char req[5] = {N6110_FRAME_HEADER, 0x00, 0x41};
76
77 smprintf(s, "Getting IMEI\n");
78 return GSM_WaitFor (s, req, 5, 0x1B, 2, ID_GetIMEI);
79}
80
81GSM_Error DCT4_GetHardware(GSM_StateMachine *s, char *value)
82{
83 return NOKIA_GetPhoneString(s,"\x00\x03\x02\x07\x00\x02",6,0x1b,value,ID_GetHardware,10);
84}
85
86GSM_Error DCT4_GetProductCode(GSM_StateMachine *s, char *value)
87{
88 return NOKIA_GetPhoneString(s,"\x00\x03\x04\x0b\x00\x02",6,0x1b,value,ID_GetProductCode,10);
89}
90
91GSM_Error DCT4_Reset(GSM_StateMachine *s, bool hard)
92{
93 unsigned char req[] = {N6110_FRAME_HEADER, 0x05,
94 0x80, /* 0x80 - reset, 0x00 - off */
95 0x00};
96 //unsigned char TimeReq[] = {N6110_FRAME_HEADER, 0x0E, 0x00, 0x00};
97
98 if (hard) return ERR_NOTSUPPORTED;
99
100 //error = DCT4_SetPhoneMode(s, DCT4_MODE_TEST);
101 //if (error != ERR_NONE) return error;
102 //error = DCT4_SetPhoneMode(s, DCT4_MODE_NORMAL);
103 //if (error != ERR_NONE) return error;
104
105 s->Phone.Data.EnableIncomingSMS = false;
106 s->Phone.Data.EnableIncomingCB = false;
107
108 return GSM_WaitFor (s, req, 6, 0x15, 2, ID_Reset);
109}
110
111#endif
112
113/* How should editor hadle tabs in this file? Add editor commands here.
114 * vim: noexpandtab sw=8 ts=8 sts=8:
115 */