summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/protocol
authorzautrix <zautrix>2004-10-05 11:13:51 (UTC)
committer zautrix <zautrix>2004-10-05 11:13:51 (UTC)
commit50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (unidiff)
tree0d1939e2297fa7bbd8e1f2030f154463854164c6 /gammu/emb/common/protocol
parentcf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff)
downloadkdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.zip
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.gz
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.bz2
updated to latest gammu version
Diffstat (limited to 'gammu/emb/common/protocol') (more/less context) (show whitespace changes)
-rw-r--r--gammu/emb/common/protocol/at/at.c6
-rw-r--r--gammu/emb/common/protocol/nokia/fbus2.c6
-rw-r--r--gammu/emb/common/protocol/nokia/fbus2.h6
-rw-r--r--gammu/emb/common/protocol/nokia/mbus2.c2
-rw-r--r--gammu/emb/common/protocol/nokia/mbus2.h2
-rw-r--r--gammu/emb/common/protocol/nokia/phonet.c5
-rw-r--r--gammu/emb/common/protocol/nokia/phonet.h5
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
@@ -45,56 +45,60 @@ typedef struct {
45 45
46static GSM_Error AT_StateMachine(GSM_StateMachine *s, unsigned char rx_char) 46static 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) {
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,26 +1,30 @@
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
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,26 +1,30 @@
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
17typedef struct { 21typedef 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
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,26 +1,26 @@
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
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,26 +1,26 @@
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
14typedef struct { 14typedef 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.
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,26 +1,29 @@
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,
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,26 +1,29 @@
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
15typedef struct { 18typedef 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