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)

白い熊 2010-03-19 18:39

Re: SMS from CLI (Command Line)?
 
Forget the above, that's not right, pnatd is part of phonet-at, but purging it would have you uninstall mp-fremantle-generic-pr which you don't wanna do.
Code:

apt-get --reinstall install phonet-at

白い熊 2010-03-19 18:47

Re: SMS from CLI (Command Line)?
 
Alternatively try just to setuid the pnatd executable
Code:

chmod 4555 /usr/bin/pnatd

zoner 2010-03-19 19:03

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

Originally Posted by 白い熊 (Post 573776)
alternatively try just to setuid the pnatd executable
Code:

chmod 4555 /usr/bin/pnatd

solved!!! :D

白い熊 2010-03-19 19:10

Re: SMS from CLI (Command Line)?
 
Send an SMS?

zoner 2010-03-19 20:41

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

Originally Posted by 白い熊 (Post 573804)
Send an SMS?

yes, everything works exactly as you intended.

I cannot edit my bbdb entries though, but bbdb is a funny animal. But that's a trivial matter running through the .bbdb file a few times with a keyboard macro or two.

It's this type of function (sms/call from emacs) that makes this device so powerful, it's unfortunate that the number of folks interested seems so small.

Thanks for helping figure out my issues.

白い熊 2010-04-05 14:43

Re: SMS from CLI (Command Line)?
 
New version of bbdb-nokia-n900 v 0.3:
http://sumoudou.org/0/27.html

Modified script, so point stays on record selected in BBDB and doesn't move to end after sending an SMS, or calling.

tremby 2010-05-18 13:00

Re: SMS from CLI (Command Line)?
 
I can't get the SMS script (http://www.paraiso.dk/pymaemosms.txt) working. I'm in the UK in case that matters and am feeding a number like
07123456789
and a message like
testing testing

It says "Message sent" but the phone I sent it to gets nothing. Any ideas what could be wrong?

There's also nothing new in the el.db file but perhaps I shouldn't be expecting anything there anyway when sending an SMS like this? (That's actually a major problem for me -- I will want my sent messages to appear in history.)

Thanks

tremby 2010-05-18 13:11

Re: SMS from CLI (Command Line)?
 
And it sounds like the Telepathy API way of sending SMSes would make more sense given that I want the message to be stored in "sent". What's the current state of that -- is there anything working and available?

gLobster 2010-05-18 13:15

Re: SMS from CLI (Command Line)?
 
It's way connect to phone for send message, but not connect to Message application for send.
By dbus-send you send "direct_to_phone" as modem.

tremby 2010-05-18 13:26

Re: SMS from CLI (Command Line)?
 
If I understand you correctly, I'm already clear on the differences between using dbus and Telepathy. But what I'm asking is whether the Telepathy API for SMS is working and usable -- and if so, where can I read about it?

krk969 2010-05-18 13:31

Re: SMS from CLI (Command Line)?
 
if I may suggest another option, Tpsession is even simpler to use in case it helps you. Its a wrapper over the telepathy libs, if you dont want to get your hands dirty ;)
http://tpsession.garage.maemo.org/

tremby 2010-05-18 14:12

Re: SMS from CLI (Command Line)?
 
Hmm, having had a look it looks nice but I don't even want to get my hands that dirty... If there were Python bindings on the other hand...

I actually just tried to install the Maemo SDK, thinking if it must be C it must be C, but am having no luck. That's a question for another thread, though.

ossipena 2010-05-18 14:17

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

Originally Posted by tremby (Post 664089)
I can't get the SMS script (http://www.paraiso.dk/pymaemosms.txt) working. I'm in the UK in case that matters and am feeding a number like
07123456789
and a message like
testing testing

It says "Message sent" but the phone I sent it to gets nothing. Any ideas what could be wrong?

