Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is coding and charset MSG properties used? #1

Open
tamerMarzouk opened this issue Mar 30, 2017 · 9 comments
Open

is coding and charset MSG properties used? #1

tamerMarzouk opened this issue Mar 30, 2017 · 9 comments
Assignees

Comments

@tamerMarzouk
Copy link

tamerMarzouk commented Mar 30, 2017

When using the smsbox.send, I don't see that the charset nor coding properties are used.
How do I send Arabic text. In kannel url I used to set coding=2 url parameter, and charset=UTF-16BE, and text = hex
I changed the sendSMS function like this to add charset and coding
the text I sent as a buffer with hex encoding.

smsbox.prototype.sendSMS = function(conf) {
    var def = {
        id: true,
        time: Math.floor((new Date).getTime() / 1000),
        sender: undefined,
        receiver: undefined,
        msgdata: undefined,
        charset: undefined, //added these two lines
        coding: undefined
    };
    for (var property in def)
        if (!conf.hasOwnProperty(property))
            conf[property] = def[property];
    if (!conf.receiver || !conf.msgdata) return null;
    this.write("sms", {
        sender: conf.sender,
        receiver: conf.receiver,
        msgdata: conf.msg || conf.text || conf.msgdata,
        time: conf.time,
        id: conf.id || true,
        sms_type: status.sms.mt_reply,
        coding: conf.coding, //added these two lines
        charset: conf.charset
    });
    return true;
};
@badlee badlee self-assigned this Mar 30, 2017
@badlee
Copy link
Owner

badlee commented Mar 30, 2017

Hey @tamerMarzouk thank's to use my nodejs module, I'll add this feature.

@badlee
Copy link
Owner

badlee commented Mar 30, 2017

@tamerMarzouk, I have add two functions to hep you,

app.sendUCS2SMS({
	sender: 'TEST',
	receiver: '06462845',
	msgdata: 'Bonjour, Hi, 你好, صباح الخير', // UCS2 text
});
app.flashUCS2SMS({
	sender: 'TEST',
	receiver: '06462845',
	msgdata: 'Bonjour, Hi, 你好, صباح الخير', // UCS2 text
});

I hope help you again.

@badlee badlee closed this as completed Mar 30, 2017
@tamerMarzouk
Copy link
Author

I think the example is not correct.
you should provide the msgdata must be encoded as UTF-16BE, if sent as is it will not received correctly.
I use

msgdata: Buffer.from('063106330627064406290020','hex')

@badlee
Copy link
Owner

badlee commented Mar 30, 2017

Can you test, UCS2 is UTF16BE, the buffer has correctly converted now.

@tamerMarzouk
Copy link
Author

My Setup is not connected to a live SMSC right now. I will try to send as soon as I could.
But in nodejs , UCS2 s an alias for UTF-16LE

@badlee
Copy link
Owner

badlee commented Mar 31, 2017

@tamerMarzouk, do you have test the new version of kannel(nom module)?

@badlee badlee reopened this Mar 31, 2017
@tamerMarzouk
Copy link
Author

I've tested the new version of kannel.
The MSG class has a missing ")" on line node_modules/kannel/lib/MSG.js:76
I've added the missing ")" and tried using the flashUCS2SMS with utf-16be encoded buffer but the SMS received was not correct format.
I tried using flashUCS2SMS with an Arabic string as is but the msg received was not correct format and the coding was 0 and charset utf-8

@tamerMarzouk
Copy link
Author

tamerMarzouk commented Apr 9, 2017

I've just used sendSMS function and added two lines to the following code

 this.write("sms", {
        sender: conf.sender,
        receiver: conf.receiver,
        msgdata: conf.msg || conf.text || conf.msgdata,
        coding: conf.coding, //added this line
        charset: conf.charset,// added this line
        time: conf.time,
        id: conf.id || true,
        sms_type: status.sms.mt_reply
    });

then When I send Arabic text I provide code=2 and charset='UTF-16BE' and the msgdata is a string representation in hex for example '06310633062706440629' which is the Arabic word 'رسالة'

The above works good for me and is the same format received by an SMS app as if it was sent from kannel push SMS URL.

@badlee
Copy link
Owner

badlee commented Apr 11, 2017

Hi @tamerMarzouk,

Please update kannel.js to the last version, and use sendUCS2SMS or flashUCS2SMS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants