author | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
commit | 50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (unidiff) | |
tree | 0d1939e2297fa7bbd8e1f2030f154463854164c6 /gammu/emb/common/protocol/at/at.c | |
parent | cf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff) | |
download | kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.zip kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.gz kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.bz2 |
updated to latest gammu version
Diffstat (limited to 'gammu/emb/common/protocol/at/at.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/protocol/at/at.c | 6 |
1 files changed, 5 insertions, 1 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 | ||
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) { |