通过具有EasySMPP API的SMPP协议将命令发送到Simcard(例如,如何更新spn)

时间:2019-07-08 14:53:34

标签: smpp

我正在为通过我的大学的最终项目通过smsc发送命令到卡片的应用程序工作。 我找到了一个非常不错的名为EasySMPP的软件,可以向我的手机发送短信。但是我仍然没有成功将命令发送到卡,例如,更新spn 我不知道此函数的值是什么,以及如何填充它们。请说明它们是什么以及如何填充它们。 请立即帮助我

public int SubmitSM(

byte sourceAddressTon, 
byte sourceAddressNpi, 
sourceAddress,
byte destinationAddressTon,
byte destinationAddressNpi, 
destinationAddress, 
byte esmClass, 
byte protocolId,
byte priorityFlag, 
DateTime sheduleDeliveryTime, 
DateTime validityPeriod, 
byte registeredDelivery,
byte replaceIfPresentFlag,
byte dataCoding,
byte smDefaultMsgId,
byte[] message)
{
try
{
            byte[] _destination_addr;
            byte[] _source_addr;
            byte[] _SUBMIT_SM_PDU;
            byte[] _shedule_delivery_time;
            byte[] _validity_period;
            int _sequence_number;
            int pos;
            byte _sm_length;

            _SUBMIT_SM_PDU = new byte[KernelParameters.MaxPduSize];

            ////////////////////////////////////////////////////////////////////////////////////////////////
            /// Start filling PDU                       

            Tools.CopyIntToArray(0x00000004, _SUBMIT_SM_PDU, 4);
            _sequence_number = smscArray.currentSMSC.SequenceNumber;
            Tools.CopyIntToArray(_sequence_number, _SUBMIT_SM_PDU, 12);


            pos = 16;
            _SUBMIT_SM_PDU[pos] = 0x00; //service_type
            pos += 1;
            _SUBMIT_SM_PDU[pos] = sourceAddressTon;
            pos += 1;
            _SUBMIT_SM_PDU[pos] = sourceAddressNpi;
            pos += 1;
            _source_addr = Tools.ConvertStringToByteArray(Tools.GetString(sourceAddress, 20, ""));
            Array.Copy(_source_addr, 0, _SUBMIT_SM_PDU, pos, _source_addr.Length);
            pos += _source_addr.Length;
            _SUBMIT_SM_PDU[pos] = 0x00;
            pos += 1;
            _SUBMIT_SM_PDU[pos] = destinationAddressTon;
            pos += 1;
            _SUBMIT_SM_PDU[pos] = destinationAddressNpi;
            pos += 1;
            _destination_addr = Tools.ConvertStringToByteArray(Tools.GetString(destinationAddress, 20, ""));
            Array.Copy(_destination_addr, 0, _SUBMIT_SM_PDU, pos, _destination_addr.Length);
            pos += _destination_addr.Length;
            _SUBMIT_SM_PDU[pos] = 0x00;
            pos += 1;
            _SUBMIT_SM_PDU[pos] = esmClass;
            pos += 1;
            _SUBMIT_SM_PDU[pos] = protocolId;
            pos += 1;
            _SUBMIT_SM_PDU[pos] = priorityFlag;
            pos += 1;
            _shedule_delivery_time = Tools.ConvertStringToByteArray(Tools.GetDateString(sheduleDeliveryTime));
            Array.Copy(_shedule_delivery_time, 0, _SUBMIT_SM_PDU, pos, _shedule_delivery_time.Length);
            pos += _shedule_delivery_time.Length;
            _SUBMIT_SM_PDU[pos] = 0x00;
            pos += 1;
            _validity_period = Tools.ConvertStringToByteArray(Tools.GetDateString(validityPeriod));
            Array.Copy(_validity_period, 0, _SUBMIT_SM_PDU, pos, _validity_period.Length);
            pos += _validity_period.Length;
            _SUBMIT_SM_PDU[pos] = 0x00;
            pos += 1;
            _SUBMIT_SM_PDU[pos] = registeredDelivery;
            pos += 1;
            _SUBMIT_SM_PDU[pos] = replaceIfPresentFlag;
            pos += 1;
            _SUBMIT_SM_PDU[pos] = dataCoding;
            pos += 1;
            _SUBMIT_SM_PDU[pos] = smDefaultMsgId;
            pos += 1;

            _sm_length = message.Length > 254 ? (byte)254 : (byte)message.Length;

            _SUBMIT_SM_PDU[pos] = _sm_length;
            pos += 1;
            Array.Copy(message, 0, _SUBMIT_SM_PDU, pos, _sm_length);
            pos += _sm_length;

            Tools.CopyIntToArray(pos, _SUBMIT_SM_PDU, 0);

            Send(_SUBMIT_SM_PDU, pos);

            undeliveredMessages++;
            return _sequence_number;
        }
        catch (Exception ex)
        {
            logMessage(LogLevels.LogExceptions, "SubmitSM | " + ex.ToString());
        }
        return -1;

    }

0 个答案:

没有答案