⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmpp_protocol2.pas

📁 CMPP2版短信平台行业版,运营商支持下400条/S
💻 PAS
📖 第 1 页 / 共 2 页
字号:
        Src_Id: array[0..20] of Char; //源号码SP的服务代码或前缀为服务代码的长号码, 网关将该号码完整的填到SMPP协议Submit_SM消息相应的source_addr字段,该号码最终在用户手机上显示为短消息的主叫号码
        DestUsr_tl: Byte; //接收信息的用户数量(小于100个用户)
    end;

    PCMPP_SUBMIT_QF2 = ^TCMPP_SUBMIT_QF2;
    TCMPP_SUBMIT_QF2 = packed record
        Msg_Length: Byte; //信息长度(Msg_Fmt值为0时:<160个字节;其它<=140个字节)
        Msg_Content: array[0..MSG_LENGTH - 1] of Char; //信息内容
        Reserve: array[0..7] of Char; //保留
    end;

    PCMPP_SUBMIT_RESP = ^tCMPP_SUBMIT_RESP;
    TCMPP_SUBMIT_RESP = packed record
        Msg_Id: Int64; //信息标识
        Result: Byte; //结果
    end;

    ////////////////////////////////////////////////////////////////////////////
    // SP 向 ISMG 查询发送短信状态
    PCMPP_QUERY = ^TCMPP_QUERY;
    TCMPP_QUERY = packed record
        Time: array[0..7] of Char; //时间YYYYMMDD(精确至日)
        Query_Type: Byte; //查询类别0:总数查询1:按业务类型查询
        Query_Code: array[0..9] of Char; //查询码当Query_struct为0时,此项无效;当Query_struct为1时,此项填写业务类型Service_Id.
        Reserve: array[0..7] of Char; //保留
    end;

    PCMPP_QUERY_RESP = ^TCMPP_QUERY_RESP;
    TCMPP_QUERY_RESP = packed record
        Time: array[0..7] of Char; //时间(精确至日)
        Query_Type: Byte; //查询类别0:总数查询1:按业务类型查询
        Query_Code: array[0..9] of Char; //查询码
        MT_TLMsg: LongWord; //从SP接收信息总数
        MT_Tlusr: LongWord; //从SP接收用户总数
        MT_Scs: LongWord; //成功转发数量
        MT_WT: LongWord; //待转发数量
        MT_FL: LongWord; //转发失败数量
        MO_Scs: LongWord; //向SP成功送达数量
        MO_WT: LongWord; //向SP待送达数量
        MO_FL: LongWord; //向SP送达失败数量
    end;

    ////////////////////////////////////////////////////////////////////////////
    // ISMG 向 SP 送交短信
    // 由于在CMPP中,DELIVER和REPORT同一个命令号,所以读包体中也分两步,即先读前
    // 部份,再从Msg_Length和Registered_Delivery中判断剩余长度和内容
    PCMPP_DELIVER_HEAD = ^TCMPP_DELIVER_HEAD;
    TCMPP_DELIVER_HEAD = packed record
        Msg_Id: Int64; //信息标识
        Dest_Id: array[0..20] of Char; //目的号码
        Service_Id: array[0..9] of Char; //业务类型,是数字、字母和符号的组合。
        TP_pid: Byte; //GSM协议类型。详细解释请参考GSM03.40中的9.2.3.9
        TP_udhi: Byte; //GSM协议类型。详细解释请参考GSM03.40中的9.2.3.23,仅使用1位,右对齐
        Msg_Fmt: Byte; //信息格式
        Src_terminal_Id: array[0..20] of Char; //源终端MSISDN号码
        Registered_Delivery: Byte; //是否为状态报告0:非状态报告1:状态报告
        Msg_Length: Byte; //消息长度
    end;
    // Deliver后半部分
    PCMPP_DELIVER = ^TCMPP_DELIVER;
    TCMPP_DELIVER = packed record
        Msg_Content: array[0..MSG_LENGTH - 1] of Char; //消息内容
        Reserved: array[0..7] of Char; //保留项
    end;
    // ISMG 向 SP 送交状态报告
    PCMPP_REPORT = ^TCMPP_REPORT;
    TCMPP_REPORT = packed record
        //  ISMG 向 SP 送交状态报告时,信息内容字段(Msg_Content)格式定义
        Msg_ID: Int64; //信息标识
        Stat: array[0..6] of Char; //短信应答结果,详见CMPP
        Submit_time: array[0..9] of Char; //提交时间
        Done_time: array[0..9] of Char; //完成时间
        Dest_Terminal_Id: array[0..20] of Char; //目的终端号码
        SMSC_sequence: LongWord;
        //////////////////////////////
        Reserved: array[0..7] of Char; //保留项
    end;

    PCMPP_DELIVER_RESP = ^TCMPP_DELIVER_RESP;
    TCMPP_DELIVER_RESP = packed record
        Msg_Id: Int64; //信息标识
        Result: Byte; //结果
    end;

    ////////////////////////////////////////////////////////////////////////////
    // SP 向 ISMG 发起删除短信操作
    PCMPP_CANCEL = ^TCMPP_CANCEL;
    TCMPP_CANCEL = packed record
        Msg_Id: Int64; //信息标识
    end;
    PCMPP_CANCEL_RESP = ^TCMPP_CANCEL_RESP;
    TCMPP_CANCEL_RESP = packed record
        Success_Id: Byte; //结果
    end;

    ////////////////////////////////////////////////////////////////////////////
    //链路检测操作
    PCMPP_ACTIVE_TEST = ^TCMPP_ACTIVE_TEST;
    TCMPP_ACTIVE_TEST = TEmpty;

    PCMPP_ACTIVE_TEST_RESP = ^TCMPP_ACTIVE_TEST_RESP;
    TCMPP_ACTIVE_TEST_RESP = packed record
    Success_ID: Byte; //结果
    end;
    function GET_CMPP_CONNECT_RESP_ERRORINFO(Status : byte):String;
    function GET_CMPP_SUBMIT_RESP_ERRORINFO(Status : integer):String;
    function GET_CMPP_REPORT_STATUS(MessageStatus :String):String;
