Create your own SMS Server/Gateway

Robert AndresenProgramming, Tutorials 6 Comments

This tutorial will guide you through the install of an SMS server on a Windows 2008 R2 server (I have also tested it successfully on W7, W8 and 2012 server).

My setup for this guide:

  • Physical server running Windows 2008 R2 (64-bit)
  • Wamp server (PHP, MySQL…)
  • Huawei E230 USB 3G Modem
  • Diafaan software
  • MySQL connector ODBC 32-bit

Diafaan SMS Gateway

Diafaan is a SMS software for Windows-platform. Diafaan has support for several of «SMS modems/devices», like 3G modems, dedicated SMS gateways, android phone, etc…

They have some great manuals and reviews on different SMS-devices on their webpage.

Webpage:  http://www.diafaan.com/

Prices (at publishing date) is from $195 to $995. They have three versions: light, basic and full. The difference is mostly how many gateways and connector you can add.

Diafaan communication software dates back to 1992 on their homepage, and the have released 3-4 software updates each year for the last years. So they seems pretty serious of what their doing 🙂

Modem

I found a Huawei E230 3G modem at home. At diafaan they only testet the E220, but E230 seems to be working just fine 🙂 You can get the E220 for about $20 (120 NOK) at ebay.

Short summary of the installation:

  1. Download the software
  2. Install Diafaan
  3. Install ODBC driver
  4. Set up a Gateway in Diafaan
  5. Set up MySQL connector
  6. Set up a Web connector
  7. Send an SMS

I will not show how to install MySQL. Simple way to do this, is to download Wamp server, that is an developer package that includes PHP, MySQL, Apache, PHPMyAdmin, etc…

Step-by-step installation

1. Download Diafaan software

Go to http://www.diafaan.com/ to download a FREE trial for 30-days.

diafaan_smsserver_01

2. Install Diafaan software

This should be straight forward and the only user-input needed is to check the license-agreement (and the install path if you don’t want it to be default).

diafaan_smsserver_02

3. Download ODBC driver

This step is only needed if you are going to use is with MySQL.

Go to http://dev.mysql.com/downloads/connector/odbc/ to download. In my case I only got the 32-bit ODBC to work. Remember you don’t need a user to download, just click download at the bottom of the page (after you clicked the first download button).

diafaan_smsserver_16

4. Install ODBC

Just click next, next, next all the way…

diafaan_smsserver_19

5. Going back to Diafaan

As you start Diafaan, you should get a wizard.

Create a admin-user for your Diafaan installation.

diafaan_smsserver_08

6. Select gateway type

Select which gateway type you want to set up. In my case I have a Huawei E230 as mentioned, so I select the «GSM Modem Gateway».

diafaan_smsserver_09

7. Add GSM Modem

Find you GSM modem in the dropdown-list, input the pin code and click the Test-button. I also had to input the SIM-card’s phone number for some reason.

Wonder what would happen if I write another number? 🙂

diafaan_smsserver_11

8. Name your gateway

I went with the default name. If you are going to have multiple gateways, for ex. multiple customers – you could write the customer name.

diafaan_smsserver_12

9. Select a connector

Select which connector you want. I’m starting with the SQL Connector, but will install the Web connector later in this tutorial.

Connector is the way you want to handle your messages. If you have a website, the SQL could be great, just insert message in the database and it will be sent automatically – but the Web connector has a URL-parameter you can use to send messages with from your webpage/application. To use both, you need at least the basic license.

diafaan_smsserver_13

10. Select database type

I have an MySQL database, so I’m selecting the ODBC.

diafaan_smsserver_14

In the next step you’ll need to connect to your database with the ODBC connector. This means that you need a MySQL database, user and a password ready. You don’t need any tables in your database yet, as you define which tables and columns the Diafaan is going to use in the next steps.

But to make it simple, we are going to use Diafaan’s sample database from their manual here: http://www.diafaan.com/how-to/mysql-database/.

11. Creating the database and structure with PHPMyAdmin

diafaan_smsserver_26

