Cannot get Delivery Receipt

Apr 20, 2012 at 10:50 PM

Dear,

     I'm a new user use this great library, but i'm facing a little problem with message delivery receipt, i cannot catch this event.

I'm using the ASCII on DataCoding, and when i made some tracing, i found that getting delivery event throw exception 'Index out bound size....' because  it's using SMCDefault as DataCoding.

I'm trying to build an application to send SMS via gateway Or GSM modem, and get the delivery reports to SQL database.

 

here my code:

m_Client = new SmppClient();

            m_Client.Properties.Host = "xxx.xxx.xxx.xxx";
            m_Client.Properties.Port = 8888;
            m_Client.Properties.Password ="MyPassword";
            m_Client.Properties.SystemID = "MyUserName";
            //m_Client.Properties.AddressNpi = NumberingPlanIndicator.Data;
            //m_Client.Properties.AddressTon = TypeOfNumber.Aphanumeric;
            m_Client.Properties.DefaultEncoding = DataCoding.ASCII;
            m_Client.Properties.SystemType = "NET";
            m_Client.Properties.DefaultServiceType = "NET";

            m_Client.ConnectionStateChanged += (s, eArg) =>
            {
                WriteLog("ConnectionStateChanged : " + eArg.CurrentState.ToString());
            };
            m_Client.StateChanged += (s, eArg) =>
                {
                    WriteLog("StateChanged : " + eArg.Started.ToString());
                };
            m_Client.MessageDelivered += (s, eArg) =>
                {
                    WriteLog("MessageDelivered", eArg.ShortMessage);
                };
            m_Client.MessageReceived += (s, eArg) =>
            {
                WriteLog("MessageReceived", eArg.ShortMessage);
            };
            m_Client.MessageSent += (s, eArg) =>
            {
                WriteLog("MessageSent", eArg.ShortMessage);
            };
            m_Client.Start();

private void Send_Click(object sender, EventArgs e)
        {
            DataCoding l_coding = DataCoding.ASCII;
            SubmitSm mSubReq = new SubmitSm();
            mSubReq.DataCoding = l_coding;
            mSubReq.SourceAddress.Address = txtSender.Text;
            mSubReq.DestinationAddress.Address = txtTo.Text;
            mSubReq.EsmClass = EsmClass.DeliveryReceipt;
            mSubReq.RegisteredDelivery = RegisteredDelivery.DeliveryReceipt;
            mSubReq.ServiceType = "NET";


            Random mrandom = new Random();
            string minput = txtMessage.Text;
            
            string[] splittedMsg = Split(minput, 153); 
            if (null == splittedMsg || splittedMsg.Length == 0)
                return;
            int SegID = mrandom.Next(1000, 9999); 
            int totalSegments = splittedMsg.Length;
            Udh mmUdh = new Udh(SegID, totalSegments, 0);
            mmUdh.MessageCount = totalSegments;

            for (int i = 0; i < totalSegments; i++)
            {
                mmUdh.MessageSequence = i + 1;
                mSubReq.SetMessageText(splittedMsg[i], l_coding, mmUdh);
                SubmitSmResp mmSubmitSmResp = m_Client.CustomSendPDU(mSubReq) as SubmitSmResp;
                WriteLog(mmSubmitSmResp.MessageID);
                WriteLog(mmSubmitSmResp.Header.ErrorCode.ToString());
            }
        }
        private string[] Split(string txt, int number)
        {
            if (string.IsNullOrEmpty(txt)) return null;
            if (txt.Length <= number) return new string[] { txt };
            List<string> l_list = new List<string>();
            int l_len = txt.Length;
            int l_index = 0;
            int l_step = 0;

            while (l_index < l_len)
            {
                if (number + l_index > l_len)
                    l_step = l_len - l_index;
                else
                    l_step = number;

                l_list.Add(txt.Substring(l_index, l_step));
                l_index += l_step;

               
            }
            return l_list.ToArray();
        }

 

Appreciate your kindly help on this.

private void button1_Click(object sender, EventArgs e)
        {
            DataCoding l_coding = DataCoding.ASCII;
            SubmitSm mSubReq = new SubmitSm();
            mSubReq.DataCoding = l_coding;
            mSubReq.SourceAddress.Address = txtSender.Text;
            mSubReq.DestinationAddress.Address = txtTo.Text;
            mSubReq.EsmClass = EsmClass.DeliveryReceipt;
            mSubReq.RegisteredDelivery = RegisteredDelivery.DeliveryReceipt;
            mSubReq.ServiceType = "NET";


            Random mrandom = new Random();
            string minput = txtMessage.Text;
           
            string[] splittedMsg = Split(minput, 153);
            if (null == splittedMsg || splittedMsg.Length == 0)
                return;
            int SegID = mrandom.Next(1000, 9999);
            int totalSegments = splittedMsg.Length;
            Udh mmUdh = new Udh(SegID, totalSegments, 0);
            mmUdh.MessageCount = totalSegments;

            for (int i = 0; i < totalSegments; i++)
            {
                mmUdh.MessageSequence = i + 1;
                mSubReq.SetMessageText(splittedMsg[i], l_coding, mmUdh);
                SubmitSmResp mmSubmitSmResp = m_Client.CustomSendPDU(mSubReq) as SubmitSmResp;
                WriteLog(mmSubmitSmResp.MessageID);
                WriteLog(mmSubmitSmResp.Header.ErrorCode.ToString());
            }
        }
        private string[] Split(string txt, int number)
        {
            if (string.IsNullOrEmpty(txt)) return null;
            if (txt.Length <= number) return new string[] { txt };
            List<string> l_list = new List<string>();
            int l_len = txt.Length;
            int l_index = 0;
            int l_step = 0;

            while (l_index < l_len)
            {
                if (number + l_index > l_len)
                    l_step = l_len - l_index;
                else
                    l_step = number;

                l_list.Add(txt.Substring(l_index, l_step));
                l_index += l_step;

              
            }
            return l_list.ToArray();
        }
Aug 14, 2012 at 7:43 PM

Yes, i had this problem. 

SmppClient.PduReceivedEventHander method required DeliverSm.EsmClass value is set to EsmClass.DeliveryReceipt. But i can't receive this information from SMSC. 

However, i'm hack Parse method in DeliverSm class. Because i'm have no time to examine for detailed solution...

DeliverSm, line: 191

vEsmClass = (EsmClass)GetByte(buffer) -> vEsmClass = (EsmClass)GetByte(buffer) | Protocol.EsmClass.DeliveryReceipt 

it works !! 

(sorry my English)