There's also nothing new in the el.db file but perhaps I shouldn't be expecting anything there anyway when sending an SMS like this? (That's actually a major problem for me -- I will want my sent messages to appear in history.)

Thanks

it is some kind of a bug, number formatting function gives you errorenous data and message is not sent.

just copypaste the el.db code from gitorious?
www.gitorious.org/VertSMS

it is about 10 lines if I remember correctly. should be found in SMS.py

e: python bindings aren't a problem, you can use ctypes. But with rtcom API I haven't got anything working with storing the sms.

tremby 2010-05-18 14:22

Re: SMS from CLI (Command Line)?
 
Any idea how I can fix it?

And just so we're clear, the code you're pointing to is to add the SMS to the database, right?

Would the conversations app then have to be prodded to reload the database before the sent messages appear?

Thanks.

ossipena 2010-05-18 14:41

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

Originally Posted by tremby (Post 664225)
Any idea how I can fix it?

And just so we're clear, the code you're pointing to is to add the SMS to the database, right?

Would the conversations app then have to be prodded to reload the database before the sent messages appear?

Thanks.

I don't have any ideas yet. could you log the conversations dbus-output and the python scripts output when sending a message to 07 number?
(dbus-monitor > logfile.txt for example)

yes it adds it to database, there is small delay but don't know how it acts if conversations is open in background

tremby 2010-05-18 14:54

Re: SMS from CLI (Command Line)?
 
This is with the http://www.paraiso.dk/pymaemosms.txt script as is: http://sprunge.us/aIhe

This is with Cue's script back on page 6: http://sprunge.us/YMHI

I've replaced the number with 07XXXXXXXXX (same number of digits though).

ossipena 2010-05-19 06:02

Re: SMS from CLI (Command Line)?
 
update: there is now an API way to write stuff to rtcom eventlogger database!!! (million thankses again to frals and gri)

it can be found at newest push from gitorious.

should be straight in sms.py (green lines)

http://gitorious.org/vertsms/vertsms...faf78da4fed051

Patola 2010-06-26 17:27

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

Originally Posted by pende (Post 449749)
Hi there,

I added some code and now you are able to send sms and receive a reply. Code is available for download here http://ztbsauer.com/sender.py

For now it replies only for one command but feel free to expand it for own needs.

pende,

thanks for your script. It works wonderfully... For non-accented messages. It seems your deoctify() function fails for accented messages, any plans to fix this?

KiberGus 2010-06-26 21:31

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

Originally Posted by Patola (Post 730414)
pende,

thanks for your script. It works wonderfully... For non-accented messages. It seems your deoctify() function fails for accented messages, any plans to fix this?

Many people tend to think, that English is the only language in the world and ascii is the only encoding. In real, SMS is not always hex encoded 7-bit ascii. You may need to convert it from GSM encoding to needed (UTF-8?) encoding. Or it can be in UCS encoding. Or it can be mysterious user defined encoding.
Many posts ago I've written correct solution for decoding SMS PDU:
http://kibergus.su/node/17
The only change is that gsmdecode.py is now in ussd4all package instead of ussd-common.
Use gsmdecode.decode_pdu() for decoding PDU.

sergulo 2010-11-30 16:41

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

Originally Posted by goodwill (Post 438487)
I used dbus_glib to do the job. To send your SMS, I can do something like this.
Code:

#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#define MYTYPE (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_UCHAR_ARRAY))

DBusGConnection* dbus_conn;
DBusGProxy* dbus_proxy;

dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
dbus_proxy = dbus_g_proxy_new_for_name(dbus_conn, "com.nokia.phone.SMS", "/com/nokia/phone/SMS/ba212ae1","com.nokia.csd.SMS.Outgoing");

GPtrArray* ptrarray;
GArray* array;
guchar values[] = {33,5,11,145,33,67,101,135,9,241,0,0,10,225,112,56,28,14,135,195,225,48};

ptrarray = g_ptr_array_new();
array = g_array_new(FALSE, FALSE, sizeof(guchar));

g_array_append_vals(array, values, sizeof(values)/sizeof(guchar));
g_ptr_array_add(ptrarray, (gpointer)array);

dbus_g_proxy_call_no_reply(dbus_proxy, "Send", MY_TYPE, ptrarray, G_TYPE_STRING,"",G_TYPE_INVALID);

g_ptr_array_free(ptrarray,TRUE);
g_object_unref(dbus_proxy);
dbus_g_connection_unref(dbus_conn);


Hello dear Goodwill

I have tried this example to send an sms via G-LIB library but currently I need to send an sms using "dbus_g_proxy_call" g-lib method. Unfortunately I got a Segmentation Failure (though sms is sent) when calling this:

GError* error;

dbus_g_proxy_call_no_reply(dbus_proxy, "Send", &error, MY_TYPE, ptrarray, G_TYPE_STRING,"",G_TYPE_INVALID);

Please could you please give a hint how to fix that or is there any way to send an sms with reply version.

sutaburosu 2010-11-30 23:03

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

Originally Posted by Cue (Post 558430)
Code:

        try:
                digit_1 = int(str[0])
                digit_2 = int(str[1])
                octet = (digit_2 << 4) | digit_1
        except:
                octet = (1 << 4) | digit_1

        return octet


This doesn't work for me when sending to odd length numbers. When sending to 88555, after ~30 seconds I get a report saying "Could not deliver to 885551".
It does work after changing the 'except' clause to:
Code:

                octet = (15 << 4) | digit_1

Cue 2010-11-30 23:49

Re: SMS from CLI (Command Line)?
 
That script is shauns and pendes script put together with the addition of CLI arguments so the caveats that are mentioned here
http://talk.maemo.org/showpost.php?p...8&postcount=23
apply to that script too. I recommend using one of the later more robust methods in the thread.

sutaburosu 2010-12-01 00:27

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

Originally Posted by Cue (Post 886558)
I recommend using one of the later more robust methods in the thread.

Sadly the paraiso.dk domain is no longer active. I would have liked to see the changes made in that code.

Despite my inexperience with Python I tried using TpSession, but kept getting "ImportError: No module named QtMobility.Messaging". I couldn't find a package to satisfy this dependency; python2.5-mobility-common and libqtm-messaging seemed the only likely candidates, but didn't help. Any clues gratefully received. :)