diafaan_smsserver_27

The Diafaan database example from their webpage:


CREATE DATABASE SMSServer DEFAULT CHARACTER SET utf8;

CREATE TABLE MessageOut (
Id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
MessageTo VARCHAR(80),
MessageFrom VARCHAR(80),
MessageText TEXT,
MessageType VARCHAR(20),
Gateway VARCHAR(80),
UserId VARCHAR(80),
UserInfo TEXT,
Priority INT,
Scheduled DATETIME,
IsSent TINYINT(1) NOT NULL DEFAULT 0,
IsRead TINYINT(1) NOT NULL DEFAULT 0) CHARACTER SET utf8;

CREATE TABLE MessageIn (
Id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
SendTime DATETIME,
ReceiveTime DATETIME,
MessageFrom VARCHAR(80),
MessageTo VARCHAR(80),
SMSC VARCHAR(80),
MessageText TEXT,
MessageType VARCHAR(20),
MessagePDU TEXT,
Gateway VARCHAR(80),
UserId VARCHAR(80)) CHARACTER SET utf8;

CREATE TABLE MessageLog (
Id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
SendTime DATETIME,
ReceiveTime DATETIME,
StatusCode INT,
StatusText VARCHAR(80),
MessageTo VARCHAR(80),
MessageFrom VARCHAR(80),
MessageText TEXT,
MessageType VARCHAR(20),
MessageId VARCHAR(80),
ErrorCode VARCHAR(20),
ErrorText VARCHAR(80),
Gateway VARCHAR(80),
MessagePDU TEXT,
UserId VARCHAR(80),
UserInfo TEXT) CHARACTER SET utf8;

12. Add ODBC string (SQL connector)

As you selected ODBC in the last step and clicked next, you need to add the ODBC connector string. This can also be found in the Diafaan webpage as linked above.

You also need to find the driver name for you ODBC. You can find the driver name in Control panel -> Administrative tools -> Data sources (ODBC) -> Drivers. Write the driver name in the ODBC string, with your database name, user and password. Click Test to test the connection.

diafaan_smsserver_29

My string:

Driver={MySQL ODBC 5.3 ANSI Driver};Server=127.0.0.1;charset=UTF8;Database=smsserver;User=smsserver; Password=kake123%;Option=3;

Edit 20.11.2014: Use «MySQL ODBC 5.3 UNICODE Driver»… instead, to support ex. norwegian characters.

diafaan_smsserver_31

13. Where to put the text messages in the database

If you database connection was successful, you now have to set up where your messages are going to be stored in your database.

diafaan_smsserver_32 diafaan_smsserver_33 diafaan_smsserver_34

14. Write a name for the connector

diafaan_smsserver_35

 15. Yey! Your done!

diafaan_smsserver_37

16. Try sending a SMS

You can choose different message types – I’m testing a sms.text.flash just for fun.

diafaan_smsserver_48

20140917_223707

17. Setting up the Web Connector

Click Add connector to the right.

diafaan_smsserver_38

18. Select the «Web Connector»

diafaan_smsserver_39

19. Set you HTTP Port and click Test

diafaan_smsserver_40

20. Name the connector

diafaan_smsserver_41

21. Test the URL

diafaan_smsserver_42

I tested it from another computer and works like a charm. The default username is «admin» and the password is the same as you created at the first wizard, after installing Diafaan.

diafaan_smsserver_43

22. Test a message from the page.

diafaan_smsserver_44

Yey, I got a message. Trying to reply…

diafaan_smsserver_45

The message above is from a desktop application called SMS+ from my provider (Telenor), that let’s me send and receive SMS from my computer.

And here is the reply 🙂

diafaan_smsserver_46

And the database is also updated with the text message.

diafaan_smsserver_47

If you want to send and/or receive messages with HTTP command (URL / XML), look here: http://www.diafaan.com/applications/web-service-sms-gateway/

And there you go! Your own SMS Gateway/server for about $215 (1290 NOK) ($20 for Huawei E220 and $195 for light edition of Diafaan).