SMS Server Tools 3
This site is hosted by Kekekasvi.com
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. Please login or register. Thu Mar 28, 2024 14:03
SMSTools3 Community » Help and support Bottom

[answered] Eventhandler or Checkhandler in C language

  This topic is locked

Page:  1

Author Post
Member
Registered:
Dec 2010
Location: DKI Jakarta, Indonesia
Operating system name and version: FreeBSD Version 8
Version of smsd: 3.1.11
Smsd installed from: sources
Name and model of a modem / phone: Sierra Aircard 850
Interface: serial

Hi there,

I have a question, whether I can use C programming language for eventhandler or checkhandler?

If yes, do you have a simple script to send and receive sms and store to DB?

Thank you in advance.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Any language, including C, can be used for eventhandler and checkhandler. Use language that is familiar to you.

Most of samples are written in Bash, or PHP, not in C.

Member
Registered:
Dec 2010
Location: DKI Jakarta, Indonesia
Topic owner
Oh I see, so means all I need to do is just write down the location of the file on smsd.conf


with the extension of the file regarding to the language, is it correct?

My second question, do I need to declare/include any file on the eventhandler?

My third question, I see on the eventhandler written in bash, the following code


I wonder, How do I distinguish the type of the sms?

Thank you in advance.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
maulana23 wrote
Oh I see, so means all I need to do is just write down the location of the file on smsd.conf


with the extension of the file regarding to the language, is it correct?

With PHP yes, and with Bash the extension is not mandatory, but can be used (to enable syntax highlight in some editors). But with C, of course the source file should not be defined, as the C is compiled language. I think that if you have never before used C, do not even try to use it in eventhandler.

maulana23 wrote
My second question, do I need to declare/include any file on the eventhandler?

It depends on the language. With C, headers of libraries should be included. With PHP, probably some external libraries and functions could be included, it depends on the solution. With Bash, in many cases all functionality is written in the same file, but external files can also be used.

maulana23 wrote
My third question, I see on the eventhandler written in bash, the following code


I wonder, How do I distinguish the type of the sms?

Such kind of a code should not exists. If you have seen that code on this board, or in the documentation or samples, please report so I can delete it ;).

First argument to the eventhandler defines the type. If can be "SENT", "RECEIVED", "FAILED", "REPORT" or "CALL". Just check the first argument, and you know the type. "CALL" means the incoming phonecall, it's not actual SMS. Second argument ($2 in shell script) is the name of SMS file.

Member
Registered:
Dec 2010
Location: DKI Jakarta, Indonesia
Topic owner
Hi Keke,

Thank you for your reply, and I apologies for the very late reply.

For PHP, I'm still wondering how do you get the SENT, RECEIVED, SENDER, RECEIVER, MSG?

Is it using the HTTP_GET and/or HTTP_POST? Something like this:


I have read this as well. From that post, does the php file define as eventhandler?

Yes, I'm actually not used to C in Linux/Unix environment, just in Windows env. And to be honest, I dont know how to compile the C in Unix/Linux env. XD

Thank you again in advance.

Member
Registered:
Dec 2010
Location: DKI Jakarta, Indonesia
Topic owner
Hi again Keke,

I have (ALSO) read :mrgreen: this. And this is actually what I'm looking for.

From there, i'm confused with

what items actually does it store? i believe

is one of them, can I use $sms_headers['SentTime'] to get the time of sms sent?

I have modified the smsd.conf and also chmod 755 the sms.php file
eventhandler = /usr/local/bin/sms.php
'smsdconf' Syntax Highlight powered by GeSHi


inside the sms.php file, I have included the koneksi.php (a file to connect to database). And I put the koneksi.php file under /usr/local/bin and chmod 755 the file as well.

but after I run and test receiving the sms.


What is wrong actually? What am I missing?

Thank you again in advance.

ps: I'm sorry if this getting out of topic, but I would like to continue discussing with you about this.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
maulana23 wrote
I have (ALSO) read :mrgreen: this. And this is actually what I'm looking for.

From there, i'm confused with

what items actually does it store? i believe

is one of them, can I use $sms_headers['SentTime'] to get the time of sms sent?

The first sample was a "web application". It requires a web server and is not meant to use as eventhandler.

The second sample is for eventhandler, as you have noticed. It reads the whole SMS file, and creates an array which contains all headers which are presented in the file. Use cat /var/spool/sms/incoming/GSM1.CF3eUt to see what headers are existing. Headers -part ends on the first blank line. There is no 'SentTime', but there is 'Sent' which tells the same thing. See fileformat for more details.

