Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sms can be longer than 127 characters #24

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# -*- encoding : utf-8 -*-
require "rubygems"
require "bundler/setup"
1 change: 1 addition & 0 deletions examples/sample_gateway.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
#!/usr/bin/env ruby

# Sample SMS gateway that can receive MOs (mobile originated messages) and
Expand Down
1 change: 1 addition & 0 deletions examples/sample_smsc.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
#!/usr/bin/env ruby

# Sample SMPP SMS Gateway.
Expand Down
1 change: 1 addition & 0 deletions lib/smpp.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# SMPP v3.4 subset implementation.
# SMPP is a short message peer-to-peer protocol typically used to communicate
# with SMS Centers (SMSCs) over TCP/IP.
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
require 'timeout'
require 'scanf'
require 'monitor'
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/encoding/utf8_encoder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
require 'iconv'

module Smpp
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/optional_parameter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::OptionalParameter

attr_reader :tag, :value
Expand Down
7 changes: 6 additions & 1 deletion lib/smpp/pdu/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# PDUs are the protcol base units in SMPP
module Smpp::Pdu
class Base
Expand Down Expand Up @@ -88,7 +89,11 @@ def initialize(command_id, command_status, seq, body='')
@command_status = command_status
@body = body
@sequence_number = seq
@data = fixed_int(length) + fixed_int(command_id) + fixed_int(command_status) + fixed_int(seq) + body
if RUBY_VERSION < "1.9"
@data = fixed_int(length) + fixed_int(command_id) + fixed_int(command_status) + fixed_int(seq) + body
else
@data = (fixed_int(length) + fixed_int(command_id) + fixed_int(command_status) + fixed_int(seq)).force_encoding("UTF-8") + body.force_encoding("UTF-8")
end
end

def logger
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/bind_base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# this class serves as the base for all the bind* commands.
# since the command format remains the same for all bind commands,
# sub classes just change the @@command_id
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/bind_receiver.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::BindReceiver < Smpp::Pdu::BindBase
@command_id = BIND_RECEIVER
handles_cmd BIND_RECEIVER
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/bind_receiver_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::BindReceiverResponse < Smpp::Pdu::BindRespBase
@command_id = BIND_RECEIVER_RESP
handles_cmd BIND_RECEIVER_RESP
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/bind_resp_base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::BindRespBase < Smpp::Pdu::Base
class << self; attr_accessor :command_id ; end
attr_accessor :system_id
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/bind_transceiver.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::BindTransceiver < Smpp::Pdu::BindBase
@command_id = BIND_TRANSCEIVER
handles_cmd BIND_TRANSCEIVER
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/bind_transceiver_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::BindTransceiverResponse < Smpp::Pdu::BindRespBase
@command_id = BIND_TRANSCEIVER_RESP
handles_cmd BIND_TRANSCEIVER_RESP
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/bind_transmitter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::BindTransmitter < Smpp::Pdu::BindBase
@command_id = BIND_TRANSMITTER
handles_cmd BIND_TRANSMITTER
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/bind_transmitter_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::BindTransmitterResponse < Smpp::Pdu::BindRespBase
@command_id = BIND_TRANSMITTER_RESP
handles_cmd BIND_TRANSMITTER_RESP
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/deliver_sm.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-

# Received for MO message or delivery notification
class Smpp::Pdu::DeliverSm < Smpp::Pdu::Base
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/deliver_sm_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::DeliverSmResponse < Smpp::Pdu::Base
handles_cmd DELIVER_SM_RESP

Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/enquire_link.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::EnquireLink < Smpp::Pdu::Base
handles_cmd ENQUIRE_LINK

Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/enquire_link_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::EnquireLinkResponse < Smpp::Pdu::Base
handles_cmd ENQUIRE_LINK_RESP

Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/generic_nack.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# signals invalid message header
class Smpp::Pdu::GenericNack < Smpp::Pdu::Base
handles_cmd GENERIC_NACK
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/submit_multi.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# Sending an MT message to multiple addresses
# Author: Abhishek Parolkar, (abhishek[at]parolkar.com)
#TODO: Implement from_wire_data for this pdu class.
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/submit_multi_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# Recieving response for an MT message sent to multiple addresses
# Author: Abhishek Parolkar, (abhishek[at]parolkar.com)
class Smpp::Pdu::SubmitMultiResponse < Smpp::Pdu::Base
Expand Down
2 changes: 2 additions & 0 deletions lib/smpp/pdu/submit_sm.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- encoding : utf-8 -*-

