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)

Stargazers 2010-01-16 00:05

Re: SMS from CLI (Command Line)?
 
Hi! Tested myself too that Python app and gotta say that I loved it, it worked well! Thank you very much :)

luigi 2010-01-31 12:20

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.

Hi pende, I tried your code but it doesn't work. If I run it and send an sms (with "ping" ) to the device, I receive the sms and on stdout it shows:

New message received from +xxxxxxxxxxx
Message length 4
Message: ping
Sending reply: pong

But I don't receive the "pong" message on my other mobile.

In the code, I see that you replace the '+' by "00"; adding that to my phone number (above obfuscated with x-es) gives a total number of 13 digits. Is the odd number still a problem? If so, how can I resolve this?

白い熊 2010-01-31 14:51

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

Originally Posted by pende (Post 449749)
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

This might be a daft question, but never worked with python before...

How do you initiate a function in the python file.

I.e. I see that the default with sender.py is listen. How do I run the sendmessage with number and text from CLI?

zoner 2010-02-26 05:28

Re: SMS from CLI (Command Line)?
 
<hijack>

Quote:

Originally Posted by 白い熊 (Post 447781)
I'm asking since I already programmed elisp code for Emacs's BBDB to initiate calling, and automatically record, who you've called etc. including the call time to BBDB database

could you please (in another thread) discuss your setup for dialing with bbdb?

</hijack>

白い熊 2010-02-26 10:33

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

I modified
Code:

if __name__ == '__main__':
        listen()

to
Code:

if __name__ == '__main__':
        sendmessage("+XXXXXXXX", "Test")


to test it, but nothing gets sent... Where's the problem?

白い熊 2010-02-26 10:54

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

Originally Posted by zoner (Post 546999)
could you please (in another thread) discuss your setup for dialing with bbdb?

I'll release the full elisp code once I get this SMS stuff settled, can't get it to work so far.

白い熊 2010-02-26 16:02

Re: SMS from CLI (Command Line)?
 
A programmer has modified the script for me to accept commandline arguments, to send an SMS, so:
Code:

#!/usr/bin/python

import dbus
import sys

def octify(str):
    '''   
    Returns a list of octet bytes representing
    each char of the input str.             
    '''                                     

    bytes = map(ord, str)
    bitsconsumed = 0   
    referencebit = 7   
    octets = []         

    while len(bytes):
            byte = bytes.pop(0)
            byte = byte >> bitsconsumed
                                     
            try:
                    nextbyte = bytes[0]
                    bitstocopy = (nextbyte & (0xff >> referencebit)) << referencebit
                    octet = (byte | bitstocopy)

            except:
                    octet = (byte | 0x00)

            if bitsconsumed != 7:
                    octets.append(byte | bitstocopy)
                    bitsconsumed += 1
                    referencebit -= 1
            else:
                    bitsconsumed = 0
                    referencebit = 7

    return octets

def semi_octify(str):
    '''
    Expects a string containing two digits.
    Returns an octet -
    first nibble in the octect is the first
    digit and the second nibble represents
    the second digit.
    '''
    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

def resetnumber(number):
        '''
        Adds trailing F to number if length is
        odd.
        '''
        length = len(number)
        if (length % 2) != 0:
            number = number + 'F'
        return number

def createPDUstring(number, msg):
    '''
    Returns a list of bytes to represent a valid PDU message
    '''
    octifiedmsg = octify(msg)
    number = resetnumber(number)
    octifiednumber = [ semi_octify(number[i:i+2]) for i in range(0, len(number), 2) ]
       
    HEADER = 1
    FIRSTOCTETOFSMSDELIVERMSG = 10
    ADDR_TYPE = 129 #unknown format
    number_length = len(number)
    msg_length = len(msg)
    pdu_message = [HEADER, FIRSTOCTETOFSMSDELIVERMSG, number_length, ADDR_TYPE]
    pdu_message.extend(octifiednumber)
    pdu_message.append(0)
    pdu_message.append(0)
    pdu_message.append(msg_length)
    pdu_message.extend(octifiedmsg)
    return pdu_message

class SMS(object):
    '''
    Sends sms messages
    '''
   
    def __init__(self, msg, number):
        self.pdustring = createPDUstring(number, msg)
       
    def send(self):
        self.__dbus_send(self.pdustring)

    def __dbus_send(self, pdu_string):
        import dbus
        bus = dbus.SystemBus()
        smsobject = bus.get_object('com.nokia.phone.SMS', '/com/nokia/phone/SMS/ba212ae1')
        smsiface = dbus.Interface(smsobject, 'com.nokia.csd.SMS.Outgoing')
        arr = dbus.Array(pdu_string)
        msgdeliver = dbus.Array([arr])
        smsiface.Send(msgdeliver,'')
       
    def print_pdustring(self):
        print self.pdustring       

if __name__ == "__main__":
    if len(sys.argv) != 3:
        print "usage %s number message" % sys.argv[0]
    else:
        sms = SMS(sys.argv[2], sys.argv[1])
        sms.send()
        print "sending sms..."

However, when you use an international format with the leading plus like: "+XXX" for the number, it bombs with:
Code:

Traceback (most recent call last):
  File "./send_sms.py", line 114, in <module>
    sms = SMS(sys.argv[2], sys.argv[1])
  File "./send_sms.py", line 93, in __init__
    self.pdustring = createPDUstring(number, msg)
  File "./send_sms.py", line 72, in createPDUstring
    octifiednumber = [ semi_octify(number[i:i+2]) for i in range(0,
  len(number), 2) ]
  File "./send_sms.py", line 52, in semi_octify
    octet = (1 << 4) | digit_1
UnboundLocalError: local variable 'digit_1' referenced before assignment

When you use two leading zeros like "00XXXX..." it doesn't bomb, but the SMS is not received, therefore probably not sent.

It seems the problem is with the PDU encoding. Anyone got the above (prior) script to actually send an SMS? Where is the problem?

白い熊 2010-02-27 09:51

Re: SMS from CLI (Command Line)?
 
It seems the fault is definitely with this PDU encoding process. Isn't there a possibility to forward the text and number to internal Nokia PDU encoding and SMS sending routine, if there is such a thing? I.e. telepathy etc. Have been reading up through telepathy documents, but don't know how to send an SMS through its API.

XTC 2010-02-27 10:02

Re: SMS from CLI (Command Line)?
 
Just thinking - is there any /dev/tty... interface inside OS to communicate with GSM engine using AT commands?
If such port exists, sending SMS should be rather straightforward.

白い熊 2010-02-27 10:20

Re: SMS from CLI (Command Line)?
 
Of course, you're my man, there's pnatd for communicating with the modem. OK, no to check how to send plain text SMSes via AT commands. Do you know how to do this?

白い熊 2010-02-27 11:22

Re: SMS from CLI (Command Line)?
 
OK:
1. Using http://talk.maemo.org/showpost.php?p...5&postcount=20 as inspiration, I see how to send a number of AT commands one by one to pnatd via python.
2. The references http://www.control.com.sg/at_commands_sms.aspx http://www.smssolutions.net/tutorials/gsm/sendsmsat/ and http://www.activexperts.com/xmstoolk...ommands/nokia/ show the necessary AT commands for SMS sending.

As I'm not familiar with python, can someone help me with the following:

To send the SMS number and text, you need to input AT+CMGS="+yyyyy", hit Enter then enter the message text and hit Ctrl-Z, maybe twice. How do I modify the above python code to send Ctrl-z?

白い熊 2010-02-27 15:54

Re: SMS from CLI (Command Line)?
 
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...

KiberGus 2010-02-27 16:48

Re: SMS from CLI (Command Line)?
 
Timers are not good. You'd better read replies from modem and proceed, when you get confirmation, that it is ready for the next command.
https://garage.maemo.org/plugins/scm...et&view=markup

白い熊 2010-02-27 16:54

Re: SMS from CLI (Command Line)?
 
I'll take a look into it.

Anyhow, here's my next question, the above way only sends SMSes up to 160 chars, i.e. if the SMS is longer, sending it in one AT command doesn't split it into multiples and trasmit. The SMS is not transmitted.

Obviously one could break it up manually and send successively, but that way, it's not gonna be automatically merged on the other end.

Anyone know how to enable long SMS sending this way via AT commands?

白い熊 2010-02-28 00:34

Re: SMS from CLI (Command Line)?
 
I need some help with the Unicode SMS sending.

As per http://www.smssolutions.net/tutorials/gsm/sendsmsat/ I can't send

Code:

