Reply
Thread Tools
Posts: 1,086 | Thanked: 2,964 times | Joined on Jan 2010
#1
I have a small arduino project and Im using the n900 to run/send commands to it on receipt of particular sms messages. For example, if the subject line of a SMS is "led1red" it sends a message to the arduino to turn the led at 1 to the colour red. To do this, currently Im polling the event log database with a simple sql query at 10 minute intervals to read through the sms collection and determine if one has arrived with a trigger message.

This is inefficient and I want it to be a real time reaction. That way I can control my project on receipt of the sms, rather than waiting for the next polling cycle to come around. I know this has been done before but I don't know how to do it, and Im new to Maemo and confused by some of the things Ive read. Im hoping for some direction or advice, and if Im extra lucky maybe a code snippet, but a pointer in the right direction would be great. I think it has something to do with the Dbus, can I monitor it for a sms message arriving, intercept it and read it? At the same time, I don't want to interfere with the normal process of logging my other personal sms messages to the event log database.

My project is written in PyQt. Many thanks for all help, much appreciated.
 
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#2
Listening for a dbus message sounds just right. By registering as a listener, you won't interfere and can use this to either start your search in the database as now, or try to pick just the right message and use that data directly.

There are good resources on the wiki covering the dbus and how it will behave both on incoming calls and SMS messages.
 

The Following User Says Thank You to Joorin For This Useful Post:
jflatt's Avatar
Posts: 534 | Thanked: 723 times | Joined on Oct 2009
#3
 

The Following 2 Users Say Thank You to jflatt For This Useful Post:
Posts: 1,086 | Thanked: 2,964 times | Joined on Jan 2010
#4
Originally Posted by jflatt View Post
Did you see this page?
http://wiki.maemo.org/Documentation/..._in_Freemantle
Yes Im just on there this very second, it looks like a signal called the IncomingSegment is the key to my kingdom. It even has a python code snippet *thumbs up*

Code:
import gobject, dbus
   from dbus.mainloop.glib import DBusGMainLoop
   
   def handle_sms(pdu, msgcenter, somestring, sendernumber):
       print 'New message from %s' % sendernumber
       
   DBusGMainLoop(set_as_default=True)
   bus = dbus.SystemBus()
   bus.add_signal_receiver(handle_sms, path='/com/nokia/phone/SMS',   dbus_interface='Phone.SMS', signal_name='IncomingSegment')
   gobject.MainLoop().run()
One thing slightly annoying me is that at the top of the page is a big message box suggesting that the method might be not recommended or outdated:

"Please be aware that the recommended way to use the phone functionality is Telepathy"

But if it works then it works, i'll not worry too much about Telepathy.

Last edited by kojacker; 2010-05-11 at 14:50.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 23:24.