Giter VIP home page Giter VIP logo

ruby-smpp's Introduction

Ruby-SMPP

<img src=“https://travis-ci.org/raykrueger/ruby-smpp.png” />

DESCRIPTION:

Ruby-SMPP is a Ruby implementation of the SMPP v3.4 protocol. It is suitable for writing gateway daemons that communicate with SMSCs for sending and receiving SMS messages.

The implementation is based on the Ruby/EventMachine library.

NOTE: Breaking change from 0.1.2 to 0.1.3. See below.

For help please use the Google group here: groups.google.com/group/ruby-smpp/topics

Glossary

  • SMSC: SMS Center. Mobile operators normally operate an SMSC in their network. The SMSC stores and forwards SMS messages.

  • MO: Mobile Originated SMS: originated in a mobile phone, ie. sent by an end user.

  • MT: Mobile Terminated SMS: terminated in a mobile phone, ie. received by an end user.

  • DR: Delivery Report, or delivery notification. When you send an MT message, you should receive a DR after a while.

  • PDU: Protcol Base Unit, the data units that SMPP is comprised of. This implementation does not implement all SMPP PDUs.

Protocol

The SMPP 3.4 protocol spec can be downloaded here: smsforum.net/SMPP_v3_4_Issue1_2.zip

Testing/Sample Code

Logica provides an SMPP simulator that you can download from opensmpp.logica.com. You can also sign up for a demo SMPP account at one of the many bulk-SMS providers out there.

For a quick test, download smscsim.jar and smpp.jar from the Logica site, and start the simulator by typing:

java -cp smscsim.jar:smpp.jar com.logica.smscsim.Simulator

Then type 1 (start simulation), and enter 6000 for port number. The simulator then starts a server socket on a background thread. In another terminal window, start the sample sms gateway from the ruby-smpp/examples directory by typing:

ruby sample_gateway.rb

You will be able to send MT messages from the sample gateway terminal window by typing the message body. In the simulator terminal window you should see SMPP PDUs being sent from the sample gateway.

You can also send MO messages from the simulator to the sample gateway by typing 7 (log to screen off) and then 4 (send message). MO messages received by the sample gateway will be logged to ./sms_gateway.log.

FEATURES/PROBLEMS:

  • Implements only typical client subset of SMPP 3.4 with single-connection Transceiver.

  • Contributors are encouraged to add missing PDUs.

BASIC USAGE:

Start the transceiver. Receive delegate callbacks whenever incoming messages or delivery reports arrive. Send messages with Transceiver#send_mt.