apollovy 2011-01-01 23:00

Re: SMS from CLI (Command Line)?
 
Hello! I'm to send a message:
./sms-script +79111234567 hello
and after some time got an announcement, that it cannot be sent to number 0079111234567
How can I fix it? What's wrong, guys?

n900f4n 2011-02-07 08:08

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

Originally Posted by 白い熊 (Post 548948)
Got it:

to send an SMS from the commandline with Python:

Code:

#!/usr/bin/env python2.5

import pexpect
import time
from subprocess import *

child = pexpect.spawn('pnatd');
child.send('at\r');
time.sleep(0.25);
child.send('at+cmgf=1\r');
time.sleep(0.25);
child.send('at+cmgs="+XXXXXXX"\r');
child.send('SMSTEXTSMSTEXTSMSTEXT');
child.send(chr(26));
child.send(chr(26));
child.sendeof();

Working on an Emacs way now, it should be easy. Complications only for converting UTF-8 text to hex etc. but will get it done...

Hello, I'm trying to get arguments to your script with command line,
exactly:
import sys
phonenumber = sys.argv[1]
message = sys.argv[2]

How can I put variables phonenumber and message in:
child.send('at+cmgs="+XXXXXXX"\r');
child.send('SMSTEXTSMSTEXTSMSTEXT');
?

Thanks in advance for any help!

kingoddball 2011-02-07 08:22

Re: SMS from CLI (Command Line)?
 
apt-get install phone-control (Mo-AG Strikes again!)

hutchinsfairy 2011-02-08 11:24

Re: SMS from CLI (Command Line)?
 
I didn't think the current release (0.2-4 in devel) of phone-control could send an SMS? Is there some undocumented feature?

sakya 2011-02-08 15:42

Re: SMS from CLI (Command Line)?
 
I made this just for fun. :)
Code:

Usage:
  smssend [options] -n +39xxxxxx:+39xxxxxx -m "Text"
Options:
  -c      : compose message with conversation

You can send the same message to multiple numbers (separate each number with ":").
Messages longer than 160 characters should be splitted in more than one message.

To use this utility you need to run it as root (or use the -c option, which works also as user)
If you want to run it as user:
Code:

chmod 4555 /usr/bin/pnatd
You can find it here:
http://maemo.org/packages/view/smssend/

hutchinsfairy 2011-02-09 10:34

Re: SMS from CLI (Command Line)?
 
Works a treat for me! The only thing I'd say is that if I use the -c option the message doesn't send, it just prefills the text box. Is there any way you could auto send with the -c option? Using it without seems to work well but then I don't get a record of the text in my conversation window.
Thank you!

sakya 2011-02-09 11:16

Re: SMS from CLI (Command Line)?
 
It's possible to send the message using conversation, but it makes no sense in my opinion, because the QtMobility implementation always open the conversation app also when the message has been sent.
Since I think it's confusing for the user I preferred to just compose it and let the user push the "send" button.

jj0 2011-02-09 11:49

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

Originally Posted by sakya (Post 939063)
I made this just for fun. :)

Can you provide the source for this?

sakya 2011-02-09 11:58

Re: SMS from CLI (Command Line)?
 
Source code are available on the "homepage" (there's not really a page).
http://www.assembla.com/code/smssend/subversion/nodes

hutchinsfairy 2011-02-09 12:02

Re: SMS from CLI (Command Line)?
 
Thanks for getting back sakya! The only trouble I have is that without the -c option I have no record of the sms messages I send and with it it's not really command line only! I have also noticed that if I am viewing a conversation with a recipient and I send to that recipient with the -c option it brings up the dashboard. This means that the first sms I send brings up the conversation window and the second sends it away again (or at least means I have to tap it in the dashboard).

tremby 2011-02-09 12:30

Re: SMS from CLI (Command Line)?
 
In case it helps, here is a bash snippet which adds a text message to the database. I don't know how safe it is, but it /does/ appear in the conversations window after some variable delay. I was planning to use this with my own SMS script but never quite finished the SMS part (I got stuck on sending >160-char texts).

Code:

# $number is like '+447123456789'

# the end bit of the number. this seems to be used in the group_uid field -- no idea what for
partialnumber=$(echo $number | sed -r 's/.*([0-9]{7})$/\1/')

# $message is the message
message=${message//\'/\'\'} #replace singlequotes with double-singlequotes for sqlite

# build query
query="insert into Events (service_id, event_type_id, storage_time, start_time, end_time, is_read, flags, bytes_sent, bytes_received, local_uid, local_name, remote_uid, free_text, group_uid, outgoing, mc_profile) values (3, 7, strftime('%s', 'now'), strftime('%s', 'now'), 0, 1, 0, 0, 0, 'ring/tel/ring', '<SelfHandle>', '$number', '$message', '$partialnumber', 1, 0);"
echo "$query" | sqlite3 $HOME/.rtcom-eventlogger/el-v1.db


sakya 2011-02-09 12:40

Re: SMS from CLI (Command Line)?
 
A direct insert in the db table doesn't seem the best way to me. :)
I'll look if there's some API to save a message. ;)
Many thanks

hutchinsfairy 2011-02-09 12:57

Re: SMS from CLI (Command Line)?
 
This in the wiki used to work for me and would sometimes add the message to the conversation window but it was never very reliable and no longer works for me.

sakya 2011-02-09 20:48

Re: SMS from CLI (Command Line)?
 
The package is available in the Extras-devel repository
http://maemo.org/packages/view/smssend/

Btw I looked at the QtMobility APIs and it seems there's no way to save a message in the sent folder.
I think I'll use the db insert. :p

tremby 2011-02-10 00:21

Re: SMS from CLI (Command Line)?
 
Yeah, I never claimed it wasn't messy! With a bit of testing maybe it'll turn out to be fine, maybe it won't.

sakya 2011-02-10 08:33

Re: SMS from CLI (Command Line)?
 
I tried it and it seems to work fine. ;)

hutchinsfairy 2011-02-10 08:52

Re: SMS from CLI (Command Line)?
 
Could I persuade you to add autosend to the -c option as well? It's nice to be able to send as user, over 160 characters and without risking simultaneous database writes (if I scheduled a text via alarmd with smssend)?


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

vBulletin® Version 3.8.8