Added support for flash messages
This commit is contained in:
+4
-1
@@ -93,7 +93,8 @@ consts = {
|
|||||||
ISO_2022_JP: 0x0A,
|
ISO_2022_JP: 0x0A,
|
||||||
EXTENDED_KANJI_JIS: 0x0D,
|
EXTENDED_KANJI_JIS: 0x0D,
|
||||||
X_0212_1990: 0x0D,
|
X_0212_1990: 0x0D,
|
||||||
KS_C_5601: 0x0E
|
KS_C_5601: 0x0E,
|
||||||
|
FLASH: 0x10
|
||||||
},
|
},
|
||||||
NETWORK: {
|
NETWORK: {
|
||||||
GENERIC: 0x00,
|
GENERIC: 0x00,
|
||||||
@@ -451,6 +452,8 @@ encodings.ASCII = { // GSM 03.38
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
encodings.FLASH = encodings.ASCII;
|
||||||
|
|
||||||
encodings.ASCII.init();
|
encodings.ASCII.init();
|
||||||
|
|
||||||
encodings.LATIN1 = {
|
encodings.LATIN1 = {
|
||||||
|
|||||||
@@ -341,6 +341,7 @@ function sendReturn(pdu, status, params, closeAfterSend, callback) {
|
|||||||
* to - international format
|
* to - international format
|
||||||
* message - string
|
* message - string
|
||||||
* dlr - boolean defaults to false
|
* dlr - boolean defaults to false
|
||||||
|
* flash - boolean defaults to false
|
||||||
* @param func callback(err, smsIds, retPduObjs)
|
* @param func callback(err, smsIds, retPduObjs)
|
||||||
*/
|
*/
|
||||||
function sendSms(smsOptions, callback) {
|
function sendSms(smsOptions, callback) {
|
||||||
@@ -354,6 +355,12 @@ function sendSms(smsOptions, callback) {
|
|||||||
'short_message': smsOptions.message
|
'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!
|
// Request DLRs!
|
||||||
if (smsOptions.dlr) {
|
if (smsOptions.dlr) {
|
||||||
pduObj.params.registered_delivery = 0x01;
|
pduObj.params.registered_delivery = 0x01;
|
||||||
@@ -650,6 +657,10 @@ function session(sock) {
|
|||||||
'sendDlr': smsDlr
|
'sendDlr': smsDlr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (pduObj.params.data_coding === 0x10) {
|
||||||
|
smsObj.flash = true;
|
||||||
|
}
|
||||||
|
|
||||||
returnObj.emit('sms', smsObj);
|
returnObj.emit('sms', smsObj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -405,13 +405,16 @@ function objToPdu(obj, callback) {
|
|||||||
|
|
||||||
// If param "short_message" exists, encode it and set parameter "data_coding" accordingly
|
// 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)) {
|
if (obj.params.short_message !== undefined && ! Buffer.isBuffer(obj.params.short_message)) {
|
||||||
// Detect encoding
|
|
||||||
|
// Detect encoding if is not set already
|
||||||
|
if (obj.params.data_coding === undefined) {
|
||||||
obj.params.data_coding = defs.encodings.detect(obj.params.short_message);
|
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');
|
log.silly('larvitsmpp: lib/utils.js: objToPdu() - data_coding "' + obj.params.data_coding + '" detected');
|
||||||
|
|
||||||
// Now set the hex value
|
// Now set the hex value
|
||||||
obj.params.data_coding = defs.consts.ENCODING[obj.params.data_coding];
|
obj.params.data_coding = defs.consts.ENCODING[obj.params.data_coding];
|
||||||
|
}
|
||||||
|
|
||||||
// Acutally encode the string
|
// Acutally encode the string
|
||||||
shortMsg = obj.params.short_message;
|
shortMsg = obj.params.short_message;
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@
|
|||||||
"url": "https://github.com/larvit/larvitsmpp",
|
"url": "https://github.com/larvit/larvitsmpp",
|
||||||
"type": "git"
|
"type": "git"
|
||||||
},
|
},
|
||||||
"version": "0.1.3",
|
"version": "0.1.4",
|
||||||
"readmeFilename": "README.md",
|
"readmeFilename": "README.md",
|
||||||
"readme": "larvitsmpp",
|
"readme": "larvitsmpp",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|||||||
Reference in New Issue
Block a user