# connect to SMSC
tx = EventMachine::run do
  $tx = EventMachine::connect(
  host,
  port,
  Smpp::Transceiver,
  config,             # a property hash
  delegate            # delegate class that will receive callbacks on MOs and DRs and other events
end

# send a message
tx.send_mt(id, from, to, body)

As of 0.1.3 the delegate method signatures are as follows:

  • mo_received(transceiver, deliver_sm_pdu)

  • delivery_report_received(transceiver, deliver_sm_pdu)

  • message_accepted(transceiver, mt_message_id, submit_sm_response_pdu)

  • message_rejected(transceiver, mt_message_id, submit_sm_response_pdu)

  • bound(transceiver)

  • unbound(transceiver)

Where ‘pdu’ above is the actual actual instance of the Smpp:Pdu

class created.

For a more complete example, see examples/sample_gateway.rb

REQUIREMENTS:

  • Eventmachine >= 0.10.0

INSTALL:

sudo gem install ruby-smpp

LICENSE:

Copyright © 2008 Apparat AS Released under the MIT license.

ruby-smpp's People

Contributors

benders avatar cornet avatar crondaemon avatar dwilkie avatar floehopper avatar floehopper-and-kalv avatar lazyatom avatar malmckay avatar parolkar avatar presskey avatar puzanov avatar raykrueger avatar tomafro avatar uncleandy avatar yury 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  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

ruby-smpp's Issues

Fix needed for ruby2.0

Current tests don't pass in ruby 2.0. Code needs update to fix encoding issues between 1.8, 1.9 and 2.0. Contributions needed.

anjlab or rubymspp

Hello

I'm looking for the must up to date version of the ruby-smpp gem. I have found another gem called anjlab-ruby-smpp (https://rubygems.org/gems/anjlab-ruby-smpp).
Does anyone knows if this one still has the problems reported here, ie, all those issues that haven't been merge in the master branch of the original from raykrueger

Some issues using this library

I've started to use this library to connect to a SMPP server and I've seen some limitations:

  1. It is not possible to send multiple SMSs using an alphanumerical sender. The Smpp::Pdu::SubmitMulti has constants in the initialize method. Just replacing this code and using the values from the options hash is possible to send messages:
service_type            = options[:service_type]? options[:service_type] :''
source_addr_ton         = options[:source_addr_ton]?options[:source_addr_ton]:0 # network specific
source_addr_npi         = options[:source_addr_npi]?options[:source_addr_npi]:1 # unknown
number_of_dests         = destination_addr_array.length # Max value can be 254
dest_addr_ton           = options[:dest_addr_ton]?options[:dest_addr_ton]:1 # international
dest_addr_npi           = options[:dest_addr_npi]?options[:dest_addr_npi]:1 # unknown
dest_addresses          = build_destination_addresses(destination_addr_array,dest_addr_ton,dest_addr_npi,IS_SMEADDR)
esm_class               = options[:esm_class]
protocol_id             = options[:protocol_id]?options[:protocol_id]:0
priority_flag           = options[:priority_flag]?options[:priority_flag]:0
schedule_delivery_time  = options[:schedule_delivery_time]?options[:schedule_delivery_time]:''
validity_period         = options[:validity_period]?options[:validity_period]:''
registered_delivery     = options[:registered_delivery]?options[:registered_delivery]:1
replace_if_present_flag = options[:replace_if_present_flag]?options[:replace_if_present_flag]:0
data_coding             = options[:dcs]
sm_default_msg_id       = options[:sm_default_msg_id]?options[:sm_default_msg_id]:0
payload                 = udh ? udh + short_message : short_message # this used to be (short_message + "\0")
sm_length               = payload.length
  1. The released version (0.6.0) is far from the master version. The "Transmitter" class doesn't exist and it is not possible to connect to an SMPP server only as a sender.

  2. I'm using the version from the master branch and it is not possible to send multiple SMS's if you are connected as a "Transmiter". The solution is just copy/paste the method from the "Transceiver" class or create an intermediate class that implement both the send_mt and the send_multiple_mt methods.

Still encoding issues

Today I experienced my code broken, without any explanation.
With the very same code as before, code stopped with

incompatible character encodings: ASCII-8BIT and US-ASCII at /usr/local/rvm/gems/ruby-1.9.3-p194/bundler/gems/ruby-smpp-dfc81b559bdd/lib/smpp/pdu/base.rb

After digging a bit, the only way I found to make it work was

@data = fixed_int(length) + fixed_int(command_id) + fixed_int(command_status) + fixed_int(seq)
@data = @data.force_encoding("US-ASCII") + body

That's a bad way to solve the problem. Any idea about how patch the calling code? Any idea about how to solve definitively the encoding issues?
Thanks.

Moving repo to organization

Hi @raykrueger
This project is wonderful but seems to be abandoned... I'm not working anymore on smpp and seems the same for you. So why don't you put it into an organization repo and take on board some developer that actively work on it? To have an active and collaborative community could solve the lack of time/manpower on it.

Again, it's a good project and it would be a pity to leave it rusting...

Bug in numeric optional parameters

Hello everybody
I'm experiencing a small bug in optional_parameters when using send_mt.
That's the piece of code I'm using

def self.send_mt(*args)
      @@mt_id += 1
      #@@tx.send_mt(@@mt_id, *args)
      op1 = Smpp::OptionalParameter.new(0x0424, "TEXT TEXT TEXT")
      op2 = Smpp::OptionalParameter.new(0xe, 0x01)
      op3 = Smpp::OptionalParameter.new(0x6, 0x01)

      @@tx.send_mt(@@mt_id, "1234", "4567", "",
          { 
              :optional_parameters => { 
                  op1.tag => op1, 
                  op2.tag => op2,
                  op3.tag => op3
              }
          }
      )
  end

Code in base class is

length = optional_param.value.length

but it is broken when using numeric values (as in my case) since length is not defined for FixNums.

I've fixed it:

< length = optional_param.value.length
> length = optional_param.value.to_s.length

Wireshark decodes it correctly. Can it be fixed without a pull request?

Why is this code not the same as what is in the gem?

I have a problem but the code in github pdu/base.rb line 91 is not the same as in the gem:
eg:
gem: @DaTa = fixed_int(length) + fixed_int(command_id) + fixed_int(command_status) + fixed_int(seq) + body
github: @DaTa = header + body

I am happy to work to fix this as I think kureinko as already fixed but I would like to start from the same source as the gem.

Any suggestions?

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.