Keywords: Mode: All keywords (AND) |
Thu Aug 15, 2013 16:39
|
chadpriddle: Operating system name and version: Ubuntu 12.04.1 LTS
Version of smsd: 3.1.15
Smsd installed from: This site
Name and model of a modem / phone: Option ICON 322
Interface: USB
Towards the end of this event handler I want to put the date, time stamp and modem in the GET part of the URL string along with the from number and message.
#!/usr/bin/php
<?php
$sms_type = $argv[1];
$sms_file = $argv[2];
$sms_file_content = file_get_contents($sms_file);
$i = strpos($sms_file_content, "\n\n");
$sms_headers_part = substr($sms_file_content, 0, $i);
$sms_message_body = substr($sms_file_content, $i + 2);
$sms_header_lines = split("\n", $sms_headers_part);
$sms_headers = array();
foreach ($sms_header_lines as $header)
{
$i = strpos($header, ":");
if ($i !== false)
$sms_headers[substr($header, 0, $i)] = substr($header, $i + 2);
}
if ($sms_type == "RECEIVED")
{
$to_exec = "wget -q \"http://localhost/sms/index.php"
."?sender=" .$sms_headers['From']
."&message=" .urlencode($sms_message_body)
."\" -O /dev/null";
exec($to_exec);
}
|
Tue Dec 21, 2010 10:54
|
chadpriddle:
I figured it out! :D
It WAS an issue with the device mapping on the USB BUS. I read on a lot of different forums with people having issues with USB devices getting swapped around because every time udev gets restarted it might reassign it a new tty* ID. And it also does not help that I am using a 7 port USB powered hub and it also doesnt help that my ICON Option 322 GSM modems don't provide a unique serial number per device when I get the udev info, and my specific USB modems create 5 different tty* mounts per modem; example: ttyHS1 = Control, ttyHS2 = Application, ttyHS4 = Diagnostic2, ttyHS5 = Modem, ttyHS6 = Diagnostic.
My solution is to create symlinks for each kernel that maps to the BUS and then to the specific port on the hub. So as long as I label my modems and plug them into the right port everything should sync up the way it was intended.
Create a new rule file:
/etc/udev/rules.d/65-gsm-modems.rules
sudo chmod 644 /etc/udev/rules.d/65-gsm-modems.rules
Create a symlink per line in the file:
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", KERNELS=="1-3.1:1.0", SYMLINK+="BUS3-HUB1-PORT1"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", KERNELS=="1-3.2:1.0", SYMLINK+="BUS3-HUB1-PORT2"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", KERNELS=="1-3.3:1.0", SYMLINK+="BUS3-HUB1-PORT3"
As in the example above my hub is plugged into the "3" BUS on my motherboard and then the following number "1" is the port number and then the "1.0" is just the modem specific modes (Control). You might have to restart your server to get the new symlink rules to get working.
Info on how udev works:
http://reactivated.net/writing_udev_rules.html#udevinfo
To figure out the variables that you need to find, type this:
lsusb
This will output your USB devices
ls /dev/tty*
This will output the devices that are available to choose from. In my case they were the "ttyHS0" through "ttyHS15"
Now what is probably the easiest is to plug one USB modem in and then repeat this process on each port to get the kernel values, they should be towards the beginning of the output.
sudo udevadm info -n /dev/ttyHS0 -a
sudo udevadm info -n /dev/ttyHS1 -a
sudo udevadm info -n /dev/ttyHS2 -a
etc...
And then update your smsd.conf file:
[GSM1]
device = /dev/BUS3-HUB1-PORT1
[GSM2]
device = /dev/BUS3-HUB1-PORT2
[GSM3]
device = /dev/BUS3-HUB1-PORT3
Restart sms3
service sms3 restart
Hope this helps someone else as it was really frustrating me!! No fault to keke or the sms3 software and my configuration was correct too but the devices paths were screwed up.
|
Tue Dec 21, 2010 09:04
|
chadpriddle:
Have I understood you correctly?: When you receive a message to your phone, it seems that it was sent by GSM1. And when you use GSM2 to send the message, still the message is received from a number which belongs to SIM card in GSM1 device?
Yes exactly.
You could change the loglevel to 7. After you restart the smsd, all modems will report CGSN (serial number) and IMSI in the log. Those should be all different. Are they?
Yes, I'm getting different CGSN and IMSI numbers in the log per modem.
When I originally looked in the smsd.log it was about 3mb of text and towards the bottom a lot of little image boxes like it couldn't read the text. So I just copied the file over and deleted everything in the log and restarted the service and then the log seemed to be running more smoothly. Any reasons as to why it got corrupt? Or is that a common thing?
|
Sun Dec 19, 2010 20:29
|
|
Sun Dec 19, 2010 19:24
|
chadpriddle: I have 3 gsm modems with 3 different activated sims. The IMSI number that it's pulling I think is from GSM1 because when it sends back out it's defaulting to GSM1
|
Sat Dec 18, 2010 21:11
|
chadpriddle: Operating system name and version: Ubuntu Server 10.10
Version of smsd: 3.1.14
Name and model of a modem / phone: (3) Option ICON 322
Interface: USB
I'm having trouble with sending and receiving from multiple modems. I searched the forums and have tried different configurations and I cannot get the receiving message to go to the correct GSM device
My config file:
# Global configuration
devices = GSM1,GSM2,GSM3
loglevel = 4
logfile = /var/log/sms/smstools.log
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
incoming = /var/spool/sms/incoming
sent = /var/spool/sms/sent
delaytime = 6
errorsleeptime = 12
blocktime = 180
autosplit = 3
receive_before_send = yes
[queues]
GSM1 = /var/spool/sms/GSM1
GSM2 = /var/spool/sms/GSM2
GSM3 = /var/spool/sms/GSM3
[providers]
GSM1 = 0,1,2,3,4,5,6,7,8,9,s
GSM2 = 0
GSM3 = 0
# Modem configuration
[GSM1]
device = /dev/ttyHS0
incoming = yes
baudrate = 115200
queues = GSM1
[GSM2]
device = /dev/ttyHS3
incoming = yes
baudrate = 115200
queues = GSM2
[GSM3]
device = /dev/ttyHS6
incoming = yes
baudrate = 115200
queues = GSM3
eventhandler = /usr/local/bin/sms/index.php
When a message is spooled it goes in the correct GSM folder to be queued but when the message reaches my phone it keeps defaulting to GSM1.
These are what is in the sent folder:
To: 1916XXXXXXX
Queue: GSM3
Modem: GSM3
Sent: 10-12-18 13:00:04
IMSI: 310410362590413
Test text message
To: 1916XXXXXXX
Queue: GSM2
Modem: GSM2
Sent: 10-12-18 12:43:59
IMSI: 310410362590413
Test text message
Everything seems to be working. I've rebooted and restarted the service multiple times. And I also know that the /dev/tty* locations are correct because I've tested them without all the queues and the message sends out to the right number.
My goal is to receive a message from GSM1 and send back out to GSM1, receive from GSM2 and send back out to GSM2, etc.
Thanks in advanced!! :D
|
Thu Dec 16, 2010 19:20
|
chadpriddle: Well if thats the case then I would be better off keeping my website and database with a third party hosting company that manages my server with dual quad core xeon processors and 16gb of ram and then host my sms server on my own and just manage it myself because then i can have physical access to the modems and sim cards.
My test server right now:
ASUS NCLV-D server motherboard
Dual Xeon processors
2GB ECC Ram
2 (1) TB SATA hardrives running RAID 1
Dual gigabyte ethernet
Ubuntu Server 10.10
|
Wed Dec 15, 2010 21:38
|
chadpriddle: Operating system name and version: Ununtu 10.10 or CentOS 5.5
Version of smsd: Latest
Name and model of a modem / phone: Option ICON 322
Interface: USB
I'm looking for some hardware specs on dedicated server. I would like to run SMS Server Tools 3, my website, mysql and PHP all on one server with about 30 GSM USB modems that will send and receive messages individually. I mean are we talking dual core processors and 2GB of RAM or something more powerful? I dont want the system to get bogged down where it takes 60 seconds for it to post back a text message.
Thanks in advance!!
|
Tue Dec 14, 2010 20:19
|
chadpriddle: This is software is amazing! Thanks for everything
FYI
I have Ubuntu server running SMS Server Tools 3, PHP and Apache with my scripts to tell what the incoming/outgoing texts should do. My business website with the SQL database is hosted separately. I'm looking into hosting everything all on one server or at lease on the same local network.
|
Tue Dec 14, 2010 12:30
|
chadpriddle: Do you mean I should add the LOCK and then when the file is done being created then I should rename it after is is complete?! Because that makes sense to me
|
Tue Dec 14, 2010 12:27
|
chadpriddle: So the files in the outgoing folder should have ".LOCK" at the end? Example: "sms_send_581204.LOCK"
I modified my script and now the files won't send out, they just stay in the outgoing folder. Could you please clarify?
|
Tue Dec 14, 2010 11:40
|
chadpriddle: I know this is really basic:
$filename = "/var/spool/sms/outgoing/sms_send_" .date("siH");
$fp = fopen($filename,'w');
$nextline = "To: $from_number" ."\r\n" ."\r\n$respond_text" ."\r\n";
fwrite($fp,$nextline);
fclose($fp);
I'm sure I'm going to have to so some string conversion to make sure everything pass through correctly.
Everything works perfectly tho! I'm so stoked :mrgreen:
|
Tue Dec 14, 2010 06:53
|
chadpriddle: I got it to work! Thanks for your help! The problem was that the index.php file that was being called from the eventhandler was orginally created in windows so I did some research and used dos2unix command to convert it and then it worked and now not only does the wget command work in terminal, it also works when I send a text to the modem from my phone!! :)
One more thing! lol Sorry :/
Since I am running the PHP script from localhost how might I post back a message to the the same GSM modem that recieved the message for example:
Text sent to GMS1 "Hello"
Runs through PHP scripts
Updates sql database
Then at the end of the script it automatically replies back to the number that sent it
GSM1 replies: "Thanks for texting me"
Is that done through another eventhandler or is it done through PHP on the Apache side?
|
Mon Dec 13, 2010 23:54
|
chadpriddle: I get:
bash: syntax error near unexpected token `newline'
|
Sun Dec 12, 2010 20:29
|
chadpriddle: Apache did not log anything for the script to be called. And yes wget is installed as i have Ubuntu 10.10
|
Sun Dec 12, 2010 19:09
|
chadpriddle: Thanks for the response!
This is what I have so far:
smsd.conf
# Global configuration
devices = GSM1
loglevel = 4
logfile = /var/log/sms/smstools.log
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
incoming = /var/spool/sms/incoming
sent = /var/spool/sms/sent
delaytime = 6
errorsleeptime = 12
blocktime = 180
autosplit = 3
receive_before_send = yes
# Modem configuration
[GSM1]
#init =
device = /dev/ttyHS0
incoming = yes
#pin =
baudrate = 115200
eventhandler = /usr/local/bin/sms/index.php
index.php file that is called from eventhandler
#!/usr/bin/php
<?php
$sms_type = $argv[1];
$sms_file = $argv[2];
$sms_file_content = file_get_contents($sms_file);
$i = strpos($sms_file_content, "\n\n");
$sms_headers_part = substr($sms_file_content, 0, $i);
$sms_message_body = substr($sms_file_content, $i + 2);
$sms_header_lines = split("\n", $sms_headers_part);
$sms_headers = array();
foreach ($sms_header_lines as $header)
{
$i = strpos($header, ":");
if ($i !== false)
$sms_headers[substr($header, 0, $i)] = substr($header, $i + 2);
}
if ($sms_type == "RECEIVED")
{
$to_exec = "wget -q \"http://localhost/sms/sms.php"
."?sender=" .$sms_headers['From']
."&message=" .urlencode($sms_message_body)
."\" -O /dev/null";
exec($to_exec);
}
When I send a text message it seems to not go to my apache server with the GET variables to run my script. I've restarted the service multiple times with no errors and all my files & folders are executable. Do I have something wrong?
|
Sat Dec 11, 2010 01:53
|
chadpriddle: Operating system name and version: Ubuntu 10.10
Version of smsd: 3.1.14
Name and model of a modem / phone: Option ICON 322 Unlocked
Interface: USB
I got my modem sending and receiving messages without a problem, but now I'd like to do something with those incoming and outgoing messages. I've searched on the forums and have messed around with the eventhandler function but cannot get it to work.
My goal is to receive a message, have the eventhandler extract all the data from the text and turn it into variables (from_number, date, message, etc.) and then have the shell script execute the php files that I have in /var/www/sms/sms.php so that when the php files are executed they run through a series of checks and update my SQL database.
So i guess i would like an example of the shell script that would be called and then what would the smsd.conf file look like with the eventhandler called?
I've also messed around with a popular program called "NowSMS" for windows and they allow to post the incoming messages to HTTP with a bunch of GET variables but I don't know if this linux program could do something like this.
Thanks in advanced!!
Chad
|