Added support for flash messages

This commit is contained in:
2015-06-16 17:58:39 +02:00
parent 2f65fd118b
commit 96a9e2c46a
4 changed files with 24 additions and 7 deletions
+4 -1
View File
@@ -93,7 +93,8 @@ consts = {
ISO_2022_JP: 0x0A,
EXTENDED_KANJI_JIS: 0x0D,
X_0212_1990: 0x0D,
KS_C_5601: 0x0E
KS_C_5601: 0x0E,
FLASH: 0x10
},
NETWORK: {
GENERIC: 0x00,
@@ -451,6 +452,8 @@ encodings.ASCII = { // GSM 03.38
}
};
encodings.FLASH = encodings.ASCII;
encodings.ASCII.init();
encodings.LATIN1 = {
+11
View File
@@ -341,6 +341,7 @@ function sendReturn(pdu, status, params, closeAfterSend, callback) {
* to - international format
* message - string
* dlr - boolean defaults to false
* flash - boolean defaults to false
* @param func callback(err, smsIds, retPduObjs)
*/
function sendSms(smsOptions, callback) {
@@ -354,6 +355,12 @@ function sendSms(smsOptions, callback) {
'short_message': smsOptions.message
};
// Flash messages overrides default data_coding
if (smsOptions.flash) {
log.debug('larvitsmpp: lib/session.js: sendSms() - Flash SMS detected, set data_coding to 0x10!');
pduObj.params.data_coding = 0x10;
}
// Request DLRs!
if (smsOptions.dlr) {
pduObj.params.registered_delivery = 0x01;
@@ -650,6 +657,10 @@ function session(sock) {
'sendDlr': smsDlr
};
if (pduObj.params.data_coding === 0x10) {
smsObj.flash = true;
}
returnObj.emit('sms', smsObj);
};
+8 -5
View File
@@ -405,13 +405,16 @@ function objToPdu(obj, callback) {
// If param "short_message" exists, encode it and set parameter "data_coding" accordingly
if (obj.params.short_message !== undefined && ! Buffer.isBuffer(obj.params.short_message)) {
// Detect encoding
obj.params.data_coding = defs.encodings.detect(obj.params.short_message);
log.silly('larvitsmpp: lib/utils.js: objToPdu() - data_coding "' + obj.params.data_coding + '" detected');
// Detect encoding if is not set already
if (obj.params.data_coding === undefined) {
obj.params.data_coding = defs.encodings.detect(obj.params.short_message);
// Now set the hex value
obj.params.data_coding = defs.consts.ENCODING[obj.params.data_coding];
log.silly('larvitsmpp: lib/utils.js: objToPdu() - data_coding "' + obj.params.data_coding + '" detected');
// Now set the hex value
obj.params.data_coding = defs.consts.ENCODING[obj.params.data_coding];
}
// Acutally encode the string
shortMsg = obj.params.short_message;