[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Make fake be able to send sms
From: |
Pavel Machek |
Subject: |
Make fake be able to send sms |
Date: |
Sun, 19 May 2002 18:24:32 +0200 |
User-agent: |
Mutt/1.3.28i |
Hi!
This is dirty hack to make fake.c send something.
My plan to fix CVS:
Reintroduce SMSMessage_Layout, but mark it deprecated. Kill Layout
from gsm-sms.c, and move it to sms-layout.c and mark deprecated.
Pavel
Index: common/gsm-api.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-api.c,v
retrieving revision 1.44
diff -u -u -r1.44 gsm-api.c
--- common/gsm-api.c 30 Apr 2002 18:56:12 -0000 1.44
+++ common/gsm-api.c 19 May 2002 16:12:17 -0000
@@ -128,6 +128,8 @@
strncpy(sm->Link.PortDevice, device, sizeof(sm->Link.PortDevice) - 1);
REGISTER_PHONE(nokia_7110, NULL);
+ REGISTER_PHONE(fake, NULL);
+#if 0
REGISTER_PHONE(nokia_6510, NULL);
REGISTER_PHONE(nokia_6100, NULL);
REGISTER_PHONE(nokia_3110, NULL);
@@ -135,8 +137,7 @@
REGISTER_PHONE(nokia_2110, NULL);
REGISTER_PHONE(dancall_2711, NULL);
#endif
- REGISTER_PHONE(fake, NULL);
REGISTER_PHONE(at, model);
-
+#endif
return (GE_UNKNOWNMODEL);
}
Index: common/gsm-sms.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-sms.c,v
retrieving revision 1.59
diff -u -u -r1.59 gsm-sms.c
--- common/gsm-sms.c 17 May 2002 00:22:09 -0000 1.59
+++ common/gsm-sms.c 19 May 2002 16:12:37 -0000
@@ -23,11 +23,14 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Copyright (C) 2001-2002 Paweł Kot <address@hidden>
+ Copyright (C) 2001-2002 Pavel Machek <address@hidden>
Library for parsing and creating Short Messages (SMS).
*/
+#define DEBUG
+
#include <stdlib.h>
#include <string.h>
@@ -958,13 +961,480 @@
return GE_NONE;
}
-/* Fake functions. To let gnokii compile */
-API GSM_Error SendSMS(GSM_Data *data, GSM_Statemachine *state)
+/***
+ *** ENCODING SMS (fixme: should this go to separate file?)
+ ***/
+
+/* These 4 functions are mainly for the AT mode, where MessageCenter and
+ * RemoteNumber have variable length */
+
+/* Returns a new offset of the field */
+static int change_offset(int base, int orig, int offset)
+{
+ if (orig <= base) return orig;
+ else return (orig + offset);
+}
+
+static void change_offsets2(SMSMessage_Layout *layout, int pos, int offset)
+{
+ if (pos < 0) return;
+ layout->MessageCenter = change_offset(pos, layout->MessageCenter,
offset);
+ layout->MoreMessages = change_offset(pos, layout->MoreMessages, offset);
+ layout->ReplyViaSameSMSC = change_offset(pos, layout->ReplyViaSameSMSC,
offset);
+ layout->RejectDuplicates = change_offset(pos, layout->RejectDuplicates,
offset);
+ layout->Report = change_offset(pos, layout->Report, offset);
+ layout->Number = change_offset(pos, layout->Number, offset);
+ layout->Reference = change_offset(pos, layout->Reference, offset);
+ layout->PID = change_offset(pos, layout->PID, offset);
+ layout->ReportStatus = change_offset(pos, layout->ReportStatus, offset);
+ layout->Length = change_offset(pos, layout->Length, offset);
+ layout->DataCodingScheme = change_offset(pos, layout->DataCodingScheme,
offset);
+ layout->Validity = change_offset(pos, layout->Validity, offset);
+ layout->UserDataHeader = change_offset(pos, layout->UserDataHeader,
offset);
+ layout->RemoteNumber = change_offset(pos, layout->RemoteNumber ,
offset);
+ layout->SMSCTime = change_offset(pos, layout->SMSCTime, offset);
+ layout->Time = change_offset(pos, layout->Time, offset);
+ layout->MemoryType = change_offset(pos, layout->MemoryType, offset);
+ layout->Status = change_offset(pos, layout->Status, offset);
+ layout->UserData = change_offset(pos, layout->UserData, offset);
+}
+
+/* Use this one when you have decoded message (in struct SMS) */
+static void change_offsets_struct(SMSMessage_Layout *layout, SMS_Number mc,
SMS_Number rn)
+{
+ unsigned char aux[16];
+ unsigned int mc_len, rn_len;
+
+ mc_len = SemiOctetPack(mc.Number, aux, mc.Type);
+ rn_len = SemiOctetPack(rn.Number, aux, rn.Type);
+ if (mc_len) {
+ if (mc_len % 2) mc_len++;
+ mc_len /= 2;
+ mc_len++;
+ }
+ if (rn_len) {
+ if (rn_len % 2) rn_len++;
+ rn_len /= 2;
+ rn_len++;
+ }
+ if (layout->MessageCenter < layout->RemoteNumber) {
+ if (!layout->HasMessageCenterFixedLen && layout->MessageCenter
> -1)
+ change_offsets2(layout, layout->MessageCenter, mc_len);
+ if (!layout->HasRemoteNumberFixedLen && layout->RemoteNumber >
-1)
+ change_offsets2(layout, layout->RemoteNumber, rn_len);
+ } else {
+ if (!layout->HasRemoteNumberFixedLen && layout->RemoteNumber >
-1)
+ change_offsets2(layout, layout->RemoteNumber, rn_len);
+ if (!layout->HasMessageCenterFixedLen && layout->MessageCenter
> -1)
+ change_offsets2(layout, layout->MessageCenter, mc_len);
+ }
+}
+
+/***
+ *** ENCODING SMS
+ ***/
+
+/**
+ * EncodeData - encodes the date from the SMS structure to the phone frame
+ *
+ * @SMS: SMS structure to be encoded
+ * @dcs: Data Coding Scheme field in the frame to be set
+ * @message: phone frame to be filled in
+ * @multipart: do we send one message or more?
+ * @clen: coded data length
+ *
+ * This function does the phone frame encoding basing on the given SMS
+ * structure. This function is capable to create only one frame at a time.
+ */
+static GSM_Error EncodeData(GSM_API_SMS *SMS, GSM_SMSMessage *OutSMS, char
*dcs, char *message, bool multipart, int *clen)
{
+ SMS_AlphabetType al;
+ unsigned int i, length, size = 0, offset = 0;
+ int text_index = -1, bitmap_index = -1, ringtone_index = -1;
+
+ /* Version: Smart Messaging Specification 3.0.0 */
+ message[0] = 0x30;
+ for (i = 0; i < 3; i++) {
+ switch (SMS->UserData[i].Type) {
+ case SMS_PlainText:
+ text_index = i; break;
+ case SMS_BitmapData:
+ bitmap_index = i; break;
+ case SMS_RingtoneData:
+ ringtone_index = i; break;
+ default:
+ break;
+ }
+ }
+
+ length = strlen(SMS->UserData[0].u.Text);
+
+ /* Additional Headers */
+ switch (SMS->DCS.Type) {
+ case SMS_GeneralDataCoding:
+ switch (SMS->DCS.u.General.Class) {
+ case 1: dcs[0] |= 0xf0; break; /* Class 0 */
+ case 2: dcs[0] |= 0xf1; break; /* Class 1 */
+ case 3: dcs[0] |= 0xf2; break; /* Class 2 */
+ case 4: dcs[0] |= 0xf3; break; /* Class 3 */
+ default: break;
+ }
+ if (SMS->DCS.u.General.Compressed) {
+ /* Compression not supported yet */
+ /* dcs[0] |= 0x20; */
+ }
+ al = SMS->DCS.u.General.Alphabet;
+ break;
+ case SMS_MessageWaiting:
+ al = SMS->DCS.u.MessageWaiting.Alphabet;
+ if (SMS->DCS.u.MessageWaiting.Discard) dcs[0] |= 0xc0;
+ else if (SMS->DCS.u.MessageWaiting.Alphabet == SMS_UCS2) dcs[0]
|= 0xe0;
+ else dcs[0] |= 0xd0;
+
+ if (SMS->DCS.u.MessageWaiting.Active) dcs[0] |= 0x08;
+ dcs[0] |= (SMS->DCS.u.MessageWaiting.Type & 0x03);
+
+ break;
+ default:
+ return GE_SMSWRONGFORMAT;
+ }
+
+ if ((al == SMS_8bit) && multipart) al = SMS_DefaultAlphabet;
+ OutSMS->Length = *clen = 0;
+
+ /* Text Coding */
+ if (text_index != -1) {
+ switch (al) {
+ case SMS_DefaultAlphabet:
+ if (multipart) {
+ offset = 4;
+ memcpy(message + 1, "\x00\x00\x00", 3);
+ dcs[0] |= 0xf4;
+ }
+#define UDH_Length 0
+ size = Pack7BitCharacters((7 - (UDH_Length % 7)) % 7,
SMS->UserData[text_index].u.Text, message + offset);
+ // SMS->Length = 8 * 0 + (7 - (0 % 7)) % 7 + length +
offset;
+ OutSMS->Length =
strlen(SMS->UserData[text_index].u.Text);
+ *clen = size + offset;
+ if (multipart) {
+ message[2] = (size & 0xff00) >> 8;
+ message[3] = (size & 0x00ff);
+ }
+ break;
+ case SMS_8bit:
+ dcs[0] |= 0xf4;
+ memcpy(message, SMS->UserData[text_index].u.Text + 1,
SMS->UserData[text_index].u.Text[0]);
+ *clen = OutSMS->Length =
SMS->UserData[text_index].u.Text[0];
+ break;
+ case SMS_UCS2:
+ if (multipart) {
+ offset = 4;
+ memcpy(message + 1, "\x02\x00\x00", 3);
+ }
+ dcs[0] |= 0x08;
+ EncodeUnicode(message + offset,
SMS->UserData[text_index].u.Text, length);
+ length *= 2;
+ *clen = OutSMS->Length = length + offset;
+ if (multipart) {
+ message[2] = (length & 0xff00) >> 8;
+ message[3] = (length & 0x00ff);
+ }
+ break;
+ default:
+ return GE_SMSWRONGFORMAT;
+ }
+ }
+
+ /* Bitmap coding */
+ if (bitmap_index != -1) {
+#ifdef BITMAP_SUPPORT
+ size =
GSM_EncodeSMSBitmap(&(SMS->UserData[bitmap_index].u.Bitmap), message +
OutSMS->Length);
+ OutSMS->Length += size;
+ *clen += size;
+#else
+ return GE_NOTSUPPORTED;
+#endif
+ }
+
+ /* Ringtone coding */
+ if (ringtone_index != -1) {
+#ifdef RINGTONE_SUPPORT
+ size = GSM_EncodeSMSRingtone(message + OutSMS->Length,
&SMS->UserData[ringtone_index].u.Ringtone);
+ OutSMS->Length += size;
+ *clen += size;
+#else
+ return GE_NOTSUPPORTED;
+#endif
+ }
return GE_NONE;
}
-API GSM_Error SaveSMS(GSM_Data *data, GSM_Statemachine *state)
+/**
+ * EncodeUDH - encodes User Data Header
+ * @UDHi: User Data Header information
+ * @SMS: SMS structure with the data source
+ * @UDH: phone frame where to save User Data Header
+ *
+ * This function encodes the UserDataHeader as described in:
+ * o GSM 03.40 version 6.1.0 Release 1997, section 9.2.3.24
+ * o Smart Messaging Specification, Revision 1.0.0, September 15, 1997
+ * o Smart Messaging Specification, Revision 3.0.0
+ */
+static GSM_Error EncodeUDH(SMS_UDHInfo UDHi, GSM_SMSMessage *SMS, char *UDH)
{
+ unsigned char pos;
+
+ pos = UDH[0];
+ switch (UDHi.Type) {
+ case SMS_NoUDH:
+ break;
+ case SMS_VoiceMessage:
+ case SMS_FaxMessage:
+ case SMS_EmailMessage:
+ UDH[pos+4] = UDHi.u.SpecialSMSMessageIndication.MessageCount;
+ if (UDHi.u.SpecialSMSMessageIndication.Store) UDH[pos+3] |=
0x80;
+ case SMS_ConcatenatedMessages:
+ printf("Adding ConcatMsg header\n");
+ case SMS_OpLogo:
+ printf("Adding OpLogo header\n");
+ case SMS_CallerIDLogo:
+ case SMS_Ringtone:
+ case SMS_MultipartMessage:
+ UDH[0] += headers[UDHi.Type].length;
+ memcpy(UDH+pos+1, headers[UDHi.Type].header,
headers[UDHi.Type].length);
+ break;
+ default:
+ dprintf("Not supported User Data Header type\n");
+ break;
+ }
return GE_NONE;
+}
+
+/**
+ * EncodeSMSSubmitHeader - prepares a phone frame with a SMS header
+ * @SMS - SMS structure with a data source
+ * @frame - a phone frame to fill in
+ *
+ * We prepare here a part of the frame with a submit header (phone originated)
+ */
+static GSM_Error EncodeSMSSubmitHeader(SMSMessage_Layout *layout, GSM_API_SMS
*sms, GSM_SMSMessage *rawsms, char *frame)
+{
+ GSM_Error error = GE_NONE;
+
+ /* Standard Header: */
+ memcpy(frame + layout->UserDataHeader,
"\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa9\x00\x00\x00\x00\x00\x00",
24);
+
+ /* Reply Path */
+ if (layout->ReplyViaSameSMSC > -1) {
+ if (rawsms->ReplyViaSameSMSC) frame[layout->ReplyViaSameSMSC]
|= 0x80;
+ }
+
+#if 0
+ /* User Data Header Indicator */
+ if (layout->UserDataHeader > -1) {
+ if (rawsms->UDH_No) frame[layout->UserDataHeader] |= 0x40;
+ }
+#endif
+
+ /* Status (Delivery) Report Request */
+ if (layout->Report > -1) {
+ if (rawsms->Report) frame[layout->Report] |= 0x20;
+ }
+
+#if 0
+ /* Validity Period Format: mask - 0x00, 0x10, 0x08, 0x18 */
+ if (layout->Validity > -1) {
+ frame[layout->Validity] |= ((SMS->Validity.VPF & 0x03) << 3);
+ }
+#endif
+
+ /* Reject Duplicates */
+ if (layout->RejectDuplicates > -1) {
+ if (rawsms->RejectDuplicates) frame[layout->RejectDuplicates]
|= 0x04;
+ }
+
+ /* Protocol Identifier */
+ /* FIXME: allow to change this in better way.
+ currently only 0x5f == `Return Call Message' is used */
+ if (layout->PID > -1) {
+ if (rawsms->PID) frame[layout->PID] = rawsms->PID;
+ }
+
+#if 0
+ /* Data Coding Scheme */
+ if (layout->DataCodingScheme > -1) {
+ switch (SMS->DCS.Type) {
+ case SMS_GeneralDataCoding:
+ if (SMS->DCS.u.General.Compressed)
frame[layout->DataCodingScheme] |= 0x20;
+ if (SMS->DCS.u.General.Class)
frame[layout->DataCodingScheme] |= (0x10 | (SMS->DCS.u.General.Class - 1));
+ frame[layout->DataCodingScheme] |=
((SMS->DCS.u.General.Alphabet & 0x03) << 2);
+ break;
+ case SMS_MessageWaiting:
+ if (SMS->DCS.u.MessageWaiting.Discard)
frame[layout->DataCodingScheme] |= 0xc0;
+ else if (SMS->DCS.u.MessageWaiting.Alphabet ==
SMS_UCS2) frame[layout->DataCodingScheme] |= 0xe0;
+ else frame[layout->DataCodingScheme] |= 0xd0;
+ if (SMS->DCS.u.MessageWaiting.Active)
frame[layout->DataCodingScheme] |= 0x80;
+ frame[layout->DataCodingScheme] |=
(SMS->DCS.u.MessageWaiting.Type & 0x03);
+ break;
+ default:
+ dprintf("Wrong Data Coding Scheme (DCS) format\n");
+ return GE_SMSWRONGFORMAT;
+ }
+ }
+#endif
+
+ /* Destination Address */
+ if (layout->RemoteNumber > -1) {
+ frame[layout->RemoteNumber] = SemiOctetPack(sms->Remote.Number,
frame + layout->RemoteNumber + 1, sms->Remote.Type);
+ }
+
+#if 0
+ /* Validity Period */
+ if (layout->Validity > -1) {
+ switch (SMS->Validity.VPF) {
+ case SMS_EnhancedFormat:
+ return GE_NOTSUPPORTED;
+ case SMS_RelativeFormat:
+ frame[layout->Validity] = SMS->Validity.u.Relative;
+ break;
+ case SMS_AbsoluteFormat:
+ break;
+ default:
+ return GE_SMSWRONGFORMAT;
+ }
+ }
+#endif
+ return error;
+}
+
+/**
+ * EncodeSMSDeliverHeader - prepares a phone frame with a SMS header
+ * @SMS - SMS structure with a data source
+ * @frame - a phone frame to fill in
+ *
+ * We prepare here a part of the frame with a deliver header (phone terminated)
+ */
+static GSM_Error EncodeSMSDeliverHeader()
+{
+ return GE_NONE;
+}
+
+
+/**
+ * EncodePDUSMS - prepares a phone frame with a given SMS
+ * @SMS:
+ * @message:
+ * @num:
+ * @length:
+ *
+ * This function encodes SMS as described in:
+ * o GSM 03.40 version 6.1.0 Release 1997, section 9
+ */
+static GSM_Error EncodePDUSMS(SMSMessage_Layout *layout, GSM_API_SMS *SMS,
GSM_SMSMessage *OutSMS, char *message, unsigned int num, int *length)
+{
+ GSM_Error error = GE_NONE;
+ int i, clen, mm = 0;
+
+ *length = 0;
+ switch (OutSMS->Type = SMS->Type) {
+ case SMS_Submit:
+ case SMS_Deliver:
+ break;
+ case SMS_Picture:
+ case SMS_Delivery_Report:
+ default:
+ dprintf("Not supported message type: %d\n", OutSMS->Type);
+ return GE_NOTSUPPORTED;
+ }
+
+ change_offsets_struct(layout, SMS->SMSC, SMS->Remote);
+
+ /* OutSMSC number (not needed for AT phones) */
+ if (layout->MessageCenter > -1) {
+ message[layout->MessageCenter] =
SemiOctetPack(SMS->SMSC.Number, message + layout->MessageCenter + 1,
SMS->SMSC.Type);
+ if (message[layout->MessageCenter]) {
+ if (message[layout->MessageCenter] % 2)
message[layout->MessageCenter]++;
+ message[layout->MessageCenter] =
message[layout->MessageCenter] / 2 + 1;
+ }
+ }
+
+ /* Common Header */
+ error = EncodeSMSSubmitHeader(layout, SMS, OutSMS, message);
+ if (error != GE_NONE) return error;
+
+#if 0
+ /* User Data Header - if present */
+ for (i = 0; i < OutSMS->UDH_No; i++) {
+ printf("Adding user data headers...\n");
+ error = EncodeUDH(OutSMS->UDH[i], OutSMS, message +
layout->UserData);
+ if (OutSMS->UDH[i].Type == OutSMS_MultipartMessage) mm = 1;
+ if (error != GE_NONE) return error;
+ }
+ 0 = ((OutSMS->UDH_No > 0) ? message[layout->UserData]+1 : 0);
+#endif
+ /* User Data */
+ EncodeData(SMS, OutSMS, message + layout->DataCodingScheme, message +
layout->UserData + 0, mm, &clen);
+ message[layout->Length] = OutSMS->Length + 0;
+ *length = clen + layout->UserData + 0;
+ return GE_NONE;
+}
+
+static SMSMessage_Layout at_submit = {
+ true, /* Is the SMS type
supported */
+ -1, true, false, /* SMSC */
+ -1, 1, 1, 1, -1, 2, 4, -1, 7, 5, 1,
+ 6, -1, -1, /* Validity */
+ 3, true, false, /* Remote Number */
+ -1, -1, /* Time */
+ -1, -1, /* Nonstandard fields */
+ 8, true /* User Data */
+};
+
+/**
+ * SendSMS - The main function for the SMS sending
+ * @data:
+ * @state:
+ */
+API GSM_Error SendSMS(GSM_Data *data, GSM_Statemachine *state)
+{
+ GSM_Error error = GE_NONE;
+ GSM_RawData rawdata;
+ int i, count;
+ SMSMessage_Layout *layout = &at_submit;
+
+ dprintf("Sending SMS...\n");
+ count = 1;
+#if 0
+ /* AT does not need smsc */
+ if (data->SMS->MessageCenter.No) {
+ data->MessageCenter = &data->SMS->MessageCenter;
+ error = SM_Functions(GOP_GetSMSCenter, data, state);
+ if (error != GE_NONE) return error;
+ }
+#endif
+
+ dprintf("COUNT: %d\n", count);
+ if (count < 1) return GE_SMSWRONGFORMAT;
+
+ dprintf("Strlen: %d\n", strlen(data->SMS->UserData[0].u.Text));
+ memset(&rawdata, 0, sizeof(rawdata));
+ data->RawData = &rawdata;
+ for (i = 0; i < count; i++) {
+ data->RawData->Data = calloc(256, 1);
+ data->RawSMS = malloc(sizeof(*data->RawSMS));
+ memset(data->RawSMS, 0, sizeof(*data->RawSMS));
+ error = EncodePDUSMS(layout, data->SMS, data->RawSMS,
data->RawData->Data, i, &data->RawData->Length);
+
+ if (error == GE_NONE) error = SM_Functions(GOP_SendSMS, data,
state);
+ dprintf("%d\n", data->RawSMS->Length);
+ free(data->RawData->Data);
+ if (error != GE_NONE) break;
+ }
+ data->RawData = NULL;
+ return error;
+}
+
+API GSM_Error SaveSMS(GSM_Data *data, GSM_Statemachine *state)
+{
+ return GE_NOTSUPPORTED;
}
Index: common/links/atbus.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/links/atbus.c,v
retrieving revision 1.17
diff -u -u -r1.17 atbus.c
--- common/links/atbus.c 29 Apr 2002 15:35:02 -0000 1.17
+++ common/links/atbus.c 19 May 2002 16:12:41 -0000
@@ -26,6 +26,8 @@
*/
+#define DEBUG
+
/* System header files */
#include <stdio.h>
#include <string.h>
Index: common/phones/Makefile
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/phones/Makefile,v
retrieving revision 1.12
diff -u -u -r1.12 Makefile
--- common/phones/Makefile 17 Apr 2002 21:29:24 -0000 1.12
+++ common/phones/Makefile 19 May 2002 16:12:42 -0000
@@ -20,16 +20,12 @@
OBJS = generic.o \
nokia.o \
nk7110.o \
- nk6510.o \
- nk6100.o \
- nk3110.o \
- nk2110.o \
- atgen.o \
- ateric.o \
- atnok.o \
- atsie.o \
- dc2711.o \
fake.o
+
+# nk6510.o \
+# nk6100.o \
+# nk3110.o \
+# nk2110.o \
all: PHONES.o
Index: common/phones/atgen.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/phones/atgen.c,v
retrieving revision 1.36
diff -u -u -r1.36 atgen.c
--- common/phones/atgen.c 16 May 2002 11:27:14 -0000 1.36
+++ common/phones/atgen.c 19 May 2002 16:12:54 -0000
@@ -145,32 +145,6 @@
Functions
};
-static const SMSMessage_Layout at_deliver = {
- true, /* Is the SMS type
supported */
- 1, true, false, /* SMSC */
- 2, 2, -1, 2, -1, -1, 4, -1, 13, 5, 2,
- -1, -1, -1, /* Validity */
- 3, true, false, /* Remote Number */
- 6, -1, /* Time */
- -1, -1, /* Nonstandard fields */
- 14, true /* User Data */
-};
-
-static const SMSMessage_Layout at_submit = {
- true, /* Is the SMS type
supported */
- -1, true, false, /* SMSC */
- -1, 1, 1, 1, -1, 2, 4, -1, 7, 5, 1,
- 6, -1, -1, /* Validity */
- 3, true, false, /* Remote Number */
- -1, -1, /* Time */
- -1, -1, /* Nonstandard fields */
- 8, true /* User Data */
-};
-
-static const SMSMessage_Layout at_not_supported = { false };
-
-static SMSMessage_PhoneLayout at_layout;
-
static GSM_MemoryType memorytype = GMT_XX;
static GSMAT_Charset atdefaultcharset = CHARNONE;
static GSMAT_Charset atcharset = CHARNONE;
@@ -652,7 +626,7 @@
static GSM_Error AT_GetSMS(GSM_Data *data, GSM_Statemachine *state)
{
unsigned char req[16];
- sprintf(req, "AT+CMGR=%d\r", data->SMSMessage->Number);
+ sprintf(req, "AT+CMGR=%d\r", data->RawSMS->Number);
dprintf("%s", req);
if (SM_SendMessage(state, strlen(req), GOP_GetSMS, req) != GE_NONE)
return GE_NOTREADY;
@@ -971,9 +945,9 @@
/* SendSMS or SaveSMS */
if (!strncmp("+CMGW:", buf.line2, 6) ||
!strncmp("+CMGS:", buf.line2, 6))
- data->SMSMessage->Number = atoi(buf.line2 + 6);
+ data->RawSMS->Number = atoi(buf.line2 + 6);
else
- data->SMSMessage->Number = -1;
+ data->RawSMS->Number = -1;
dprintf("Message sent okay\n");
return GE_NONE;
}
@@ -1107,16 +1081,6 @@
/* Copy in the phone info */
memcpy(&(state->Phone), &phone_at, sizeof(GSM_Phone));
-
- /* SMS Layout */
- at_layout.Type = 0; /* Locate the Type of the mesage field. */
- at_layout.SendHeader = 0;
- at_layout.ReadHeader = 0;
- at_layout.Deliver = at_deliver;
- at_layout.Submit = at_submit;
- at_layout.DeliveryReport = at_not_supported;
- at_layout.Picture = at_not_supported;
- layout = at_layout;
for (i = 0; i < GOPAT_Max; i++) {
AT_Functions[i] = NULL;
Index: common/phones/fake.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/phones/fake.c,v
retrieving revision 1.6
diff -u -u -r1.6 fake.c
--- common/phones/fake.c 15 May 2002 22:45:43 -0000 1.6
+++ common/phones/fake.c 19 May 2002 16:12:56 -0000
@@ -27,10 +27,9 @@
/* Some globals */
-static SMSMessage_PhoneLayout fake_layout;
-
static GSM_Error Pfake_Functions(GSM_Operation op, GSM_Data *data,
GSM_Statemachine *state);
+#if 0
static const SMSMessage_Layout at_deliver = {
true, /* Is the SMS type
supported */
1, true, false, /* SMSC */
@@ -52,6 +51,7 @@
-1, -1, /* Nonstandard fields */
8, true /* User Data */
};
+#endif
GSM_Phone phone_fake = {
NULL,
@@ -88,16 +88,6 @@
/* Copy in the phone info */
memcpy(&(state->Phone), &phone_fake, sizeof(GSM_Phone));
-
- /* SMS Layout */
- fake_layout.Type = 8; /* Locate the Type of the mesage field. */
- fake_layout.SendHeader = 6;
- fake_layout.ReadHeader = 4;
- fake_layout.Deliver = at_deliver;
- fake_layout.Submit = at_submit;
- fake_layout.DeliveryReport = at_deliver;
- fake_layout.Picture = at_deliver;
- layout = fake_layout;
dprintf("Connecting\n");
Index: include/gsm-sms.h
===================================================================
RCS file: /cvsroot/gnokii/gnokii/include/gsm-sms.h,v
retrieving revision 1.33
diff -u -u -r1.33 gsm-sms.h
--- include/gsm-sms.h 17 May 2002 00:22:10 -0000 1.33
+++ include/gsm-sms.h 19 May 2002 16:13:04 -0000
@@ -364,6 +364,55 @@
SMS_DateTime Time; /* Delivery timestamp. Only for
reading. */
} GSM_API_SMS;
+/* Define the layout of the SMS message header */
+/* Misc notes:
+ * - value -1 indicates in the location field means that the field is not
+ * supported,
+ * - when SMSC/Remote numbers have variable width all other fields should
+ * contain values as its value was 1 ('0x00' as the length) -- if field X
+ * follows SMSCNumber, X's locations would be SMSC's location + 1,
+ * - see the examples in common/phones/7110.c, commmon/phones/6100.c,
+ * common/phones/atgen.c.
+
+ * DO NOT USE THIS. OBSOLETE INTERFACE TO BE KILLED.
+ */
+typedef struct {
+ bool IsSupported; /* Indicates if SMS is supported */
+
+ short MessageCenter; /* Location of the MessageCenter */
+ bool IsMessageCenterCoded; /* Indicates if the MessageCenter
address is BCD coded */
+ bool HasMessageCenterFixedLen; /* Indicates if the MessageCenter field
has always the fixed length */
+
+ short MoreMessages; /* Location of the MoreMessages bit */
+ short ReplyViaSameSMSC; /* Location of the ReplyPath bit */
+ short RejectDuplicates; /* Location of the RejectDuplicates bit
*/
+ short Report; /* Location of the Report bit */
+ short Number; /* Location of the MessageReference
number */
+ short Reference; /* Location of the Reference bit */
+ short PID; /* Location of the ProtocolIdentifier
bit */
+ short ReportStatus; /* Location of the ReportStatus bit */
+ short Length; /* Location of the UserDataLength field
*/
+ short DataCodingScheme; /* Location of the DataCodingScheme
field */
+ short UserDataHeader; /* Location of the UserDataHeader
indicator bit */
+
+ short ValidityIndicator; /* Location of the ValidityType
Indicator field */
+ short Validity; /* Location of the Validity field */
+ short ValidityLen; /* Length ot the Validity field. -1 if
the length is variable (as with GSM SPEC) */
+
+ short RemoteNumber; /* Location of the RemoteNumber */
+ bool IsRemoteNumberCoded; /* Indicates if the RemoteNumber
address is BCD coded */
+ bool HasRemoteNumberFixedLen; /* Indicates if the MessageCenter field
has always the fixed length */
+
+ short SMSCTime; /* Location of the SMSC Response time */
+ short Time; /* Location of the Delivery time */
+
+ short MemoryType; /* Location of the Memory Type field */
+ short Status; /* Location of the Status field */
+ short UserData; /* Location of the UserData field */
+ bool IsUserDataCoded; /* Indicates if the UserData should be
PDU coded */
+} SMSMessage_Layout;
+
+
/* Define datatype for SMS messages, describes precisely GSM Spec 03.40 */
typedef struct {
unsigned int Type; /* Message Type
Indicator - 2 bits (9.2.3.1) */
Index: testsuite/testit
===================================================================
RCS file: /cvsroot/gnokii/gnokii/testsuite/testit,v
retrieving revision 1.4
diff -u -u -r1.4 testit
--- testsuite/testit 19 May 2002 11:15:56 -0000 1.4
+++ testsuite/testit 19 May 2002 16:13:06 -0000
@@ -7,7 +7,7 @@
)
export HOME=`pwd`
GNOKII=../common/gnokii-debug
-for A in test.*; do
+for A in test.?.*; do
echo -n "Doing $A... "
B=`echo $A | sed s/test/out/`
source $A 2>&1 | grep -v ^GNOKII | grep -v '^Doing operation' > my$B
--
(about SSSCA) "I don't say this lightly. However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Make fake be able to send sms,
Pavel Machek <=