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

some exceptions fixed #7

Open
wants to merge 6 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
2 changes: 1 addition & 1 deletion lib/smpp/pdu/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ 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
@data = fixed_int(length) + fixed_int(command_id) + fixed_int(command_status) + fixed_int(seq) + body.force_encoding("ascii-8bit")
end

def logger
Expand Down
15 changes: 12 additions & 3 deletions lib/smpp/transceiver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,29 @@ def send_mt(message_id, source_addr, destination_addr, short_message, options={}

# Send a concatenated message with a body of > 160 characters as multiple messages.
def send_concat_mt(message_id, source_addr, destination_addr, message, options = {})
message = message.dup
logger.debug "Sending concatenated MT: #{message}"
if @state == :bound
# Split the message into parts of 153 characters. (160 - 7 characters for UDH)
parts = []
while message.size > 0 do
parts << message.slice!(0..Smpp::Transceiver.get_message_part_size(options))
if options[:data_coding] != 8
while message.size > 0 do
parts << message.slice!(0..Smpp::Transceiver.get_message_part_size(options))
end
else
bytes = message.bytes.to_a
0.upto(bytes.length / 134) do |part|
parts << bytes.slice(part * 134, 134).pack("C*")
end
end

0.upto(parts.size-1) do |i|
udh = sprintf("%c", 5) # UDH is 5 bytes.
udh << sprintf("%c%c", 0, 3) # This is a concatenated message

#TODO Figure out why this needs to be an int here, it's a string elsewhere
udh << sprintf("%c", message_id) # The ID for the entire concatenated message
# so, we can use object_id because it`s always integer
udh << sprintf("%c", message_id.object_id & 0xFF) # The ID for the entire concatenated message

udh << sprintf("%c", parts.size) # How many parts this message consists of
udh << sprintf("%c", i+1) # This is part i+1
Expand Down