-rw-r--r-- | gammu/emb/common/protocol/at/at.c | 6 | ||||
-rw-r--r-- | gammu/emb/common/protocol/nokia/fbus2.c | 6 | ||||
-rw-r--r-- | gammu/emb/common/protocol/nokia/fbus2.h | 6 | ||||
-rw-r--r-- | gammu/emb/common/protocol/nokia/mbus2.c | 2 | ||||
-rw-r--r-- | gammu/emb/common/protocol/nokia/mbus2.h | 2 | ||||
-rw-r--r-- | gammu/emb/common/protocol/nokia/phonet.c | 5 | ||||
-rw-r--r-- | gammu/emb/common/protocol/nokia/phonet.h | 5 |
7 files changed, 25 insertions, 7 deletions
diff --git a/gammu/emb/common/protocol/at/at.c b/gammu/emb/common/protocol/at/at.c index f4a75b7..f8ddc06 100644 --- a/gammu/emb/common/protocol/at/at.c +++ b/gammu/emb/common/protocol/at/at.c | |||
@@ -1,172 +1,176 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */ | 1 | /* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */ |
2 | 2 | ||
3 | #include "../../gsmstate.h" | 3 | #include "../../gsmstate.h" |
4 | 4 | ||
5 | #if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT) | 5 | #if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT) |
6 | 6 | ||
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | #include <string.h> | 8 | #include <string.h> |
9 | 9 | ||
10 | #include "../../gsmcomon.h" | 10 | #include "../../gsmcomon.h" |
11 | #include "at.h" | 11 | #include "at.h" |
12 | 12 | ||
13 | static GSM_Error AT_WriteMessage (GSM_StateMachine *s, unsigned char *buffer, | 13 | static GSM_Error AT_WriteMessage (GSM_StateMachine *s, unsigned char *buffer, |
14 | int length, unsigned char type) | 14 | int length, unsigned char type) |
15 | { | 15 | { |
16 | int i,sent = 0; | 16 | int i,sent = 0; |
17 | 17 | ||
18 | GSM_DumpMessageLevel2(s, buffer, length, type); | 18 | GSM_DumpMessageLevel2(s, buffer, length, type); |
19 | GSM_DumpMessageLevel3(s, buffer, length, type); | 19 | GSM_DumpMessageLevel3(s, buffer, length, type); |
20 | if (s->Protocol.Data.AT.FastWrite) { | 20 | if (s->Protocol.Data.AT.FastWrite) { |
21 | while (sent != length) { | 21 | while (sent != length) { |
22 | if ((i = s->Device.Functions->WriteDevice(s,buffer + sent, length - sent)) == 0) { | 22 | if ((i = s->Device.Functions->WriteDevice(s,buffer + sent, length - sent)) == 0) { |
23 | return ERR_DEVICEWRITEERROR; | 23 | return ERR_DEVICEWRITEERROR; |
24 | } | 24 | } |
25 | sent += i; | 25 | sent += i; |
26 | } | 26 | } |
27 | } else { | 27 | } else { |
28 | for (i=0;i<length;i++) { | 28 | for (i=0;i<length;i++) { |
29 | if (s->Device.Functions->WriteDevice(s,buffer+i,1)!=1) return ERR_DEVICEWRITEERROR; | 29 | if (s->Device.Functions->WriteDevice(s,buffer+i,1)!=1) return ERR_DEVICEWRITEERROR; |
30 | /* For some phones like Siemens M20 we need to wait a little | 30 | /* For some phones like Siemens M20 we need to wait a little |
31 | * after writing each char. Possible reason: these phones | 31 | * after writing each char. Possible reason: these phones |
32 | * can't receive so fast chars or there is bug here in Gammu */ | 32 | * can't receive so fast chars or there is bug here in Gammu */ |
33 | my_sleep(1); | 33 | my_sleep(1); |
34 | } | 34 | } |
35 | my_sleep(400); | 35 | my_sleep(400); |
36 | } | 36 | } |
37 | 37 | ||
38 | return ERR_NONE; | 38 | return ERR_NONE; |
39 | } | 39 | } |
40 | 40 | ||
41 | typedef struct { | 41 | typedef struct { |
42 | char*text; | 42 | char*text; |
43 | intlines; | 43 | intlines; |
44 | } SpecialAnswersStruct; | 44 | } SpecialAnswersStruct; |
45 | 45 | ||
46 | static GSM_Error AT_StateMachine(GSM_StateMachine *s, unsigned char rx_char) | 46 | static GSM_Error AT_StateMachine(GSM_StateMachine *s, unsigned char rx_char) |
47 | { | 47 | { |
48 | GSM_Protocol_Message Msg2; | 48 | GSM_Protocol_Message Msg2; |
49 | GSM_Protocol_ATData *d = &s->Protocol.Data.AT; | 49 | GSM_Protocol_ATData *d = &s->Protocol.Data.AT; |
50 | int i; | 50 | int i; |
51 | 51 | ||
52 | /* These are lines with end of "normal" answers */ | 52 | /* These are lines with end of "normal" answers */ |
53 | static char *StartStrings[] = { | 53 | static char *StartStrings[] = { |
54 | "OK" , "ERROR" , | 54 | "OK" , "ERROR" , |
55 | "+CME ERROR:" , "+CMS ERROR:", | 55 | "+CME ERROR:" , "+CMS ERROR:", |
56 | 56 | ||
57 | "+CPIN: " ,/*A2D issue*/ | 57 | "+CPIN: " ,/*A2D issue*/ |
58 | 58 | ||
59 | NULL}; | 59 | NULL}; |
60 | 60 | ||
61 | /* Some info from phone can be inside "normal" answers | 61 | /* Some info from phone can be inside "normal" answers |
62 | * It starts with strings written here | 62 | * It starts with strings written here |
63 | */ | 63 | */ |
64 | static SpecialAnswersStructSpecialAnswers[] = { | 64 | static SpecialAnswersStructSpecialAnswers[] = { |
65 | {"_OSIGQ:" ,1}, {"_OBS:",1}, | 65 | {"_OSIGQ:" ,1}, {"_OBS:",1}, |
66 | {"^SCN:" ,1}, {"+CGREG:",1}, | 66 | {"^SCN:" ,1}, {"+CGREG:",1}, |
67 | {"+CBM:" ,1}, {"+CMT:",2}, | 67 | {"+CBM:" ,1}, {"+CMT:",2}, |
68 | {"+CMTI:" ,1}, {"+CDS:",2}, | 68 | {"+CMTI:" ,1}, {"+CDS:",2}, |
69 | {"+CREG:",1}, | 69 | {"+CREG:" ,1}, {"+CUSD",1}, |
70 | 70 | ||
71 | {"RING" ,1}, {"NO CARRIER",1}, | 71 | {"RING" ,1}, {"NO CARRIER",1}, |
72 | {"NO ANSWER" ,1}, {"+COLP",1}, | 72 | {"NO ANSWER" ,1}, {"+COLP",1}, |
73 | {"+CLIP",1}, | 73 | {"+CLIP",1}, |
74 | 74 | ||
75 | {"SDNDCRC =" ,1},/* Samsung binary transfer end */ | ||
76 | |||
75 | {NULL ,1}}; | 77 | {NULL ,1}}; |
76 | 78 | ||
79 | //printf("%c",rx_char); | ||
80 | |||
77 | /* Ignore leading CR, LF and ESC */ | 81 | /* Ignore leading CR, LF and ESC */ |
78 | if (d->Msg.Length == 0) { | 82 | if (d->Msg.Length == 0) { |
79 | if (rx_char == 10 || rx_char == 13 || rx_char == 27) return ERR_NONE; | 83 | if (rx_char == 10 || rx_char == 13 || rx_char == 27) return ERR_NONE; |
80 | d->LineStart = d->Msg.Length; | 84 | d->LineStart = d->Msg.Length; |
81 | } | 85 | } |
82 | 86 | ||
83 | if (d->Msg.BufferUsed < d->Msg.Length + 2) { | 87 | if (d->Msg.BufferUsed < d->Msg.Length + 2) { |
84 | d->Msg.BufferUsed= d->Msg.Length + 2; | 88 | d->Msg.BufferUsed= d->Msg.Length + 2; |
85 | d->Msg.Buffer = (unsigned char *)realloc(d->Msg.Buffer,d->Msg.BufferUsed); | 89 | d->Msg.Buffer = (unsigned char *)realloc(d->Msg.Buffer,d->Msg.BufferUsed); |
86 | } | 90 | } |
87 | d->Msg.Buffer[d->Msg.Length++] = rx_char; | 91 | d->Msg.Buffer[d->Msg.Length++] = rx_char; |
88 | d->Msg.Buffer[d->Msg.Length ] = 0; | 92 | d->Msg.Buffer[d->Msg.Length ] = 0; |
89 | 93 | ||
90 | switch (rx_char) { | 94 | switch (rx_char) { |
91 | case 0: | 95 | case 0: |
92 | break; | 96 | break; |
93 | case 10: | 97 | case 10: |
94 | case 13: | 98 | case 13: |
95 | if (!d->wascrlf) d->LineEnd = d->Msg.Length-1; | 99 | if (!d->wascrlf) d->LineEnd = d->Msg.Length-1; |
96 | d->wascrlf = true; | 100 | d->wascrlf = true; |
97 | if (d->Msg.Length > 0 && rx_char == 10 && d->Msg.Buffer[d->Msg.Length-2]==13) { | 101 | if (d->Msg.Length > 0 && rx_char == 10 && d->Msg.Buffer[d->Msg.Length-2]==13) { |
98 | i = 0; | 102 | i = 0; |
99 | while (StartStrings[i] != NULL) { | 103 | while (StartStrings[i] != NULL) { |
100 | if (strncmp(StartStrings[i],d->Msg.Buffer+d->LineStart,strlen(StartStrings[i])) == 0) { | 104 | if (strncmp(StartStrings[i],d->Msg.Buffer+d->LineStart,strlen(StartStrings[i])) == 0) { |
101 | s->Phone.Data.RequestMsg= &d->Msg; | 105 | s->Phone.Data.RequestMsg= &d->Msg; |
102 | s->Phone.Data.DispatchError= s->Phone.Functions->DispatchMessage(s); | 106 | s->Phone.Data.DispatchError= s->Phone.Functions->DispatchMessage(s); |
103 | d->Msg.Length = 0; | 107 | d->Msg.Length = 0; |
104 | break; | 108 | break; |
105 | } | 109 | } |
106 | i++; | 110 | i++; |
107 | } | 111 | } |
108 | if (d->Msg.Length == 0) break; | 112 | if (d->Msg.Length == 0) break; |
109 | 113 | ||
110 | i = 0; | 114 | i = 0; |
111 | while (SpecialAnswers[i].text != NULL) { | 115 | while (SpecialAnswers[i].text != NULL) { |
112 | if (strncmp(SpecialAnswers[i].text,d->Msg.Buffer+d->LineStart,strlen(SpecialAnswers[i].text)) == 0) { | 116 | if (strncmp(SpecialAnswers[i].text,d->Msg.Buffer+d->LineStart,strlen(SpecialAnswers[i].text)) == 0) { |
113 | /* We need something better here */ | 117 | /* We need something better here */ |
114 | if (s->Phone.Data.RequestID == ID_GetNetworkInfo && strncmp(SpecialAnswers[i].text,"+CREG:",6) == 0) { | 118 | if (s->Phone.Data.RequestID == ID_GetNetworkInfo && strncmp(SpecialAnswers[i].text,"+CREG:",6) == 0) { |
115 | i++; | 119 | i++; |
116 | continue; | 120 | continue; |
117 | } | 121 | } |
118 | d->SpecialAnswerStart = d->LineStart; | 122 | d->SpecialAnswerStart = d->LineStart; |
119 | d->SpecialAnswerLines= SpecialAnswers[i].lines; | 123 | d->SpecialAnswerLines= SpecialAnswers[i].lines; |
120 | } | 124 | } |
121 | i++; | 125 | i++; |
122 | } | 126 | } |
123 | 127 | ||
124 | 128 | ||
125 | if (d->SpecialAnswerLines == 1) { | 129 | if (d->SpecialAnswerLines == 1) { |
126 | /* This is end of special answer. We copy it and send to phone module */ | 130 | /* This is end of special answer. We copy it and send to phone module */ |
127 | Msg2.Buffer = malloc(d->LineEnd - d->SpecialAnswerStart + 3); | 131 | Msg2.Buffer = malloc(d->LineEnd - d->SpecialAnswerStart + 3); |
128 | memcpy(Msg2.Buffer,d->Msg.Buffer+d->SpecialAnswerStart,d->LineEnd - d->SpecialAnswerStart + 2); | 132 | memcpy(Msg2.Buffer,d->Msg.Buffer+d->SpecialAnswerStart,d->LineEnd - d->SpecialAnswerStart + 2); |
129 | Msg2.Length = d->LineEnd - d->SpecialAnswerStart + 2; | 133 | Msg2.Length = d->LineEnd - d->SpecialAnswerStart + 2; |
130 | Msg2.Buffer[Msg2.Length] = 0; | 134 | Msg2.Buffer[Msg2.Length] = 0; |
131 | 135 | ||
132 | s->Phone.Data.RequestMsg= &Msg2; | 136 | s->Phone.Data.RequestMsg= &Msg2; |
133 | s->Phone.Data.DispatchError= s->Phone.Functions->DispatchMessage(s); | 137 | s->Phone.Data.DispatchError= s->Phone.Functions->DispatchMessage(s); |
134 | free(Msg2.Buffer); | 138 | free(Msg2.Buffer); |
135 | 139 | ||
136 | /* We cut special answer from main buffer */ | 140 | /* We cut special answer from main buffer */ |
137 | d->Msg.Length = d->SpecialAnswerStart; | 141 | d->Msg.Length = d->SpecialAnswerStart; |
138 | if (d->Msg.Length != 0) d->Msg.Length = d->Msg.Length - 2; | 142 | if (d->Msg.Length != 0) d->Msg.Length = d->Msg.Length - 2; |
139 | 143 | ||
140 | /* We need to find earlier values of all variables */ | 144 | /* We need to find earlier values of all variables */ |
141 | d->wascrlf = false; | 145 | d->wascrlf = false; |
142 | d->LineStart = 0; | 146 | d->LineStart = 0; |
143 | for (i=0;i<d->Msg.Length;i++) { | 147 | for (i=0;i<d->Msg.Length;i++) { |
144 | switch(d->Msg.Buffer[i]) { | 148 | switch(d->Msg.Buffer[i]) { |
145 | case 0: | 149 | case 0: |
146 | break; | 150 | break; |
147 | case 10: | 151 | case 10: |
148 | case 13: | 152 | case 13: |
149 | if (!d->wascrlf) d->LineEnd = d->Msg.Length-1; | 153 | if (!d->wascrlf) d->LineEnd = d->Msg.Length-1; |
150 | d->wascrlf = true; | 154 | d->wascrlf = true; |
151 | break; | 155 | break; |
152 | default: | 156 | default: |
153 | if (d->wascrlf) { | 157 | if (d->wascrlf) { |
154 | d->LineStart= d->Msg.Length-1; | 158 | d->LineStart= d->Msg.Length-1; |
155 | d->wascrlf = false; | 159 | d->wascrlf = false; |
156 | } | 160 | } |
157 | } | 161 | } |
158 | } | 162 | } |
159 | d->Msg.Buffer[d->Msg.Length] = 0; | 163 | d->Msg.Buffer[d->Msg.Length] = 0; |
160 | } | 164 | } |
161 | if (d->SpecialAnswerLines > 0) d->SpecialAnswerLines--; | 165 | if (d->SpecialAnswerLines > 0) d->SpecialAnswerLines--; |
162 | } | 166 | } |
163 | break; | 167 | break; |
164 | case 'T': | 168 | case 'T': |
165 | /* When CONNECT string received, we know there will not follow | 169 | /* When CONNECT string received, we know there will not follow |
166 | * anything AT related, after CONNECT can follow ppp data, alcabus | 170 | * anything AT related, after CONNECT can follow ppp data, alcabus |
167 | * data and also other things. | 171 | * data and also other things. |
168 | */ | 172 | */ |
169 | if (strncmp(d->Msg.Buffer+d->LineStart, "CONNECT", 7) == 0) { | 173 | if (strncmp(d->Msg.Buffer+d->LineStart, "CONNECT", 7) == 0) { |
170 | s->Phone.Data.RequestMsg = &d->Msg; | 174 | s->Phone.Data.RequestMsg = &d->Msg; |
171 | s->Phone.Data.DispatchError= s->Phone.Functions->DispatchMessage(s); | 175 | s->Phone.Data.DispatchError= s->Phone.Functions->DispatchMessage(s); |
172 | d->LineStart = -1; | 176 | d->LineStart = -1; |
diff --git a/gammu/emb/common/protocol/nokia/fbus2.c b/gammu/emb/common/protocol/nokia/fbus2.c index 8b3e024..2b41f8b 100644 --- a/gammu/emb/common/protocol/nokia/fbus2.c +++ b/gammu/emb/common/protocol/nokia/fbus2.c | |||
@@ -1,98 +1,102 @@ | |||
1 | /* (c) 2002-2003 by Marcin Wiacek */ | 1 | /* (c) 2002-2003 by Marcin Wiacek */ |
2 | /* based on some work from Gnokii and MyGnokii */ | 2 | /* based on some work from MyGnokii (www.mwiacek.com) */ |
3 | /* Based on some work from Gnokii (www.gnokii.org) | ||
4 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
5 | * GNU GPL version 2 or later | ||
6 | */ | ||
3 | 7 | ||
4 | #include "../../gsmstate.h" | 8 | #include "../../gsmstate.h" |
5 | 9 | ||
6 | #if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303) | 10 | #if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303) |
7 | 11 | ||
8 | #include <stdio.h> | 12 | #include <stdio.h> |
9 | #include <string.h> | 13 | #include <string.h> |
10 | 14 | ||
11 | #include "../../gsmcomon.h" | 15 | #include "../../gsmcomon.h" |
12 | #include "fbus2.h" | 16 | #include "fbus2.h" |
13 | 17 | ||
14 | static GSM_Error FBUS2_WriteFrame(GSM_StateMachine *s, | 18 | static GSM_Error FBUS2_WriteFrame(GSM_StateMachine *s, |
15 | unsigned char *MsgBuffer, | 19 | unsigned char *MsgBuffer, |
16 | int MsgLength, | 20 | int MsgLength, |
17 | unsigned char MsgType) | 21 | unsigned char MsgType) |
18 | { | 22 | { |
19 | unsigned char buffer2[FBUS2_MAX_TRANSMIT_LENGTH + 10]; | 23 | unsigned char buffer2[FBUS2_MAX_TRANSMIT_LENGTH + 10]; |
20 | unsigned char checksum=0; | 24 | unsigned char checksum=0; |
21 | int i, len, sent; | 25 | int i, len, sent; |
22 | 26 | ||
23 | buffer2[0] = FBUS2_FRAME_ID; | 27 | buffer2[0] = FBUS2_FRAME_ID; |
24 | if (s->ConnectionType==GCT_FBUS2IRDA) buffer2[0] = FBUS2_IRDA_FRAME_ID; | 28 | if (s->ConnectionType==GCT_FBUS2IRDA) buffer2[0] = FBUS2_IRDA_FRAME_ID; |
25 | 29 | ||
26 | buffer2[1] = FBUS2_DEVICE_PHONE; //destination | 30 | buffer2[1] = FBUS2_DEVICE_PHONE; //destination |
27 | buffer2[2] = FBUS2_DEVICE_PC; //source | 31 | buffer2[2] = FBUS2_DEVICE_PC; //source |
28 | buffer2[3]= MsgType; | 32 | buffer2[3]= MsgType; |
29 | buffer2[4]= MsgLength / 256; | 33 | buffer2[4]= MsgLength / 256; |
30 | buffer2[5]= MsgLength % 256; | 34 | buffer2[5]= MsgLength % 256; |
31 | 35 | ||
32 | memcpy(buffer2 + 6, MsgBuffer, MsgLength); | 36 | memcpy(buffer2 + 6, MsgBuffer, MsgLength); |
33 | len = MsgLength + 6; | 37 | len = MsgLength + 6; |
34 | 38 | ||
35 | /* Odd messages require additional 0x00 byte */ | 39 | /* Odd messages require additional 0x00 byte */ |
36 | if (MsgLength % 2) buffer2[len++] = 0x00; | 40 | if (MsgLength % 2) buffer2[len++] = 0x00; |
37 | 41 | ||
38 | checksum = 0; | 42 | checksum = 0; |
39 | for (i = 0; i < len; i+=2) checksum ^= buffer2[i]; | 43 | for (i = 0; i < len; i+=2) checksum ^= buffer2[i]; |
40 | buffer2[len++] = checksum; | 44 | buffer2[len++] = checksum; |
41 | 45 | ||
42 | checksum = 0; | 46 | checksum = 0; |
43 | for (i = 1; i < len; i+=2) checksum ^= buffer2[i]; | 47 | for (i = 1; i < len; i+=2) checksum ^= buffer2[i]; |
44 | buffer2[len++] = checksum; | 48 | buffer2[len++] = checksum; |
45 | 49 | ||
46 | /* Sending to phone */ | 50 | /* Sending to phone */ |
47 | sent=s->Device.Functions->WriteDevice(s,buffer2,len); | 51 | sent=s->Device.Functions->WriteDevice(s,buffer2,len); |
48 | if (sent!=len) return ERR_DEVICEWRITEERROR; | 52 | if (sent!=len) return ERR_DEVICEWRITEERROR; |
49 | 53 | ||
50 | return ERR_NONE; | 54 | return ERR_NONE; |
51 | } | 55 | } |
52 | 56 | ||
53 | static GSM_Error FBUS2_WriteMessage (GSM_StateMachine *s, | 57 | static GSM_Error FBUS2_WriteMessage (GSM_StateMachine *s, |
54 | unsigned char *MsgBuffer, | 58 | unsigned char *MsgBuffer, |
55 | int MsgLength, | 59 | int MsgLength, |
56 | unsigned char MsgType) | 60 | unsigned char MsgType) |
57 | { | 61 | { |
58 | int i, nom, togo, thislength; /* number of messages, ... */ | 62 | int i, nom, togo, thislength; /* number of messages, ... */ |
59 | unsigned char buffer2[FBUS2_MAX_TRANSMIT_LENGTH + 2], seqnum; | 63 | unsigned char buffer2[FBUS2_MAX_TRANSMIT_LENGTH + 2], seqnum; |
60 | GSM_Protocol_FBUS2Data*d = &s->Protocol.Data.FBUS2; | 64 | GSM_Protocol_FBUS2Data*d = &s->Protocol.Data.FBUS2; |
61 | GSM_Error error; | 65 | GSM_Error error; |
62 | 66 | ||
63 | GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType); | 67 | GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType); |
64 | 68 | ||
65 | nom = (MsgLength + FBUS2_MAX_TRANSMIT_LENGTH - 1) / FBUS2_MAX_TRANSMIT_LENGTH; | 69 | nom = (MsgLength + FBUS2_MAX_TRANSMIT_LENGTH - 1) / FBUS2_MAX_TRANSMIT_LENGTH; |
66 | togo = MsgLength; | 70 | togo = MsgLength; |
67 | 71 | ||
68 | for (i = 0; i < nom; i++) { | 72 | for (i = 0; i < nom; i++) { |
69 | seqnum = d->MsgSequenceNumber; | 73 | seqnum = d->MsgSequenceNumber; |
70 | if (i==0) seqnum = seqnum + 0x40; | 74 | if (i==0) seqnum = seqnum + 0x40; |
71 | d->MsgSequenceNumber = (d->MsgSequenceNumber + 1) & 0x07; | 75 | d->MsgSequenceNumber = (d->MsgSequenceNumber + 1) & 0x07; |
72 | 76 | ||
73 | thislength = togo; | 77 | thislength = togo; |
74 | if (togo > FBUS2_MAX_TRANSMIT_LENGTH) thislength = FBUS2_MAX_TRANSMIT_LENGTH; | 78 | if (togo > FBUS2_MAX_TRANSMIT_LENGTH) thislength = FBUS2_MAX_TRANSMIT_LENGTH; |
75 | memcpy(buffer2, MsgBuffer + (MsgLength - togo), thislength); | 79 | memcpy(buffer2, MsgBuffer + (MsgLength - togo), thislength); |
76 | buffer2[thislength]= nom - i; | 80 | buffer2[thislength]= nom - i; |
77 | buffer2[thislength + 1]= seqnum; | 81 | buffer2[thislength + 1]= seqnum; |
78 | togo = togo - thislength; | 82 | togo = togo - thislength; |
79 | 83 | ||
80 | GSM_DumpMessageLevel2(s, buffer2, thislength, MsgType); | 84 | GSM_DumpMessageLevel2(s, buffer2, thislength, MsgType); |
81 | 85 | ||
82 | error=FBUS2_WriteFrame(s, buffer2, thislength + 2, MsgType); | 86 | error=FBUS2_WriteFrame(s, buffer2, thislength + 2, MsgType); |
83 | if (error!=ERR_NONE) return error; | 87 | if (error!=ERR_NONE) return error; |
84 | } | 88 | } |
85 | 89 | ||
86 | return ERR_NONE; | 90 | return ERR_NONE; |
87 | } | 91 | } |
88 | 92 | ||
89 | static GSM_Error FBUS2_SendAck(GSM_StateMachine *s, | 93 | static GSM_Error FBUS2_SendAck(GSM_StateMachine *s, |
90 | unsigned char MsgType, | 94 | unsigned char MsgType, |
91 | unsigned char MsgSequence) | 95 | unsigned char MsgSequence) |
92 | { | 96 | { |
93 | unsigned char buffer2[2]; | 97 | unsigned char buffer2[2]; |
94 | 98 | ||
95 | buffer2[0] = MsgType; | 99 | buffer2[0] = MsgType; |
96 | buffer2[1] = MsgSequence; | 100 | buffer2[1] = MsgSequence; |
97 | 101 | ||
98 | if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || | 102 | if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || |
diff --git a/gammu/emb/common/protocol/nokia/fbus2.h b/gammu/emb/common/protocol/nokia/fbus2.h index 5dd45d7..8dbcb07 100644 --- a/gammu/emb/common/protocol/nokia/fbus2.h +++ b/gammu/emb/common/protocol/nokia/fbus2.h | |||
@@ -1,38 +1,42 @@ | |||
1 | /* (c) 2002-2003 by Marcin Wiacek */ | 1 | /* (c) 2002-2003 by Marcin Wiacek */ |
2 | /* based on some work from Gnokii and MyGnokii */ | 2 | /* based on some work from MyGnokii (www.mwiacek.com) */ |
3 | /* Based on some work from Gnokii (www.gnokii.org) | ||
4 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
5 | * GNU GPL version 2 or later | ||
6 | */ | ||
3 | 7 | ||
4 | #ifndef fbus2_h | 8 | #ifndef fbus2_h |
5 | #define fbus2_h | 9 | #define fbus2_h |
6 | 10 | ||
7 | #include "../protocol.h" | 11 | #include "../protocol.h" |
8 | 12 | ||
9 | #define FBUS2_FRAME_ID 0x1e | 13 | #define FBUS2_FRAME_ID 0x1e |
10 | #define FBUS2_IRDA_FRAME_ID 0x1c | 14 | #define FBUS2_IRDA_FRAME_ID 0x1c |
11 | #define FBUS2_DEVICE_PHONE 0x00 /* Nokia mobile phone */ | 15 | #define FBUS2_DEVICE_PHONE 0x00 /* Nokia mobile phone */ |
12 | #define FBUS2_DEVICE_PC 0x0c /* Our PC */ | 16 | #define FBUS2_DEVICE_PC 0x0c /* Our PC */ |
13 | #define FBUS2_ACK_BYTE 0x7f /* Acknowledge of the received frame */ | 17 | #define FBUS2_ACK_BYTE 0x7f /* Acknowledge of the received frame */ |
14 | 18 | ||
15 | #define FBUS2_MAX_TRANSMIT_LENGTH 120 | 19 | #define FBUS2_MAX_TRANSMIT_LENGTH 120 |
16 | 20 | ||
17 | typedef struct { | 21 | typedef struct { |
18 | int MsgSequenceNumber; | 22 | int MsgSequenceNumber; |
19 | int MsgRXState; | 23 | int MsgRXState; |
20 | int FramesToGo; | 24 | int FramesToGo; |
21 | GSM_Protocol_MessageMultiMsg; | 25 | GSM_Protocol_MessageMultiMsg; |
22 | GSM_Protocol_MessageMsg; | 26 | GSM_Protocol_MessageMsg; |
23 | } GSM_Protocol_FBUS2Data; | 27 | } GSM_Protocol_FBUS2Data; |
24 | 28 | ||
25 | #ifndef GSM_USED_SERIALDEVICE | 29 | #ifndef GSM_USED_SERIALDEVICE |
26 | # define GSM_USED_SERIALDEVICE | 30 | # define GSM_USED_SERIALDEVICE |
27 | #endif | 31 | #endif |
28 | #if defined(GSM_ENABLE_BLUEFBUS2) | 32 | #if defined(GSM_ENABLE_BLUEFBUS2) |
29 | # ifndef GSM_USED_BLUETOOTHDEVICE | 33 | # ifndef GSM_USED_BLUETOOTHDEVICE |
30 | # define GSM_USED_BLUETOOTHDEVICE | 34 | # define GSM_USED_BLUETOOTHDEVICE |
31 | # endif | 35 | # endif |
32 | #endif | 36 | #endif |
33 | 37 | ||
34 | #endif | 38 | #endif |
35 | 39 | ||
36 | /* How should editor hadle tabs in this file? Add editor commands here. | 40 | /* How should editor hadle tabs in this file? Add editor commands here. |
37 | * vim: noexpandtab sw=8 ts=8 sts=8: | 41 | * vim: noexpandtab sw=8 ts=8 sts=8: |
38 | */ | 42 | */ |
diff --git a/gammu/emb/common/protocol/nokia/mbus2.c b/gammu/emb/common/protocol/nokia/mbus2.c index f07d6c5..8353b46 100644 --- a/gammu/emb/common/protocol/nokia/mbus2.c +++ b/gammu/emb/common/protocol/nokia/mbus2.c | |||
@@ -1,98 +1,98 @@ | |||
1 | /* (c) 2001-2003 by Marcin Wiacek */ | 1 | /* (c) 2001-2003 by Marcin Wiacek */ |
2 | /* based on some work from MyGnokii */ | 2 | /* based on some work from MyGnokii (www.mwiacek.com) */ |
3 | 3 | ||
4 | #include "../../gsmstate.h" | 4 | #include "../../gsmstate.h" |
5 | 5 | ||
6 | #ifdef GSM_ENABLE_MBUS2 | 6 | #ifdef GSM_ENABLE_MBUS2 |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <string.h> | 9 | #include <string.h> |
10 | 10 | ||
11 | #include "../../gsmcomon.h" | 11 | #include "../../gsmcomon.h" |
12 | #include "mbus2.h" | 12 | #include "mbus2.h" |
13 | 13 | ||
14 | static GSM_Error MBUS2_WriteMessage (GSM_StateMachine *s, | 14 | static GSM_Error MBUS2_WriteMessage (GSM_StateMachine *s, |
15 | unsigned char *MsgBuffer, | 15 | unsigned char *MsgBuffer, |
16 | int MsgLength, | 16 | int MsgLength, |
17 | unsigned char MsgType) | 17 | unsigned char MsgType) |
18 | { | 18 | { |
19 | unsigned char *buffer2, checksum = 0; | 19 | unsigned char *buffer2, checksum = 0; |
20 | GSM_Protocol_MBUS2Data *d = &s->Protocol.Data.MBUS2; | 20 | GSM_Protocol_MBUS2Data *d = &s->Protocol.Data.MBUS2; |
21 | int i, sent, len; | 21 | int i, sent, len; |
22 | 22 | ||
23 | GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType); | 23 | GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType); |
24 | 24 | ||
25 | buffer2 = (unsigned char *)malloc(MsgLength + 8); | 25 | buffer2 = (unsigned char *)malloc(MsgLength + 8); |
26 | 26 | ||
27 | buffer2[0] = MBUS2_FRAME_ID; | 27 | buffer2[0] = MBUS2_FRAME_ID; |
28 | buffer2[1] = MBUS2_DEVICE_PHONE; // destination | 28 | buffer2[1] = MBUS2_DEVICE_PHONE; // destination |
29 | buffer2[2] = MBUS2_DEVICE_PC; // source | 29 | buffer2[2] = MBUS2_DEVICE_PC; // source |
30 | buffer2[3] = MsgType; | 30 | buffer2[3] = MsgType; |
31 | buffer2[4] = MsgLength / 256; | 31 | buffer2[4] = MsgLength / 256; |
32 | buffer2[5] = MsgLength % 256; | 32 | buffer2[5] = MsgLength % 256; |
33 | 33 | ||
34 | memcpy(buffer2 + 6, MsgBuffer, MsgLength); | 34 | memcpy(buffer2 + 6, MsgBuffer, MsgLength); |
35 | len = 6 + MsgLength; | 35 | len = 6 + MsgLength; |
36 | 36 | ||
37 | /* According to http://www.flosys.com/tdma/n5160.html some phones | 37 | /* According to http://www.flosys.com/tdma/n5160.html some phones |
38 | * can have problems with checksum equal 0x1F. Phones can recognize | 38 | * can have problems with checksum equal 0x1F. Phones can recognize |
39 | * received frame, but won't send ACK for it. When checksum is 0x1F, | 39 | * received frame, but won't send ACK for it. When checksum is 0x1F, |
40 | * we increment the sequence number | 40 | * we increment the sequence number |
41 | */ | 41 | */ |
42 | do { | 42 | do { |
43 | d->MsgSequenceNumber++; | 43 | d->MsgSequenceNumber++; |
44 | 44 | ||
45 | buffer2[len] = d->MsgSequenceNumber; | 45 | buffer2[len] = d->MsgSequenceNumber; |
46 | 46 | ||
47 | /* Calculating checksum */ | 47 | /* Calculating checksum */ |
48 | checksum = 0; | 48 | checksum = 0; |
49 | for (i = 0; i < len + 1; i++) checksum ^= buffer2[i]; | 49 | for (i = 0; i < len + 1; i++) checksum ^= buffer2[i]; |
50 | } while (checksum == 0x1f); | 50 | } while (checksum == 0x1f); |
51 | 51 | ||
52 | buffer2[len++] = d->MsgSequenceNumber; | 52 | buffer2[len++] = d->MsgSequenceNumber; |
53 | buffer2[len++] = checksum; | 53 | buffer2[len++] = checksum; |
54 | 54 | ||
55 | GSM_DumpMessageLevel2(s, buffer2+6, MsgLength, MsgType); | 55 | GSM_DumpMessageLevel2(s, buffer2+6, MsgLength, MsgType); |
56 | 56 | ||
57 | /* Sending to phone */ | 57 | /* Sending to phone */ |
58 | my_sleep(10); | 58 | my_sleep(10); |
59 | sent=s->Device.Functions->WriteDevice(s,buffer2,len); | 59 | sent=s->Device.Functions->WriteDevice(s,buffer2,len); |
60 | 60 | ||
61 | free(buffer2); | 61 | free(buffer2); |
62 | 62 | ||
63 | if (sent!=len) return ERR_DEVICEWRITEERROR; | 63 | if (sent!=len) return ERR_DEVICEWRITEERROR; |
64 | return ERR_NONE; | 64 | return ERR_NONE; |
65 | } | 65 | } |
66 | 66 | ||
67 | static GSM_Error MBUS2_SendAck(GSM_StateMachine *s, | 67 | static GSM_Error MBUS2_SendAck(GSM_StateMachine *s, |
68 | unsigned char type, | 68 | unsigned char type, |
69 | unsigned char sequence) | 69 | unsigned char sequence) |
70 | { | 70 | { |
71 | GSM_Device_Functions *Device = s->Device.Functions; | 71 | GSM_Device_Functions *Device = s->Device.Functions; |
72 | unsigned char buffer2[6]; | 72 | unsigned char buffer2[6]; |
73 | int i; | 73 | int i; |
74 | 74 | ||
75 | buffer2[0] = MBUS2_FRAME_ID; | 75 | buffer2[0] = MBUS2_FRAME_ID; |
76 | buffer2[1] = MBUS2_DEVICE_PHONE;//destination | 76 | buffer2[1] = MBUS2_DEVICE_PHONE;//destination |
77 | buffer2[2] = MBUS2_DEVICE_PC; //source | 77 | buffer2[2] = MBUS2_DEVICE_PC; //source |
78 | buffer2[3] = MBUS2_ACK_BYTE; | 78 | buffer2[3] = MBUS2_ACK_BYTE; |
79 | buffer2[4] = sequence; | 79 | buffer2[4] = sequence; |
80 | buffer2[5] = 0; | 80 | buffer2[5] = 0; |
81 | 81 | ||
82 | /* Calculating checksum */ | 82 | /* Calculating checksum */ |
83 | for (i = 0; i < 5; i++) buffer2[5] ^= buffer2[i]; | 83 | for (i = 0; i < 5; i++) buffer2[5] ^= buffer2[i]; |
84 | 84 | ||
85 | if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || | 85 | if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || |
86 | s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) { | 86 | s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) { |
87 | smprintf(s,"[Sending Ack of type %02x, seq: %x]\n",type,sequence); | 87 | smprintf(s,"[Sending Ack of type %02x, seq: %x]\n",type,sequence); |
88 | } | 88 | } |
89 | 89 | ||
90 | /* Sending to phone */ | 90 | /* Sending to phone */ |
91 | my_sleep(10); | 91 | my_sleep(10); |
92 | if (Device->WriteDevice(s,buffer2,6)!=6) return ERR_DEVICEWRITEERROR; | 92 | if (Device->WriteDevice(s,buffer2,6)!=6) return ERR_DEVICEWRITEERROR; |
93 | 93 | ||
94 | return ERR_NONE; | 94 | return ERR_NONE; |
95 | } | 95 | } |
96 | 96 | ||
97 | static GSM_Error MBUS2_StateMachine(GSM_StateMachine *s, unsigned char rx_char) | 97 | static GSM_Error MBUS2_StateMachine(GSM_StateMachine *s, unsigned char rx_char) |
98 | { | 98 | { |
diff --git a/gammu/emb/common/protocol/nokia/mbus2.h b/gammu/emb/common/protocol/nokia/mbus2.h index 86fcab6..5dbd8cb 100644 --- a/gammu/emb/common/protocol/nokia/mbus2.h +++ b/gammu/emb/common/protocol/nokia/mbus2.h | |||
@@ -1,28 +1,28 @@ | |||
1 | /* (c) 2001-2003 by Marcin Wiacek */ | 1 | /* (c) 2001-2003 by Marcin Wiacek */ |
2 | /* based on some work from MyGnokii */ | 2 | /* based on some work from MyGnokii (www.mwiacek.com) */ |
3 | 3 | ||
4 | #ifndef mbus2_h | 4 | #ifndef mbus2_h |
5 | #define mbus2_h | 5 | #define mbus2_h |
6 | 6 | ||
7 | #include "../protocol.h" | 7 | #include "../protocol.h" |
8 | 8 | ||
9 | #define MBUS2_FRAME_ID 0x1f | 9 | #define MBUS2_FRAME_ID 0x1f |
10 | #define MBUS2_DEVICE_PHONE 0x00 /* Nokia mobile phone */ | 10 | #define MBUS2_DEVICE_PHONE 0x00 /* Nokia mobile phone */ |
11 | #define MBUS2_DEVICE_PC 0x10 /* Our PC (MBUS) */ | 11 | #define MBUS2_DEVICE_PC 0x10 /* Our PC (MBUS) */ |
12 | #define MBUS2_ACK_BYTE 0x7f /* Acknowledge of the received frame */ | 12 | #define MBUS2_ACK_BYTE 0x7f /* Acknowledge of the received frame */ |
13 | 13 | ||
14 | typedef struct { | 14 | typedef struct { |
15 | int MsgSequenceNumber; | 15 | int MsgSequenceNumber; |
16 | int MsgRXState; | 16 | int MsgRXState; |
17 | GSM_Protocol_MessageMsg; | 17 | GSM_Protocol_MessageMsg; |
18 | } GSM_Protocol_MBUS2Data; | 18 | } GSM_Protocol_MBUS2Data; |
19 | 19 | ||
20 | #ifndef GSM_USED_SERIALDEVICE | 20 | #ifndef GSM_USED_SERIALDEVICE |
21 | # define GSM_USED_SERIALDEVICE | 21 | # define GSM_USED_SERIALDEVICE |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | /* How should editor hadle tabs in this file? Add editor commands here. | 26 | /* How should editor hadle tabs in this file? Add editor commands here. |
27 | * vim: noexpandtab sw=8 ts=8 sts=8: | 27 | * vim: noexpandtab sw=8 ts=8 sts=8: |
28 | */ | 28 | */ |
diff --git a/gammu/emb/common/protocol/nokia/phonet.c b/gammu/emb/common/protocol/nokia/phonet.c index bc5717d..db5bd72 100644 --- a/gammu/emb/common/protocol/nokia/phonet.c +++ b/gammu/emb/common/protocol/nokia/phonet.c | |||
@@ -1,98 +1,101 @@ | |||
1 | /* (c) 2002-2003 by Marcin Wiacek */ | 1 | /* (c) 2002-2003 by Marcin Wiacek */ |
2 | /* based on some work from Gnokii */ | 2 | /* Based on some work from Gnokii (www.gnokii.org) |
3 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
4 | * GNU GPL version 2 or later | ||
5 | */ | ||
3 | 6 | ||
4 | #include "../../gsmstate.h" | 7 | #include "../../gsmstate.h" |
5 | 8 | ||
6 | #if defined(GSM_ENABLE_IRDA) || defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_BLUEPHONET) | 9 | #if defined(GSM_ENABLE_IRDA) || defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_BLUEPHONET) |
7 | 10 | ||
8 | #include <stdio.h> | 11 | #include <stdio.h> |
9 | #include <string.h> | 12 | #include <string.h> |
10 | 13 | ||
11 | #include "../../gsmcomon.h" | 14 | #include "../../gsmcomon.h" |
12 | #include "phonet.h" | 15 | #include "phonet.h" |
13 | 16 | ||
14 | static GSM_Error PHONET_WriteMessage (GSM_StateMachine *s, | 17 | static GSM_Error PHONET_WriteMessage (GSM_StateMachine *s, |
15 | unsigned char *MsgBuffer, | 18 | unsigned char *MsgBuffer, |
16 | int MsgLength, | 19 | int MsgLength, |
17 | unsigned char MsgType) | 20 | unsigned char MsgType) |
18 | { | 21 | { |
19 | unsigned char *buffer2; | 22 | unsigned char *buffer2; |
20 | int sent; | 23 | int sent; |
21 | 24 | ||
22 | GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType); | 25 | GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType); |
23 | 26 | ||
24 | buffer2 = (unsigned char *)malloc(MsgLength + 6); | 27 | buffer2 = (unsigned char *)malloc(MsgLength + 6); |
25 | 28 | ||
26 | buffer2[0] = PHONET_FRAME_ID, | 29 | buffer2[0] = PHONET_FRAME_ID, |
27 | buffer2[1] = PHONET_DEVICE_PHONE; //destination | 30 | buffer2[1] = PHONET_DEVICE_PHONE; //destination |
28 | buffer2[2] = PHONET_DEVICE_PC; //source | 31 | buffer2[2] = PHONET_DEVICE_PC; //source |
29 | 32 | ||
30 | if (s->ConnectionType==GCT_PHONETBLUE || s->ConnectionType==GCT_BLUEPHONET) { | 33 | if (s->ConnectionType==GCT_PHONETBLUE || s->ConnectionType==GCT_BLUEPHONET) { |
31 | buffer2[0] = PHONET_BLUE_FRAME_ID; | 34 | buffer2[0] = PHONET_BLUE_FRAME_ID; |
32 | buffer2[1] = PHONET_DEVICE_PHONE;//destination | 35 | buffer2[1] = PHONET_DEVICE_PHONE;//destination |
33 | buffer2[2] = PHONET_BLUE_DEVICE_PC;//source | 36 | buffer2[2] = PHONET_BLUE_DEVICE_PC;//source |
34 | } | 37 | } |
35 | 38 | ||
36 | buffer2[3] = MsgType; | 39 | buffer2[3] = MsgType; |
37 | buffer2[4] = MsgLength / 256; | 40 | buffer2[4] = MsgLength / 256; |
38 | buffer2[5] = MsgLength % 256; | 41 | buffer2[5] = MsgLength % 256; |
39 | 42 | ||
40 | memcpy(buffer2 + 6, MsgBuffer, MsgLength); | 43 | memcpy(buffer2 + 6, MsgBuffer, MsgLength); |
41 | 44 | ||
42 | GSM_DumpMessageLevel2(s, buffer2+6, MsgLength, MsgType); | 45 | GSM_DumpMessageLevel2(s, buffer2+6, MsgLength, MsgType); |
43 | 46 | ||
44 | /* Sending to phone */ | 47 | /* Sending to phone */ |
45 | sent = s->Device.Functions->WriteDevice(s,buffer2,MsgLength+6); | 48 | sent = s->Device.Functions->WriteDevice(s,buffer2,MsgLength+6); |
46 | 49 | ||
47 | free(buffer2); | 50 | free(buffer2); |
48 | 51 | ||
49 | if (sent!=MsgLength+6) return ERR_DEVICEWRITEERROR; | 52 | if (sent!=MsgLength+6) return ERR_DEVICEWRITEERROR; |
50 | return ERR_NONE; | 53 | return ERR_NONE; |
51 | } | 54 | } |
52 | 55 | ||
53 | static GSM_Error PHONET_StateMachine(GSM_StateMachine *s, unsigned char rx_char) | 56 | static GSM_Error PHONET_StateMachine(GSM_StateMachine *s, unsigned char rx_char) |
54 | { | 57 | { |
55 | GSM_Protocol_PHONETData *d = &s->Protocol.Data.PHONET; | 58 | GSM_Protocol_PHONETData *d = &s->Protocol.Data.PHONET; |
56 | bool correct = false; | 59 | bool correct = false; |
57 | 60 | ||
58 | if (d->MsgRXState==RX_GetMessage) { | 61 | if (d->MsgRXState==RX_GetMessage) { |
59 | d->Msg.Buffer[d->Msg.Count] = rx_char; | 62 | d->Msg.Buffer[d->Msg.Count] = rx_char; |
60 | d->Msg.Count++; | 63 | d->Msg.Count++; |
61 | 64 | ||
62 | /* This is not last byte in frame */ | 65 | /* This is not last byte in frame */ |
63 | if (d->Msg.Count != d->Msg.Length) return ERR_NONE; | 66 | if (d->Msg.Count != d->Msg.Length) return ERR_NONE; |
64 | 67 | ||
65 | s->Phone.Data.RequestMsg= &d->Msg; | 68 | s->Phone.Data.RequestMsg= &d->Msg; |
66 | s->Phone.Data.DispatchError= s->Phone.Functions->DispatchMessage(s); | 69 | s->Phone.Data.DispatchError= s->Phone.Functions->DispatchMessage(s); |
67 | 70 | ||
68 | free(d->Msg.Buffer); | 71 | free(d->Msg.Buffer); |
69 | d->Msg.Length = 0; | 72 | d->Msg.Length = 0; |
70 | d->Msg.Buffer = NULL; | 73 | d->Msg.Buffer = NULL; |
71 | 74 | ||
72 | d->MsgRXState = RX_Sync; | 75 | d->MsgRXState = RX_Sync; |
73 | return ERR_NONE; | 76 | return ERR_NONE; |
74 | } | 77 | } |
75 | if (d->MsgRXState==RX_GetLength2) { | 78 | if (d->MsgRXState==RX_GetLength2) { |
76 | d->Msg.Length = d->Msg.Length + rx_char; | 79 | d->Msg.Length = d->Msg.Length + rx_char; |
77 | d->Msg.Buffer = (unsigned char *)malloc(d->Msg.Length); | 80 | d->Msg.Buffer = (unsigned char *)malloc(d->Msg.Length); |
78 | 81 | ||
79 | d->MsgRXState = RX_GetMessage; | 82 | d->MsgRXState = RX_GetMessage; |
80 | return ERR_NONE; | 83 | return ERR_NONE; |
81 | } | 84 | } |
82 | if (d->MsgRXState==RX_GetLength1) { | 85 | if (d->MsgRXState==RX_GetLength1) { |
83 | d->Msg.Length = rx_char * 256; | 86 | d->Msg.Length = rx_char * 256; |
84 | 87 | ||
85 | d->MsgRXState = RX_GetLength2; | 88 | d->MsgRXState = RX_GetLength2; |
86 | return ERR_NONE; | 89 | return ERR_NONE; |
87 | } | 90 | } |
88 | if (d->MsgRXState==RX_GetType) { | 91 | if (d->MsgRXState==RX_GetType) { |
89 | d->Msg.Type = rx_char; | 92 | d->Msg.Type = rx_char; |
90 | 93 | ||
91 | d->MsgRXState = RX_GetLength1; | 94 | d->MsgRXState = RX_GetLength1; |
92 | return ERR_NONE; | 95 | return ERR_NONE; |
93 | } | 96 | } |
94 | if (d->MsgRXState==RX_GetSource) { | 97 | if (d->MsgRXState==RX_GetSource) { |
95 | if (rx_char != PHONET_DEVICE_PHONE) { | 98 | if (rx_char != PHONET_DEVICE_PHONE) { |
96 | if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || | 99 | if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || |
97 | s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) { | 100 | s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) { |
98 | smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, PHONET_DEVICE_PHONE); | 101 | smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, PHONET_DEVICE_PHONE); |
diff --git a/gammu/emb/common/protocol/nokia/phonet.h b/gammu/emb/common/protocol/nokia/phonet.h index 2f6e836..e750bbd 100644 --- a/gammu/emb/common/protocol/nokia/phonet.h +++ b/gammu/emb/common/protocol/nokia/phonet.h | |||
@@ -1,35 +1,38 @@ | |||
1 | /* (c) 2002-2003 by Marcin Wiacek */ | 1 | /* (c) 2002-2003 by Marcin Wiacek */ |
2 | /* based on some work from Gnokii */ | 2 | /* Based on some work from Gnokii (www.gnokii.org) |
3 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
4 | * GNU GPL version 2 or later | ||
5 | */ | ||
3 | 6 | ||
4 | #ifndef PHONET_h | 7 | #ifndef PHONET_h |
5 | #define PHONET_h | 8 | #define PHONET_h |
6 | 9 | ||
7 | #include "../protocol.h" | 10 | #include "../protocol.h" |
8 | 11 | ||
9 | #define PHONET_FRAME_ID 0x14 | 12 | #define PHONET_FRAME_ID 0x14 |
10 | #define PHONET_BLUE_FRAME_ID0x19 | 13 | #define PHONET_BLUE_FRAME_ID0x19 |
11 | #define PHONET_DEVICE_PHONE 0x00 /* Nokia mobile phone */ | 14 | #define PHONET_DEVICE_PHONE 0x00 /* Nokia mobile phone */ |
12 | #define PHONET_DEVICE_PC 0x0c /* Our PC */ | 15 | #define PHONET_DEVICE_PC 0x0c /* Our PC */ |
13 | #define PHONET_BLUE_DEVICE_PC 0x10 /* Our PC */ | 16 | #define PHONET_BLUE_DEVICE_PC 0x10 /* Our PC */ |
14 | 17 | ||
15 | typedef struct { | 18 | typedef struct { |
16 | int MsgRXState; | 19 | int MsgRXState; |
17 | GSM_Protocol_MessageMsg; | 20 | GSM_Protocol_MessageMsg; |
18 | } GSM_Protocol_PHONETData; | 21 | } GSM_Protocol_PHONETData; |
19 | 22 | ||
20 | #if defined(GSM_ENABLE_IRDAPHONET) | 23 | #if defined(GSM_ENABLE_IRDAPHONET) |
21 | # ifndef GSM_USED_IRDADEVICE | 24 | # ifndef GSM_USED_IRDADEVICE |
22 | # define GSM_USED_IRDADEVICE | 25 | # define GSM_USED_IRDADEVICE |
23 | # endif | 26 | # endif |
24 | #endif | 27 | #endif |
25 | #if defined(GSM_ENABLE_BLUEPHONET) | 28 | #if defined(GSM_ENABLE_BLUEPHONET) |
26 | # ifndef GSM_USED_BLUETOOTHDEVICE | 29 | # ifndef GSM_USED_BLUETOOTHDEVICE |
27 | # define GSM_USED_BLUETOOTHDEVICE | 30 | # define GSM_USED_BLUETOOTHDEVICE |
28 | # endif | 31 | # endif |
29 | #endif | 32 | #endif |
30 | 33 | ||
31 | #endif | 34 | #endif |
32 | 35 | ||
33 | /* How should editor hadle tabs in this file? Add editor commands here. | 36 | /* How should editor hadle tabs in this file? Add editor commands here. |
34 | * vim: noexpandtab sw=8 ts=8 sts=8: | 37 | * vim: noexpandtab sw=8 ts=8 sts=8: |
35 | */ | 38 | */ |