Tuesday, 10 February 2015

SMPP & CF


SMPP(Short Message Peer-to-Peer) protocol. The primary use of SMPP is to send and receive medium-to-high volumes of SMS texts.

The protocol is based on pairs of request/response PDUs (protocol data units, or packets) exchanged over OSI layer 4 (TCP session or X.25 SVC3) connections.

SMSC(SMS Centre) providers use both HTTP and SMPP for sending and receiving SMS texts.


  • Advantages of SMPP over HTTP
  • High-volume SMS messaging with a high speed. 
  • Delivery report with much info.
  • Network related info.
  • Efficient use of PDU over HTTP post.


Setting up SMPP event gateway in CF admin

For setting up Event Gateway we need a cfc file to receive acknowledgements/messages and a cfg file having configuration of port and shortcode of SMSC.

Go to 



CF ADMIN>Event Gateways > Gateway Instances


The major function of the cfc are:

onIncomingMessage:Every incoming message from SMSC and Delivery ack is handled by this function.Signature : public  function onIncomingMessage(required struct CFEvent)
Note :We can have other functionalities in CFC for logging and fetching the information.  


The CFG file should contain :


# Type of binding.Value can be either transciever,transmitter or receiverbinding=transciever
# This is the IP address of SMSCip-address=102.208.328.100
# Port to bind toport=80001
# Your system idsystem-id= demo_99647878
# Your passwordpassword= MinDFire6824

Note : Port differs depending on Shortcode.


Sending and Recieving Messages in SMPP

We need to buy a ShortCode  from SMSC, and get configuration details for ShortCode. CFC and CFG files are configured in cfadmin as above. We will use 'SUBMIT' and 'SUBMITMULTI' commands for individual and group broadcasts respectively.

Demo  for Sending and receiving messages

send.cfm
 <cftry>  
   <cfscript>  
      VARIABLES.cellNumList ='1234567890'; //CellNumber list  
      VARIABLES.msg = structNew();  
      VARIABLES.msg.command = "submit";  
      VARIABLES.msg.destAddress = VARIABLES.cellNumList;  
      VARIABLES.msg.shortMessage = 'Test Message from SMPP';  
      VARIABLES.msg.alertOnMsgDelivery = "1"; //To get delivey ack  
      VARIABLES.msg.sourceAddress = '1234'; //Shortcode Registered  
      VARIABLES.msg.registeredDelivery = "1";  
      VARIABLES.result = sendGatewayMessage("SMS Menu App", VARIABLES.msg);  
   </cfscript>  
   <cfoutput>  
    <!---We will get orderno, if success else empty response --->  
    Result - #InputBaseN( VARIABLES.result , 16 )#  
   </cfoutput>  
 <cfcatch type="any" >  
   <cfoutput>Oops!! Something went wrong #CFCATCH.message#</cfoutput>  
 </cfcatch>  
 </cftry>  

recieve.cfc


component  hint="SMS Event Gateway CFC" output="false"

{
 /**
 @hint Standard Message From CF server
 @Displayname onIncomingMessage
 @output false
 */
 public  function onIncomingMessage(required struct CFEvent)
 {
   try
   {
  var data = ARGUMENTS.CFEvent.DATA;
 /* If the message came from a handset and Operator,Network info is there */
  if(isDefined("data.data.optionalParameters")){
    writeLog(text='Incoming handset message from #data.data.sourceAddress# message is #data.data.Message#',file='incomingMessageLog'); 
    }
 /* When message doesnt contains optional parameter, only delivery notification*/
  else{
    writeLog(text='Delivary ack from #data.data.sourceAddress# and status is #data.data.message#',file='incomingMessageLog');
   }
  }
  catch(any ex)
  {
   /* Log the return Value into the Log file*/
    writeLog(text='Oops!! Something went wrong #CFCATCH.message#',file='incomingMessageLog');
  }
  
 } 
}


PDU(Protocol Data Unit)'s of SMPP












SUBMIT_SM:
This is used in individual broadcast of SMS.



SUBMIT_MULTI:
This is used in Group broadcast of SMS.

PDU of Received Acknowledgement:


This is the PDU we get in recieve.cfc after SMS delivered to user's cell number. We can get Info about the delivered time, status and error.

PDU of Received Message:

This is the PDU we get when the Shortcode assigned receives a message from User. We will have 'Message' which is texted. We can decrypt 'optionalParameters' for getting vendor info and other info related to Wireless Network .

Resource:
http://docs.nimta.com/SMPP_v3_4_Issue1_2.pdf
http://www.activexperts.com/sms-component/smpp-specifications/introduction/
http://help.adobe.com/livedocs/coldfusion/8/htmldocs/help.html?content=UseSMSGateway_06.html
http://help.adobe.com/livedocs/coldfusion/8/htmldocs/help.html?content=gateways_79.html#1172422

No comments:

Post a Comment