无法在Go代码中设置SMPP可选参数

Iam studying SMPP protocol and tried to implement a simple transmitter with a golang code and selenium smpp simulator. I found a package "CodeMonkeyKevin/smpp34" from github. But Iam unable to set the "user_message_reference" optional parameter.

I slightly modified the "SubmitSm" function inside the "transmitter.go" file by adding these lines (just before the write operation):

err = p.SetTLVField(tag, length, []byte(value))
    if err != nil {
        fmt.Println("Set TLV failed")
        return 0, err
    }

But this is not working.

I supplied values tag=0516(int equivalent of 0x0204 user_message_reference) length=02 and value="91".

In the response i could see "tag=516,len=2,value=0x3931" in the SMSC simulator , the value field doesn't seem appropriate to me; also the "message_id" in the response still continues its sequence by adding 1 with the last message_id

can some one help me in setting the "user_message_reference" optional parameter to the "submit_sm" request?

Thanks in advance.

You don't have edit the function in the transmitter.go

just set your tlv fields after your submit_sm

example

pdu, err        := trx.Smpp.SubmitSm("+254720000000", 
pdu.GetField("source_addr").String(), msg, &smpp.Params{})

pdu.SetTLVField(0x0501, 1, []byte{2}) #eg a ussd_service_op

This is the proper way to add your tlv values if you are using kevin's package See https://github.com/CodeMonkeyKevin/smpp34/issues/9 Additional parameters