AT+CSMP=1,167,0,8
to specify the data coding scheme for Unicode messages.

In fact querying the N900 with
Code:

AT+CSMP=?
only gives OK as the answer, but the above command results in an error.

How can I set the coding for Unicode to successfully send a Unicode SMS?

hawaii 2010-03-04 20:18

Re: SMS from CLI (Command Line)?
 
Has anybody found a way to send CLASS 0 SMS messages?

Cue 2010-03-07 05:51

Re: SMS from CLI (Command Line)?
 
I've tried to sow the functions of both pende and shaunramos' scripst into one with command line arguments and option processing

Code:

#!/usr/bin/env python2.5         
import sched, time               
import dbus                     
import gobject                   
from dbus.mainloop.glib import DBusGMainLoop

def octify(str):
        '''   
        Returns a list of octet bytes representing
        each char of the input str.             
        '''                                     

        bytes = map(ord, str)
        bitsconsumed = 0   
        referencebit = 7   
        octets = []         

        while len(bytes):
                byte = bytes.pop(0)
                byte = byte >> bitsconsumed
                                         
                try:                     
                        nextbyte = bytes[0]
                        bitstocopy = (nextbyte & (0xff >> referencebit)) << referencebit
                        octet = (byte | bitstocopy)                                   

                except:
                        octet = (byte | 0x00)

                if bitsconsumed != 7:
                        octets.append(byte | bitstocopy)
                        bitsconsumed += 1             
                        referencebit -= 1             
                else:                                 
                        bitsconsumed = 0               
                        referencebit = 7               

        return octets

def semi_octify(str):
        '''         
        Expects a string containing two digits.
        Returns an octet -                   
        first nibble in the octect is the first
        digit and the second nibble represents
        the second digit.                     
        '''                                   
        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


def deoctify(arr):

        referencebit = 1
        doctect = []   
        bnext = 0x00   

        for i in arr:

                bcurr = ((i & (0xff >> referencebit)) << referencebit) >> 1
                bcurr = bcurr | bnext                                     

                if referencebit != 7:
                        doctect.append( bcurr )
                        bnext = (i & (0xff << (8 - referencebit)) ) >> 8 - referencebit
                        referencebit += 1                                             
                else:                                                                 
                        doctect.append( bcurr )                                       
                        bnext = (i & (0xff << (8 - referencebit)) ) >> 8 - referencebit
                        doctect.append( bnext )                                       
                        bnext = 0x00                                                 
                        referencebit = 1                                             

        return ''.join([chr(i) for i in doctect])


def createPDUmessage(number, msg):
        '''                     
        Returns a list of bytes to represent a valid PDU message
        '''                                                   
        numlength = len(number)                               
        if (numlength % 2) == 0:                               
                rangelength = numlength                       
        else:                                                 
                number = number + 'F'                         
                rangelength = len(number)                     

        octifiednumber = [ semi_octify(number[i:i+2]) for i in range(0,rangelength,2) ]
        octifiedmsg = octify(msg)                                                     
        HEADER = 1                                                                   
        FIRSTOCTETOFSMSDELIVERMSG = 10                                               
        ADDR_TYPE = 129 #unknown format                                               
        number_length = len(number)                                                   
        msg_length = len(msg)                                                         
        pdu_message = [HEADER, FIRSTOCTETOFSMSDELIVERMSG, number_length, ADDR_TYPE]   
        pdu_message.extend(octifiednumber)                                           
        pdu_message.append(0)                                                         
        pdu_message.append(0)                                                         
        pdu_message.append(msg_length)                                               
        pdu_message.extend(octifiedmsg)                                               
        return pdu_message                                                           


def sendmessage(number, message):

        bus = dbus.SystemBus()
        smsobject = bus.get_object('com.nokia.phone.SMS', '/com/nokia/phone/SMS/ba212ae1')
        smsiface = dbus.Interface(smsobject, 'com.nokia.csd.SMS.Outgoing')
        arr = dbus.Array(createPDUmessage(number.replace('+', '00'), message))

        msg = dbus.Array([arr])
        smsiface.Send(msg,'')


def callback(pdumsg, msgcenter, somestring, sendernumber):

        msglength = int(pdumsg[18])
        msgarray = pdumsg[19:len(pdumsg)]

        msg = deoctify(msgarray)

        if msg > 0:
              print 'New message received from %s' % sendernumber
              print 'Message length %d' % msglength
              print 'Message: %s' % msg

              if msg == "ping":
                      print "Sending reply: pong"
                      sendmessage(sendernumber.replace("+","00"), "pong")
              else:
                      print "Unknown command"


def listen():
        DBusGMainLoop(set_as_default=True)
        bus = dbus.SystemBus() #should connect to system bus instead of session because the former is where the incoming signals come from
        bus.add_signal_receiver(callback, path='/com/nokia/phone/SMS', dbus_interface='Phone.SMS', signal_name='IncomingSegment')
        gobject.MainLoop().run()


if __name__ == '__main__':
  import time
 
  def schedule_task(schedule, fn, *args):
      import sched
      s = sched.scheduler(time.time, time.sleep)
      startTime = time.mktime(time.strptime(schedule, '%b %d %H:%M %Y'))
      s.enterabs(startTime, 0, fn, args)
      s.run()

  import getopt, sys
  try: 
    opts, args = getopt.getopt(sys.argv[1:],"hlt:", ["help","listen","time="])

  except getopt.GetoptError, err:
    # print help information and exit:
    print str(err) # will print something like "option -a not recognized"
    usage()
    sys.exit(2) 
  listening = False
  timeofday = ''
  for opt, arg in opts:
    if opt in ("-h", "--help"):
      usage()                   
      sys.exit()                 
    elif opt in ("-l", "--listen"):
      listening = True               
    elif opt in ("-t", "--time"):
      timeofday = arg                         
    else:
      assert False, "unhandled option"
 
  number = args[0]         
  msg = args[1]
  if msg != '':
    if timeofday == '':
        sendmessage(number, msg)
    else:
        today = time.strftime('%b %d x %Y', time.localtime())
        schedule = today.replace('x', timeofday)
        schedule_task(schedule, sendmessage, number, msg)
  if listening:
    listen()

here it is if anybody is intersted. I need to create a usage help function but don't know the standard notation for help. anybody know?

so the options are currently:
to schedule a text
[-t time] or [--time=time]
to listen and reply to ping SMS
[-l] or [--listen]

the arguments are given like
./scriptname.py number message
I'd be greatful if somebody more familiar with python could go over the script too.

x61 2010-03-07 16:11

Re: SMS from CLI (Command Line)?
 
You go through all this python code simply to send a text message? You folks have time.

Cue 2010-03-07 22:15

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

Originally Posted by x61 (Post 558818)
You go through all this python code simply to send a text message? You folks have time.

lol, yeah; but now thanks to pende and shaunramos I can send a text at any time and even if I forget my phone at home.

qole 2010-03-08 18:38

Re: SMS from CLI (Command Line)?
 
x61: they're going to all this trouble so they can script SMS messages. This means, like Cue said, you can send SMS messages remotely, or send a message at a scheduled time (or place, if you tie into the GPS), or you could even write an auto-reply script, ("I'm away from the phone at the moment!").

The dark side of all of this is that a trojan could use this code to send secret text messages without the owner knowing about it.

KiberGus 2010-03-12 12:58

Re: SMS from CLI (Command Line)?
 
Hi. I'm currently working on SMS listener in ussd-widget. And I need to decode PDU. So I have two questions. Have anybody managed to write decoding code? I've already found one, but it should be rewritten:
http://www.monkeysandrobots.com/archives/207
And one more general question. It seems, that you deal only with standard GSM alphabet. Is it so? So no support for other languages (my operator uses UCS2 encoding for example). May be we can write something more general? As I remember, USSD and SMS are encoded in similar way and I already have code for decoding USSD (excluding repackaging 7bit to 8 bit, because modem does it).

KiberGus 2010-03-12 23:20

Re: SMS from CLI (Command Line)?
 
OK, I've managed to write decoder. Should work for all languages.
http://kibergus.su/node/17

白い熊 2010-03-17 03:24

Re: SMS from CLI (Command Line)?
 
Full GNU Emacs solution:
http://sumoudou.org/0/27.html

zoner 2010-03-17 13:02

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

Originally Posted by 白い熊 (Post 569931)
Full GNU Emacs solution:
http://sumoudou.org/0/27.html

Nice Work!

"Make sure you have telephone numbers stored in the international format, i.e. with a leading `+', in BBDB."

