c#中国移动短信发送平台
调用华为smeidll,cmpp2.0,能连接上模拟网关发送短信,但是没有收到返送,是什么问题呢。
代码如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace sms
{
class SmsClient
{
#region 结构体
/// <summary>
/// 发送短信参数
/// </summary>
struct SendParameter
{
public byte OrgTON;// = 2; //源地址号码类型
public byte OrgNPI;// = 0; //源地址编码方案
public byte DestTON;// = 2; //目标地址号码类型
public byte DestNPI;// = 0; //目标地址编码方案
public string DestAddr;// = ""; //目标地址
public byte PRI;// = 0; //SM优先级
public byte RD;// = 0; //当源地址和目的地址相同时,是否替换存在的短消息。
public byte RP;// = 0; //回应路径
public byte MR;// = 0; //消息索引
public byte Default_ID;// = 0; //缺省短消息
public string ServiceSubType;// = ""; //业务子类型,联通("LT"),移动("") 移动现在改成"MBJ0010501"了
public long SM_ID;// = 0; //返回:短消息ID
public long byMsgID;// = 0; //返回ACK应答消息的MsgID
//长短信参数
public byte byPKTotal;// = 1; //长短信组数量
public byte UDHI;// = 0; //内容编码
public byte byPKNumber;// = 2; //长短信序号,从1开始
//
public byte SRR;// = 1; //是否需要状态报告
public byte byMsglevel;// = 0; //信息级别
public byte byFeeUserType;// = 2; //计费用户类型字段,0:对目的终端MSISDN计费;1:对源终端MSISDN计费;
public string sFeeAddr;// = ""; //被计费用户的号码
public byte PID;// = 0; //协议类型
public byte DCS;// = 15; //数据编码方案
public string sSPID;// = "044022"; //企业代码
public string sFeeType;// = "01"; //资费类别
public string sFeeCode;// = "00"; //资费代码(以分为单位)
public string Schedule;// = DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss"); //定时 char[MAX_TIMESTAMP_LEN]
public string Expire;// = DateTime.Now.AddSeconds(5).ToString("yyyy/MM/dd hh:mm:ss"); //超时时间 char[MAX_TIMESTAMP_LEN]
public string OrgAddr; // = "106573450567"; //源地址
public byte byUserNum;// = 1; //目的地址数量
public string sDestAddrs; // = "13929966616"; //目的地址
public string UserData; // = "hello 你好"; //发送内容
public UInt32 UDLen; //= (UInt32)(UserData).Length; //内容长度
public byte FCS;// = 0; //返回:失败原因
};
/// <summary>
/// 发送短信参数
/// </summary>
struct GetParameter
{
public byte smID;
public byte DestTON;
public byte DestNPI;
public byte DestAddr;
public byte OrgTON;
public byte OrgNPI;
public byte OrgAddr;
public byte PRI;
public byte RP;
public byte UDHI;
public byte PID;
public byte DCS;
public byte TimeStamp;
public UInt32 UDLen;
public string UserData;
public byte StatusReport;
};
#endregion 结构体
#region 方法
/// <summary>
/// 链接接口
/// </summary>
[DllImport("SMEIDll.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern bool IFInitInterface(
byte dwCodeProtocol,
byte dwDriverProtocol,
byte[] pDriverParam
);
/// <summary>
/// 释放接口
/// </summary>
[DllImport("SMEIDll.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern bool IFExitInterface();
/// <summary>
/// 登录
/// </summary>
[DllImport("SMEIDll.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern bool Login_R(
string SystemID,
string Password
);
/// <summary>
/// 退出
/// </summary>
[DllImport("SMEIDll.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern bool Logout();
/// <summary>
///发送短信:CMPP2
///UDHI 类型:unsigned char。
///适用协议:SMPP
///意义:用于长短消息,表示UserData是否是结构
/// 取值 意义
/// 0 UD是正常字符串
/// 1 UD是结构
///byPKTotal 类型:unsigned char
///适用协议:CMPP
///意义:相同Msgid的消息总条数,从1开始.
///byPKNumber 类型:unsigned char
///适用协议:CMPP
///意义:相同Msgid的消息序号,从1开始.
/// </summary>
[DllImport("SMEIDll.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, EntryPoint = "SubmitAExEx")]
public static extern int SubmitA(
byte OrgTON,
byte OrgNPI,
string OrgAddr,
byte DestTON,
byte DestNPI,
string DestAddr,
byte PRI,
byte RD,
byte RP,
byte SRR,
byte MR,
byte DCS,
byte PID,
string Schedule,
string Expire,
byte DefaultID,
byte UDHI,
UInt32 UDLen,
string UserData,
string ServiceSubType,
StringBuilder byMsgID,
byte byPKTotal,
byte byPKNumber,
byte byMsglevel,
byte byFeeUserType,
string sSPID,
string sFeeType,
string sFeeAddr,
string sFeeCode,
byte byUserNum,
string sDestAddrs,
ref uint SM_ID,
StringBuilder FCS
);
/// <summary>
/// 检查是否有收信
/// </summary>
[DllImport("SMEIDll.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int HasDeliverMessage(
int dwTimeOut);
/// <summary>
/// 读取下发的短讯内容
/// </summary>
[DllImport("SMEIDll.dll", CharSet = CharSet.Ansi , CallingConvention = CallingConvention.StdCall, EntryPoint="GetDeliverSMExExEx")]
public static extern int GetDeliverSM(
ref ulong sm_ID,
ref byte DestTON,
ref byte DestNPI,
ref byte DestAddr,
ref byte OrgTON,
ref byte OrgNPI,
ref byte OrgAddr,
ref byte PRI,
ref byte RP,
ref byte UDHI,
ref byte PID,
ref byte DCS,
ref byte TimeStamp,
ref long UDLen,
StringBuilder UserData,
ref byte StatusReport,
ref byte sMsgID,
ref byte sSubmitdate,
ref byte sDonedate,
ref byte sStatus,
ref int iDeliverAckResult
);
#endregion 方法
}
}