farhadi / farhadi/node-smpp

Support for user-defined TLVs

Open
#231 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
435
Forks
194
PR merge metrics
No merged PRs in 30d

Description

It would be a great feature to add support for user-defined TLVS. From what I could see testing the code –and assuming I'm not doing something wrong–, only pre-defined TLVs are supported.

From what I could see, the library recognizes the TLVs and includes them in the PDUs with the HEX value converted to a number and passed as a string. But if I try to use the same approach when sending a message, the TLV is not passed downstream.

EXAMPLE 1 – Sent a message using a server instance, passing a custom TLV, 0x3C02 with the value "TEST" and in the PDU dump I've got:

`'15362': `

Then I tried to send it using a client instance like this:

```
import smpp from 'smpp'

const session = smpp.connect({
url: 'smpp://127.0.0.1:2775',
auto_enquire_link_period: 30000,
debug: true
}, function () {
session.bind_transceiver({
system_id: 'test',
password: 'test'
}, function (pdu) {
if (pdu.command_status === 0) {
session.submit_sm({
destination_addr: '11234567890',
short_message: 'Test TLV',
'15362': Buffer.from('TEST')
}, function (pdu) {
if (pdu.command_status === 0) {
console.log(pdu.message_id)
}
})
}
})
})
```

The TLV is not in the MT PDU:

example_1

Then I edited the "tlvs" variable in defs.js and added this at the end:

```
//Adding my own TLV.
my_own_tlv: {
id: 0x3c02,
type: types.tlv.buffer
}
```

Then tried again using the added TLV:

```
import smpp from 'smpp'

const session = smpp.connect({
url: 'smpp://127.0.0.1:2775',
auto_enquire_link_period: 30000,
debug: true
}, function () {
session.bind_transceiver({
system_id: 'test',
password: 'test'
}, function (pdu) {
if (pdu.command_status === 0) {
session.submit_sm({
destination_addr: '11234567890',
short_message: 'Test TLV',
my_own_tlv: Buffer.from('TEST')
}, function (pdu) {
if (pdu.command_status === 0) {
console.log(pdu.message_id)
}
})
}
})
})
```

Now the TLV shows up on the packet capture:

example_2

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.