Quick Start Guide

Introduction

This guide is designed in order to give you the necessary information in order to start using SMSLib. Various support questions made it obvious that the documentation is lucking in some areas. Hopefully, this document will show you how to setup and use SMSLib in your applications.

Beyond this documentation, remember that there are two sample mini apps available, the SendMessage which simply sends a message and the ReadMessages which reads messages from your phone. Be sure to have a look as, sometimes, code speaks better than the documentation. And yes, like any other programmer out there, I hate writing documentation! I prefer to express myself by coding.

By the way, do not forget to view on javadoc documentation pages. My goal and pattern is to document all public methods that are of use to you. So if you find a method that is not documented in javadocs, chances are that you should not use it directly.

SMSLib Initialization

You primary interface with SMSLib is the Service class. The entire (almost) functionality of SMSLib is exposed via the Service's methods. You should create only one instance of the Service class in your application!

Gateways

The Service itself is useless. Before starting the Service, you should define your gateways. Gateways refer to the physical devices or services which can send and/or receive messages. SMSLib has the following predefined gateways:

Each gateway has different initialization parameters (look at the javadocs for this). The point is to create one or more gateways (according to your setup) and add them to the Service using a syntax like this:

(Service).addGateway(new SerialModemGateway("modem.com1", "COM1", 57600, "Nokia", "6310i"));

Add as many gateways you wish. Once added, SMSLib will manage and use all of them via the rest of the Service class methods

Once you add all the necessary gateways, start the Service by issuing:

(Service).startService()

Reading messages

There are four (4) types of inbound messages that can be handled with SMSLib. These are:

There are two ways to read messages:

Sending messages

There are again, four (4) types of messages that SMSLib can send. These are:

Each message class has several properties, so check the javadoc for these. You can set the type, the encoding, the delivery report etc.

There are two ways to send a message:

The asynchronous sending is covered in a bit more detail in the following section.

Background sending

To send a message asynchronously, you use the queueMessage family of methods. To send a message at a specific time, you use the queueMessageAt family of methods.

Starting from v3.5, SMSLib queues can be set to operate in a non-persistent or persistent way. In the first case, queued messages are lost between SMSLib invocations (i.e. between Service restarts). This is the default operating mode, compatible with previous versions. If you set SMSLib to work in persistent mode, queued and scheduled messages are retained between SMSLib invocations.

The persistency mode is selected by setting the QUEUE_DIRECTORY parameter. Look at Configurations Parameters for more information on the use of the QUEUE_DIRECTORY parameter.

Routing and Balancing

This section briefly describes the Routing and Balancing concepts. If you use only one Gateway, you may safely skip this section.

When you have more than one Gateways define, you may wonder from which Gateway an outbound message will be sent. SMSLib provides for both an automatic way and a manual way to define your routing.

In order to define the preferred Gateway according to your wishes, you can:

There is also the concept of the wildcard gateway. This is noted by the star character. By setting the gateway to the star character, you actually state that you are letting SMSLib decide which gateway to use.

SMSLib uses a Routing and a Balancing logic in order to automatically determine the gateway to use. Routing logic takes into consideration possible routing rules in order to decide which (of all gateways) are the candidate gateways. Then the Balancing logic gets applied in order to select the preferred of the candidate gateways. This specific gateway is then used for the dispatch of the specific message.

If this all sound complicated, don't be alarmed. SMSLib uses a default set of Routing/Balancing rules which works well all the time. The default Routing rule is actually a "use-any-of" rule, where all gateways are treated as candidates. The default Balancing rule is an implementation of the Round-Robin logic. So, when you have more than one Gateways, all of them are used in turns.