Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data_coding field not set #162

Open
bluewithanas opened this issue Jan 31, 2025 · 7 comments
Open

Data_coding field not set #162

bluewithanas opened this issue Jan 31, 2025 · 7 comments

Comments

@bluewithanas
Copy link

Hello,

We have a case with our provider where they expect us to send data_coding field in the SubmitSM while using GSM7Bit encoding. They claim we do not send in the submit_SM request.

However, I do not see the support of setting this field manually. Can you please let me know how to enable this and whether we can implement this case?

THis is my implementation of building SubmitSM.

`

func newSubmitSM(dest string, source string, message string, mid int32, encoding string) (*pdu.SubmitSM, error) {
var encodedMessage []byte
var enc data.Encoding
var err error
srcAddr := pdu.NewAddress()
srcAddr.SetTon(5)
srcAddr.SetNpi(0)
_ = srcAddr.SetAddress(source)
destAddr := pdu.NewAddress()
destAddr.SetTon(1)
destAddr.SetNpi(1)
if err = destAddr.SetAddress(dest); err != nil {
	return nil, errors.Wrap(err, "SetAddress")
}

submitSM, ok := pdu.NewSubmitSM().(*pdu.SubmitSM)
if !ok {
	return nil, errors.New("NewSubmitSM")
}
submitSM.SourceAddr = srcAddr
submitSM.DestAddr = destAddr
switch strings.ToLower(encoding) {
case unicodeEncoding:
	encodedMessage, err = encodeUnicode(message)
	if err != nil {
		return nil, errors.Wrap(err, "encodeUnicode")
	}
	enc = data.UCS2
case gsmEncoding:
	encodedMessage, err = encodeGSM7(message)
	if err != nil {
		return nil, errors.Wrap(err, "encodeGSM7")
	}
	enc = data.GSM7BIT
default:
	encodedMessage, err = encodeGSM7(message)
	if err != nil {
		return nil, errors.Wrap(err, "encodeGSM7")
	}
	enc = data.GSM7BIT
 }

optionalData := pdu.Field{
	Tag:  pdu.TagMessagePayload,
	Data: encodedMessage,
}
shortMsg, err := pdu.NewShortMessageWithEncoding("", enc)
if err != nil {
	log.Println(err.Error(), "ERROR")
	return nil, errors.Wrap(err, "NewShortMessageWithEncoding")
}
submitSM.RegisterOptionalParam(optionalData)
submitSM.Message = shortMsg
submitSM.ProtocolID = 0
submitSM.RegisteredDelivery = 1
submitSM.ReplaceIfPresentFlag = 0
submitSM.EsmClass = 0
submitSM.SetSequenceNumber(mid)

return submitSM, nil

}

`
Much thanks.

@laduchesneau
Copy link
Collaborator

Looking at your code, everything looks good.

GSM isnt defined as a data_encoding in the specs. gosmpp uses 0 defined as SMSC Default Alphabet. 0 is the default encoding, if you arent sending a data_encoding, you are sending 0. My guess is you are sending 0 and your provider is expecting something else than 0.

@bluewithanas
Copy link
Author

bluewithanas commented Feb 1, 2025

My provider expects me to send data_coding value as 1 while using GSM7bit encoding . Can we provide a feature to make this configurable?

@laduchesneau
Copy link
Collaborator

Have a look at issue #143, specifically at this comment

@bluewithanas
Copy link
Author

Okay, as sugested I added the following. please check the last line. Will let you know the results here.

`

case unicodeEncoding:
	encodedMessage, err = encodeUnicode(message)
	if err != nil {
		return nil, errors.Wrap(err, "encodeUnicode")
	}
	enc = data.UCS2
case gsmEncoding:
	encodedMessage, err = encodeGSM7(message)
	if err != nil {
		return nil, errors.Wrap(err, "encodeGSM7")
	}
	enc = data.GSM7BIT
default:
	encodedMessage, err = encodeGSM7(message)
	if err != nil {
		return nil, errors.Wrap(err, "encodeGSM7")
	}
	enc = data.GSM7BIT
}

optionalData := pdu.Field{
	Tag:  pdu.TagMessagePayload,
	Data: encodedMessage,
}
shortMsg, err := pdu.NewShortMessageWithEncoding("", enc)
if err != nil {
	log.Println(err.Error(), "ERROR")
	return nil, errors.Wrap(err, "NewShortMessageWithEncoding")
}
shortMsg.SetMessageDataWithEncoding(encodedMessage, enc)

`

@bluewithanas
Copy link
Author

bluewithanas commented Feb 1, 2025

Hello,

still data_coding field is not visible here, i only see withoutDataCoding is set as false.

please check the submitSM that i logged before sending.

*pdu.SubmitSM)({
	base: (pdu.base) {
		Header: (pdu.Header) {
			CommandLength: (int32) 0,
			CommandID: (data.CommandIDType) SUBMIT_SM,
			CommandStatus: (data.CommandStatusType) ESME_ROK,
			SequenceNumber: (int32) 529127744
		},
		OptionalParameters: (map[pdu.Tag]pdu.Field) (len=1) {
			(pdu.Tag) 1060: (pdu.Field)  est disponible. RDV � aupr�s d'un vendeur avec une pi�ce d'identit� .
		}
	},
	ServiceType: (string) "",
	SourceAddr: (pdu.Address) ABC,
	DestAddr: (pdu.Address) 78981789817,
	EsmClass: (uint8) 0,
	ProtocolID: (uint8) 0,
	PriorityFlag: (uint8) 0,
	ScheduleDeliveryTime: (string) "",
	ValidityPeriod: (string) "",
	RegisteredDelivery: (uint8) 1,
	ReplaceIfPresentFlag: (uint8) 0,
	Message: (pdu.ShortMessage) {
		SmDefaultMsgID: (uint8) 0,
		message: (string) "",
		enc: (*data.gsm7bit)({
			packed: (bool) false
		}),
		udHeader: (pdu.UDH) <nil>,
		messageData: ([]uint8) (len=127) {
			<MESSAGE DATA HERE IS IN CORRECT ALPHABETS>
		},
		withoutDataCoding: (bool) false
	}
})

Also, FYI i set my encoded content in optional parameters.

@bluewithanas
Copy link
Author

bluewithanas commented Feb 1, 2025

Can i do the following here?

type SubmitSM struct {
	base
	ServiceType          string
	SourceAddr           Address
	DestAddr             Address
	EsmClass             byte
	ProtocolID           byte
	PriorityFlag         byte
	ScheduleDeliveryTime string // not used
	ValidityPeriod       string // not used
	RegisteredDelivery   byte
	ReplaceIfPresentFlag byte // not used
	Message              ShortMessage
}
  1. Support DataCoding field in Submit_sm struct.
  2. Manually assign SubmitSM.DataCoding as 1 before submitting submit_sm?
  3. Also, do i need to update the SMPP equivalent notation of the field DataCoding somewhere?

@linxGnu @laduchesneau

@laduchesneau
Copy link
Collaborator

Hi, I think you misunderstood what was mentioned in #143 .You do not need to modify the submit_sm and should not use data.GSM7BIT, this automatically set DCS to 0. You need to use a custome encoder that encode the message in GSM and sets the DCS to 1. Why you need a custom ? Because the library does not have an encoder for GSM that set DCS to 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants