Notices


Reply
Thread Tools
Posts: 4 | Thanked: 2 times | Joined on Jan 2010
#1
Ok..Here is the issue I'm facing:

I use my N900 as a pager to get work related automated alerts. We use Nagios to monitor our DC. When I get a page it comes in with a seemingly random 4 digit number as the "from" address (3296, 3453, etc) I can't find a pattern to them. I've tried merging each different page under my Work Page card and that card now has close to 1000 different contacts under it and I still get new numbers.

What I end up with is 2500 - 3000 text messages a month as individual messages. I had the same issue when I was with ATT and had an iPhone. Their solution was another domain addy after my phone number (6015551212@mobile.mycingular.com). This fixed the issue and all alerts were coming in from one number which I could then create a contact card for and they would thread like a normal txt message conversation. This also worked with my N900 before I switched to tmobile.

I've talked to tmobile tech support and they were less than helpful. So my question is has anyone run into this before? if so what did you do to fix it? Also, is there a way that I could filter incoming sms and tag them on my phone under the right contact?
 
Posts: 336 | Thanked: 610 times | Joined on Apr 2008 @ France
#2
Well, I guess we could create a small app for you that would only show texts that come from that range. Note this appears in my mind to be the most short-term solution. I've never done any GTK or Qt related stuff, so would need some help from Khertan, but selecting SMSs that come from a specific range is peanuts. Also, it's easy to make the app wake up when a new text from that range is received; however you would have the SMS in the discussions.

In the long term, I guess we would need to look into the possibility of modifying the way the SMSs are stored, and maybe allow for a generic pattern to be matched, so that numbers within a specific range are automatically piped to the same conversation. I have no idea how to do this, and would require to dig in a bit. Maybe others can help out.
 
Posts: 336 | Thanked: 610 times | Joined on Apr 2008 @ France
#3
Follow-up:

Here is the query that allows to get all the SMSs from a number between two specific intervals:

Code:
import sqlite3

class Conversation:
  def __init__(self, dbPath = '/home/user/.rtcom-eventlogger/el.db'):
    self.conn = sqlite3.connect(dbPath)
    self.c = self.conn.cursor()

  def getServices(self, serviceType = None):
    query = 'select id, name from Services'
    result = self.c.execute(query)

    if serviceType is not None:
      for (sid, sname) in result:
        if serviceType.upper() in sname.upper():
          return sid

    return result

  def getEventTypes(self, eventType):
    query = 'select id, name from EventTypes'
    result = self.c.execute(query)

    if eventType is not None:
      for (eid, ename) in result:
        if eventType.upper() in ename.upper():
          return eid

    return result

  def getSMSsFromBetween(self, low, high):
    sid = self.getServices('sms')
    eid = self.getEventTypes('sms_inbound')

    query = "select start_time, free_text from Events"
    query += " where service_id = %s and event_type_id = %s" % (sid, eid)
    query += " and cast(remote_uid as integer) between %s and %s" % (low, high)

    return self.c.execute(query)

if __name__ == '__main__':
  convo = Conversation()
  nagios = convo.getSMSsFromBetween(0, 9999)

  for text in nagios:
    print text
Probably a few typos due to the fact that I'm typing over from my N900's screen to the computer, but you get the idea. The important query is obvioulsy the one defined in getSMSsFromBetween(), the rest is just helper functions.

This is an excerpt from one of my test classes to handle SMSs.

Edit: if anyone is going to reply that the queries in getServices() and getEventTypes() can be optimised, don't bother. These are just samples that clearly explain what is happening, and not aimed at performance or to be used in production code -- regardless, the Services and EventTypes tables are very small, so the impact is very low.
 
Posts: 336 | Thanked: 610 times | Joined on Apr 2008 @ France
#4
Thanks to Khertan, I hacked together a first draft of what this app could look like.

Below is the code, and below is a screenshot.

base.py
Code:
import gtk
import hildon
import gobject
from datetime import datetime
import pango
     
from smsParser import Conversation
          
def main():
  gtk.set_application_name("SMS Filter") 
  program = hildon.Program.get_instance()
 
  window = hildon.Window()  
  program.add_window(window)
  window.connect("delete_event", gtk.main_quit, None)
               
  pana = hildon.PannableArea() 
                                
  treeview = gtk.TreeView()  
  treemodel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
  treeview.set_model(treemodel) 
  treeview.set_headers_visible(True)  
                                                       
  firstRenderer = gtk.CellRendererText() 
  firstRenderer.set_property("alignment", pango.ALIGN_CENTER)
                                                       
  secondRenderer = gtk.CellRendererText()  
  secondRenderer.set_property("wrap-mode", gtk.WRAP_WORD)
  secondRenderer.set_property("wrap-width", 640) 
                                                       
  column = gtk.TreeViewColumn("Date", firstRenderer, text=0)
  column.set_min_width(160)  
  treeview.append_column(column)    
                                                             
  column = gtk.TreeViewColumn("Text", secondRenderer, text=1) 
  column.set_max_width(640)      
  treeview.append_column(column) 
                                                              
  convo = Conversation() 
  results = convo.getSMSsFromBetween(0, 9999)
                                                              
  for (timestamp, text) in results:
    t = datetime.fromtimestamp(timestamp) 
    treemodel.append((t.strftime("%Y-%m-%d\n%H:%M:%S"), text))
                          
  pana.add(treeview)      
  window.add(pana)        
                          
  window.show_all()       

  gtk.main()  
                          
if __name__ == "__main__":
  main()
smsParser.py:
Code:
import sqlite3

class Conversation:

  def __init__(self, dbPath = '/home/user/.rtcom-eventlogger/el.db'):
    self.conn = sqlite3.connect(dbPath)
    self.c = self.conn.cursor()

  def getServices(self, serviceType = None):
    query = 'select id, name from Services'
    result = self.c.execute(query)

    if serviceType is not None:
      for (sid, sname) in result:
        if serviceType.upper() in sname.upper():
          return sid

    return result

  def getEventTypes(self, eventType):
    query = 'select id, name from EventTypes'
    result = self.c.execute(query)

    if eventType is not None:
      for (eid, ename) in result:
        if eventType.upper() in ename.upper():
          return eid

    return result

  def getSMSsFromBetween(self, low, high):
    sid = self.getServices('sms')
    eid = self.getEventTypes('sms_inbound')

    query = "select start_time, free_text from Events"
    query += " where service_id = %s and event_type_id = %s" % (sid, eid)
    query += " and cast(remote_uid as integer) between %s and %s" % (low, high)

    return self.c.execute(query)
In order to run:

Code:
run-standalone.sh python base.py
Hope this helps,
Attached Images
 

Last edited by CrashandDie; 2010-04-29 at 00:43.
 

The Following User Says Thank You to CrashandDie For This Useful Post:
Posts: 4 | Thanked: 2 times | Joined on Jan 2010
#5
Wow! thanks very much for this! I'll load it on my phone and give it a go..
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 04:52.