" gnokii --getprofile [number]\n"
" gnokii --displayoutput\n"
" gnokii --keysequence\n"
- ));
+ " gnokii --divert {--op|-o} {register|enable|query|disable|erasure}\n"
+ " {--type|-t} {all|busy|noans|outofreach|notavail}\n"
+ " {--call|-c} {all|voice|fax|data}\n"
+ " [{--timeout|-m} time_in_seconds]\n"
+ " [{--number|-n} number]\n"
+ ));
#ifdef SECURITY
fprintf(stderr, _(
" gnokii --entersecuritycode PIN|PIN2|PUK|PUK2\n"
// Simulate pressing the keys
{ "keysequence", no_argument, NULL, OPT_KEYPRESS },
-
+
+ /* Divert calls */
+ { "divert", required_argument, NULL, OPT_DIVERT },
+
// For development purposes: insert you function calls here
{ "foogle", no_argument, NULL, OPT_FOOGLE },
{ OPT_RESET, 0, 1, 0 },
{ OPT_GETPROFILE, 0, 1, 0 },
{ OPT_WRITEPHONEBOOK, 0, 1, 0 },
+ { OPT_DIVERT, 6, 10, 0 },
{ 0, 0, 0, 0 },
};
usage();
switch(c) {
- // First, error conditions
+ /* First, error conditions */
case '?':
case ':':
fprintf(stderr, _("Use '%s --help' for usage informations.\n"), argv[0]);
exit(0);
- // Then, options with no arguments
+ /* Then, options with no arguments */
case OPT_HELP:
usage();
case OPT_VERSION:
case OPT_WRITEPHONEBOOK:
rc = writephonebook(nargc, nargv);
break;
- // Now, options with arguments
+ /* Now, options with arguments */
case OPT_SETDATETIME:
rc = setdatetime(nargc, nargv);
break;
case OPT_KEYPRESS:
rc = presskeysequence();
break;
-#ifndef WIN32
- case OPT_FOOGLE:
- rc = foogle(nargv);
- break;
-#endif
case OPT_SENDDTMF:
rc = senddtmf(optarg);
break;
case OPT_RESET:
rc = reset(optarg);
break;
+ case OPT_DIVERT:
+ rc = divert(argc, argv);
+ break;
+#ifndef WIN32
+ case OPT_FOOGLE:
+ rc = foogle(nargv);
+ break;
+#endif
default:
fprintf(stderr, _("Unknown option: %d\n"), c);
break;
if (!strcmp(ans, _("yes"))) confirm = 1;
else if (!strcmp(ans, _("no"))) confirm = 0;
}
- if (!confirm) { GSM->Terminate(); return 0; }
+ if (!confirm) {
+ if (GSM && GSM->Terminate) GSM->Terminate();
+ return 0;
+ }
else break;
case GE_INVALIDSMSLOCATION:
fprintf(stderr, _("Invalid location\n"));
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return -1;
default:
-/* FIXME: Remove this fprintf when the function is thoroughly tested */
-#ifdef DEBUG
- fprintf(stderr, _("Location %d empty. Saving\n"), SMS.Number);
-#endif
+ dprintf("Location %d empty. Saving\n", SMS.Number);
break;
}
}
fprintf(stdout, _("Saving failed (error=%d)\n"), error);
}
sleep(10);
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
GSM_Error error;
memset(&MessageCenter, 0, sizeof(MessageCenter));
- MessageCenter.No=atoi(MessageCenterNumber);
+ MessageCenter.No = atoi(MessageCenterNumber);
if (GSM && GSM->GetSMSCenter && GSM->Terminate) {
error = GSM->GetSMSCenter(&MessageCenter);
else {
if (error == GE_NOTIMPLEMENTED) {
fprintf(stderr, _("Function not implemented in %s model!\n"), model);
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return -1;
}
fprintf(stdout, _("DeleteSMS %s %d failed!(%d)\n\n"), memory_type_string, count, error);
}
}
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
GSM_Error test;
GSM_SecurityCode SecurityCode;
- if (!strcmp(type,"PIN"))
- SecurityCode.Type=GSCT_Pin;
- else if (!strcmp(type,"PUK"))
- SecurityCode.Type=GSCT_Puk;
- else if (!strcmp(type,"PIN2"))
- SecurityCode.Type=GSCT_Pin2;
- else if (!strcmp(type,"PUK2"))
- SecurityCode.Type=GSCT_Puk2;
- // FIXME: Entering of SecurityCode does not work :-(
- // else if (!strcmp(type,"SecurityCode"))
- // SecurityCode.Type=GSCT_SecurityCode;
+ if (!strcmp(type, "PIN"))
+ SecurityCode.Type = GSCT_Pin;
+ else if (!strcmp(type, "PUK"))
+ SecurityCode.Type = GSCT_Puk;
+ else if (!strcmp(type, "PIN2"))
+ SecurityCode.Type = GSCT_Pin2;
+ else if (!strcmp(type, "PUK2"))
+ SecurityCode.Type = GSCT_Puk2;
+ /* FIXME: Entering of SecurityCode does not work :-(
+ else if (!strcmp(type, "SecurityCode"))
+ SecurityCode.Type = GSCT_SecurityCode;
+ */
else
usage();
printf("Enter your code: ");
gets(SecurityCode.Code);
#else
- strcpy(SecurityCode.Code,getpass(_("Enter your code: ")));
+ strcpy(SecurityCode.Code, getpass(_("Enter your code: ")));
#endif
- test = GSM->EnterSecurityCode(SecurityCode);
+ if (GSM && GSM->EnterSecurityCode) test = GSM->EnterSecurityCode(SecurityCode);
if (test == GE_INVALIDSECURITYCODE)
fprintf(stdout, _("Error: invalid code.\n"));
else if (test == GE_NONE)
else
fprintf(stdout, _("Other error.\n"));
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
{
int Status;
- if (GSM->GetSecurityCodeStatus(&Status) == GE_NONE) {
+ if (GSM && GSM->GetSecurityCodeStatus && GSM->GetSecurityCodeStatus(&Status) == GE_NONE) {
fprintf(stdout, _("Security code status: "));
}
}
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
/* Voice dialing mode. */
int dialvoice(char *Number)
{
- GSM->DialVoice(Number);
+ if (GSM && GSM->DialVoice) GSM->DialVoice(Number);
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
while (!confirm) {
fprintf(stderr, _("Saving logo. File \"%s\" exists. (O)verwrite, create (n)ew or (s)kip ? "), FileName);
GetLine(stdin, ans, 4);
- if (!strcmp(ans, "O") || !strcmp(ans, "o")) confirm = 1;
- if (!strcmp(ans, "N") || !strcmp(ans, "n")) confirm = 2;
- if (!strcmp(ans, "S") || !strcmp(ans, "s")) return GE_USERCANCELED;
+ if (!strcmp(ans, _("O")) || !strcmp(ans, _("o"))) confirm = 1;
+ if (!strcmp(ans, _("N")) || !strcmp(ans, _("n"))) confirm = 2;
+ if (!strcmp(ans, _("S")) || !strcmp(ans, _("s"))) return GE_USERCANCELED;
}
if (confirm == 1) break;
if (confirm == 2) {
if (!strcmp(argv[0], "op") || !strcmp(argv[0], "startup") || !strcmp(argv[0], "caller")) {
if (argc > 1) {
if (ReadBitmapFileOnConsole(argv[1], &bitmap) != GE_NONE) {
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return(-1);
}
if (!strcmp(argv[0], "op")) {
if (bitmap.type != GSM_OperatorLogo || argc < 3) {
- if (GSM->GetNetworkInfo(&NetworkInfo) == GE_NONE) strncpy(bitmap.netcode, NetworkInfo.NetworkCode, 7);
+ if (GSM && GSM->GetNetworkInfo && GSM->GetNetworkInfo(&NetworkInfo) == GE_NONE) strncpy(bitmap.netcode, NetworkInfo.NetworkCode, 7);
}
GSM_ResizeBitmap(&bitmap, GSM_OperatorLogo, GSM_Info);
if (argc == 3) {
}
oldbit.type = GSM_CallerLogo;
oldbit.number = bitmap.number;
- if (GSM->GetBitmap(&oldbit) == GE_NONE) {
+ if (GSM && GSM->GetBitmap && GSM->GetBitmap(&oldbit) == GE_NONE) {
/* We have to get the old name and ringtone!! */
bitmap.ringtone = oldbit.ringtone;
strncpy(bitmap.text, oldbit.text, 255);
}
} else {
fprintf(stderr, _("What kind of logo do you want to set ?\n"));
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return -1;
}
}
- error=GSM->SetBitmap(&bitmap);
+ if (GSM && GSM->SetBitmap) error = GSM->SetBitmap(&bitmap);
switch (error) {
case GE_NONE:
oldbit.type = bitmap.type;
oldbit.number = bitmap.number;
- if (GSM->GetBitmap(&oldbit) == GE_NONE) {
+ if (GSM && GSM->GetBitmap && GSM->GetBitmap(&oldbit) == GE_NONE) {
if (bitmap.type == GSM_WelcomeNoteText ||
bitmap.type == GSM_DealerNoteText) {
if (strcmp(bitmap.text, oldbit.text)) {
/* When we make it correct, we don't have this mistake */
strcpy(oldbit.text, "!\0");
- GSM->SetBitmap(&oldbit);
- GSM->GetBitmap(&oldbit);
+ if (GSM && GSM->SetBitmap) GSM->SetBitmap(&oldbit);
+ if (GSM && GSM->GetBitmap) GSM->GetBitmap(&oldbit);
if (oldbit.text[0]!='!') {
fprintf(stderr, _("SIM card and PIN is required\n"));
} else {
- GSM->SetBitmap(&bitmap);
- GSM->GetBitmap(&oldbit);
+ if (GSM && GSM->SetBitmap) GSM->SetBitmap(&bitmap);
+ if (GSM && GSM->GetBitmap) GSM->GetBitmap(&oldbit);
fprintf(stderr, _("too long, truncated to \"%s\" (length %i)\n"),oldbit.text,strlen(oldbit.text));
}
ok = false;
break;
}
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
}
}
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return error;
}
}
/* Error 22=Calendar full ;-) */
- if ((GSM->WriteCalendarNote(&CalendarNote)) == GE_NONE)
+ if (GSM && GSM->WriteCalendarNote && GSM->WriteCalendarNote(&CalendarNote) == GE_NONE)
fprintf(stdout, _("Succesfully written!\n"));
else
fprintf(stdout, _("Failed to write calendar note!\n"));
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
CalendarNote.Location = i;
- if (GSM->DeleteCalendarNote(&CalendarNote) == GE_NONE) {
+ if (GSM && GSM->DeleteCalendarNote && GSM->DeleteCalendarNote(&CalendarNote) == GE_NONE) {
fprintf(stdout, _(" Calendar note deleted.\n"));
} else {
fprintf(stderr, _("The calendar note can not be deleted\n"));
}
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
}
/* FIXME: Error checking should be here. */
- GSM->SetDateTime(&Date);
+ if (GSM && GSM->SetDateTime) GSM->SetDateTime(&Date);
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
/* In this mode we receive the date and time from mobile phone. */
-int getdatetime(void) {
+int getdatetime(void)
+{
GSM_Data data;
GSM_DateTime date_time;
GSM_Error error;
Date.Hour = atoi(argv[0]);
Date.Minute = atoi(argv[1]);
- GSM->SetAlarm(1, &Date);
+ if (GSM && GSM->SetAlarm) GSM->SetAlarm(1, &Date);
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
/* Loop here indefinitely - allows you to see messages from GSM code in
response to unknown messages etc. The loops ends after pressing the
Ctrl+C. */
- data.RFUnits=&rf_units;
- data.RFLevel=&rflevel;
- data.BatteryUnits=&batt_units;
- data.BatteryLevel=&batterylevel;
+ data.RFUnits = &rf_units;
+ data.RFLevel = &rflevel;
+ data.BatteryUnits = &batt_units;
+ data.BatteryLevel = &batterylevel;
while (!bshutdown) {
- if (SM_Functions(GOP_GetRFLevel,&data,sm) == GE_NONE)
+ if (SM_Functions(GOP_GetRFLevel, &data, sm) == GE_NONE)
fprintf(stdout, _("RFLevel: %d\n"), (int)rflevel);
- if (SM_Functions(GOP_GetBatteryLevel,&data,sm) == GE_NONE)
+ if (SM_Functions(GOP_GetBatteryLevel, &data, sm) == GE_NONE)
fprintf(stdout, _("Battery: %d\n"), (int)batterylevel);
// if (GSM->GetPowerSource(&powersource) == GE_NONE)
// fprintf(stdout, _("Power Source: %s\n"), (powersource==GPS_ACDC)?_("AC/DC"):_("battery"));
- data.MemoryStatus=&SIMMemoryStatus;
- if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE)
+ data.MemoryStatus = &SIMMemoryStatus;
+ if (SM_Functions(GOP_GetMemoryStatus, &data, sm) == GE_NONE)
fprintf(stdout, _("SIM: Used %d, Free %d\n"), SIMMemoryStatus.Used, SIMMemoryStatus.Free);
- data.MemoryStatus=&PhoneMemoryStatus;
- if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE)
+ data.MemoryStatus = &PhoneMemoryStatus;
+ if (SM_Functions(GOP_GetMemoryStatus, &data, sm) == GE_NONE)
fprintf(stdout, _("Phone: Used %d, Free %d\n"), PhoneMemoryStatus.Used, PhoneMemoryStatus.Free);
- data.MemoryStatus=&DC_MemoryStatus;
- if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE)
+ data.MemoryStatus = &DC_MemoryStatus;
+ if (SM_Functions(GOP_GetMemoryStatus, &data, sm) == GE_NONE)
fprintf(stdout, _("DC: Used %d, Free %d\n"), DC_MemoryStatus.Used, DC_MemoryStatus.Free);
- data.MemoryStatus=&EN_MemoryStatus;
- if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE)
+ data.MemoryStatus = &EN_MemoryStatus;
+ if (SM_Functions(GOP_GetMemoryStatus, &data, sm) == GE_NONE)
fprintf(stdout, _("EN: Used %d, Free %d\n"), EN_MemoryStatus.Used, EN_MemoryStatus.Free);
- data.MemoryStatus=&FD_MemoryStatus;
- if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE)
+ data.MemoryStatus = &FD_MemoryStatus;
+ if (SM_Functions(GOP_GetMemoryStatus, &data, sm) == GE_NONE)
fprintf(stdout, _("FD: Used %d, Free %d\n"), FD_MemoryStatus.Used, FD_MemoryStatus.Free);
- data.MemoryStatus=&LD_MemoryStatus;
- if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE)
+ data.MemoryStatus = &LD_MemoryStatus;
+ if (SM_Functions(GOP_GetMemoryStatus, &data, sm) == GE_NONE)
fprintf(stdout, _("LD: Used %d, Free %d\n"), LD_MemoryStatus.Used, LD_MemoryStatus.Free);
- data.MemoryStatus=&MC_MemoryStatus;
- if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE)
+ data.MemoryStatus = &MC_MemoryStatus;
+ if (SM_Functions(GOP_GetMemoryStatus, &data, sm) == GE_NONE)
fprintf(stdout, _("MC: Used %d, Free %d\n"), MC_MemoryStatus.Used, MC_MemoryStatus.Free);
- data.MemoryStatus=&ON_MemoryStatus;
- if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE)
+ data.MemoryStatus = &ON_MemoryStatus;
+ if (SM_Functions(GOP_GetMemoryStatus, &data, sm) == GE_NONE)
fprintf(stdout, _("ON: Used %d, Free %d\n"), ON_MemoryStatus.Used, ON_MemoryStatus.Free);
- data.MemoryStatus=&RC_MemoryStatus;
- if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE)
+ data.MemoryStatus = &RC_MemoryStatus;
+ if (SM_Functions(GOP_GetMemoryStatus, &data, sm) == GE_NONE)
fprintf(stdout, _("RC: Used %d, Free %d\n"), RC_MemoryStatus.Used, RC_MemoryStatus.Free);
// if (GSM->GetSMSStatus(&SMSStatus) == GE_NONE)
sleep(1);
}
- fprintf (stderr, _("Leaving monitor mode...\n"));
-
- //GSM->Terminate();
+ fprintf(stderr, _("Leaving monitor mode...\n"));
return 0;
}
}
#if 0
-// Uncomment it if used
+/* Uncomment it if used */
static GSM_Error OutputFn(char *Display, char *Indicators)
{
if (Display)
memset(&buf[0], 0, 102);
while (read(0, buf, 100) > 0) {
fprintf(stderr, "handling keys (%d).\n", strlen(buf));
- if (GSM->HandleString(buf) != GE_NONE)
+ if (GSM && GSM->HandleString && GSM->HandleString(buf) != GE_NONE)
fprintf(stdout, _("Key press simulation failed.\n"));
memset(buf, 0, 102);
}
} else
fprintf (stderr, _("Error!\n"));
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
char model[64];
profile.Number = 0;
- error = GSM->GetProfile(&profile);
+ if (GSM && GSM->GetProfile) error = GSM->GetProfile(&profile);
if (error == GE_NONE) {
- while (GSM->GetModel(model) != GE_NONE)
+ while (GSM && GSM->GetModel && GSM->GetModel(model) != GE_NONE)
sleep(1);
max_profiles = 7; /* This is correct for 6110 (at least my). How do we get
the number of profiles? */
- /*For N5110*/
- /*FIX ME: It should be set to 3 for N5130 and 3210 too*/
+ /* For N5110 */
+ /* FIXME: It should be set to 3 for N5130 and 3210 too */
if (!strcmp(model, "NSE-1"))
max_profiles = 3;
if (profile.Number < 0) {
fprintf(stderr, _("Profile number must be value from 1 to %d!\n"), max_profiles);
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return -1;
}
if (profile.Number >= max_profiles) {
fprintf(stderr, _("This phone supports only %d profiles!\n"), max_profiles);
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return -1;
}
} else {
profile.Number = i;
if (profile.Number != 0)
- GSM->GetProfile(&profile);
+ if (GSM && GSM->GetProfile) GSM->GetProfile(&profile);
fprintf(stdout, "%d. \"%s\"\n", profile.Number + 1, profile.Name);
if (profile.DefaultName == -1) fprintf(stdout, _(" (name defined)\n"));
} else {
if (error == GE_NOTIMPLEMENTED) {
fprintf(stderr, _("Function not implemented in %s model!\n"), model);
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return -1;
} else {
fprintf(stderr, _("Unspecified error\n"));
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return -1;
}
}
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
entry.Location = count;
- data.PhonebookEntry=&entry;
- error=SM_Functions(GOP_ReadPhonebook,&data,sm);
+ data.PhonebookEntry = &entry;
+ error = SM_Functions(GOP_ReadPhonebook, &data, sm);
if (error == GE_NONE) {
fprintf(stdout, "%s;%s;%s;%d;%d\n", entry.Name, entry.Number, memory_type_string, entry.Location, entry.Group);
GSM_PhonebookEntry aux;
aux.Location = entry.Location;
- error = GSM->GetMemoryLocation(&aux);
+ if (GSM && GSM->GetMemoryLocation) error = GSM->GetMemoryLocation(&aux);
if (error == GE_NONE) {
if (!aux.Empty) {
}
} else {
fprintf(stderr, _("Unknown error (%d)\n"), error);
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
}
/* Do write and report success/failure. */
- error = GSM->WritePhonebookLocation(&entry);
+ if (GSM && GSM->WritePhonebookLocation) error = GSM->WritePhonebookLocation(&entry);
if (error == GE_NONE)
fprintf (stdout, _("Write Succeeded: memory type: %s, loc: %d, name: %s, number: %s\n"), memory_type_string, entry.Location, entry.Name, entry.Number);
}
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
entry.Number = atoi(argv[0]);
entry.Location = atoi(argv[2]);
- if (GSM->SetSpeedDial(&entry) == GE_NONE) {
+ if (GSM && GSM->SetSpeedDial && GSM->SetSpeedDial(&entry) == GE_NONE) {
fprintf(stdout, _("Succesfully written!\n"));
}
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
{
int Status;
- GSM->GetDisplayStatus(&Status);
+ if (GSM && GSM->GetDisplayStatus) GSM->GetDisplayStatus(&Status);
fprintf(stdout, _("Call in progress: %s\n"), Status & (1<<DS_Call_In_Progress)?_("on"):_("off"));
fprintf(stdout, _("Unknown: %s\n"), Status & (1<<DS_Unknown)?_("on"):_("off"));
fprintf(stdout, _("Keyboard lock: %s\n"), Status & (1<<DS_Keyboard_Lock)?_("on"):_("off"));
fprintf(stdout, _("SMS storage full: %s\n"), Status & (1<<DS_SMS_Storage_Full)?_("on"):_("off"));
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
mode = 0x00;
memset(&Screen, 0, 50);
- GSM->NetMonitor(mode, Screen);
+ if (GSM && GSM->NetMonitor) GSM->NetMonitor(mode, Screen);
if (Screen)
fprintf(stdout, "%s\n", Screen);
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
char imei[64], model[64], rev[64], manufacturer[64];
GSM_Statemachine *sm = &State;
- data.Manufacturer=manufacturer;
- data.Model=model;
- data.Revision=rev;
- data.Imei=imei;
+ data.Manufacturer = manufacturer;
+ data.Model = model;
+ data.Revision = rev;
+ data.Imei = imei;
/* Retrying is bad idea: what if function is simply not implemented?
Anyway let's wait 2 seconds for the right packet from the phone. */
fprintf(stdout, _("Model: %s\n"), model);
fprintf(stdout, _("Revision: %s\n"), rev);
- //GSM->Terminate();
-
return 0;
}
int senddtmf(char *String)
{
- GSM->SendDTMF(String);
- GSM->Terminate();
+ if (GSM && GSM->SendDTMF) GSM->SendDTMF(String);
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
}
}
- GSM->Reset(_type);
- GSM->Terminate();
+ if (GSM && GSM->Reset) GSM->Reset(_type);
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
tool. */
int pmon(void)
{
-
GSM_Error error;
GSM_ConnectionType connection=GCT_Serial;
GSM_Statemachine sm;
return(-1);
}
- error = GSM->SendRingtone(&ringtone,argv[1]);
+ if (GSM && GSM->SendRingtone) 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);
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
-
}
return(-1);
}
- error = GSM->SetRingtone(&ringtone);
+ if (GSM && GSM->SetRingtone) error = GSM->SetRingtone(&ringtone);
if (error == GE_NONE)
fprintf(stdout, _("Send succeeded!\n"));
else
fprintf(stdout, _("Send failed\n"));
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
-
}
int presskeysequence(void)
memset(&buf[0], 0, 102);
while (read(0, buf, 100) > 0) {
fprintf(stderr, "handling keys (%d).\n", strlen(buf));
- if (GSM->HandleString(buf) != GE_NONE)
+ if (GSM && GSM->HandleString && GSM->HandleString(buf) != GE_NONE)
fprintf(stdout, _("Key press simulation failed.\n"));
memset(buf, 0, 102);
}
- GSM->Terminate();
+ if (GSM && GSM->Terminate) GSM->Terminate();
return 0;
}
-
+
+/* Options for --divert:
+ --op, -o [register|enable|query|disable|erasure] REQ
+ --type, -t [all|busy|noans|outofreach|notavail] REQ
+ --call, -c [all|voice|fax|data] REQ
+ --timeout, m time_in_seconds OPT
+ --number, -n number OPT
+ */
+int divert(int argc, char **argv)
+{
+ int opt;
+ GSM_CallDivert cd;
+ GSM_Statemachine *sm = &State;
+ GSM_Data data;
+ GSM_Error error;
+ struct option options[] = {
+ { "op", required_argument, NULL, 'o'},
+ { "type", required_argument, NULL, 't'},
+ { "call", required_argument, NULL, 'c'},
+ { "number", required_argument, NULL, 'n'},
+ { "timeout", required_argument, NULL, 'm'},
+ { NULL, 0, NULL, 0}
+ };
+
+ optarg = NULL;
+ optind = 0;
+
+ /* Skip --divert */
+ argc--; argv++;
+
+ memset(&cd, 0, sizeof(GSM_CallDivert));
+
+ while ((opt = getopt_long(argc, argv, "o:t:n:c:m:", options, NULL)) != -1) {
+ switch (opt) {
+ case 'o':
+ if (!strcmp("register", optarg)) {
+ cd.Operation = GSM_CDV_Register;
+ } else if (!strcmp("enable", optarg)) {
+ cd.Operation = GSM_CDV_Enable;
+ } else if (!strcmp("disable", optarg)) {
+ cd.Operation = GSM_CDV_Disable;
+ } else if (!strcmp("erasure", optarg)) {
+ cd.Operation = GSM_CDV_Erasure;
+ } else if (!strcmp("query", optarg)) {
+ cd.Operation = GSM_CDV_Query;
+ } else {
+ usage();
+ exit(-1);
+ }
+ break;
+ case 't':
+ if (!strcmp("all", optarg)) {
+ cd.DType = GSM_CDV_AllTypes;
+ } else if (!strcmp("busy", optarg)) {
+ cd.DType = GSM_CDV_Busy;
+ } else if (!strcmp("noans", optarg)) {
+ cd.DType = GSM_CDV_NoAnswer;
+ } else if (!strcmp("outofreach", optarg)) {
+ cd.DType = GSM_CDV_OutOfReach;
+ } else if (!strcmp("notavail", optarg)) {
+ cd.DType = GSM_CDV_NotAvailable;
+ } else {
+ usage();
+ exit(-1);
+ }
+ break;
+ case 'c':
+ if (!strcmp("all", optarg)) {
+ cd.CType = GSM_CDV_AllCalls;
+ } else if (!strcmp("voice", optarg)) {
+ cd.CType = GSM_CDV_VoiceCalls;
+ } else if (!strcmp("fax", optarg)) {
+ cd.CType = GSM_CDV_FaxCalls;
+ } else if (!strcmp("data", optarg)) {
+ cd.CType = GSM_CDV_DataCalls;
+ } else {
+ usage();
+ exit(-1);
+ }
+ break;
+ case 'm':
+ cd.Timeout = atoi(optarg);
+ break;
+ case 'n':
+ strcpy(cd.Number.number, optarg);
+ if (cd.Number.number[0] == '+') cd.Number.type = SMS_International;
+ else cd.Number.type = SMS_Unknown;
+ break;
+ default:
+ usage();
+ exit(-1);
+ }
+ }
+ data.CallDivert = &cd;
+ error = SM_Functions(GOP_CallDivert, &data, sm);
+
+ if (error == GE_NONE) {
+ fprintf(stderr, "Divert succeeded.\n");
+ } else {
+ fprintf(stderr, "%s\n", print_error(error));
+ }
+ return 0;
+}
+
/* This is a "convenience" function to allow quick test of new API stuff which
doesn't warrant a "proper" command line function. */
#ifndef WIN32
int foogle(char *argv[])
{
- /* Initialise the code for the GSM interface. */
- fbusinit(NULL);
- // Fill in what you would like to test here...
+ /* Fill in what you would like to test here... */
return 0;
}
#endif