# Sending an MT message
class Smpp::Pdu::SubmitSm < Smpp::Pdu::Base
handles_cmd SUBMIT_SM
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/submit_sm_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::SubmitSmResponse < Smpp::Pdu::Base
handles_cmd SUBMIT_SM_RESP

Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/unbind.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::Unbind < Smpp::Pdu::Base
handles_cmd UNBIND

Expand Down
1 change: 1 addition & 0 deletions lib/smpp/pdu/unbind_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
class Smpp::Pdu::UnbindResponse < Smpp::Pdu::Base
handles_cmd UNBIND_RESP

Expand Down
1 change: 1 addition & 0 deletions lib/smpp/receiver.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# The SMPP Receiver maintains a unidirectional connection to an SMSC.
# Provide a config hash with connection options to get started.
# See the sample_gateway.rb for examples of config values.
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/server.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# --------
# This is experimental stuff submitted by [email protected]
# --------
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/transceiver.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# The SMPP Transceiver maintains a bidirectional connection to an SMSC.
# Provide a config hash with connection options to get started.
# See the sample_gateway.rb for examples of config values.
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/transmitter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# The SMPP Transmitter maintains a unidirectional connection to an SMSC.
# Provide a config hash with connection options to get started.
# See the sample_gateway.rb for examples of config values.
Expand Down
1 change: 1 addition & 0 deletions lib/smpp/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
module Smpp
VERSION = "0.6.0"
end
3 changes: 2 additions & 1 deletion lib/sms.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# Basic SMS class for sample gateway

class Sms
Expand All @@ -6,4 +7,4 @@ class Sms
def initialize(body)
self.body = body
end
end
end
1 change: 1 addition & 0 deletions test/delegate.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# the delagate receives callbacks when interesting things happen on the connection
class Delegate

Expand Down
1 change: 1 addition & 0 deletions test/encoding_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
require 'rubygems'
require 'test/unit'
require 'smpp/encoding/utf8_encoder'
Expand Down
1 change: 1 addition & 0 deletions test/optional_parameter_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
require 'rubygems'
require 'test/unit'
require 'smpp'
Expand Down
1 change: 1 addition & 0 deletions test/pdu_parsing_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
require 'rubygems'
require 'test/unit'
require File.expand_path(File.dirname(__FILE__) + "../../lib/smpp")
Expand Down
1 change: 1 addition & 0 deletions test/receiver_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
require 'rubygems'
require 'test/unit'
require 'smpp'
Expand Down
1 change: 1 addition & 0 deletions test/responsive_delegate.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
#TODO This should be made prettier with mocha
class ResponsiveDelegate
attr_reader :seq, :event_counter
Expand Down
1 change: 1 addition & 0 deletions test/server.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
# a server which immediately requests the client to unbind
module Server
def self.config
Expand Down
1 change: 1 addition & 0 deletions test/smpp_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
require 'rubygems'
require 'test/unit'
require 'smpp'
Expand Down
1 change: 1 addition & 0 deletions test/submit_sm_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
require 'rubygems'
require 'test/unit'
require 'smpp'
Expand Down
1 change: 1 addition & 0 deletions test/transceiver_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding : utf-8 -*-
require "rubygems"
require "test/unit"
require File.expand_path(File.dirname(__FILE__) + "../../lib/smpp")
Expand Down