Added support for flash messages
This commit is contained in:
+4
-1
@@ -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 = {
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
+4
-1
@@ -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
|
||||
|
||||
// Detect encoding if is not set already
|
||||
if (obj.params.data_coding === undefined) {
|
||||
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');
|
||||
|
||||
// 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;
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
"url": "https://github.com/larvit/larvitsmpp",
|
||||
"type": "git"
|
||||
},
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"readmeFilename": "README.md",
|
||||
"readme": "larvitsmpp",
|
||||
"bugs": {
|
||||
|
||||
Reference in New Issue
Block a user