Gammu internals  1.38.0
dct4func.c
Go to the documentation of this file.
1 /* (c) 2002-2003 by Marcin Wiacek */
2 
3 #include <string.h>
4 #include <time.h>
5 
6 #include <gammu-config.h>
7 
8 #include "../../../misc/coding/coding.h"
9 #include "../../../service/gsmlogo.h"
10 #include "../nfunc.h"
11 #include "../nfuncold.h"
12 #include "../../pfunc.h"
13 #include "dct4func.h"
14 
15 #ifdef GSM_ENABLE_NOKIA_DCT4
16 
18 {
19  s->Phone.Data.PhoneString[0] = msg->Buffer[4];
20  return ERR_NONE;
21 }
22 
24 {
25  unsigned char req[] = {N6110_FRAME_HEADER, 0x02, 0x00, 0x00};
26 
27  smprintf(s,"Getting phone mode\n");
28 
29  return GSM_WaitFor (s, req, 6, 0x15, 4, ID_Reset);
30 }
31 
33 {
34  return ERR_NONE;
35 }
36 
38 {
39  unsigned char PhoneMode[10];
40  int i;
41  GSM_Error error;
42  unsigned char req[] = {N6110_FRAME_HEADER, 0x01,
43  0x04, /* phone mode */
44  0x00};
45 
47 
48  s->Phone.Data.PhoneString = PhoneMode;
49  req[4] = mode;
50 
51  smprintf(s,"Going to phone mode %i\n",mode);
52  error = GSM_WaitFor (s, req, 6, 0x15, 4, ID_Reset);
53  if (error != ERR_NONE) return error;
54  for (i=0;i<20;i++) {
55  error=DCT4_GetPhoneMode(s);
56  if (error != ERR_NONE) return error;
57  if (PhoneMode[0] == mode) break;
58  usleep(500000);
59  }
60 
61  return ERR_NONE;
62 }
63 
65 {
66  memcpy(s->Phone.Data.IMEI,msg->Buffer + 10, 16);
67  smprintf(s, "Received IMEI %s\n",s->Phone.Data.IMEI);
68  return ERR_NONE;
69 }
70 
72 {
73  unsigned char req[5] = {N6110_FRAME_HEADER, 0x00, 0x41};
74 
75  smprintf(s, "Getting IMEI\n");
76  return GSM_WaitFor (s, req, 5, 0x1B, 2, ID_GetIMEI);
77 }
78 
80 {
81  return NOKIA_GetPhoneString(s,"\x00\x03\x02\x07\x00\x02",6,0x1b,value,ID_GetHardware,10);
82 }
83 
85 {
86  return NOKIA_GetPhoneString(s,"\x00\x03\x04\x0b\x00\x02",6,0x1b,value,ID_GetProductCode,10);
87 }
88 
90 {
91  unsigned char req[] = {N6110_FRAME_HEADER, 0x05,
92  0x80, /* 0x80 - reset, 0x00 - off */
93  0x00};
94 /* unsigned char TimeReq[] = {N6110_FRAME_HEADER, 0x0E, 0x00, 0x00}; */
95 
96  if (hard) return ERR_NOTSUPPORTED;
97 
98 /* error = DCT4_SetPhoneMode(s, DCT4_MODE_TEST); */
99 /* if (error != ERR_NONE) return error; */
100 /* error = DCT4_SetPhoneMode(s, DCT4_MODE_NORMAL); */
101 /* if (error != ERR_NONE) return error; */
102 
105 
106  return GSM_WaitFor (s, req, 6, 0x15, 2, ID_Reset);
107 }
108 
109 #endif
110 
111 /* How should editor hadle tabs in this file? Add editor commands here.
112  * vim: noexpandtab sw=8 ts=8 sts=8:
113  */
GSM_Error DCT4_SetPhoneMode(GSM_StateMachine *s, DCT4_PHONE_MODE mode)
GSM_Error DCT4_ReplySetPhoneMode(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_ConnectionType ConnectionType
Definition: gsmstate.h:1402
GSM_Error DCT4_GetPhoneMode(GSM_StateMachine *s)
#define N6110_FRAME_HEADER
Definition: ncommon.h:8
GSM_Error DCT4_Reset(GSM_StateMachine *s, gboolean hard)
gboolean EnableIncomingCB
Definition: gsmstate.h:667
GSM_Error
Definition: gammu-error.h:23
GSM_Error DCT4_GetHardware(GSM_StateMachine *s, char *value)
char IMEI[GSM_MAX_IMEI_LENGTH+1]
Definition: gsmstate.h:437
GSM_Error DCT4_GetIMEI(GSM_StateMachine *s)
GSM_Error DCT4_ReplyGetIMEI(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error NOKIA_GetPhoneString(GSM_StateMachine *s, const unsigned char *msgframe, int msglen, unsigned char msgtype, char *retvalue, GSM_Phone_RequestID request, int startresponse)
int gboolean
Definition: gammu-types.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define FALSE
Definition: gammu-types.h:25
DCT4_PHONE_MODE
Definition: dct4func.h:8
GSM_Error GSM_WaitFor(GSM_StateMachine *s, unsigned const char *buffer, size_t length, int type, int timeout, GSM_Phone_RequestID request)
Definition: gsmstate.c:1029
GSM_Phone_Data Data
Definition: gsmstate.h:1369
GSM_Error DCT4_ReplyGetPhoneMode(GSM_Protocol_Message *msg, GSM_StateMachine *s)
gboolean EnableIncomingSMS
Definition: gsmstate.h:663
unsigned char * Buffer
Definition: protocol.h:22
#define UNUSED
Definition: gammu-misc.h:105
unsigned char * PhoneString
Definition: gsmstate.h:629
GSM_Error DCT4_GetProductCode(GSM_StateMachine *s, char *value)
int smprintf(GSM_StateMachine *s, const char *format,...)
Definition: debug.c:261