maulana23 wrote
inside the sms.php file, I have included the koneksi.php (a file to connect to database). And I put the koneksi.php file under /usr/local/bin and chmod 755 the file as well.

but after I run and test receiving the sms.


What is wrong actually? What am I missing?

Bad to say without seeing the script, but as the PHP says that "not found", something is just not found. You could check the code, and also you could test the functionality without giving the script to the smsd before it's tested. Manual testing can be done by calling the script from the command line:

# /usr/local/bin/sms.php RECEIVED /var/spool/sms/incoming/GSM1.CF3eUt

The script can be tested without receiving (and sending) SMS, as the incoming file already exists. It's also faster to make fixes, and test it again until it works as expected.

Member
Registered:
Dec 2010
Location: DKI Jakarta, Indonesia
Topic owner
Here is my smsd.conf
# Example smsd.conf. Read the manual for a description

devices = GSM1
logfile = /usr/logdata/smsdlog/smsd.log
loglevel = 7
smart_logging = yes
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
incoming = /var/spool/sms/incoming
eventhandler = /usr/local/bin/sms.php

#checkhandler = /usr/local/bin/multiplesms

stats = /var/spool/sms/stats

[queues]
INDONESIA = /var/spool/sms/INDONESIA
OTHER = /var/spool/sms/OTHER

[provider]
INDONESIA = 62
OTHER = 0,1,2,3,4,5,6,7,8,9


[GSM1]
device = /dev/cuau2
pre_init = yes
init = AT+CPMS="ME","ME","MT"
incoming = yes
outgoing = yes
queues = INDONESIA, OTHER
smsc = 6281100000
#pin = 1111
memory_start = 0
baudrate = 19200
mode = new
rtscts = yes
cs_convert = yes
 
 
'smsdconf' Syntax Highlight powered by GeSHi


This is my koneksi.php


And this is my sms.php


the smsd.conf is located in /usr/local/etc
koneksi.php and sms.php are located in /usr/local/bin and both with chmod 755.

I have tried to execute command you provided, but still not found.

Member
Registered:
Dec 2010
Location: DKI Jakarta, Indonesia
Topic owner
keke wrote
The first sample was a "web application". It requires a web server and is not meant to use as eventhandler.

Do you mean this?


So, should I remove this line?

keke wrote
The second sample is for eventhandler, as you have noticed. It reads the whole SMS file, and creates an array which contains all headers which are presented in the file. Use cat /var/spool/sms/incoming/GSM1.CF3eUt to see what headers are existing. Headers -part ends on the first blank line. There is no 'SentTime', but there is 'Sent' which tells the same thing. See fileformat for more details.

I see, means that I could use


and other information as written on the /var/spool/sms/incoming/GSM1.CF3eUt file. Is it case sensitive?

keke wrote
Bad to say without seeing the script, but as the PHP says that "not found", something is just not found. You could check the code, and also you could test the functionality without giving the script to the smsd before it's tested. Manual testing can be done by calling the script from the command line:

# /usr/local/bin/sms.php RECEIVED /var/spool/sms/incoming/GSM1.CF3eUt

The script can be tested without receiving (and sending) SMS, as the incoming file already exists. It's also faster to make fixes, and test it again until it works as expected.

I have followed your instruction, but still get error 'Not Found' message.

All those 3 files have been posted before this post.

Thank you again in advance.

Member
Registered:
Dec 2010
Location: DKI Jakarta, Indonesia
Topic owner
Update:
======

For the headers, I understand how it works.

For PHP, I could make it run, but then, it shows some errors. Below is the log


Now this is the problem I'm facing, hehe XD


« Last edit by maulana23 on Thu Mar 03, 2011 11:21, 159 months ago. »
Member
Registered:
Dec 2010
Location: DKI Jakarta, Indonesia
Topic owner
Finally after some research, I got it all working,..

PHP script executed from eventhandler, then store the information extracted to DB.

My problem to execute php script solved by changing
#!/usr/bin/php to #!/usr/local/bin/php
'smsdconf' Syntax Highlight powered by GeSHi

since I'm using FreeBSD.

And those warning I got is because I uncommented some extension on the php.ini, while actual extension is stored on different file /usr/local/etc/php/extension.ini. So, what I did just to re-comment some of the extensions stated on the log before.

Thank you again Keke.

Sorry if I disturb you by asking some Newbie questions :D

Have a good day mate.

  This topic is locked

Page:  1

SMSTools3 Community » Help and support Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.