cmpp

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeadLength            = 12                 // 报文头长度
	CMPP_CONNECT          = uint32(0x00000001) // 请求连接
	CMPP_CONNECT_RESP     = uint32(0x80000001) // 请求连接应答
	CMPP_TERMINATE        = uint32(0x00000002) // 终止连接
	CMPP_TERMINATE_RESP   = uint32(0x80000002) // 终止连接应答
	CMPP_SUBMIT           = uint32(0x00000004) // 提交短信
	CMPP_SUBMIT_RESP      = uint32(0x80000004) // 提交短信应答
	CMPP_DELIVER          = uint32(0x00000005) // 短信下发
	CMPP_DELIVER_RESP     = uint32(0x80000005) // 下发短信应答
	CMPP_ACTIVE_TEST      = uint32(0x00000008) // 激活测试
	CMPP_ACTIVE_TEST_RESP = uint32(0x80000008) // 激活测试应答

)

Variables

View Source
var CommandMap = make(map[uint32]string)
View Source
var ConnectStatusMap = map[uint32]string{
	0: "成功",
	1: "消息结构错",
	2: "非法源地址",
	3: "认证错",
	4: "版本太高",
	5: "其他错误",
}
View Source
var DeliveryResultMap = map[uint32]string{
	0: "正确",
	1: "消息结构错",
	2: "命令字错",
	3: "消息序号重复",
	4: "消息长度错",
	5: "资费代码错",
	6: "超过最大信息长",
	7: "业务代码错",
	8: "流量控制错",
	9: "未知错误",
}
View Source
var ErrorPacket = errors.New("error packet")
View Source
var ReportSeq codec.Sequence32
View Source
var SubmitResultMap = map[uint32]string{
	0:  "正确",
	1:  "消息结构错",
	2:  "命令字错",
	3:  "消息序号重复",
	4:  "消息长度错",
	5:  "资费代码错",
	6:  "超过最大信息长",
	7:  "业务代码错",
	8:  "流量控制错",
	9:  "本网关不负责服务此计费号码",
	10: "Src_Id 错误",
	11: "Msg_src 错误",
	12: "Fee_terminal_Id 错误",
	13: "Dest_terminal_Id 错误",
}

Functions

func MsgFmt

func MsgFmt(content string) uint8

MsgFmt 通过消息内容判断,设置编码格式。 如果是纯拉丁字符采用0:ASCII串 如果含多字节字符,这采用8:UCS-2编码

func MsgSlices

func MsgSlices(fmt uint8, content string) (slices [][]byte)

func NewDelivery

func NewDelivery(phone string, msg string, dest string, serviceId string) codec.RequestPdu

func NewSubmit

func NewSubmit(phones []string, content string, opts ...Option) (messages []codec.RequestPdu)

func NewTerminate

func NewTerminate() codec.IHead

func NewTerminateResp

func NewTerminateResp(seq uint32) codec.IHead

func TrimStr

func TrimStr(bts []byte) string

func V3

func V3() bool

Types

type ActiveTest

type ActiveTest struct {
	*MessageHeader
}

func NewActiveTest

func NewActiveTest() *ActiveTest

func (*ActiveTest) Decode

func (at *ActiveTest) Decode(header codec.IHead, frame []byte) error

func (*ActiveTest) Encode

func (at *ActiveTest) Encode() []byte

func (*ActiveTest) String

func (at *ActiveTest) String() string

func (*ActiveTest) ToResponse

func (at *ActiveTest) ToResponse(_ uint32) interface{}

type ActiveTestResp

type ActiveTestResp struct {
	*MessageHeader
	// contains filtered or unexported fields
}

func (*ActiveTestResp) Decode

func (at *ActiveTestResp) Decode(header codec.IHead, frame []byte) error

func (*ActiveTestResp) Encode

func (at *ActiveTestResp) Encode() []byte

func (*ActiveTestResp) String

func (at *ActiveTestResp) String() string

type Connect

type Connect struct {
	*MessageHeader // +12 = 12:消息头
	// contains filtered or unexported fields
}

func NewConnect

func NewConnect() *Connect

func (*Connect) Check

func (connect *Connect) Check() uint32

func (*Connect) Decode

func (connect *Connect) Decode(header codec.IHead, frame []byte) error

func (*Connect) Encode

func (connect *Connect) Encode() []byte

func (*Connect) String

func (connect *Connect) String() string

func (*Connect) ToResponse

func (connect *Connect) ToResponse(code uint32) interface{}

type ConnectResp

type ConnectResp struct {
	*MessageHeader // 协议头, 12字节
	// contains filtered or unexported fields
}

func (*ConnectResp) Decode

func (resp *ConnectResp) Decode(header codec.IHead, frame []byte) error

func (*ConnectResp) Encode

func (resp *ConnectResp) Encode() []byte

func (*ConnectResp) Status

func (resp *ConnectResp) Status() uint32

func (*ConnectResp) String

func (resp *ConnectResp) String() string

type Delivery

type Delivery struct {
	*MessageHeader
	// contains filtered or unexported fields
}

Delivery 上行短信或状态报告,不支持长短信

func (*Delivery) Decode

func (d *Delivery) Decode(header codec.IHead, frame []byte) error

func (*Delivery) Encode

func (d *Delivery) Encode() []byte

func (*Delivery) RegisteredDelivery

