question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use the short_message object with UDH and message properties?

See original GitHub issue

Hi. I’m having trouble using UDH to concatenate the messages. Can someone show me a simple example? The below is what I have tried:

` // begin const config = require(‘…/src/config.json’);

var smpp = require(‘smpp’); var session = smpp.connect(config.smppSession);

smpp.encodings.default = ‘UCS2’;

session.bind_transceiver({ system_id: config.systemId, password: config.systemPassword }, (pdu) => { if (pdu.command_status === 0) {

// here I try to send some messages
session.submit_sm({
  source_addr: config.sourceAddress,
  destination_addr: config.destinationAddress,
  short_message: {
    udh: Buffer.from([0x05, 0x00, 0x03, 0x05, 0x02, 0x01]),
    message: "Hello World!"
  }
}, (pdu) => {
  if (pdu.command_status === 0) {
    console.log("First OK");
  } else {
    console.log("First Error");
  }
});

// here's the second message I want to concatenate with
// the first
session.submit_sm({
  source_addr: config.sourceAddress,
  destination_addr: config.destinationAddress,
  short_message: {
    udh: Buffer.from([0x05, 0x00, 0x03, 0x05, 0x02, 0x02]),
    message: "Hello from Another World!"
  }
}, (pdu) => {
  if (pdu.command_status === 0) {
    console.log("Second OK");
  } else {
    console.log("Second Error");
  }
});

} }); // end `

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ritmascommented, Sep 14, 2017

Try this code snippet (that’s what I’m using):

/* concatenate SMS */
var messages = [
        'Hello World!',
        'Hello from Another World!'
    ],
    concatRef = Math.floor(Math.random() * 255);
for (var i = 0; i < messages.length; i++) {
    var smsPart = messages[i],
        udh = new Buffer(6);
    udh.write(String.fromCharCode(0x5), 0); /* Length of UDH */
    udh.write(String.fromCharCode(0x0), 1); /* Indicator for concatenated message */
    udh.write(String.fromCharCode(0x3), 2); /* Subheader Length (3 bytes) */
    udh.write(String.fromCharCode(concatRef), 3); /* Same reference for all concatenated messages */
    udh.write(String.fromCharCode(messages.length), 4); /* Number of total messages in the split */
    udh.write(String.fromCharCode(i + 1), 5); /* Sequence number (used by the mobile to concatenate the split messages) */

    session.submit_sm({
        destination_addr: config.destinationAddress,
        source_addr: config.sourceAddress,
        short_message: {udh: udh, message: smsPart}
    }, function(pdu) {
        //
    });
}

If that does not resolve your issue, probably you need to debug on server side.

0reactions
hmnk-hdmcommented, Sep 20, 2017

The error turned out to be server side. I’m not sure why and how it was fixed. Sorry. I think some changes were made on server-connection.js file in this https://github.com/Roave/shorty in lib and that caused the issue with UDH messages. After it was fixed, I could run your code. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Short Message Peer to Peer Protocol Specification v3.4 - SMPP
WARRANT THE ACCURACY OR SUITABILITY OF SAME FOR ANY SPECIFIC USE. SMPP ... The Short Message Peer to Peer (SMPP) protocol is an...
Read more >
17 Binary Short Messaging
udh. String in base64Binary. Specifies if the TP-User Data (TP-UD) field contains only the short message, or if it also contains the header...
Read more >
ETSI TS 131 115 V9.1.1 (2013-08)
The generalised structure of the UDH in the Short Message element is contained in the User Data part of the Short. Message element...
Read more >
TimeSent Property (Message Object) - Microsoft Learn
The TimeReceived and TimeSent properties set and return dates and times as the local time for the users system. When you send messages...
Read more >
3GPP TS 23.040 V9.3.0 (2010-09)
Technical realization of the Short Message Service (SMS) ... The Organizational Partners accept no liability for any use of this ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found