Could you point me to a work-around for this? In particular, to dial for (123) 456-7890 setup? For some reason, I can't edit bbdb records to add the +1, I have to delete and recreate the record.

白い熊 2010-03-17 19:15

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

Originally Posted by zoner (Post 570396)
Could you point me to a work-around for this? In particular, to dial for (123) 456-7890 setup? For some reason, I can't edit bbdb records to add the +1, I have to delete and recreate the record.

Move the point (cursor) to the phone number in the BBDB record you want to edit; hit `e';

It'll bring up the number in the minibuffer and you can edit it.

zoner 2010-03-17 20:38

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

Originally Posted by 白い熊 (Post 570895)
Move the point (cursor) to the phone number in the BBDB record you want to edit; hit `e';

It'll bring up the number in the minibuffer and you can edit it.

sure, I know how to edit the numbers. For some reason, adding +1 <RET> does nothing. Number reverts to previous value with no message. I've made the rounds through all of the bbdb variables, I don't see anything. I'll try later with a cleaner .emacs file to see what's happening.

That said, when the number in bbdb is formatted correctly, dialing works, and that's worth a big slap on the back.

with SMS - i get:

"Pipe endpoint allocation: Operation not permitted
Process n900-sms-dispatch exited abnormally with code 1"

白い熊 2010-03-17 20:48

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

Originally Posted by zoner (Post 571015)
sure, I know how to edit the numbers. For some reason, adding +1 <RET> does nothing. Number reverts to previous value with no message. I've made the rounds through all of the bbdb variables, I don't see anything.

Oh so that's gotta be something with .emacs setting. I vaguely recall seeing some bbdb-us-number-format or something like that which automatically forces us numbers. If you search for bbdb and us format, I'm sure you'll get to the bottom of it.

Quote:

with SMS - i get:

"Pipe endpoint allocation: Operation not permitted
Process n900-sms-dispatch exited abnormally with code 1"
Do you have pnatd installed?

zoner 2010-03-17 21:04

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

Originally Posted by 白い熊 (Post 571032)
Oh so that's gotta be something with .emacs setting. I vaguely recall seeing some bbdb-us-number-format or something like that which automatically forces us numbers. If you search for bbdb and us format, I'm sure you'll get to the bottom of it.

I've tried
(setq bbdb-default-north-american-phone-numbers-p nil), didn't help

Quote:

Do you have pnatd installed?
yes, v0.7.6, built Aug 27 2009

白い熊 2010-03-17 23:57

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

Originally Posted by zoner (Post 571049)
I've tried
(setq bbdb-default-north-american-phone-numbers-p nil), didn't help

OK, you need to use:
Code:

(setq bbdb-north-american-phone-numbers-p nil)
For pnatd lemme think a while.

白い熊 2010-03-17 23:58

Re: SMS from CLI (Command Line)?
 
OK, backup your .emacs, and start .emacs with a completely empty one, except for stuff that'll let you start bbdb and bbdb-nokia-n900.

Cut everything else out, and see if you get the same error, that way we can debug it.

zoner 2010-03-18 03:18

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

Originally Posted by 白い熊 (Post 571289)
OK, backup your .emacs, and start .emacs with a completely empty one, except for stuff that'll let you start bbdb and bbdb-nokia-n900.

Cut everything else out, and see if you get the same error, that way we can debug it.

Thanks for your help

I tried the clean .emacs earlier with no luck, but I'm starting over

current .emacs file
Code:

(menu-bar-mode 0)
(tool-bar-mode -1)

(add-to-list 'load-path "~/MyDocs/elisp")
(add-to-list 'load-path "~/MyDocs/bbdb-2.35/lisp")

(require 'maxframe)
(add-hook 'window-setup-hook 'maximize-frame t)
(maximize-frame)
(setq dired-use-ls-dired nil)
(setq list-directory-brief-switches "-C")

(require 'bbdb)
(bbdb-initialize)
(setq bbdb-file "~/MyDocs/.bbdb")

(require 'bbdb-nokia-n900)

(custom-set-variables
 '(bbdb-north-american-phone-numbers-p nil))

The north american variable was actually a typo before, it was correct (but posted incorrectly). The N American variable here was set through the customize-group dialog.

With the above, no luck.

An attempt to SMS to the number +1704-254-1111

sends same error to a new buffer
Code:

Pipe endpoint allocation: Operation not permitted
Process n900-sms-dispatch exited abnormally with code 1

now also sends this message to the minibuffer
Code:

Sending SMS to: +1704-254-1111 (Mobile)
while: Process n900-sms-dispatch does not exist

calls to this number via bbdb-nokia-n900.el work perfectly, including timestamps

How did you setup your bbdb? In an attempt to keep things light on the handheld, I simply copied the bbdb-2.35 directory to ~/MyDocs/ I deleted everything but the lisp directory. Could my problem be related to this?

fwiw i still cannot edit an existing from number from (xxx) xxx-xxxx to +1xxx-xxx-xxxx

白い熊 2010-03-18 21:14

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

Code:

(custom-set-variables
 '(bbdb-north-american-phone-numbers-p nil))

The north american variable was actually a typo before, it was correct (but posted incorrectly). The N American variable here was set through the customize-group dialog.
Throw this out, just realized I put it together so that it'll dial even american style numbers. So you can dial even the americanized numbers - try that. You're just not gonna be able to call from abroad, since they're not in an international format, but since you've got them in your phonebook that way, it prob'ly doesn't matter to you.

Quote:

Code:

Sending SMS to: +1704-254-1111 (Mobile)
while: Process n900-sms-dispatch does not exist


OK, it doesn't create the process, something wrong with pnatd on your side or communication from Emacs with it.

Which Emacs version, and from where, are you using?

Then, with the following code:
Code:

(start-process "n900-sms-dispatch" "*n900-sms-dispatch*" "pnatd")
(display-buffer "*n900-sms-dispatch*")
(process-send-string "n900-sms-dispatch" "at\r")
(process-send-string "n900-sms-dispatch" "AT+CSCS=\"HEX\"\r")
(process-send-string "n900-sms-dispatch" "AT+CSMP=17,167,0,8\r")
(process-send-string "n900-sms-dispatch" "at+cmgf=1\r")
(process-send-string "n900-sms-dispatch" (concat "at+cmgs=\"" "7042541111" "\"\r"))
(process-send-string "n900-sms-dispatch" (concat "This is a sample SMS message." "\C-z"))

Copy it to your *scratch* buffer, and eval line by line - if you're not familiar with Emacs, move to the end of each line: C-e and eval the line: C-x C-e

This should send the sample SMS. Report what you see here and we can get it fixed.

zoner 2010-03-18 22:15

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

Throw this out
done

Quote:

I put it together so that it'll dial even american style numbers. So you can dial even the americanized numbers - try that
trying (704) 254-1111
Code:

replace-regexp-in-string: Wrong type argument: sequencep, 704
+1704-254-1111 continues to work perfectly
Quote:

Which Emacs version, and from where, are you using?
http://sumoudou.org/%E7%9B%B8%E6%92%...ia%20N900.html - followed your basic instructions :)

Quote:

Report what you see here and we can get it fixed.
(start-process "n900-sms-dispatch" "*n900-sms-dispatch*" "pnatd")

#<process n900-sms-dispatch>


(display-buffer "*n900-sms-dispatch*")

#<window 6 on *n900-sms-dispatch*>


(process-send-string "n900-sms-dispatch" "at\r")

nil

(process-send-string "n900-sms-dispatch" "AT+CSCS=\"HEX\"\r")

Debugger entered--Lisp error: (error "Process n900-sms-dispatch does not exist")
process-send-string("n900-sms-dispatch" "AT+CSCS=\"HEX\"
")
eval((process-send-string "n900-sms-dispatch" "AT+CSCS=\"HEX\"
"))
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)


(process-send-string "n900-sms-dispatch" "AT+CSMP=17,167,0,8\r")

Debugger entered--Lisp error: (error "Process n900-sms-dispatch does not exist")
process-send-string("n900-sms-dispatch" "AT+CSMP=17,167,0,8
")
eval((process-send-string "n900-sms-dispatch" "AT+CSMP=17,167,0,8
"))
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)
recursive-edit()
byte-code(" @=!

(process-send-string "n900-sms-dispatch" "at+cmgf=1\r")...

the remaining evals continue to throw errors to the backtrace buffer, which I can't paste into these text boxes.

birdwes 2010-03-19 00:11

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

"Hi. I'm currently working on SMS listener in ussd-widget. And I need to decode PDU.........."

I read your post about having already solved this, but I thought you might be interested in seeing Kannel, as it contains PDU encoders and decoders: http://www.kannel.org/

白い熊 2010-03-19 05:06

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

Code:

replace-regexp-in-string: Wrong type argument: sequencep, 704
+1704-254-1111 continues to work perfectly
This is very strange. What do you get when evaluating:
Code:

(replace-regexp-in-string "-" "" (replace-regexp-in-string " " "" (replace-regexp-in-string "(" "" (replace-regexp-in-string ")" "" "(704) 254-1111"))))
Quote:

http://sumoudou.org/%E7%9B%B8%E6%92%...ia%20N900.html - followed your basic instructions :)
OK, I tested with this version, it works, so it's not Emacs' fault.

Quote:

(process-send-string "n900-sms-dispatch" "at\r")

nil

(process-send-string "n900-sms-dispatch" "AT+CSCS=\"HEX\"\r")

Debugger entered--Lisp error: (error "Process n900-sms-dispatch does not exist")
OK, something is killing the pnatd process between the first and second send. "AT" gets sent, then the process is killed.

Post the contents of *Messages* buffer, maybe it gives some clues as to what is happening.

Also, can you start pnatd from the terminal and enter this sequence of commands, or does it also die?:
Code:

at
AT+CSCS="HEX"
AT+CSMP=17,167,0,8
at+cmgf=1
at+cmgs="7042541111"
This is a sample SMS message.
C-z


zoner 2010-03-19 10:49

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

Originally Posted by 白い熊 (Post 572837)
this is very strange. What do you get when evaluating:
Code:

(replace-regexp-in-string "-" "" (replace-regexp-in-string " " "" (replace-regexp-in-string "(" "" (replace-regexp-in-string ")" "" "(704) 254-1111"))))

Code:

"7042541111"
Quote:

Post the contents of *Messages* buffer, maybe it gives some clues as to what is happenin
I collected all the messages I could find

Quote:

Also, can you start pnatd from the terminal and enter this sequence of commands, or does it also die?:
As user it throws the pipe error - could that be part of it?

As root:
at
OK
AT+CSCS="HEX"
OK
AT+CSMP=17,167,0,8
OK
at+cmgf=1
OK
at+cmgs="7042541111"
>T
ERROR

704 254 1111 is not a real number if that helps, but it doesn't look like it get that far

白い熊 2010-03-19 17:50

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

Originally Posted by zoner (Post 573104)
Code:

"7042541111"

OK, evaluates fine, so should send fine. So maybe it's connected with the following.

Quote:

As user it throws the pipe error - could that be part of it?
Yeah, that's the reason, pnatd must be run as user.

Code:

which pnatd
should give you
Code:

/usr/bin/pnatd
Code:

ls -l /usr/bin/pnatd
should start with
Code:

-rwsr-sr-x
What do you get for
Code:

ls -l /usr/bin/pnatd
.
Try purging pnatd and reinstalling clean.

You must be able to start it as user and then send one or two commands without crash.

The problem lay with pnatd on your system, not the Emacs coding...

zoner 2010-03-19 18:01

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

Originally Posted by 白い熊 (Post 573677)
Code:

which pnatd
should give you
Code:

/usr/bin/pnatd

yes

Quote:

Code:

ls -l /usr/bin/pnatd
should start with
Code:

-rwsr-sr-x

no

Quote:

What do you get for
Code:

ls -l /usr/bin/pnatd

Code:

-rwxr-xr-x    1 root  root  12676 Aug 27  2009 /usr/bin/pnatd
Quote:

Try purging pnatd and reinstalling clean.
can you point me to some instructions on that?
I thought it should be
Code:

apt-get remove --purge pnatd
but I get a "couldn't find package pnatd"

Quote:

You must be able to start it as user and then send one or two commands without crash.

The problem lay with pnatd on your system, not the Emacs coding...
thanks again, I appreciate your help - this will be great once these issues are corrected

白い熊 2010-03-19 18:11

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

apt-get purge pnatd
apt-get install pnatd


zoner 2010-03-19 18:21

Re: SMS from CLI (Command Line)?
 
man, I'm feeling like a big lump of fail
Code:

# apt-get purge pnatd
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package pnatd

# which pnatd
/usr/bin/pnatd



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

vBulletin® Version 3.8.8