diff --git a/lib/smpp/pdu/base.rb b/lib/smpp/pdu/base.rb index 530a4c6..c772d2d 100644 --- a/lib/smpp/pdu/base.rb +++ b/lib/smpp/pdu/base.rb @@ -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 diff --git a/lib/smpp/transceiver.rb b/lib/smpp/transceiver.rb index 70516c6..4b16da6 100644 --- a/lib/smpp/transceiver.rb +++ b/lib/smpp/transceiver.rb @@ -31,12 +31,20 @@ 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| @@ -44,7 +52,8 @@ def send_concat_mt(message_id, source_addr, destination_addr, message, options = 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