maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   SMS from CLI (Command Line)? (https://talk.maemo.org/showthread.php?t=36148)

sakya 2011-02-10 09:48

Re: SMS from CLI (Command Line)?
 
The problem with autosend is that the conversation app always popups showing the sent message, there's no way in QtMobility to avoid this.
I can easily add this feature, but is it what you want/need?

To avoid simultaneous database writes I'll add an "IMMEDIATE TRANSACTION", thanks.

hutchinsfairy 2011-02-10 09:56

Re: SMS from CLI (Command Line)?
 
I would want it to pop up, I think that would be the expected behaviour for me! I use smssend over ssh at work so I'm not obviously using my phone but I can still look at it for replies. I also schedule (alarmd) sms messages if I'm up in the night (kids) and don't want to wake people so it's useful to get that feedback that it was sent!

sakya 2011-02-10 10:04

Re: SMS from CLI (Command Line)?
 
Ok, I'll add this feature soon. ;)

hutchinsfairy 2011-02-10 13:16

Re: SMS from CLI (Command Line)?
 
0.1.4 Works a charm! Thank you very much.

sakya 2011-02-10 13:24

Re: SMS from CLI (Command Line)?
 
Many thanks for the feedback. :)

tremby 2011-02-10 15:58

Re: SMS from CLI (Command Line)?
 
I'll definitely be trying this at some point soon. But hutchinsfairy, I might have something that interests you so you can check your replies without looking at your phone...

http://sprunge.us/HMQH?sh
(plain text: http://sprunge.us/HMQH)

Help message:
Code:

<user@t900:~> texts --help
Usage: texts [-h|--help] [-n <contact name>] [-d <date of earliest message to be returned>|--latest|--recent]
--latest or --recent switch gives last 24 hours' worth

Last 24 hours' worth (piped to tail to get last 3 messages):
Code:

<user@t900:~>$ texts --latest | tail -n 3
2011-02-09 1748        Simon        <        Running by Tesco on my way home. Anything you guys need? Si :-)
2011-02-09 1801        Simon        >        vitamins, if it's not too late
2011-02-09 1907        Rikki        <        Http://innocentdrinks.com/recipearchive

As you can see, it puts the date and time, their number or their name if it knows it (from an optional mapping file, tab-separated number to name), then < for incoming or > for outgoing, then the message.

First three messages from a particular date from a particular person (it looks at an optional mapping file to turn numbers into names):
Code:

<user@t900:~>$ texts -d 2010-04-01 -n Kiwi | head -n 3
2010-04-02 1507        Kiwi        <        Are your faces going to be at Claires tomorrow? Looking forward to seeing you if the are. Xx
2010-04-02 1509        Kiwi        >        didn't know Claire had a thing. kinda want to see Tiny anyway.
2010-04-02 1511        Kiwi        <        Is Tiny visiting? Bring him to Claires!? How are you? X

