Module: CIMD

Defined in:
lib/cimd/version.rb,
lib/cimd_loop.rb,
lib/cimd_messages.rb,
lib/cimd_constants.rb,
lib/cimd_structures.rb

Overview

Set of extensions

Defined Under Namespace

Classes: Connection, Dcs, Loop, Message, Parameter

Constant Summary collapse

VERSION =

Gem version

"0.0.1"
STX =
0x02
ETX =
0x03
TAB =
"\t"
CC =
0xFF
PARAM_SEP =
":"
OP_LOGIN =

OP - OPERATION CODES

1
OP_LOGOUT =
2
OP_SUBMIT =
3
OP_ENQUIRE_MESSAGE_STATUS =
4
OP_DELIVERY_REQUEST =
5
OP_CANCEL_MESSAGE =
6
OP_SET =
8
OP_GET =
9
OP_DELIVERY_MESSAGE =
20
OP_DELIVERY_STATUS_REPORT =
23
OP_ALIVE =
40
OP_LOGIN_RESPONSE =
51
OP_LOGOUT_RESPONSE =
52
OP_SUBMIT_RESPONSE =
53
OP_ENQUIRE_MESSAGE_STATUS_RESPONSE =
54
OP_DELIVERY_REQUEST_RESPONSE =
55
OP_CANCEL_MESSAGE_RESPONSE =
56
OP_SET_RESPONSE =
58
OP_GET_RESPONSE =
59
OP_DELIVERY_MESSAGE_RESPONSE =
70
OP_DELIVERY_STATUS_REPORT_RESPONSE =
73
OP_ALIVE_RESPONSE =
90
OP_GENERAL_ERROR_RESPONSE =
98
OP_NACK =
99
P_USER_IDENTITY =

P - PARAMETER

10
P_PASSWORD =
11
P_SUBADDR =
12
P_WINDOW_SIZE =
19
P_DESTINATION_ADDRESS =
21
P_ORIGINATOR_ADDRESS =
23
P_ALPHA_ORIG_ADDRESS =
27
P_DATA_CODING_SCHEME =
30
P_USER_DATA_HEADER =
32
P_USER_DATA =
33
P_USER_DATA_BINARY =
34
P_PROTOCOL_IDENTIFIER =
52
P_SERVICE_CENTRE_TIME_STAMP =
60
P_ERROR_CODE =
900
P_ERROR_TEXT =
901
DEFAULT_WINDOW_SIZE =
1
DEFAULT_KEEP_ALIVE =
60
ALPHABET_DEFAULT =
0
ALPHABET_8BIT =
1
ALPHABET_UCS2 =
2
ALPHABET_RESERVED =
3
ALPHABET_BINARY =
8

Class Method Summary collapse

Class Method Details

.alive_messageObject



51
52
53
54
# File 'lib/cimd_messages.rb', line 51

def self.alive_message
  m = Message.new(OP_ALIVE)
  return m
end

.login_message(connection) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/cimd_messages.rb', line 3

def self.(connection)
  m = Message.new(OP_LOGIN)
   = Parameter.new(P_USER_IDENTITY,connection.user_identity)
  p_password = Parameter.new(P_PASSWORD,connection.password)
  m.add()
  m.add(p_password)
  return m
end

.logout_messageObject



12
13
14
15
# File 'lib/cimd_messages.rb', line 12

def self.logout_message
  m = Message.new(OP_LOGOUT)
  return m
end

.only_response_message(message) ⇒ Object



45
46
47
48
49
# File 'lib/cimd_messages.rb', line 45

def self.only_response_message(message)
  m = Message.new(message.operation_code + 50)
  m.packet_number = message.packet_number
  return m
end

.opcode_description(op_code) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cimd_constants.rb', line 35

def self.opcode_description(op_code)
  descs = {
    OP_LOGIN => "OP_LOGIN",
    OP_LOGOUT => "OP_LOGOUT",
    OP_SUBMIT=> "OP_SUBMIT",
    OP_ENQUIRE_MESSAGE_STATUS => "OP_ENQUIRE_MESSAGE_STATUS",
    OP_DELIVERY_REQUEST => "OP_DELIVERY_REQUEST",
    OP_CANCEL_MESSAGE => "OP_CANCEL_MESSAGE",
    OP_SET => "OP_SET",
    OP_GET => "OP_GET",
    OP_DELIVERY_MESSAGE => "OP_DELIVERY_MESSAGE",
    OP_DELIVERY_STATUS_REPORT => "OP_DELIVERY_STATUS_REPORT",
    OP_ALIVE => "OP_ALIVE",
    OP_LOGIN_RESPONSE => "OP_LOGIN_RESPONSE",
    OP_LOGOUT_RESPONSE => "OP_LOGOUT_RESPONSE",
    OP_SUBMIT_RESPONSE => "OP_SUBMIT_RESPONSE",
    OP_ENQUIRE_MESSAGE_STATUS_RESPONSE => "OP_ENQUIRE_MESSAGE_STATUS_RESPONSE",
    OP_DELIVERY_REQUEST_RESPONSE => "OP_DELIVERY_REQUEST_RESPONSE",
    OP_CANCEL_MESSAGE_RESPONSE => "OP_CANCEL_MESSAGE_RESPONSE",
    OP_SET_RESPONSE => "OP_SET_RESPONSE",
    OP_GET_RESPONSE => "OP_GET_RESPONSE",
    OP_DELIVERY_MESSAGE_RESPONSE => "OP_DELIVERY_MESSAGE_RESPONSE",
    OP_DELIVERY_STATUS_REPORT_RESPONSE => "OP_DELIVERY_STATUS_REPORT_RESPONSE",
    OP_ALIVE_RESPONSE => "OP_ALIVE_RESPONSE",
    OP_GENERAL_ERROR_RESPONSE => "OP_GENERAL_ERROR_RESPONSE",
    OP_NACK => "",
  }
  return descs.has_key?(op_code) ? "(#{descs[op_code]})" : "(UNKNOWN)"
end

.submit_binary_message(connection, msisdn, binary_text) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cimd_messages.rb', line 30

def self.submit_binary_message(connection,msisdn,binary_text)
  m = Message.new(OP_SUBMIT)
  p_msisdn = Parameter.new(P_DESTINATION_ADDRESS,msisdn)
  p_text = Parameter.new(P_USER_DATA_BINARY,binary_text)
  p_dcs = Parameter.new(P_DATA_CODING_SCHEME,ALPHABET_BINARY)
  m.add(p_msisdn)
  m.add(p_text)
  m.add(p_dcs)
  unless connection.alpha_orig_address.nil?
    p_orig = Parameter.new(P_ALPHA_ORIG_ADDRESS,connection.alpha_orig_address)
    m.add(p_orig)
  end
  return m
end

.submit_text_message(connection, msisdn, text) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cimd_messages.rb', line 17

def self.submit_text_message(connection,msisdn,text)
  m = Message.new(OP_SUBMIT)
  p_msisdn = Parameter.new(P_DESTINATION_ADDRESS,msisdn)
  p_text = Parameter.new(P_USER_DATA,text)
  m.add(p_msisdn)
  m.add(p_text)
  unless connection.alpha_orig_address.nil?
    p_orig = Parameter.new(P_ALPHA_ORIG_ADDRESS,connection.alpha_orig_address)
    m.add(p_orig)
  end
  return m
end