Class: Ucp::Pdu::Ucp01Operation

Inherits:
UCP01 show all
Defined in:
lib/ucp/pdu/ucp01_operation.rb

Overview

Ruby library implementation of EMI/UCP protocol v4.6 for SMS Copyright © 2011, Sergio Freire <[email protected]>

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Constant Summary

Constants inherited from UCPMessage

Ucp::Pdu::UCPMessage::DELIMITER, Ucp::Pdu::UCPMessage::ETX, Ucp::Pdu::UCPMessage::STX

Instance Attribute Summary

Attributes inherited from UCPMessage

#dcs, #message_ref, #operation, #operation_type, #part_nr, #total_parts, #trn

Instance Method Summary collapse

Methods inherited from UCP01

#initialize_message, #set_fields

Methods inherited from UCPMessage

#checksum, #get_field, #is_ack?, #is_nack?, #is_operation?, #is_result?, #length, #set_field, #set_fields, #to_s

Constructor Details

#initialize(fields = nil) ⇒ Ucp01Operation

Returns a new instance of Ucp01Operation.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ucp/pdu/ucp01_operation.rb', line 22

def initialize(fields=nil)
  super()
  @operation_type="O"
  @fields=[:adc,:oadc,:ac,:mt,:msg]

  if fields.nil?
    return
  end

  @trn=fields[0]
  @operation_type=fields[2]
  @operation=fields[3]

  # *02/00050/O/01/961234567/0931D98C8607//3/6F7618/72#

   for i in 4..(fields.length-1)
     field=@fields[i-4]
     @h[field]=fields[i]
   end


end

Instance Method Details

#basic_submit(originator, recipient, message, ucpfields = {}) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ucp/pdu/ucp01_operation.rb', line 45

def basic_submit(originator,recipient,message,ucpfields={})
  #super()
  #@operation_type="O"
  #@fields=[:adc,:oadc,:ac,:mt,:msg]

  # UCP01 only supports IRA encoded SMS (7bit GSM alphabet chars, encoded in 8bits)
  msg=UCP.ascii2ira(message).encoded

  # UCP01 does NOT support alphanumeric oadc
  oadc=originator

  @h={:oadc=>oadc, :adc=>recipient, :msg=>msg,:mt=>3}
  
  @h=@h.merge ucpfields
end