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

TLV Data #31

Closed
yepher opened this issue Dec 7, 2015 · 9 comments
Closed

TLV Data #31

yepher opened this issue Dec 7, 2015 · 9 comments

Comments

@yepher
Copy link

yepher commented Dec 7, 2015

I have your sample code which works fine with one SMPP server but in another case I am have having a problem. This is what I have:

var smpp = require('smpp');
var session = smpp.connect('smpp_server', 2775);
session.bind_transceiver({
    system_id: 'smppclient1',
    password: 'password'
}, function(pdu) {
    if (pdu.command_status == 0) {
        // Successfully bound
        session.submit_sm({
            destination_addr: '8475551212',
            short_message: 'Hello!'
        }, function(pdu) {
            if (pdu.command_status == 0) {
                // Message successfully sent
                console.log(pdu.message_id);
            }
        });
    }
});

Turns out I need to send TLV like this one:

abc42xyz_operator,   0x1520,1,5, 5,0x03,CUSTMR_13914533_TESTIPC_111_D

I looked at the GitHub page and I see you mention TLV as an Array but I don't see how it would be put into the javascript.

I see this in smpp.js but I am not sure how to apply that to the TLV:

exports.addTLV = function(tag, options) {
    options.tag = tag;
    defs.tlvs[tag] = options;
    defs.tlvsById[options.id] = options;
};
@ihusejnovic
Copy link

Try:

smpp.tlvs['abc42xyz_operator'] = {
    id: 0x1520,
    type: smpp.types.tlv.string
};

session.submit_sm({
                destination_addr: '8475551212',
                short_message: 'Hello!',
                abc42xyz_operator: 'CUSTMR_13914533_TESTIPC_111_D'    
           }, function(pdu) {
                if (pdu.command_status == 0) {
                    // Message successfully sent
                    console.log(pdu.message_id);
                }
           });

@yepher
Copy link
Author

yepher commented Dec 8, 2015

Yes, you were exactly right. Thank you. I've seen question here and there for how to do this. I will add an example to the README and send a pull request. Use it if you want.

@yepher yepher closed this as completed Dec 8, 2015
@farhadi
Copy link
Owner

farhadi commented Dec 8, 2015

The correct way to add a custom TLV is by using addTLV method like this:

smpp.addTLV('abc42xyz_operator', {
    id: 0x1520,
    type: smpp.types.tlv.string
});

@yepher
Copy link
Author

yepher commented Dec 8, 2015

Do you still need this in the sumit_sm body?

abc42xyz_operator: 'CUSTMR_13914533_TESTIPC_111_D' 

@farhadi
Copy link
Owner

farhadi commented Dec 8, 2015

Yes, you need to use addTLV once to tell smpp module how to handle a abc42xyz_operator TLV parameter. And then you can use this TLV parameter in your PDUs e.g. in a submit_sm.

@yepher
Copy link
Author

yepher commented Dec 9, 2015

Since you said to only include once is this what you mean?

var smpp = require('smpp');
smpp.addTLV('abc42xyz_operator', {
    id: 0x1520,
    type: smpp.types.tlv.string
});
var session = smpp.connect('smpp_server', 2775);
session.bind_transceiver({
    system_id: 'smppclient1',
    password: 'password'
}, function(pdu) {
    if (pdu.command_status == 0) {
        // Successfully bound
        session.submit_sm({
            destination_addr: '8475551212',
            short_message: 'Hello!'
            abc42xyz_operator: 'CUSTMR_13914533_TESTIPC_111_D'    
        }, function(pdu) {
            if (pdu.command_status == 0) {
                // Message successfully sent
                console.log(pdu.message_id);
            }
        });
    }
});

Originally I was doing the tlv setup in the just before session_submit_sm but I think based on your feedback that is wrong.

@farhadi
Copy link
Owner

farhadi commented Dec 10, 2015

Yes, that is exactly how addTLV method should be used.

@yepher
Copy link
Author

yepher commented Dec 10, 2015

Thanks @farhadi

By the way this is a very nice tool you have built.

@farhadi
Copy link
Owner

farhadi commented Dec 13, 2015

@yepher Thanks for your interest.

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

3 participants