SMPP Lua Agent


The SMPPLuaAgent is an asynchronous helper for Lua scripts running within the LogicApp. It is used for sending out SMPP client requests.

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.

SMPP Agent API methods are accessed via the “n2.n2svcd.smpp_agent” module:

local smpp_agent = require "n2.n2svcd.smpp_agent"

Configuring SMPPLuaAgent

The SMPPLuaAgent is configured within a LogicApp.

    <?xml version="1.0" encoding="utf-8"?>
        <application name="Logic" module="LogicApp">
            <parameter name="default_smpp_app_name" value="SMPP-CLIENT"/>
              <agent module="SMPPApp::SMPPLuaAgent" libs="../apps/smpp/lib"/>

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_appname String Attribute Use this format when SMPPLuaAgent will communicate with more than one SMPPApp.
(Default = SMPPLuaAgent uses only the default route/SMPP end-point).

The SMPPLuaAgent API

All methods may raise a Lua Error in the case of exception, including:

The SMPPLuaAgent API can be loaded as follows.

local smpp_agent = require "n2.n2svcd.smpp_agent"

.request_response [Asynchronous]

Send a new SMPP message to the network via the same SMPP App that processed the initially-received message.

The Lua service logic will suspend until the request is acknowledged by the far-end.

The request_response 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 (Submit SM):

    smpp_agent.request_response ("submit_sm", { source_addr = "123", destination_addr = "641234567" })

.submit and .deliver [Asynchronous]

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 request_response method.

[Fragment] Example (Submit, Deliver):

    smpp_agent.submit ("123", "641234567", "Hello, world!")
    smpp_agent.deliver ("641234567", "123", "Hello, world!")