GithubHelp home page GithubHelp logo

Comments (7)

CodeMonkeyKevin avatar CodeMonkeyKevin commented on September 22, 2024
x, _ := smpp.ParsePdu(b)

// Writing Normal Fields
x.SetField("data_coding", 1)
x.SetField("destination_addr", "15156855111")
x.SetField("validity_period", "")

// Reading all Normal Fields
for _, v := range x.MandatoryFieldsList() {
  f := x.GetField(v)
  fmt.Println(v, ":", f, "|")
}

// Writing Optional Fields
x.SetTLVField(30, 2, []byte{0, 0})

// Reading Optional Fields
for t, v := range x.TLVFields() {
  fmt.Println(t, ":", v.Value())
}

from smpp34.

jaroszan avatar jaroszan commented on September 22, 2024

Thanks, I have checked in the code and from I've found (fair warning: my golang knowledge is rather crude) it seems that I can't extend examples (trx_example.go in particular) with this code and some deeper code manipulation is required.

In particular it seems that I need to extend smpp34/smpp.go to accept extra parameter for the TLV fields for the selected PDU. Is it a proper way to go?

Or may be the optimal way would be to copy code from smpp.go and build PDU in the example code from the ground up?

from smpp34.

CodeMonkeyKevin avatar CodeMonkeyKevin commented on September 22, 2024

You won't have the change smpp.go. You can set any TLV using SetTLVField. Which PDU are you trying to set TLV for and what is the TLV you are trying to set?

from smpp34.

jaroszan avatar jaroszan commented on September 22, 2024

I am trying to set user_message_reference, payload_type and message_payload TLVs for submit_sm in transceiver mode and I am looking at transceiver example.

It looks that the following line does both building and sending PDU:

seq, err := trx.SubmitSm("test", "test2", "msg", &smpp.Params{})

When I look at smpp.go I see that only regular fields are processed as params and no handling of TLV fields is done on that level. I suspect that setting TLVs should be done on the lower level (I have been trying to understand in details how library works but so far not everything is clear to me)

from smpp34.

CodeMonkeyKevin avatar CodeMonkeyKevin commented on September 22, 2024

Jaroszan,

I see what you mean. This will require a trx api change to SubmitSm I'll put it out in the next release but you use the below code as a drop in replacement and a work around before the api change.

// create SubmitSm PDU without writing it to the write
pdu, err := trx.Smpp.SubmitSm("test", "test2", "msg", &smpp.Params{})

// set TLV
pdu.SetTLVField(30, 2, []byte{0, 0})

// write PDU to write
if err := trx.Write(p); err != nil {
    // sending PDU error
}

from smpp34.

jaroszan avatar jaroszan commented on September 22, 2024

Thanks, it worked almost outside the box:

if err := trx.Write(pdu); err != nil {
// sending PDU error
}

It seems that setting TLV field in the following way is rather prone:

pdu.SetTLVField(30, 2, []byte{0, 0})

I am setting it in the following way:

message_payload := []byte{0x73, 0x73, 0x73}
length_mp := len(message_payload)
seq.SetTLVField(1060, length_mp, message_payload)

I guess SetTLVField could be optimized to accept 2 parameters and calculate payload length inside this function:

func (s *SubmitSm) SetTLVField(t int, v []byte) error {
    l := len(v) 
    s.tlvFields[uint16(t)] = &TLVField{uint16(t), uint16(l), v}
    return nil
}

But I haven't checked it yet.

As far as I am concerned this particular issue is clarified and can be closed.

from smpp34.

kharry5 avatar kharry5 commented on September 22, 2024

Was any change ever made to support this at the transmitter / transceiver level?

from smpp34.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.