implementation

function GET_CMPP_REPORT_STATUS(MessageStatus :String):String;
begin
  if MessageStatus = 'DELIVRD' then
  begin
    Result := 'Delivered To Destination';
    Exit;
  end;
  if MessageStatus = 'EXPIRED' then
  begin
    Result := 'Message validity period has expired';
    Exit;
  end;
  if MessageStatus = 'DELETED' then
  begin
    Result := 'Message has been deleted.';
    Exit;
  end;
  if MessageStatus = 'UNDELIV' then
  begin
    Result := 'Message is undeliverable';
    Exit;
  end;
  if MessageStatus = 'ACCEPTD' then
  begin
    Result := 'Message is in accepted state(i.e. has been manually read on behalf of the subscriber by customer service)';
    Exit;
  end;
  if MessageStatus = 'UNKNOWN' then
  begin
    Result := 'Message is in invalid state';
    Exit;
  end;
  if MessageStatus = 'REJECTD' then
  begin
    Result := 'Message is in a rejected state';
    Exit;
  end;









end;


function GET_CMPP_CONNECT_RESP_ERRORINFO(Status : byte):String;
begin
  case Status of
    1: Result := '消息结构错';
    2: Result := '非法源地址';
    3: Result := '认证错';
    4: Result := '版本太高';
    5: Result := '其他错误';
  end;
end;

function GET_CMPP_SUBMIT_RESP_ERRORINFO(Status : integer):String;
begin
  case Status of
    1: Result := '消息结构错';
    2: Result := '命令字错';
    3: Result := '消息序号重复';
    4: Result := '消息长度错';
    5: Result := '资费代码错';
    6: Result := '超过最大信息长';
    7: Result := '业务代码错';
    8: Result := '流量控制错';
    9: Result := '本网关不负责服务此计费号码';
    10: Result := 'Src_Id错误';
    11: Result := 'Msg_src错误';
    12: Result := 'Fee_terminal_Id错误';
    13: Result := 'Dest_terminal_Id错误';
  end;
end;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -