[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS: gnokii/common gsm-encoding.c,1.14,1.15 gsm-sms.c,1.46,1.47
From: |
BORBELY Zoltan <address@hidden> |
Subject: |
CVS: gnokii/common gsm-encoding.c,1.14,1.15 gsm-sms.c,1.46,1.47 |
Date: |
Tue, 02 Apr 2002 20:02:08 -0500 |
Update of /cvsroot/gnokii/gnokii/common
In directory subversions:/tmp/cvs-serv4529/common
Modified Files:
gsm-encoding.c gsm-sms.c
Log Message:
SemiOctetPack and GetBCDNumber moved from gsm-sms.c to gsm-encoding.c These
functions are more general (e.g. we are using it in call divert and sms
center functions)
Index: gsm-encoding.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-encoding.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** gsm-encoding.c 29 Mar 2002 20:51:21 -0000 1.14
--- gsm-encoding.c 3 Apr 2002 01:02:06 -0000 1.15
***************
*** 34,37 ****
--- 34,39 ----
#include "misc.h"
+ #include "gsm-common.h"
+ #include "gsm-encoding.h"
#define NUMBER_OF_7_BIT_ALPHABET_ELEMENTS 128
***************
*** 320,322 ****
--- 322,396 ----
else dest[2 * i + 1] += ('A' - 10);
}
+ }
+
+ /* This function implements packing of numbers (SMS Center number and
+ destination number) for SMS sending function. */
+ int SemiOctetPack(char *Number, unsigned char *Output, SMS_NumberType type)
+ {
+ unsigned char *IN_NUM = Number; /* Pointer to the input number */
+ unsigned char *OUT_NUM = Output; /* Pointer to the output */
+ int count = 0; /* This variable is used to notify us about count of
already
+ packed numbers. */
+
+ /* The first byte in the Semi-octet representation of the address field
is
+ the Type-of-Address. This field is described in the official GSM
+ specification 03.40 version 6.1.0, section 9.1.2.5, page 33. We
support
+ only international and unknown number. */
+
+ *OUT_NUM++ = type;
+ if (type == SMS_International) IN_NUM++; /* Skip '+' */
+ if ((type == SMS_Unknown) && (*IN_NUM == '+')) IN_NUM++; /* Optional
'+' in Unknown number type */
+
+ /* The next field is the number. It is in semi-octet representation -
see
+ GSM scpecification 03.40 version 6.1.0, section 9.1.2.3, page 31. */
+ while (*IN_NUM) {
+ if (count & 0x01) {
+ *OUT_NUM = *OUT_NUM | ((*IN_NUM - '0') << 4);
+ OUT_NUM++;
+ }
+ else
+ *OUT_NUM = *IN_NUM - '0';
+ count++; IN_NUM++;
+ }
+
+ /* We should also fill in the most significant bits of the last byte
with
+ 0x0f (1111 binary) if the number is represented with odd number of
+ digits. */
+ if (count & 0x01) {
+ *OUT_NUM = *OUT_NUM | 0xf0;
+ OUT_NUM++;
+ }
+
+ return (2 * (OUT_NUM - Output - 1) - (count % 2));
+ }
+
+ char *GetBCDNumber(u8 *Number)
+ {
+ static char Buffer[20] = "";
+ int length = Number[0]; /* This is the length of BCD coded number */
+ int count, Digit;
+
+ memset(Buffer, 0, 20);
+ switch (Number[1]) {
+ case SMS_Alphanumeric:
+ Unpack7BitCharacters(0, length, length, Number+2, Buffer);
+ Buffer[length] = 0;
+ break;
+ case SMS_International:
+ sprintf(Buffer, "+");
+ case SMS_Unknown:
+ case SMS_National:
+ case SMS_Network:
+ case SMS_Subscriber:
+ case SMS_Abbreviated:
+ default:
+ for (count = 0; count < length - 1; count++) {
+ Digit = Number[count+2] & 0x0f;
+ if (Digit < 10) sprintf(Buffer, "%s%d", Buffer, Digit);
+ Digit = Number[count+2] >> 4;
+ if (Digit < 10) sprintf(Buffer, "%s%d", Buffer, Digit);
+ }
+ break;
+ }
+ return Buffer;
}
Index: gsm-sms.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-sms.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** gsm-sms.c 2 Apr 2002 14:16:15 -0000 1.46
--- gsm-sms.c 3 Apr 2002 01:02:06 -0000 1.47
***************
*** 78,153 ****
***/
- /* This function implements packing of numbers (SMS Center number and
- destination number) for SMS sending function. */
- int SemiOctetPack(char *Number, unsigned char *Output, SMS_NumberType type)
- {
- unsigned char *IN_NUM = Number; /* Pointer to the input number */
- unsigned char *OUT_NUM = Output; /* Pointer to the output */
- int count = 0; /* This variable is used to notify us about count of
already
- packed numbers. */
-
- /* The first byte in the Semi-octet representation of the address field
is
- the Type-of-Address. This field is described in the official GSM
- specification 03.40 version 6.1.0, section 9.1.2.5, page 33. We
support
- only international and unknown number. */
-
- *OUT_NUM++ = type;
- if (type == SMS_International) IN_NUM++; /* Skip '+' */
- if ((type == SMS_Unknown) && (*IN_NUM == '+')) IN_NUM++; /* Optional
'+' in Unknown number type */
-
- /* The next field is the number. It is in semi-octet representation -
see
- GSM scpecification 03.40 version 6.1.0, section 9.1.2.3, page 31. */
- while (*IN_NUM) {
- if (count & 0x01) {
- *OUT_NUM = *OUT_NUM | ((*IN_NUM - '0') << 4);
- OUT_NUM++;
- }
- else
- *OUT_NUM = *IN_NUM - '0';
- count++; IN_NUM++;
- }
-
- /* We should also fill in the most significant bits of the last byte
with
- 0x0f (1111 binary) if the number is represented with odd number of
- digits. */
- if (count & 0x01) {
- *OUT_NUM = *OUT_NUM | 0xf0;
- OUT_NUM++;
- }
-
- return (2 * (OUT_NUM - Output - 1) - (count % 2));
- }
-
- char *GetBCDNumber(u8 *Number)
- {
- static char Buffer[20] = "";
- int length = Number[0]; /* This is the length of BCD coded number */
- int count, Digit;
-
- memset(Buffer, 0, 20);
- switch (Number[1]) {
- case SMS_Alphanumeric:
- Unpack7BitCharacters(0, length, length, Number+2, Buffer);
- Buffer[length] = 0;
- break;
- case SMS_International:
- sprintf(Buffer, "+");
- case SMS_Unknown:
- case SMS_National:
- case SMS_Network:
- case SMS_Subscriber:
- case SMS_Abbreviated:
- default:
- for (count = 0; count < length - 1; count++) {
- Digit = Number[count+2] & 0x0f;
- if (Digit < 10) sprintf(Buffer, "%s%d", Buffer, Digit);
- Digit = Number[count+2] >> 4;
- if (Digit < 10) sprintf(Buffer, "%s%d", Buffer, Digit);
- }
- break;
- }
- return Buffer;
- }
-
#ifdef DEBUG
static char *PrintDateTime(u8 *Number)
--- 78,81 ----
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- CVS: gnokii/common gsm-encoding.c,1.14,1.15 gsm-sms.c,1.46,1.47,
BORBELY Zoltan <address@hidden> <=
- Prev by Date:
CVS: gnokii/common/phones nk6100.c,1.55,1.56
- Next by Date:
CVS: gnokii/include gsm-sms.h,1.28,1.29 gsm-encoding.h,1.6,1.7
- Previous by thread:
CVS: gnokii/common/phones nk6100.c,1.55,1.56
- Next by thread:
CVS: gnokii/include gsm-sms.h,1.28,1.29 gsm-encoding.h,1.6,1.7
- Index(es):