SMPP Lua Agent
Introduction
The SMPPLuaAgent is an asynchronous helper for Lua scripts running within the LogicApp. It is used for sending out SMPP client requests.
- The SMPP Client Agent may be used by any Lua script, regardless of which Service initiated that script.
- For receiving SMPP server requests you need to use the SMPPLuaService Service.
The SMPPLuaAgent communicates with one or more instances of the SMPPApp which can be used to communicate with one or more external SMPP entities.
The SMPPLuaAgent communicates with the SMPPApp using the SMPP-C-… messages.

- The SMPPLuaAgent is tied to the
smpp
action key. - The
SMPP-C-SENT
message is written to the debug trace log, but not available to the Lua script.
Configuring SMPPLuaAgent
The SMPPLuaAgent is configured within a LogicApp.
<?xml version="1.0" encoding="utf-8"?>
<n2svcd>
...
<applications>
...
<application name="Logic" module="LogicApp">
<include>
<lib>../apps/logic/lib</lib>
</include>
<parameters>
...
<parameter name="default_smpp_app_name" value="SMPP-CLIENT"/>
</parameters>
<config>
<services>
...
</services>
<agents>
<agent module="SMPPApp::SMPPLuaAgent" libs="../apps/smpp/lib"/>
</agents>
</config>
</application>
...
</application>
...
</n2svcd>
Under normal installation, the following agent
attributes apply:
Parameter Name | Type | XML Type | Description |
---|---|---|---|
module
|
SMPPApp::SMPPLuaAgent
|
Attribute | [Required] The module name containing the Lua Agent code. |
libs
|
../apps/smpp/lib
|
Element |
Location of the module for SMPPLuaAgent.
|
In addition, the SMPPLuaAgent must be configured with the name of the SMPPApp with which
it will communicate. This is configured within the parameters
of the containing
LogicApp
.
Parameter Name | Type | XML Type | Description |
---|---|---|---|
parameters
|
Array | Element |
Array of name = value Parameters for this Application instance.
|
.default_smpp_app_name
|
String | Attribute | Default name for the SMPPApp with which SMPPLuaAgent will communicate. |
.smpp_app_name_
|
String | Attribute |
Use this format when SMPPLuaAgent will communicate with more than one SMPPApp .(Default = SMPPLuaAgent uses only the default route/SMPP end-point). |
Invoking SMPPLuaAgent
A Lua Script can access the SMPPLuaAgent smpp
action with code such as the following:
local n2svcd = require "n2.n2svcd"
local smpp_api = require "n2.n2svcd.smpp"
local handler = function (smpp)
local response = smpp_api.reply("Received!")
if (not response.smpp) then
-- message was not sent successfully
else
if smpp.command_status == "0" then
-- message was sent successfully and received success result code from network
else
-- message was sent successfully but received non-success result code from network
end
end
return {
command_status = 0;
}
end
return n2svcd.handler (handler)
This is standard Lua-style library usage. The n2/n2svcd/smpp.lua
library is loaded
with require "n2.n2svcd.smpp"
. Then methods are invoked on the returned library object.
The SMPPLuaAgent API
All methods may raise a Lua Error in the case of exception, including:
- Invalid input parameters supplied by Lua script.
- Unexpected results structure returned from SMPPApp.
- Processing error occurred at SMPPApp.
- Timeout occurred at SMPPApp.
The SMPPLuaAgent API can be loaded as follows.
local smpp_api = require "n2.n2svcd.smpp"
.send
Send a new SMPP message to the network via the same SMPP App that processed the initially-received message.
The send
method takes the following parameters.
Parameter | Type | Description |
---|---|---|
pdu
|
String |
The SMPP message type to send. Must be either deliver_sm > or submit_sm >.
|
fields
|
Object |
The fields to send for the message. The possible fields are as shown in the
fields parameter of the SMPP-C-REQUEST message.
|
This method returns a single parameter as a Lua table containing the contents of the received SMPP-C-RESPONSE message.
[Fragment] Example sent message:
...
smpp_api.send ("submit_sm", { source_addr = "123", destination_addr = "641234567" })
...
.submit and .deliver
Sends a new SMPP submit_sm
or deliver_sm
message to the network as per the send
method.
The submit
and deliver
methods take the following parameters.
Parameter | Type | Description |
---|---|---|
source_addr
|
String | Address of the SME from which the message originated. |
destination_addr
|
Object | Address of the SME from which the message originated. |
short_message_text
|
String | The non-encoded message text. This will be automatically encoded when the message is constructed. |
This method has the same response as the send
method.
[Fragment] Example sent messages:
...
smpp_api.submit ("123", "641234567", "Hello, world!")
smpp_api.deliver ("641234567", "123", "Hello, world!")
...
.reply
Send a new SMPP message to the network via the Lua SMPP Agent. This message will be sent to the originator of the first message, from the destination of the first message.
The reply
method takes the following parameters.
Parameter | Type | Description |
---|---|---|
short_message_text
|
String | The non-encoded message text. This will be automatically encoded when the message is constructed. |
This method has the same response as the send
method.
[Fragment] Example sent message:
...
smpp_api.reply ("Hello, world!")
...