There are a lot of ways this could be improved (it'd be very nice for instance to be able to use the N900's contacts database itself rather than a mapping file, but I don't know how) but this does the trick for now.

Hope it helps.

sakya 2011-02-11 10:24

Re: SMS from CLI (Command Line)?
 
To promote the smssend package please test and rate for karma
http://maemo.org/packages/package_in...smssend/0.1.5/

sakya 2011-02-14 13:17

Re: SMS from CLI (Command Line)?
 
If someone cares this is the code to save a sms in the sent folder using rtcom-eventlogger:
Code:

bool SmsSender::saveMsgToSentFolder(QString number, QString message)
{
    bool result = false;
    QString partNumber = number.right(7);

    RTComElEvent* ev = rtcom_el_event_new();

    RTCOM_EL_EVENT_SET_FIELD(ev, service, g_strdup(QString("RTCOM_EL_SERVICE_SMS").toLatin1().data()));
    RTCOM_EL_EVENT_SET_FIELD(ev, event_type, g_strdup(QString("RTCOM_EL_EVENTTYPE_SMS_OUTBOUND").toLatin1().data()));
    RTCOM_EL_EVENT_SET_FIELD(ev, start_time, time(NULL));
    RTCOM_EL_EVENT_SET_FIELD(ev, end_time, time(NULL));
    RTCOM_EL_EVENT_SET_FIELD(ev, is_read, TRUE);
    RTCOM_EL_EVENT_SET_FIELD(ev, remote_ebook_uid, 0);
    RTCOM_EL_EVENT_SET_FIELD(ev, local_uid, g_strdup(QString("ring/tel/ring").toLatin1().data()));
    RTCOM_EL_EVENT_SET_FIELD(ev, local_name, g_strdup(QString("<SelfHandle>").toLatin1().data()));
    RTCOM_EL_EVENT_SET_FIELD(ev, remote_uid, number.toLatin1().data());
    RTCOM_EL_EVENT_SET_FIELD(ev, remote_name, g_strdup(QString("").toLatin1().data()));
    RTCOM_EL_EVENT_SET_FIELD(ev, group_uid, g_strdup(partNumber.toLatin1().data()));
    RTCOM_EL_EVENT_SET_FIELD(ev, free_text, g_strdup(message.toUtf8().data()));

    int id = rtcom_el_add_event(m_El, ev, NULL);
    if (id >= 0){
        QUuid uid = QUuid::createUuid();
        rtcom_el_add_header(m_El, id, QString("message-token").toLatin1().data(), uid.toString().toLatin1().data(), NULL);
        result = true;
    }

    rtcom_el_event_free(ev);

    return result;
}


tremby 2011-02-14 14:24

Re: SMS from CLI (Command Line)?
 
Sakya, do you have any plans to try to figure out longer-than-160-char texts?

laustmcgregor 2011-02-28 13:46

Re: SMS from CLI (Command Line)?
 
Hi,

I get
Code:

ERR: Failed to send at+cmgf command
From a comment in the source I understand (or think so) that it's because my SIM card is PIN protected.

I don't want to remove the PIN from my card, and I guess that the PIN code must be stored somewhere in the device for use when the "normal" sms application needs it.

-> Have you planned to search on that subject? I'll also search on my side and let you know if I find something.

sakya 2011-02-28 14:00

Re: SMS from CLI (Command Line)?
 
I'll add an argument to pass the pin to the program. ;)
Or maybe as you say it's stored somewhere (I'm not sure that this information is easily available, it shouldn't...)

laustmcgregor 2011-02-28 22:08

Re: SMS from CLI (Command Line)?
 
I think it must be available in d-bus stuff somewhere but haven't managed to get it yet..

tremby 2011-04-05 13:07

Re: SMS from CLI (Command Line)?
 
I finally got around to trying your SMS sender, sakya. From the small amount of testing I've done so far it seems good, but both of the >160 character tests I've tried so far (without the compose dialog) have failed. In both cases I got this output (same number of dots each time too):

Code:

WARNING: SMS exceding 160 characters
        Splitted in 2 parts
Sendind SMS:
[1/2]....
ERR: Failed to send text message
[2/2].....OK

My friend's phone gets the second half of the message fine, the first half has not arrived.

The content of the text, if it matters, was this:
Code:

1......... 2......... 3......... 4......... 5......... 6......... 7......... 8......... 9......... 10........ 11........ 12........ 13........ 14........ 15........ 16........ 17........ let's see if this all gets through
I've got some suggestions for other improvements but we'll get to those soon.

tremby 2011-04-05 13:24

Re: SMS from CLI (Command Line)?
 
Not sure if it's a clue, but I looked at the events database and in the remote_uid column for both of the failed >160-char texts contains
Code:

+447
rather than the full number they were sent to (which did start +447 -- not sure where the 0011 character came from).

sakya 2011-04-05 16:45

Re: SMS from CLI (Command Line)?
 
@tremby: thanks for the feedback.
Can you please try to send the message adding this argument?
Code:

-l logfile.txt
It should log the strings sent/received from pnatd.

tremby 2011-04-05 18:00

Re: SMS from CLI (Command Line)?
 
Hope the following helps:

Code:

$ smssend -l smslog -n $(num Pat) -m "1........ 2........ 3........ 4........ 5........ 6........ 7........ 8........ 9........ 10....... 11....... 12....... 13....... 14.......  this was the half and here is second half. let me know if you got the first half"

[snip]
WARNING: SMS exceding 160 characters
        Splitted in 2 parts
Sendind SMS:
[1/2]....
ERR: Failed to send text message
[2/2].....OK

$ cat smslog
AT
AT+CMGF=1
OK
AT+CSMP=17,167,0,0
OK
AT+CMGS="+447xxxxxxxxx"
> 1........ 2........ 3........ 4........ 5........ 6........ 7........ 8........ 9........ 10....... 11....... 12....... 13....... 14.......  this was the half 1........ 2........ 3........ 4........ 5........ 6........ 7........ 8........ 9........ 10AT..... 11....... 12....... 13....... 14.......  this was the half AT
AT+CMGF=1
OK
AT+CSMP=17,167,0,0
OK
AT+CMGS="+447xxxxxxxxx"
> and here is second half. let me know if you got the first halfand here is second half. let me know if you got the first half
+CMGS: 203

OK


sakya 2011-04-05 19:30

Re: SMS from CLI (Command Line)?
 
Fixed, updated to version 0.1.8. ;)
Many thanks for your help.

