gosmpp
gosmpp copied to clipboard
SubmitSM.Split() Sends the same sequence number for all the parts
Hello,
When creating a SubmitSM like so. The transmitted sequence numbers are the same.
func (s *SmppClientService) BuildSubmitSMs(msg *smppMessage) ([]*pdu.SubmitSM, error) {
p, ok := pdu.NewSubmitSM().(*pdu.SubmitSM)
if !ok {
log.Panic().Caller().Msg("should be of type SubmitSM")
}
p.ServiceType = string(msg.ServiceType)
sourceAddr, err := pdu.NewAddressWithTonNpiAddr(byte(msg.SourceAddressTon), 0, msg.SourceAddr)
if err != nil {
return nil, err
}
p.SourceAddr = sourceAddr
destinationAddr, err := pdu.NewAddressWithTonNpiAddr(1, 1, msg.DestinationAddr)
if err != nil {
return nil, err
}
p.DestAddr = destinationAddr
p.ProtocolID = 0
p.RegisteredDelivery = 1
p.ReplaceIfPresentFlag = 0
p.EsmClass = 0
p.ServiceType = string(msg.ServiceType)
encoding := data.GSM7BIT
p.RegisterOptionalParam(pdu.Field{
Tag: pdu.Tag(CustomTLVMessageID),
Data: []byte(msg.ID),
})
p.RegisterOptionalParam(pdu.Field{
Tag: pdu.Tag(CustomTLVOrgID),
Data: []byte(msg.OrgID),
})
if msg.CampaignID != "" {
p.RegisterOptionalParam(pdu.Field{
Tag: pdu.Tag(CustomTLVCampaignID),
Data: []byte(msg.CampaignID),
})
}
if msg.Encoding == SmppEncodingUCS2 {
encoding = data.UCS2
}
// same problem with that method
// m, err := pdu.NewShortMessageWithEncoding(msg.ShortMessage, encoding)
// if err != nil {
// return nil, err
// }
// p.Message = m
if err := p.Message.SetLongMessageWithEnc(msg.ShortMessage, encoding); err != nil {
return nil, err
}
return p.Split()
}
// I then send like this
ps, err := s.BuildSubmitSMs(msg)
if err != nil {
return err
}
for _, p := range ps {
if err := s.session.Transceiver().Submit(p); err != nil {
return err
} else {
s.submitIds.Store(p.SequenceNumber, msg.ID)
}
}
Looks like all the splits reuse the same base as the original message, hence the same sequence number.
I'll submit a pull request shortly.
I cant check code right now, but im sure split handles the ShortMessage only, not the SubmitSm.
You need to create a NewSubmitSm for each segment/split.
Split() does create an array of SubmitSM which are expected to be sent as-is.
I created the pull request. Works as expected after this fix.