|
|
SMS Server Tools 3 Community |
Welcome, Guest. The forum is currently read-only, but will open soon. |
Fri Mar 14, 2025 14:36 |
Page: 1
Keywords: Mode: All keywords (AND) |
Thu Jun 09, 2016 16:02
|
pkeroulas: It's complicated to support so many different modems. However, the download page shows a recent 3.1.16 beta version which may address this in a better way.
No matter if you try 3.1.16 or patch 3.1.15, you have no choice but downloading the source and rebuild.
Looking at the Makefile, it should be straight forward:
make compile
Just make sure the package is removed before you install the custom tool.
|
Thu Jun 09, 2016 13:49
|
pkeroulas: Not sure I understand your difficulty.
It's been a while, but we're running the version of smsd, so Linux patch tool should be able to apply the fix on source.
Then you'll probably need to insert your CMGF somewhere.
Does that help?
Thanks
|
Wed Feb 19, 2014 21:34
|
pkeroulas: Operating system name and version: Ubuntu 12.04.4 LT, x86_64
Version of smsd: 3.1.15
Smsd installed from: sources
Name and model of a modem / phone: MicroHard IPn4G
Interface: serial
My modem only support sms messages in text mode, not PDU. Therefore, I added the option 'sms_mode' in the conf file for this device. In this case, the GSM character conversion must be disabled.
devices = MicroHard_IPn4G
logfile = /var/log/syslog
infofile=/var/run/smsd/smsd.working
pidfile=/var/run/smsd/smsd.pid
loglevel = 7
#Default value: 4 for logfile, 7 for syslog.
# Settings to run smsd without root priviledges:
user = root
group = dialout
delaytime = 1
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
incoming = /var/spool/sms/incoming
[MicroHard_IPn4G]
device = /dev/ttyS4
rtscts = no
pre_init = no
read_timeout = 1
serial_login = admin
serial_password = password
pin = ignore
check_network = 0
status_signal_quality = no
incoming = no
# sms PDU mode (0) or text mode (1)
sms_mode = 1
cs_convert = no
detect_unexpected_input = no
For more details on the other options, check my previous thread.
Basically, the patch reads the sms_mode in the conf file. In text mode, make_pdu() isn't used and the message buffer is copied as is.
diff --git a/smstools3/src/smsd.c b/smstools3/src/smsd.c
index 3cc6377..4175619 100755
--- a/smstools3/src/smsd.c
+++ b/smstools3/src/smsd.c
@@ -3761,29 +3761,41 @@ int send_part(char* from, char* to, char* text, int textlen, int alphabet, int w
}
}
- // Compose the modem command
- make_pdu(to,text,textlen,alphabet,flash,report,with_udh,udh_data,DEVICE.mode,pdu,validity, replace_msg, system_msg, to_type, smsc);
- if (strcasecmp(DEVICE.mode,"old")==0)
- sprintf(command,"AT+CMGS=%i\r",(int)strlen(pdu)/2);
- else
- sprintf(command,"AT%s+CMGS=%i\r", (DEVICE.verify_pdu)? "E1" : "", (int)strlen(pdu)/2-1); // 3.1.4: verify_pdu
-
- sprintf(command2,"%s\x1A",pdu);
-
- if (store_sent_pdu)
+ if(DEVICE.sms_mode == 0)
{
- char *title = "PDU: ";
+ make_pdu(to,text,textlen,alphabet,flash,report,with_udh,udh_data,DEVICE.mode,pdu,validity, replace_msg, system_msg, to_type, smsc);
+ if (strcasecmp(DEVICE.mode,"old")==0)
+ sprintf(command,"AT+CMGS=%i\r",(int)strlen(pdu)/2);
+ else
+ sprintf(command,"AT%s+CMGS=%s\r", (DEVICE.verify_pdu)? "E1" : "", to); // 3.1.4: verify_pdu
- if (!outgoing_pdu_store)
- {
- if ((outgoing_pdu_store = (char *)malloc(strlen(title) +strlen(pdu) +2)))
- *outgoing_pdu_store = 0;
- }
- else
- outgoing_pdu_store = (char *)realloc((void *)outgoing_pdu_store, strlen(outgoing_pdu_store) +strlen(title) +strlen(pdu) +2);
+ sprintf(command2,"%s\x1A",text);
+
+ if (store_sent_pdu)
+ {
+ char *title = "PDU: ";
- if (outgoing_pdu_store)
- sprintf(strchr(outgoing_pdu_store, 0), "%s%s\n", title, pdu);
+ if (!outgoing_pdu_store)
+ {
+ if ((outgoing_pdu_store = (char *)malloc(strlen(title) +strlen(pdu) +2)))
+ *outgoing_pdu_store = 0;
+ }
+ else
+ outgoing_pdu_store = (char *)realloc((void *)outgoing_pdu_store, strlen(outgoing_pdu_store) +strlen(title) +strlen(pdu) +2);
+
+ if (outgoing_pdu_store)
+ sprintf(strchr(outgoing_pdu_store, 0), "%s%s\n", title, pdu);
+ }
+ }
+ else if(DEVICE.sms_mode == 1)
+ {
+ // Compose the modem command in text mode
+ sprintf(command,"AT%s+CMGS=%s\r", (DEVICE.verify_pdu)? "E1" : "", to); // 3.1.4: verify_pdu
+ char buf[160];
+ strncpy(buf, text, textlen);
+ buf[textlen] = '\0';
+ sprintf(command2,"%s\x1A",buf);
+ writelogfile(LOG_NOTICE, 0, "sent, Message: %s=>%s, l=%i.", text, buf, textlen);
}
@@ -3878,11 +3892,11 @@ int send_part(char* from, char* to, char* text, int textlen, int alphabet, int w
{
char answer2[1024];
- put_command("ATE0\r", answer2 ,sizeof(answer2), 1, EXPECT_OK_ERROR);
+ put_command("\r", answer2 ,sizeof(answer2), 1, EXPECT_OK_ERROR);
}
// Check answer
if (strstr(answer,"OK"))
diff --git a/smstools3/src/smsd_cfg.c b/smstools3/src/smsd_cfg.c
index 7884efa..cb3e4bd 100755
--- a/smstools3/src/smsd_cfg.c
+++ b/smstools3/src/smsd_cfg.c
@@ -335,6 +335,10 @@ void initcfg()
devices.keep_messages = 0;
devices.trust_spool = 1;
devices.smsc_pdu = 0;
+ devices.sms_mode = 0;
devices.telnet_login[0] = 0;
snprintf(devices.telnet_login_prompt, sizeof(devices.telnet_login_prompt), "%s", TELNET_LOGIN_PROMPT_DEFAULT);
snprintf(devices.telnet_login_prompt_ignore, sizeof(devices.telnet_login_prompt_ignore), "%s", TELNET_LOGIN_PROMPT_IGNORE_DEFAULT);
@@ -1647,6 +1651,24 @@ int readcfg()
startuperror(yesno_error, name, value);
}
else
+ if (strcasecmp(name,"sms_mode")==0)
+ {
+ if ((NEWDEVICE.sms_mode = yesno_check(ask_value(NEWDEVICE.name, name, value))) == -1)
+ startuperror(yesno_error, name, value);
+ }
+ else
if (strcasecmp(name,"telnet_login")==0)
strcpy2(NEWDEVICE.telnet_login, ask_value(NEWDEVICE.name, name, value));
else
diff --git a/smstools3/src/smsd_cfg.h b/smstools3/src/smsd_cfg.h
index 70221c2..5f6c88e 100755
--- a/smstools3/src/smsd_cfg.h
+++ b/smstools3/src/smsd_cfg.h
@@ -221,6 +221,10 @@ typedef struct
char stopstring[100]; // 3.1.7: Command(s) to send to the modem when a devicespooler is stopping.
int trust_spool; // 3.1.9
int smsc_pdu; // 3.1.12: 1 if smsc is included in the PDU.
+ int sms_mode; // 0 for PDU, 1 for TEXT
char telnet_login[64]; // 3.1.12: Settings for telnet.
char telnet_login_prompt[64];
char telnet_login_prompt_ignore[64];
|
Wed Feb 19, 2014 20:25
|
pkeroulas: I fixed it. A login was added to the conf file in the device section.
Several features were also disabled because MicroHard IPn4G modem doesn't support the corresponding AT commands.
# Example smsd.conf. Read the manual for a description
devices = MicroHard_IPn4G
logfile = /var/log/syslog
infofile=/var/run/smsd/smsd.working
pidfile=/var/run/smsd/smsd.pid
loglevel = 7
#Default value: 4 for logfile, 7 for syslog.
# Settings to run smsd without root priviledges:
user = root
group = dialout
delaytime = 1
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
incoming = /var/spool/sms/incoming
[MicroHard_IPn4G]
device = /dev/ttyS4
rtscts = no
pre_init = no
read_timeout = 1
serial_login = admin
serial_password = password
pin = ignore
check_network = 0
status_signal_quality = no
incoming = no
cs_convert = no
detect_unexpected_input = no
And here is the patch:
diff --git a/smstools3/src/modeminit.c b/smstools3/src/modeminit.c
index 4fc39c5..c317363 100755
--- a/smstools3/src/modeminit.c
+++ b/smstools3/src/modeminit.c
@@ -1252,37 +1252,39 @@ int initmodem(char *new_smsc, int receiving)
read_from_modem(answer, sizeof(answer), 2);
}
+ *answer = 0;
+ put_command("AT\r", answer, sizeof(answer), 1, EXPECT_OK_ERROR);
+
retries=0;
do
{
- flush_smart_logging();
-
- retries++;
- put_command("AT\r", answer, sizeof(answer), 1, EXPECT_OK_ERROR);
- if (!strstr(answer, "OK") && !strstr(answer, "ERROR"))
- {
- if (terminate)
- return 7;
-
- // if Modem does not answer, try to send a PDU termination character
- put_command("\x1A\r", answer, sizeof(answer), 1, EXPECT_OK_ERROR);
-
- if (terminate)
- return 7;
- }
-
- // 3.1.7: If it looks like modem does not respond, try to close and open the port:
- if (retries >= 5 && !strstr(answer, "OK"))
- {
- try_closemodem(1);
- t_sleep(1);
+ flush_smart_logging();
- // If open fails, nothing can be done. Error is already logged. Will return 1.
- if (!try_openmodem())
- break;
- }
+ if (strstr(answer, "OK"))
+ {
+ writelogfile(LOG_INFO, 0, "Login succedeed.");
+ break;
+ }
+ else if (strstr(answer, "login"))
+ {
+ *answer = 0;
+ writelogfile0(LOG_ERR, 1, tb_sprintf(" Use login: %s and passwd: %s ",
+ DEVICE.serial_login, DEVICE.serial_password));
+ sprintf(command, "%s\r", DEVICE.serial_login);
+ put_command(command, answer, sizeof(answer), 1, 0);
+ }
+ else if (strstr(answer, "Password"))
+ {
+ *answer = 0;
+ sprintf(command, "%s\r", DEVICE.serial_password);
+ put_command(command, answer, sizeof(answer), 3, 0);
+ }
+ else
+ put_command("AT\r", answer, sizeof(answer), 1, EXPECT_OK_ERROR);
}
- while (retries <= 10 && !strstr(answer,"OK"));
+ while (retries++ < 10);
+
if (!strstr(answer,"OK"))
{
// 3.1: more detailed error message:
diff --git a/smstools3/src/smsd_cfg.c b/smstools3/src/smsd_cfg.c
index 7884efa..cb3e4bd 100755
--- a/smstools3/src/smsd_cfg.c
+++ b/smstools3/src/smsd_cfg.c
@@ -335,6 +335,10 @@ void initcfg()
devices.keep_messages = 0;
devices.trust_spool = 1;
devices.smsc_pdu = 0;
+ devices.serial_login[0] = 0;
+ devices.serial_password[0] = 0;
devices.telnet_login[0] = 0;
snprintf(devices.telnet_login_prompt, sizeof(devices.telnet_login_prompt), "%s", TELNET_LOGIN_PROMPT_DEFAULT);
snprintf(devices.telnet_login_prompt_ignore, sizeof(devices.telnet_login_prompt_ignore), "%s", TELNET_LOGIN_PROMPT_IGNORE_DEFAULT);
@@ -1647,6 +1651,24 @@ int readcfg()
startuperror(yesno_error, name, value);
}
else
+ if (strcasecmp(name,"serial_login")==0)
+ strcpy2(NEWDEVICE.serial_login, ask_value(NEWDEVICE.name, name, value));
+ else
+ if (strcasecmp(name,"serial_password")==0)
+ strcpy2(NEWDEVICE.serial_password, ask_value(NEWDEVICE.name, name, value));
+ else
if (strcasecmp(name,"telnet_login")==0)
strcpy2(NEWDEVICE.telnet_login, ask_value(NEWDEVICE.name, name, value));
else
diff --git a/smstools3/src/smsd_cfg.h b/smstools3/src/smsd_cfg.h
index 70221c2..5f6c88e 100755
--- a/smstools3/src/smsd_cfg.h
+++ b/smstools3/src/smsd_cfg.h
@@ -221,6 +221,10 @@ typedef struct
char stopstring[100]; // 3.1.7: Command(s) to send to the modem when a devicespooler is stopping.
int trust_spool; // 3.1.9
int smsc_pdu; // 3.1.12: 1 if smsc is included in the PDU.
+ char serial_login[64];
+ char serial_password[64];
char telnet_login[64]; // 3.1.12: Settings for telnet.
char telnet_login_prompt[64];
char telnet_login_prompt_ignore[64];
|
Tue Feb 04, 2014 20:13
|
pkeroulas: Operating system name and version: Ubuntu 12.04.4 LT, x86_64
Version of smsd: 3.1.15
Smsd installed from: sources
Name and model of a modem / phone: MicroHard IPn4G
Interface: serial
Hi,
I'm trying to integrate SMSTools3 with my modem, via serial port (I can't use telnet).
However, a login is required to access the AT cmd interface . Don't know how common this feature is.
I can't find any reference to this feature in the source code. And the "init" field in smsd.conf is for a regular AT cmd.
Do I have to hack the initmodem method?
thanks,
pk.
|
Page: 1
Time in this board is UTC.
|
|
|
 |
|
 |
|