really powerful and useful :-)
$Log$
- Revision 1.1.1.1 2001/11/25 21:59:18 short
- :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
+ Revision 1.1.1.12 2002/04/03 01:44:15 short
+ Implemented connection type "tcp" (GCT_TCP), use <hostname>:<port> as "port"
- Revision 1.151 2001/11/22 17:56:53 pkot
- smslib update. sms sending
-
- Revision 1.150 2001/11/20 16:22:22 pkot
- First attempt to read Picture Messages. They should appear when you enable DEBUG. Nokia seems to break own standards. :/ (Markus Plail)
-
- Revision 1.149 2001/11/19 16:00:15 pkot
- Another typo
-
- Revision 1.148 2001/11/19 13:46:43 pkot
- reading unread SMS in 6210 from Inbox. Folder updates (Markus Plail)
-
- Revision 1.147 2001/11/18 00:54:32 pkot
- Bugfixes. I18n of the user responses. UDH support in libsms. Business Card UDH Type
-
- Revision 1.146 2001/11/17 20:18:33 pkot
- Added dau9p connection type for 6210/7110
-
- Revision 1.145 2001/11/14 10:46:12 pkot
- Small cleanup with __unices__
-
- Revision 1.144 2001/11/08 16:34:19 pkot
- Updates to work with new libsms
+ Revision 1.1.1.11 2002/04/03 00:08:17 short
+ Found in "gnokii-working" directory, some November-patches version
Revision 1.143 2001/09/14 13:30:07 pkot
Fixed bugs introduced during 0.3.3 merge
*/
+#include "config.h"
#include "misc.h"
#include <stdio.h>
#include <getopt.h>
#endif
+
#ifdef USE_NLS
#include <locale.h>
#endif
-#include "gsm-sms.h"
#include "gsm-common.h"
#include "gsm-api.h"
#include "gsm-networks.h"
" gnokii --setspeeddial number memory_type location\n"
" gnokii --getsms memory_type start [end] [-f file] [-F file] [-d]\n"
" gnokii --deletesms memory_type start [end]\n"
- " gnokii --sendsms destination [--smsc message_center_number |\n"
- " --smscno message_center_index] [-r] [-C n] [-v n]\n"
- " [--long n]\n"
+ " gnokii --sendsms destination [-r] [-C n] [-v n]\n"
+ " [--longtext|--longudh] [--udh] [-8]\n"
+ " [--smsc message_center_number | --smscno message_center_index]\n"
" gnokii --savesms [-m] [-l n] [-i]\n"
" gnokii --getsmsc message_center_number\n"
" gnokii --setdatetime [YYYY [MM [DD [HH [MM]]]]]\n"
" gnokii --identify\n"
" gnokii --senddtmf string\n"
" gnokii --sendlogo {caller|op} destination logofile [network code]\n"
+ " [--smsc message_center_number | --smscno message_center_index]\n"
" gnokii --sendringtone destination rtttlfile\n"
+ " [--smsc message_center_number | --smscno message_center_index]\n"
" gnokii --setlogo op [logofile] [network code]\n"
" gnokii --setlogo startup [logofile]\n"
" gnokii --setlogo caller [logofile] [caller group number] [group name]\n"
void fbusinit(void (*rlp_handler)(RLP_F96Frame *frame))
{
- int count = 0;
+ int count=0;
GSM_Error error;
- GSM_ConnectionType connection = GCT_Serial;
+ GSM_ConnectionType connection=GCT_Serial;
GSM_DataClear(&data);
- if (!strcasecmp(Connection, "dau9p")) connection = GCT_DAU9P;
- if (!strcasecmp(Connection, "infrared")) connection = GCT_Infrared;
- if (!strcasecmp(Connection, "irda")) connection = GCT_Irda;
+ if (!strcmp(Connection, "infrared")) connection=GCT_Infrared;
+ if (!strcmp(Connection, "irda")) connection=GCT_Irda;
+ if (!strcmp(Connection, "tcp")) connection=GCT_TCP;
/* Initialise the code for the GSM interface. */
// Send SMS message mode
{ "sendsms", required_argument, NULL, OPT_SENDSMS },
- // Ssve SMS message mode
+ // Save SMS message mode
{ "savesms", optional_argument, NULL, OPT_SAVESMS },
// Send logo as SMS message mode
{ OPT_DELETESMS, 2, 3, 0 },
{ OPT_SENDSMS, 1, 10, 0 },
{ OPT_SAVESMS, 0, 6, 0 },
- { OPT_SENDLOGO, 3, 4, GAL_XOR },
- { OPT_SENDRINGTONE, 2, 2, 0 },
+ { OPT_SENDLOGO, 3, 6, 0 },
+ { OPT_SENDRINGTONE, 2, 6, 0 },
{ OPT_GETSMSC, 1, 1, 0 },
{ OPT_GETWELCOMENOTE, 1, 1, 0 },
{ OPT_SETWELCOMENOTE, 1, 1, 0 },
rc = setringtone(nargc, nargv);
break;
case OPT_SENDRINGTONE:
- rc = sendringtone(nargc, nargv);
+ rc = sendringtone(argc, argv);
break;
case OPT_GETPROFILE:
rc = getprofile(nargc, nargv);
exit(-1);
}
+#define SMSC_SHORTCHAR_SMSC (0xF0)
+#define SMSC_SHORTCHAR_SMSCNO (0xF1)
+#define SMSC_OPTIONS \
+ { "smsc", required_argument, NULL, SMSC_SHORTCHAR_SMSC}, \
+ { "smscno", required_argument, NULL, SMSC_SHORTCHAR_SMSCNO}
+
+/* RETURNS: Whether the options was found as ours (=>rerun getopt_long())
+ */
+static bool smsc_options_parse(int option,GSM_SMSMessage *SMS)
+{
+ switch (option) {
+
+ case SMSC_SHORTCHAR_SMSC: /* SMSC number */
+ SMS->MessageCenter.No = 0;
+ strcpy(SMS->MessageCenter.Number,optarg);
+ break;
+
+ case SMSC_SHORTCHAR_SMSCNO: /* SMSC number index in phone memory */
+ SMS->MessageCenter.No = atoi(optarg);
+
+ if (SMS->MessageCenter.No < 1 || SMS->MessageCenter.No > 5)
+ usage();
+ break;
+
+ default:
+ return(false); /* option not recognized */
+ }
+
+ return(true); /* option was successfuly processed */
+}
+
+/* RETURNS: Success
+ */
+bool sendsms_deconcatenated(GSM_SMSMessage *sms,char *buf,size_t buflen,bool useudh)
+{
+ GSM_Deconcatenate_state SMS_Deconcatenate_state;
+ GSM_Error error;
+
+ SMS_Deconcatenate_state.first=true;
+ while (SMS_Deconcatenate(&SMS_Deconcatenate_state,sms,buf,buflen,useudh)) {
+ /* Send the message. */
+ error = GSM->SendSMSMessage(sms);
+
+ if (error == GE_SMSSENDOK) {
+ fprintf(stdout, _("Send succeeded!\n"));
+ } else {
+ fprintf(stdout, _("SMS Send failed (error=%d)\n"), error);
+ return(false);
+ }
+ /* Here the sleep have no meaning.
+ * If it is required by some backend phone driver, it should be done THERE!
+ */
+ /* sleep(10); */
+ }
+ return(true);
+}
+
/* Send SMS messages. */
int sendsms(int argc, char *argv[])
{
GSM_SMSMessage SMS;
- GSM_Error error;
- // char UDH[GSM_MAX_USER_DATA_HEADER_LENGTH];
/* The maximum length of an uncompressed concatenated short message is
255 * 153 = 39015 default alphabet characters */
- char message_buffer[255 * GSM_MAX_SMS_LENGTH];
+ char message_buffer[GSM_MAX_CONCATENATED_SMS_LENGTH];
int input_len, chars_read;
- int i; /*, offset, nr_msg, aux;*/
+ int i;
+ bool useudh = false;
struct option options[] = {
- { "smsc", required_argument, NULL, '1'},
- { "smscno", required_argument, NULL, '2'},
- { "long", required_argument, NULL, '3'},
- { NULL, 0, NULL, 0}
+ SMSC_OPTIONS,
+ { "longtext", no_argument, NULL, '3'},
+ { "longudh", no_argument, NULL, '4'},
+ { "udh", no_argument, NULL, '5'},
+ { NULL, 0, NULL, 0}
};
input_len = GSM_MAX_SMS_LENGTH;
- unset user data header indicator
*/
- memset(&SMS, 0, sizeof(GSM_SMSMessage));
-
- SMS.Type = SMS_Submit;
- SMS.DCS.Type = SMS_GeneralDataCoding;
- SMS.DCS.u.General.Compressed = false;
- SMS.DCS.u.General.Alphabet = SMS_DefaultAlphabet;
- SMS.DCS.u.General.Class = 0;
+ SMS.Type = GST_MO;
+ SMS.Class = -1;
+ SMS.Compression = false;
+ SMS.EightBit = false;
SMS.MessageCenter.No = 1;
- SMS.Validity.VPF = SMS_RelativeFormat;
- SMS.Validity.u.Relative = 4320; /* 4320 minutes == 72 hours */
- SMS.UDH_No = 0;
+ SMS.Validity = 4320; /* 4320 minutes == 72 hours */
+ SMS.UDHPresent = false;
- strcpy(SMS.RemoteNumber.number, argv[0]);
- if (SMS.RemoteNumber.number[0] == '+') SMS.RemoteNumber.type = SMS_International;
- else SMS.RemoteNumber.type = SMS_Unknown;
+ strcpy(SMS.Destination, argv[0]);
optarg = NULL;
optind = 0;
while ((i = getopt_long(argc, argv, "r8cC:v:", options, NULL)) != -1) {
- switch (i) { // -8 is for 8-bit data, -c for compression. both are not yet implemented.
- case '1': /* SMSC number */
- SMS.MessageCenter.No = 0;
- strcpy(SMS.MessageCenter.Number, optarg);
+ if (smsc_options_parse(i,&SMS))
+ continue;
+ switch (i) { // -c for compression. not yet implemented.
+ case '3': /* we send long message in text format */
+ input_len = GSM_MAX_CONCATENATED_SMS_LENGTH;
+ useudh = false;
break;
- case '2': /* SMSC number index in phone memory */
- SMS.MessageCenter.No = atoi(optarg);
-
- if (SMS.MessageCenter.No < 1 || SMS.MessageCenter.No > 5)
- usage();
- data.MessageCenter = &SMS.MessageCenter;
- error = SM_Functions(GOP_GetSMSCenter, &data, &State);
- break;
- case '3': /* we send long message */
- input_len = atoi(optarg);
- if (input_len > 255 * GSM_MAX_SMS_LENGTH) {
- fprintf(stderr, _("Input too long!\n"));
- exit(-1);
- }
+ case '4': /* we send long message in UDH format */
+ input_len = GSM_MAX_CONCATENATED_SMS_LENGTH;
+ useudh = true;
+ break;
+ case '5': /* UDH indication requested */
+ SMS.UDHPresent = true;
break;
case 'r': /* request for delivery report */
- SMS.Type = SMS_Delivery_Report;
+ SMS.Type = GST_DR;
break;
case 'C': /* class Message */
switch (*optarg) {
case '0':
- SMS.DCS.u.General.Class = 1;
+ SMS.Class = 0;
break;
case '1':
- SMS.DCS.u.General.Class = 2;
+ SMS.Class = 1;
break;
case '2':
- SMS.DCS.u.General.Class = 3;
+ SMS.Class = 2;
break;
case '3':
- SMS.DCS.u.General.Class = 4;
+ SMS.Class = 3;
break;
default:
usage();
}
break;
+ case '8': /* 8-bit data */
+ SMS.EightBit = true;
+ break;
case 'v':
- SMS.Validity.u.Relative = atoi(optarg);
+ SMS.Validity = atoi(optarg);
break;
default:
usage(); /* Would be better to have an sendsms_usage() here. */
return -1;
}
+ if (SMS.UDHPresent) {
+u8 UDHlen = 1 + message_buffer[0]; /* designifify */
+
+ if (chars_read < UDHlen || sizeof(SMS.UDH) < UDHlen) {
+ fprintf(stderr, _("Input too short to satisfy UDH!\n"));
+ return -1;
+ }
+ memcpy(SMS.UDH, message_buffer, UDHlen);
+ chars_read-=UDHlen;
+ memmove(message_buffer, message_buffer + UDHlen, chars_read);
+ }
+
/* Null terminate. */
message_buffer[chars_read] = 0x00;
- strncpy(SMS.MessageText, message_buffer, chars_read);
- data.SMSMessage = &SMS;
-
- /* Send the message. */
- error = SM_Functions(GOP_SendSMS, &data, &State);
- if (error == GE_SMSSENDOK) {
- fprintf(stdout, _("Send succeeded!\n"));
- } else {
- fprintf(stdout, _("SMS Send failed (error=%d)\n"), error);
- }
+ sendsms_deconcatenated(&SMS,message_buffer,chars_read,useudh);
- if (GSM && GSM->Terminate) GSM->Terminate();
+ GSM->Terminate();
return 0;
}
GSM_Error error;
/* The maximum length of an uncompressed concatenated short message is
255 * 153 = 39015 default alphabet characters */
- char message_buffer[255 * GSM_MAX_SMS_LENGTH];
+ char message_buffer[GSM_MAX_CONCATENATED_SMS_LENGTH];
int input_len, chars_read;
int i, confirm = -1;
int interactive = 0;
char ans[8];
/* Defaults */
- SMS.Type = SMS_Deliver;
- SMS.DCS.Type = SMS_GeneralDataCoding;
- SMS.DCS.u.General.Compressed = false;
- SMS.DCS.u.General.Alphabet = SMS_DefaultAlphabet;
- SMS.DCS.u.General.Class = 0;
+ SMS.Type = GST_MO;
+ SMS.Destination[0] = '\0';
+ SMS.Class = -1;
+ SMS.Compression = false;
+ SMS.EightBit = false;
SMS.MessageCenter.No = 1;
- SMS.Validity.VPF = SMS_RelativeFormat;
- SMS.Validity.u.Relative = 4320; /* 4320 minutes == 72 hours */
- SMS.UDH_No = 0;
- SMS.Status = SMS_Unsent;
- SMS.Number = 0;
+ SMS.Validity = 4320; /* 4320 minutes == 72 hours */
+ SMS.UDHPresent = false;
+ SMS.Status = GSS_NOTSENTREAD;
+ SMS.Location = 0;
+ SMS.MemoryType = GMT_SM;
input_len = GSM_MAX_SMS_LENGTH;
while ((i = getopt(argc, argv, "ml:in:s:c:")) != -1) {
switch (i) {
case 'm': /* mark the message as sent */
- SMS.Status = SMS_Sent;
+ SMS.Status = GSS_SENTREAD;
break;
case 'l': /* Specify the location */
- SMS.Number = atoi(optarg);
+ SMS.Location = atoi(optarg);
break;
case 'i': /* Ask before overwriting */
interactive = 1;
if (interactive) {
GSM_SMSMessage aux;
- aux.Number = SMS.Number;
+ aux.Location = SMS.Location;
data.SMSMessage = &aux;
error = SM_Functions(GOP_GetSMS, &data, &State);
switch (error) {
while (confirm < 0) {
fprintf(stderr, _("Overwrite? (yes/no) "));
GetLine(stdin, ans, 7);
- if (!strcmp(ans, _("yes"))) confirm = 1;
- else if (!strcmp(ans, _("no"))) confirm = 0;
+ if (!strcmp(ans, "yes")) confirm = 1;
+ else if (!strcmp(ans, "no")) confirm = 0;
}
if (!confirm) { GSM->Terminate(); return 0; }
else break;
default:
/* FIXME: Remove this fprintf when the function is thoroughly tested */
#ifdef DEBUG
- fprintf(stderr, _("Location %d empty. Saving\n"), SMS.Number);
+ fprintf(stderr, _("Location %d empty. Saving\n"), SMS.Location);
#endif
break;
}
strncpy (SMS.MessageText, message_buffer, chars_read);
SMS.MessageText[chars_read] = 0;
+ SMS.MessageTextLength=chars_read;
error = GSM->SaveSMSMessage(&SMS);
/* Get SMSC number */
int getsmsc(char *MessageCenterNumber)
{
- SMS_MessageCenter MessageCenter;
+ GSM_MessageCenter MessageCenter;
GSM_Data data;
GSM_Error error;
fprintf(stdout, _("Messages sent as "));
switch (MessageCenter.Format) {
- case SMS_Text:
+ case GSMF_Text:
fprintf(stdout, _("Text"));
break;
- case SMS_VoiceMail:
- fprintf(stdout, _("VoiceMail"));
+ case GSMF_Paging:
+ fprintf(stdout, _("Paging"));
break;
- case SMS_Fax:
+ case GSMF_Fax:
fprintf(stdout, _("Fax"));
break;
- case SMS_Email:
-// case GSMF_UCI:
+ case GSMF_Email:
+ case GSMF_UCI:
fprintf(stdout, _("Email"));
break;
-/* case GSMF_ERMES:
+ case GSMF_ERMES:
fprintf(stdout, _("ERMES"));
break;
case GSMF_X400:
fprintf(stdout, _("X.400"));
- break; */
+ break;
default:
fprintf(stdout, _("Unknown"));
break;
fprintf(stdout, _("Message validity is "));
switch (MessageCenter.Validity) {
- case SMS_V1H:
+ case GSMV_1_Hour:
fprintf(stdout, _("1 hour"));
break;
- case SMS_V6H:
+ case GSMV_6_Hours:
fprintf(stdout, _("6 hours"));
break;
- case SMS_V24H:
+ case GSMV_24_Hours:
fprintf(stdout, _("24 hours"));
break;
- case SMS_V72H:
+ case GSMV_72_Hours:
fprintf(stdout, _("72 hours"));
break;
- case SMS_V1W:
+ case GSMV_1_Week:
fprintf(stdout, _("1 week"));
break;
- case SMS_VMax:
+ case GSMV_Max_Time:
fprintf(stdout, _("Maximum time"));
break;
default:
int getsms(int argc, char *argv[])
{
int del = 0;
- SMS_Folder folder;
- SMS_FolderList folderlist;
GSM_SMSMessage message;
char *memory_type_string;
int start_message, end_message, count, mode = 1;
mode = 0;
case 'f':
if (optarg) {
- dprintf("Saving into %s\n", optarg);
+ dprintf(_("Saving into %s\n"), optarg);
strncpy(filename, optarg, 64);
if (strlen(optarg) > 63) {
fprintf(stderr, _("Filename too long - will be truncated to 63 characters.\n"));
}
}
}
- data.SMSFolderList = &folderlist;
- folder.FolderID = 0;
- data.SMSFolder = &folder;
+
/* Now retrieve the requested entries. */
for (count = start_message; count <= end_message; count ++) {
- int offset = 0;
- message.Number = count;
+ message.Location = count;
data.SMSMessage = &message;
- dprintf("MemoryType (gnokii.c) : %i\n", data.SMSMessage->MemoryType);
error = SM_Functions(GOP_GetSMS, &data, &State);
switch (error) {
case GE_NONE:
switch (message.Type) {
- case SMS_Text:
- fprintf(stdout, _("%d. MO Message "), message.Number);
+ case GST_MO:
+ fprintf(stdout, _("%d. Outbox Message "), message.MessageNumber);
if (message.Status)
fprintf(stdout, _("(sent)\n"));
- fprintf(stdout, _("%d. MO Message "), message.Number);
- if (message.Status)
+ else
fprintf(stdout, _("(not sent)\n"));
fprintf(stdout, _("Text: %s\n\n"), message.MessageText);
break;
- case SMS_Delivery_Report:
- fprintf(stdout, _("%d. Delivery Report "), message.Number);
+ case GST_DR:
+ fprintf(stdout, _("%d. Delivery Report "), message.MessageNumber);
if (message.Status)
fprintf(stdout, _("(read)\n"));
else
fprintf(stdout, _("(not read)\n"));
- fprintf(stdout, _("Sending date/time: %02d/%02d/%04d %02d:%02d:%02d "), \
+ fprintf(stdout, _("Sending date/time: %d/%d/%d %d:%02d:%02d "), \
message.Time.Day, message.Time.Month, message.Time.Year, \
message.Time.Hour, message.Time.Minute, message.Time.Second);
if (message.Time.Timezone) {
fprintf(stdout,_("%02d00"), message.Time.Timezone);
}
fprintf(stdout, "\n");
- fprintf(stdout, _("Response date/time: %02d/%02d/%04d %02d:%02d:%02d "), \
+ fprintf(stdout, _("Response date/time: %d/%d/%d %d:%02d:%02d "), \
message.SMSCTime.Day, message.SMSCTime.Month, message.SMSCTime.Year, \
message.SMSCTime.Hour, message.SMSCTime.Minute, message.SMSCTime.Second);
if (message.SMSCTime.Timezone) {
fprintf(stdout,_("%02d00"),message.SMSCTime.Timezone);
}
fprintf(stdout, "\n");
- fprintf(stdout, _("Receiver: %s Msg Center: %s\n"), message.RemoteNumber.number, message.MessageCenter.Number);
+ fprintf(stdout, _("Receiver: %s Msg Center: %s\n"), message.Sender, message.MessageCenter.Number);
fprintf(stdout, _("Text: %s\n\n"), message.MessageText);
break;
default:
- fprintf(stdout, _("%d. Inbox Message "), message.Number);
+ fprintf(stdout, _("%d. Inbox Message "), message.MessageNumber);
if (message.Status)
fprintf(stdout, _("(read)\n"));
else
fprintf(stdout, _("(not read)\n"));
- fprintf(stdout, _("Date/time: %02d/%02d/%04d %02d:%02d:%02d "), \
+ fprintf(stdout, _("Date/time: %d/%d/%d %d:%02d:%02d "), \
message.Time.Day, message.Time.Month, message.Time.Year, \
message.Time.Hour, message.Time.Minute, message.Time.Second);
if (message.Time.Timezone) {
fprintf(stdout,_("%02d00"),message.Time.Timezone);
}
fprintf(stdout, "\n");
- fprintf(stdout, _("Sender: %s Msg Center: %s\n"), message.RemoteNumber.number, message.MessageCenter.Number);
- switch (message.UDH[0].Type) {
- case SMS_OpLogo:
+ fprintf(stdout, _("Sender: %s Msg Center: %s\n"), message.Sender, message.MessageCenter.Number);
+ switch (SMS_DetectUDH(&message)) {
+ case GSM_OpLogo:
fprintf(stdout, _("GSM operator logo for %s (%s) network.\n"), bitmap.netcode, GSM_GetNetworkName(bitmap.netcode));
- if (!strcmp(message.RemoteNumber.number, "+998000005") && !strcmp(message.MessageCenter.Number, "+886935074443")) dprintf(_("Saved by Logo Express\n"));
- if (!strcmp(message.RemoteNumber.number, "+998000002") || !strcmp(message.RemoteNumber.number, "+998000003")) dprintf(_("Saved by Operator Logo Uploader by Thomas Kessler\n"));
- offset = 3;
- case SMS_CallerIDLogo:
+ if (!strcmp(message.Sender, "+998000005") && !strcmp(message.MessageCenter.Number, "+886935074443")) dprintf(_("Saved by Logo Express\n"));
+ if (!strcmp(message.Sender, "+998000002") || !strcmp(message.Sender, "+998000003")) dprintf(_("Saved by Operator Logo Uploader by Thomas Kessler\n"));
+ case GSM_CallerIDLogo:
fprintf(stdout, ("Logo:\n"));
/* put bitmap into bitmap structure */
- GSM_ReadSMSBitmap(message.UDH[0].Type, message.MessageText+2+offset, message.MessageText, &bitmap);
+ GSM_ReadSMSBitmap(&message, &bitmap);
GSM_PrintBitmap(&bitmap);
if (*filename) {
error = GE_NONE;
fprintf(stdout, _("File %s exists.\n"), filename);
fprintf(stderr, _("Overwrite? (yes/no) "));
GetLine(stdin, ans, 4);
- if (!strcmp(ans, _("yes"))) {
+ if (!strcmp(ans, "yes")) {
error = GSM_SaveBitmapFile(filename, &bitmap);
}
} else error = GSM_SaveBitmapFile(filename, &bitmap);
- if (error != GE_NONE) fprintf(stderr, _("Couldn't save logofile %s!\n"), filename);
+ if (error!=GE_NONE) fprintf(stderr, _("Couldn't save logofile %s!\n"), filename);
}
break;
- case SMS_Ringtone:
- fprintf(stdout, _("Ringtone\n"));
+ case GSM_RingtoneUDH:
+ fprintf(stdout, ("Ringtone\n"));
break;
- case SMS_ConcatenatedMessages:
- fprintf(stdout, _("Linked (%d/%d):\n"),
- message.UDH[0].u.ConcatenatedShortMessage.CurrentNumber,
- message.UDH[0].u.ConcatenatedShortMessage.MaximumNumber);
- case SMS_NoUDH:
+ case GSM_ConcatenatedMessages:
+ fprintf(stdout, _("Linked (%d/%d):\n"),message.UDH[5],message.UDH[4]);
+ case GSM_NoUDH:
fprintf(stdout, _("Text:\n%s\n\n"), message.MessageText);
if ((mode != -1) && *filename) {
char buf[1024];
mode = GSM_SaveTextFile(buf, message.MessageText, mode);
}
break;
- case SMS_BusinessCard:
- fprintf(stdout, _("Business Card:\n%s"), message.MessageText);
- break;
default:
fprintf(stderr, _("Unknown\n"));
break;
fprintf(stderr, _("SMS location %s %d empty.\n"), memory_type_string, count);
break;
default:
- fprintf(stdout, _("GetSMS %s %d failed!(%s)\n\n"), memory_type_string, count, print_error(error));
+ fprintf(stdout, _("GetSMS %s %d failed!(%d)\n\n"), memory_type_string, count, error);
break;
}
}
/* Now delete the requested entries. */
for (count = start_message; count <= end_message; count ++) {
- message.Number = count;
+ message.Location = count;
data.SMSMessage = &message;
error = SM_Functions(GOP_DeleteSMS, &data, &State);
{
GSM_SMSMessage SMS;
GSM_Bitmap bitmap;
- GSM_Error error;
- char UserDataHeader[7] = { 0x06, /* UDH Length */
- 0x05, /* IEI: application port addressing scheme, 16 bit address */
- 0x04, /* IEI length */
- 0x15, /* destination address: high byte */
- 0x00, /* destination address: low byte */
- 0x00, /* originator address */
- 0x00};
+ char Data[sizeof(bitmap.bitmap) +64/*headers safety*/];
- char Data[7] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ int current=0, i;
- int current=0;
+ struct option options[] = {
+ SMSC_OPTIONS,
+ { NULL, 0, NULL, 0}
+ };
/* Default settings for SMS message:
- no delivery report
- validity 3 days
- set UserDataHeaderIndicator
*/
- SMS.Type = SMS_Submit;
- SMS.DCS.Type = SMS_GeneralDataCoding;
- SMS.DCS.u.General.Compressed = false;
- SMS.DCS.u.General.Alphabet = SMS_8bit;
- SMS.DCS.u.General.Class = 2;
+
+ SMS.Type = GST_MO;
+ SMS.Class = 1;
+ SMS.Compression = false;
+ SMS.EightBit = true;
SMS.MessageCenter.No = 1;
- SMS.Validity.VPF = SMS_RelativeFormat;
- SMS.Validity.u.Relative = 4320; /* 4320 minutes == 72 hours */
+ SMS.Validity = 4320; /* 4320 minutes == 72 hours */
+
+ optarg = NULL;
+ optind = 0;
+ while ((i = getopt_long(argc, argv, "", options, NULL)) != -1) {
+ if (smsc_options_parse(i,&SMS))
+ continue;
+ switch (i) {
+ default:
+ usage(); /* Would be better to have an sendsms_usage() here. */
+ }
+ }
+
+/*
+ if (argc!=3 && argc!=4)
+ usage();
+*/
/* The first argument is the type of the logo. */
if (!strcmp(argv[0], "op")) {
- SMS.UDH[0].Type = SMS_OpLogo;
- UserDataHeader[4] = 0x82; /* NBS port 0x1582 */
+ SMS_SetupUDH(&SMS,GSM_OpLogo); /* error ignored */
fprintf(stdout, _("Sending operator logo.\n"));
- } else if (!strcmp(argv[0], "caller")) {
- SMS.UDH[0].Type = SMS_CallerIDLogo;
- UserDataHeader[4] = 0x83; /* NBS port 0x1583 */
+ } else if (!strcmp(argv[0], "caller")) { /* error ignored */
+ SMS_SetupUDH(&SMS,GSM_CallerIDLogo);
fprintf(stdout, _("Sending caller line identification logo.\n"));
} else {
fprintf(stderr, _("You should specify what kind of logo to send!\n"));
}
/* The second argument is the destination, ie the phone number of recipient. */
- SMS.MemoryType = atoi(argv[1]);
+ strcpy(SMS.Destination,argv[1]);
/* The third argument is the bitmap file. */
GSM_ReadBitmapFile(argv[2], &bitmap);
}
/* Set the logo size */
- current++;
+ Data[current++] = 0x00; /* RFU by Nokia */
Data[current++] = bitmap.width;
Data[current++] = bitmap.height;
- Data[current++] = 0x01;
-
- memcpy(SMS.MessageText, UserDataHeader, 7);
- memcpy(SMS.MessageText, Data, current);
- memcpy(SMS.MessageText+current, bitmap.bitmap, bitmap.size);
+ Data[current++] = 0x01; /* depth=number of grayscales */
+ memcpy(Data+current,bitmap.bitmap,bitmap.size);
+ current+=bitmap.size;
+
/* Send the message. */
- error = GSM->SendSMSMessage(&SMS,current+bitmap.size);
-
- if (error == GE_SMSSENDOK)
- fprintf(stdout, _("Send succeeded!\n"));
- else
- fprintf(stdout, _("SMS Send failed (error=%d)\n"), error);
+ sendsms_deconcatenated(&SMS,Data,current,true/*useudh*/);
GSM->Terminate();
return 0;
int sendringtone(int argc, char *argv[])
{
+ GSM_SMSMessage SMS;
GSM_Ringtone ringtone;
- GSM_Error error;
+ int i;
+ int size = GSM_MAX_RINGTONE_PACKAGE_LENGTH;
+ char Package[GSM_MAX_RINGTONE_PACKAGE_LENGTH];
- if (GSM_ReadRingtoneFile(argv[0], &ringtone)) {
+ struct option options[] = {
+ SMSC_OPTIONS,
+ { NULL, 0, NULL, 0}
+ };
+
+ /* Default settings for SMS message:
+ - no delivery report
+ - Class Message 1
+ - no compression
+ - 8 bit data
+ - SMSC no. 1
+ - validity 3 days
+ - set UserDataHeaderIndicator
+ */
+
+ SMS.Type = GST_MO;
+ SMS.Class = 1;
+ SMS.Compression = false;
+ SMS.EightBit = true;
+ SMS.MessageCenter.No = 1;
+ SMS.Validity = 4320; /* 4320 minutes == 72 hours */
+
+ SMS_SetupUDH(&SMS,GSM_RingtoneUDH); /* error ignored */
+
+ optarg = NULL;
+ optind = 0;
+ argv[1]=argv[0];
+ argv++;
+ argc--;
+ while ((i = getopt_long(argc, argv, "", options, NULL)) != -1) {
+ if (smsc_options_parse(i,&SMS))
+ continue;
+ switch (i) {
+ default:
+ usage(); /* Would be better to have an sendsms_usage() here. */
+ }
+ }
+ argc-=optind;
+ argv+=optind;
+
+ if (argc!=2)
+ usage();
+
+ if (GSM_ReadRingtoneFile(argv[1], &ringtone)) {
fprintf(stdout, _("Failed to load ringtone.\n"));
return(-1);
}
+ if (strlen(argv[0])+1 > sizeof(SMS.Destination)) {
+ fprintf(stdout, _("Destination number \"%s\" length too long!\n"), argv[0]);
+ return(-1);
+ }
+ strcpy(SMS.Destination, argv[0]);
+ GSM_PackRingtone(&ringtone, Package, &size);
- error = GSM->SendRingtone(&ringtone,argv[1]);
-
- if (error == GE_NONE)
- fprintf(stdout, _("Send succeeded!\n"));
- else
- fprintf(stdout, _("SMS Send failed (error=%d)\n"), error);
+ sendsms_deconcatenated(&SMS,Package,size,true/*useudh*/);
GSM->Terminate();
return 0;
-
}
GSM->Terminate();
return 0;
-
}
int presskeysequence(void)