RubyGSM

From MobileHacking.org

Jump to: navigation, search

Ruby software that directly interfaces with AT-compatible GSM modems or phones. This could be used in place of Kannel or Gnokii.

Installation

1) Download RubyGSM from GitHub using the following command (you will have to install Git to do this).

git://github.com/adammck/rubygsm.git

2) You will need to install the Ruby serial port bindings:

  • from a package manager, for Debian/Ubuntu type:
sudo apt-get install libserialport-ruby
  • from source, go here:
http://ruby-serialport.rubyforge.org/

3) Find the port that your Modem is running on. This depends highly on your OS and distribution. Most likely it will be /dev/ttyX where X is something like USB0. On Linux distros you can type:

dmesg

to print the kernel ring buffer after you connect your modem to see where the kernel assigns it. Look for a line something like:

[40787.826312] usb 4-1: pl2303 converter now attached to ttyUSB0

(This is for a USB/Serial Modem on Ubuntu Linux)

Running the Demo Server

Once you have it installed, you can run the demo app from the rubygsm directory:

ruby rubygsm your_serial_port

When the modem has finished initializing, you can send it an SMS and it will send you one back with the characters reversed.

Usage

The following shows the code for the SMS Reverse Demo Server. It explains how you set up the modem and register the actions to perform on receiving an SMS.

# initialize the modem
m = Modem.new("/dev/ttyS0")
mc = ModemCommander.new(m)

class ReverseApp
    def initialize(mc)
        @mc = mc
    end

    def send(to, msg)
        puts ">> #{to}: #{msg}"
        @mc.send to, msg
    end

    def incomming(from, msg)
        puts "<< #{from}: #{msg}"
        send from, msg.reverse
    end
end

# create an instance of the application, and call
# the "incomming" method when a new sms arrives
app = ReverseApp.new(mc)
mc.receive app.method(:incomming)

Personal tools