summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone/nokia/dct4/dct4func.c
blob: 9fa931f13502c7958876705908dce247b204298f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* (c) 2002-2003 by Marcin Wiacek */

#include "../../../gsmstate.h"

#include <string.h>
#include <time.h>

#include "../../../gsmcomon.h"
#include "../../../misc/coding/coding.h"
#include "../../../service/gsmlogo.h"
#include "../nfunc.h"
#include "../nfuncold.h"
#include "../../pfunc.h"
#include "dct4func.h"

#ifdef GSM_ENABLE_NOKIA_DCT4

GSM_Error DCT4_ReplyGetPhoneMode(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
	s->Phone.Data.PhoneString[0] = msg.Buffer[4];
	return ERR_NONE;
}

GSM_Error DCT4_GetPhoneMode(GSM_StateMachine *s)
{
	unsigned char req[] = {N6110_FRAME_HEADER, 0x02, 0x00, 0x00};

	smprintf(s,"Getting phone mode\n");

	return GSM_WaitFor (s, req, 6, 0x15, 4, ID_Reset);
}

GSM_Error DCT4_ReplySetPhoneMode(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
	return ERR_NONE;
}

GSM_Error DCT4_SetPhoneMode(GSM_StateMachine *s, DCT4_PHONE_MODE mode)
{
	unsigned char PhoneMode[10];
	int	      i;
	GSM_Error     error;
	unsigned char req[] = {N6110_FRAME_HEADER, 0x01,
			       0x04,		/* phone mode */
			       0x00};

	if (s->ConnectionType != GCT_FBUS2) return ERR_OTHERCONNECTIONREQUIRED;

	s->Phone.Data.PhoneString 	= PhoneMode;
	req[4] 				= mode;

	while (1) {
		smprintf(s,"Going to phone mode %i\n",mode);
		error = GSM_WaitFor (s, req, 6, 0x15, 4, ID_Reset);
		if (error != ERR_NONE) return error;
		for (i=0;i<20;i++) {
			error=DCT4_GetPhoneMode(s);
			if (error != ERR_NONE) return error;
			if (PhoneMode[0] == mode) return ERR_NONE;
			my_sleep(500);
		}
	}
	return ERR_NONE;
}

GSM_Error DCT4_ReplyGetIMEI(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
	memcpy(s->Phone.Data.IMEI,msg.Buffer + 10, 16);
	smprintf(s, "Received IMEI %s\n",s->Phone.Data.IMEI);
	return ERR_NONE;
}

GSM_Error DCT4_GetIMEI (GSM_StateMachine *s)
{
	unsigned char req[5] = {N6110_FRAME_HEADER, 0x00, 0x41};

	smprintf(s, "Getting IMEI\n");
	return GSM_WaitFor (s, req, 5, 0x1B, 2, ID_GetIMEI);
}

GSM_Error DCT4_GetHardware(GSM_StateMachine *s, char *value)
{
	return NOKIA_GetPhoneString(s,"\x00\x03\x02\x07\x00\x02",6,0x1b,value,ID_GetHardware,10);
}

GSM_Error DCT4_GetProductCode(GSM_StateMachine *s, char *value)
{
	return NOKIA_GetPhoneString(s,"\x00\x03\x04\x0b\x00\x02",6,0x1b,value,ID_GetProductCode,10);
}

GSM_Error DCT4_Reset(GSM_StateMachine *s, bool hard)
{
	unsigned char req[] = {N6110_FRAME_HEADER, 0x05,
			       0x80,		/* 0x80 - reset, 0x00 - off */
			       0x00};
//	unsigned char TimeReq[] = {N6110_FRAME_HEADER, 0x0E, 0x00, 0x00};

	if (hard) return ERR_NOTSUPPORTED;

//	error = DCT4_SetPhoneMode(s, DCT4_MODE_TEST);
//	if (error != ERR_NONE) return error;
//	error = DCT4_SetPhoneMode(s, DCT4_MODE_NORMAL);
//	if (error != ERR_NONE) return error;

	s->Phone.Data.EnableIncomingSMS = false;
	s->Phone.Data.EnableIncomingCB  = false;

	return GSM_WaitFor (s, req, 6, 0x15, 2, ID_Reset);
}

#endif

/* How should editor hadle tabs in this file? Add editor commands here.
 * vim: noexpandtab sw=8 ts=8 sts=8:
 */