godofwar424 2011-04-06 09:36

Re: SMS from CLI (Command Line)?
 
Hi

Could somebody help me make a desktop shortcut that sends this through x-term?

Code:

sudo smssend -n 150 -m "Ba"
Just need the desktop shortcut to open x-term, enter the command and then close x-term when done. Could anybody help me with this?

The reason I want this is because my service provider T-Mobile UK only allows me to check my balance using this method. I have to send a text to that number and they reply with my balance. A desktop shortcut that sends the text for me would save me ALOT of time.

Thanks in advance :)

EDIT: Figured it out myself :) Thanks for the awesome smssend app though :)

tremby 2011-04-06 12:10

Re: SMS from CLI (Command Line)?
 
Quote:

Originally Posted by sakya (Post 982607)
Fixed, updated to version 0.1.8. ;)
Many thanks for your help.

This time:

Code:

$ smssend -l smslog -n $(num Pat) -m "1........ 2........ 3........ 4........ 5........ 6........ 7........ 8........ 9........ 10....... 11....... 12....... 13....... 14... this was the first half and here is second half. let me know if you got the first half"
The output of that showed two "OK"s.

Here is the log:

Code:

AT
AT+CMGF=1
OK
AT+CSMP=17,167,0,0
OK
AT+CMGS="+447xxxxxxxxx"
> 1........ 2........ 3........ 4........ 5........ 6........ 7........ 8........ 9........ 10....... 11....... 12....... 13....... 14... this was the first half 1........ 2........ 3........ 4........ 5........ 6........ 7........ 8........ 9........ 10....... 11....... 12....... 13....... 14... this was the first half
+CMGS: 219

OK
AT
AT+CMGF=1
OK
AT+CSMP=17,167,0,0
OK
AT+CMGS="+447xxxxxxxxx"
> and here is second half. let me know if you got the first halfand here is second half. let me know if you got the first half
+CMGS: 220

OK

He received all the text but with the halves as separate messages, not a single joined message. Is that a known problem? Any plan to implement proper concatenated SMS?

Also, I then note that in the conversations app the message appears as sent to "(null)" and I can't open its conversation window. I looked in the database and I see that everything looks normal except the remote_uid column, which is, in this case (censored):

Code:

447xxxxxxxxx' AND local_uid = 'ring/tel/ring';
Any idea why that's happening?

sakya 2011-04-06 18:19

Re: SMS from CLI (Command Line)?
 
Quote:

Originally Posted by tremby (Post 982989)
He received all the text but with the halves as separate messages, not a single joined message. Is that a known problem? Any plan to implement proper concatenated SMS?

Yes it is a known problem (I never read about joined sms, but I thought something should be done to join them on the receiver mobile).
I'll read some docs to see if it is feasible.

Quote:

Also, I then note that in the conversations app the message appears as sent to "(null)" and I can't open its conversation window. I looked in the database and I see that everything looks normal except the remote_uid column, which is, in this case (censored):
It happened to me also a couple of times, I'll check if something is wrong.
If you update that record with the correct number all should be fine.

Many thanks again for the feedback.

tremby 2011-04-06 18:25

Re: SMS from CLI (Command Line)?
 
Are patches welcome? If so I'll fix some typos and suggest some invocation changes.

sakya 2011-04-06 18:58

Re: SMS from CLI (Command Line)?
 
Quote:

Originally Posted by tremby (Post 983210)
Are patches welcome?

Sure, patches are welcome! :)

tremby 2011-04-06 19:03

Re: SMS from CLI (Command Line)?
 
OK, here's an easy one -- some English fixed and the VP option's usage text clarified a bit.

http://sprunge.us/FhLK?diff

(Lose the ?diff extension for the raw version.)

I'll suggest my invocation changes later -- got a deadline tomorrow morning to see to first!


All times are GMT. The time now is 03:31.

vBulletin® Version 3.8.8