func (d *Delivery) RegisteredDelivery() uint8

func (*Delivery) String

func (d *Delivery) String() string

func (*Delivery) ToResponse

func (d *Delivery) ToResponse(code uint32) interface{}

type DeliveryResp

type DeliveryResp struct {
	*MessageHeader
	// contains filtered or unexported fields
}

func (*DeliveryResp) Decode

func (r *DeliveryResp) Decode(header codec.IHead, frame []byte) error

func (*DeliveryResp) Encode

func (r *DeliveryResp) Encode() []byte

func (*DeliveryResp) SetResult

func (r *DeliveryResp) SetResult(result uint32)

func (*DeliveryResp) String

func (r *DeliveryResp) String() string

type MessageHeader

type MessageHeader struct {
	TotalLength uint32
	CommandId   uint32
	SequenceId  uint32
}

func (*MessageHeader) Decode

func (header *MessageHeader) Decode(frame []byte) error

func (*MessageHeader) Encode

func (header *MessageHeader) Encode() []byte

func (*MessageHeader) String

func (header *MessageHeader) String() string

type MtOptions

type MtOptions struct {
	RegisteredDel   uint8
	MsgLevel        uint8
	FeeUsertype     uint8
	FeeTerminalType uint8
	ServiceId       string
	FeeTerminalId   string
	FeeType         string
	FeeCode         string
	ValidTime       string
	AtTime          string
	SrcId           string
	LinkID          string
}

type Option

type Option func(mtOps *MtOptions)

func MtAtTime

func MtAtTime(t time.Time) Option

MtAtTime 定时发送时间,格式遵循SMPP3.3协议

func MtAtTimeStr

func MtAtTimeStr(s string) Option

MtAtTimeStr 定时发送时间,格式:yyMMddHHmmss

func MtFeeCode

func MtFeeCode(s string) Option

MtFeeCode 资费代码(以分为单位)

func MtFeeTerminalId

func MtFeeTerminalId(id string) Option

MtFeeTerminalId 计费号码与FeeTerminalType配合使用

func MtFeeTerminalType

func MtFeeTerminalType(t uint8) Option

MtFeeTerminalType 被计费用户的号码类型,0:真实号码;1:伪码

func MtFeeType

func MtFeeType(s string) Option

MtFeeType 资费类别 01:对“计费用户号码”免费 02:对“计费用户号码”按条计信息费 03:对“计费用户号码”按包月收取信息费 04:对“计费用户号码”的信息费封顶 05:对“计费用户号码”的收费是由SP实现

func MtFeeUsertype

func MtFeeUsertype(t uint8) Option

MtFeeUsertype 计费用户类型字段 0:对目的终端MSISDN计费; 1:对源终端MSISDN计费; 2:对SP计费; 3:表示本字段无效,对谁计费参见Fee_terminal_Id 字段。

func MtLinkID

func MtLinkID(s string) Option

MtLinkID 点播业务使用的LinkID,非点播类业务的MT流程不使用该字段

func MtMsgLevel

func MtMsgLevel(l uint8) Option

MtMsgLevel 消息优先级

func MtRegisteredDel

func MtRegisteredDel(tf uint8) Option

MtRegisteredDel 是否需状态报告

func MtServiceId

func MtServiceId(id string) Option

MtServiceId 业务标识,是数字、字母和符号的组合

func MtSrcId

func MtSrcId(s string) Option

MtSrcId SP的服务代码或前缀为服务代码的长号码, 网关将该号码完整的填到SMPP协议Submit_SM消息相应的source_addr字段,该号码最终在用户手机上显示为短消息的主叫号码

func MtValidTime

func MtValidTime(s string) Option

MtValidTime 存活有效期,格式遵循SMPP3.3协议

func WithOptions

func WithOptions(opt *MtOptions) Option

WithOptions 设置配置项

type Report

type Report struct {
	// contains filtered or unexported fields
}

func NewReport

func NewReport(msgId uint64, destTerminalId string, submitTime string, doneTime string) *Report

func (*Report) Decode

func (rt *Report) Decode(frame []byte) error

func (*Report) Encode

func (rt *Report) Encode() []byte

func (*Report) String

func (rt *Report) String() string

type Submit

type Submit struct {
	*MessageHeader // 消息头,【12字节】
	// contains filtered or unexported fields
}

func (*Submit) Decode

func (sub *Submit) Decode(header codec.IHead, frame []byte) error

func (*Submit) Encode

func (sub *Submit) Encode() []byte

func (*Submit) String

func (sub *Submit) String() string

func (*Submit) ToDeliveryReport

func (sub *Submit) ToDeliveryReport(msgId uint64) *Delivery

func (*Submit) ToResponse

func (sub *Submit) ToResponse(result uint32) interface{}

type SubmitResp

type SubmitResp struct {
	*MessageHeader
	// contains filtered or unexported fields
}

func (*SubmitResp) Decode

func (resp *SubmitResp) Decode(header codec.IHead, frame []byte) error

func (*SubmitResp) Encode

func (resp *SubmitResp) Encode() []byte

func (*SubmitResp) MsgId

func (resp *SubmitResp) MsgId() uint64

func (*SubmitResp) Result

func (resp *SubmitResp) Result() uint32

func (*SubmitResp) String

func (resp *SubmitResp) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL