Coder Social home page Coder Social logo

rubygsm's Introduction

RubyGSM is a Ruby library which uses ruby-serialport to provide a nifty interface to send and receive SMS messages via a GSM modem.

Sample Usage

class ReverseApp
    def initialize(gsm)
        gsm.receive(method(:incoming))
        @gsm = gsm
    end

    def incoming(from, datetime, message)
        @gsm.send(from, message.reverse)
    end
end

gsm = Gsm::Modem.new("/dev/tty.usbserial")
ReverseApp.new(gsm)

If you just want to send sms

gsm = Gsm::Modem.new("/dev/tty.usbserial")
msg = Gsm::Outgoing.new(gsm, "+447777777777", "Oh hai")
msg.send!

Installing

RubyGSM is distributed via GitHub, which you must add as a gem source before installing:

$ sudo gem sources -a http://gems.github.com

The library depends upon ruby-serialport, which is currently maintained on GitHub by Toholio. This library is included as a Gem dependancy, so to install both:

$ sudo gem install adammck-rubygsm

For Debian/Ubuntu users…

The ruby-serialport library is available in the APT repository as a binary package, which is substatially less hassle to install than the Gem, for those who don’t have a compiler installed (I prefer not to, on production servers). To install the package via apt, and ignore the Gem dependancy:

$ sudo apt-get install libserialport-ruby
$ sudo gem install --ignore-dependencies adammck-rubygsm

Building gem

$ gem build rubygsm.gemspec

Known issues

There is a known issue when you try to send message to shortcode. Enble :debug to see problem.

Devices Tested

  • Multitech MTCBA

  • Wavecom M1306B

rubygsm's People

Contributors

adammck avatar jakuboboza avatar wiiikiii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rubygsm's Issues

Infinite ack (+CNMA) and reboot (+CFUN) loop.

Let me start by saying thanks for making this library available. Secondly I realise that you haven't touched the code in a long time, so I'm not expecting you to look into this, but maybe you have an idea of how to fix it that would be consistent.

I ran into an issues around retries. I received a message which the library then attempts to ack with a +CNMA.
The modem responds with +CMS ERROR 340, which is "No +CNMA acknowledgement expected". The command is retried 5 times, all of which fail. The device is then reset with a +CFUN command, which succeeds, and the command is retried. The code then gets stuck in an infinite loop of try and fail command, reset device.

This problem will always be triggered with a command that fails legitimately (ie. it will always fail), and a modem that always resets successfully.

I see a few options:

  1. A simple workaround of making @reset_on_failure false. Based on your comments it does seem like the reset is a very useful feature, so I don't really want to change that.
  2. Change parse_incoming_sms! to use try_command for +CNMA. Any errors rising from that command are ignored anyway (they are just logged). I like this, but it still doesn't solve the root problem.
  3. Only reboot once in command. eg. Try 5 times, reboot, try 5 times again, propgate error.

I like the idea of doing both 2 and 3, so I'll throw together a patch, unless you have a better idea.

Thanks,
Liehann

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.