summaryrefslogtreecommitdiff
path: root/libgammu/phone/at/atgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgammu/phone/at/atgen.c')
-rw-r--r--libgammu/phone/at/atgen.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/libgammu/phone/at/atgen.c b/libgammu/phone/at/atgen.c
index c1b65ca..067f5d4 100644
--- a/libgammu/phone/at/atgen.c
+++ b/libgammu/phone/at/atgen.c
@@ -437,7 +437,7 @@ GSM_Error ATGEN_WaitFor(GSM_StateMachine *s, const char * cmd, size_t len,
*
* \return True when text does not contain non hex chars.
*/
-INLINE gboolean ATGEN_HasOnlyHexChars(const char *text, const size_t length)
+gboolean ATGEN_HasOnlyHexChars(const char *text, const size_t length)
{
size_t i = 0;
@@ -456,7 +456,7 @@ INLINE gboolean ATGEN_HasOnlyHexChars(const char *text, const size_t length)
*
* \return True when text does not contain non digits chars.
*/
-INLINE gboolean ATGEN_HasOnlyDigits(const char *text, const size_t length)
+gboolean ATGEN_HasOnlyDigits(const char *text, const size_t length)
{
size_t i = 0;
@@ -476,7 +476,7 @@ INLINE gboolean ATGEN_HasOnlyDigits(const char *text, const size_t length)
* \param text Text.
* \return True when text can be UCS2.
*/
-INLINE gboolean ATGEN_IsUCS2(const char *text, const size_t length)
+gboolean ATGEN_IsUCS2(const char *text, const size_t length)
{
return (length > 3) &&
(length % 4 == 0) &&
@@ -491,7 +491,7 @@ INLINE gboolean ATGEN_IsUCS2(const char *text, const size_t length)
* \param text Text.
* \return True when text can be HEX.
*/
-INLINE gboolean ATGEN_IsHex(const char *text, const size_t length)
+gboolean ATGEN_IsHex(const char *text, const size_t length)
{
return (length > 4) &&
(length % 2 == 0) &&
@@ -506,7 +506,7 @@ INLINE gboolean ATGEN_IsHex(const char *text, const size_t length)
* \param text Text.
* \return True when text can be HEX.
*/
-INLINE gboolean ATGEN_IsNumber(const char *text, const size_t length)
+gboolean ATGEN_IsNumber(const char *text, const size_t length)
{
return ATGEN_HasOnlyDigits(text, length);
}
@@ -759,7 +759,10 @@ GSM_Error ATGEN_DecodeText(GSM_StateMachine *s,
return ERR_MOREMEMORY;
}
DecodeHexBin(buffer, input, length);
- if (2 * strlen(buffer) >= outlength) return ERR_MOREMEMORY;
+ if (2 * strlen(buffer) >= outlength) {
+ free(buffer);
+ return ERR_MOREMEMORY;
+ }
DecodeDefault(output, buffer, strlen(buffer), TRUE, NULL);
free(buffer);
buffer = NULL;
@@ -1613,6 +1616,7 @@ GSM_Error ATGEN_SQWEReply(GSM_Protocol_Message *msg UNUSED, GSM_StateMachine *s)
GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s)
{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_USSDMessage ussd;
GSM_Error error;
unsigned char *pos = NULL;
@@ -1719,13 +1723,16 @@ GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s)
coding = GSM_GetMessageCoding(&(s->di), dcs);
}
- smprintf(s, "coding %d -> %d\n", dcs, coding);
+ smprintf(s, "USSD coding DCS = %d -> Coding = %d\n", dcs, coding);
if (coding == SMS_Coding_Default_No_Compression) {
- DecodeHexBin(packed, hex_encoded, strlen(hex_encoded));
- GSM_UnpackEightBitsToSeven(0, strlen(hex_encoded), sizeof(decoded), packed, decoded);
- DecodeDefault(ussd.Text, decoded, strlen(decoded), TRUE, NULL);
-
+ if (Priv->Charset == AT_CHARSET_HEX || GSM_IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_ENCODED_USSD)) {
+ DecodeHexBin(packed, hex_encoded, strlen(hex_encoded));
+ GSM_UnpackEightBitsToSeven(0, strlen(hex_encoded), sizeof(decoded), packed, decoded);
+ DecodeDefault(ussd.Text, decoded, strlen(decoded), TRUE, NULL);
+ } else {
+ DecodeDefault(ussd.Text, hex_encoded, strlen(hex_encoded), TRUE, NULL);
+ }
} else if (coding == SMS_Coding_Unicode_No_Compression) {
DecodeHexUnicode(ussd.Text, hex_encoded + offset, strlen(hex_encoded));
} else if (coding == SMS_Coding_8bit) {
@@ -4766,7 +4773,7 @@ GSM_Error ATGEN_ReplyGetDivert(GSM_Protocol_Message *msg, GSM_StateMachine *s)
if (error != ERR_NONE) {
error = ATGEN_ParseReply(s, str,
- "+CCFC: @i, @i, @p, @I, @s, @i, @i",
+ "+CCFC: @i, @i, @p, @I, @s, @I, @I",
&status,
&class,
response->Entries[response->EntriesNum].Number,
@@ -6146,7 +6153,6 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
{ATGEN_GenericReply, "AT+CLIP" ,0x00,0x00,ID_SetIncomingCall },
{ATGEN_GenericReply, "AT+CCWA" ,0x00,0x00,ID_SetIncomingCall },
{ATGEN_GenericReply, "AT+CUSD" ,0x00,0x00,ID_SetUSSD },
-{ATGEN_ReplyGetUSSD, "AT+CUSD" ,0x00,0x00,ID_GetUSSD },
{ATGEN_ReplyGetUSSD, "+CUSD" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_ReplyIncomingCallInfo, "+CLIP" ,0x00,0x00,ID_IncomingFrame },
@@ -6205,6 +6211,7 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
{ATGEN_GenericReplyIgnore, "^HCSQ:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReplyIgnore, "^SRVST:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReplyIgnore, "^SIMST:" ,0x00,0x00,ID_IncomingFrame },
+{ATGEN_GenericReplyIgnore, "^STIN:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReplyIgnore, "+ZUSIMR:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReplyIgnore, "+ZEND" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReplyIgnore, "+CDSI:" ,0x00,0x00,ID_IncomingFrame },