gsm

Anton Kovalenko: GSM library for tcl


A library [L1 ] (broken link) to communicate with GSM mobile phone and to send/receive SMS.

Usage samples:

    set phone [open COM1 r+]
    foreach {manuf model revision} [gsm::phone::acquire $phone] {break}
    puts "Phone model: $manuf $model ($revision)"
    gsm::io::atcmd $phone Z
    # set default timeout
    gsm::io::timeout $phone 4000
    set gdconts [gsm::io::atcmd $phone +CGDCONT]
    ...
    gsm::phone::sendsms $phone +79163453402 \
                 "Hello Anton, I'm testing your library"
    gsm::phone::sendsms $phone +79163453402 "Unicode test: \u0412 "

    foreach sm [gsm::pdu::assemble [gsm::phone::readsms $tty ME 4]] {
      array set sm1 $sm
      puts "Storage id $sm1(id), assembled from $sm1(parts)"
      puts "From/to $sm1(peer): $sm1(text)"
    }

It is possible to use it with my infrared mini-extension. Just pass to gsm::phone::acquire a socket connected to IrDA:IrCOMM service.


This library is used in SMS Reception Center [L2 ]


As an alternative to the character conversion implemented in the gsm library, the encoding command can be extended with a gsm0338 encoding: GSM 03.38 encoding


dzach 2006-8-1: I was trying the library, and sent a message in greek, even in lowcase! That's very nice! Is there any way to receive a message or a RING as it comes in like with the +CNMI=1,2,0,0,0 command? When I enter +CNMI=1,2,0,0,0 the library pops an error and stops responding to commands (NOKIA 6310):

 invalid command name "RING"
    while executing 
 "RING"
    (in namespace eval "::" script line 1)
    invoked from within
 "namespace eval :: $state(handler,$fd) [list $str]"
    (procedure "_unsolicited" line 3)
    invoked from within
 "_unsolicited $fd $str"
    (procedure "::gsm::io::_reader" line 52)
    invoked from within
 "::gsm::io::_reader file4"

What could be the cause of this?

dzach (some hours later) Aha! you give it an event handler for any unknown event and everything works smoothly now:

 ::gsm::phone::acquire $phone ::handler 

where ::handler can be as simple as:

 proc ::handler args {puts $args}

I tried it with a RING and with a +CMT event (with +CNMI=1,2,0,0,0, allowing for automatic reception of SMSs). It needed also a change to the -translation option in the fconfigure command to {auto cr} from {auto crlf} for the NOKIA 6310.

Anton, I like the capability to handle lower case greek characters very much. Nice work!


Arlie, did this:

    package require gsm

    set phone [open COM8 r+]

    ::gsm::phone::acquire $phone ::handler

    foreach {manuf model revision} [gsm::phone::acquire $phone] {break}
    puts "Phone model: $manuf $model ($revision)"

    gsm::io::atcmd $phone Z
    # set default timeout
    gsm::io::timeout $phone 4000

    set gdconts [gsm::io::atcmd $phone +CGDCONT]

    #gsm::phone::sendsms $phone +79163453402 "Hello Anton, I'm testing your library"
    #gsm::phone::sendsms $phone +79163453402 "Unicode test: \u0412 "

    foreach sm [gsm::pdu::assemble [gsm::phone::readsms $tty ME 4]] {
         array set sm1 $sm
         puts "Storage id $sm1(id), assembled from $sm1(parts)"
         puts "From/to $sm1(peer): $sm1(text)"
    }

    proc ::handler args {puts $args}

But got this:

    Phone model:  WAVECOM MODEM  MULTIBAND  900E  1800  (641c09gg.Q2406B 1349424 092 404 15:49)
    +CME ERROR: 3
        while executing
    "error $state(result,$fd)"
        (procedure "gsm::io::atcmd" line 26)
        invoked from within
    "gsm::io::atcmd $phone +CGDCONT"
        invoked from within
    "set gdconts [gsm::io::atcmd $phone +CGDCONT]"
        (file "gsm-modem.tcl" line 14)

Please help. I really need this to work.


[ Category Package | Category Internet | Category Channel | Category Device Control ]