da_funk 3.31.0 → 3.34.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -1
  3. data/Gemfile.lock +18 -8
  4. data/README.md +0 -0
  5. data/README_GUIDE.md +0 -0
  6. data/RELEASE_NOTES.md +22 -0
  7. data/Rakefile +14 -0
  8. data/guides/sample_input_output.rb +0 -0
  9. data/guides/sample_message_iso8583.rb +0 -0
  10. data/guides/sample_network_gprs.rb +0 -0
  11. data/guides/sample_read_magnect_card.rb +0 -0
  12. data/guides/sample_socket.rb +0 -0
  13. data/guides/sample_transaction.rb +0 -0
  14. data/guides/sample_transaction_download_application.rb +0 -0
  15. data/guides/sample_transaction_download_file.rb +0 -0
  16. data/guides/sample_transaction_download_parameter_file.rb +0 -0
  17. data/lib/da_funk/connection_management.rb +25 -10
  18. data/lib/da_funk/event_handler.rb +1 -1
  19. data/lib/da_funk/helper.rb +55 -16
  20. data/lib/da_funk/helper/status_bar.rb +42 -46
  21. data/lib/da_funk/params_dat.rb +65 -25
  22. data/lib/da_funk/transaction/download.rb +0 -0
  23. data/lib/da_funk/transaction/iso.rb +0 -0
  24. data/lib/da_funk/version.rb +1 -1
  25. data/lib/device.rb +0 -0
  26. data/lib/device/crypto.rb +0 -0
  27. data/lib/device/display.rb +0 -0
  28. data/lib/device/io.rb +53 -0
  29. data/lib/device/network.rb +19 -33
  30. data/lib/device/printer.rb +0 -0
  31. data/lib/device/setting.rb +0 -0
  32. data/lib/device/version.rb +0 -0
  33. data/lib/device/virtual_keyboard.rb +81 -34
  34. data/lib/file_db.rb +0 -0
  35. data/lib/iso8583/bitmap.rb +94 -54
  36. data/lib/iso8583/codec.rb +3 -3
  37. data/lib/iso8583/field.rb +48 -4
  38. data/lib/iso8583/fields.rb +3 -1
  39. data/lib/iso8583/message.rb +25 -12
  40. data/lib/iso8583/util.rb +1 -1
  41. data/test/iso8583/bitmap_test.rb +277 -0
  42. data/test/iso8583/message_test.rb +111 -0
  43. data/test/iso8583/minitest_helper.rb +11 -0
  44. metadata +12 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5492c7a7c61fc8559c3d0267a010c62fc6b85f47ff9c40b6164d6afef3536cfd
4
- data.tar.gz: 06cccc06f994055eb85e68163412af8b076b2342a59661f92e2ab2907514be32
3
+ metadata.gz: ca17006779ad6c0d5b9bda06b03b39206539d23769be8e1eae50368dcc341195
4
+ data.tar.gz: 25df4cf6175cf3b04053b16a7a99f8f27e36864bef6afe380a3baf2e1bd9ba79
5
5
  SHA512:
6
- metadata.gz: 158eb51a52a2895383bfb2864c5717659aa3d601a3780c0abcc42029b3ad86e7606aa5b1c02c55bb95e6c90dbe187f55e5fdc0ab3a1af659a4320598ef192703
7
- data.tar.gz: cdff69f582095c79cbe9a5e1e063e495aec2a21fd74e29cc132b12653942b770da6d56d8fa309a07c433ea4e2d0a3ac8b9680c47692c109897d68020d615fa56
6
+ metadata.gz: c19b050fec970e04fb6d681af3ae11d2eda01c42cde7ee8cc32cab784bda523f2967b4d175f6ceef84e35dc1376a26c7b063b2defac68c3a4711b41e02026331
7
+ data.tar.gz: 161f31d14b80fdaeeebe6120104471295ada25d06ae28940914169188ee01a64dde5b7d5c66c8cc91bcb3caa5332aaab8965056236faff1df28a17796eafd4c4
data/Gemfile CHANGED
@@ -4,4 +4,13 @@ gem 'cloudwalk'
4
4
  gem 'rubocop', require: false
5
5
  gem 'funky-mock'
6
6
 
7
- gemspec
7
+ group :test do
8
+ gem 'minitest', group: :test
9
+ gem 'simplecov', group: :test
10
+ end
11
+
12
+ group :development, :test do
13
+ gem 'byebug'
14
+ end
15
+
16
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- da_funk (3.31.0)
4
+ da_funk (3.34.1)
5
5
  archive-zip (~> 0.5)
6
6
  bundler
7
7
  cloudwalk_handshake
@@ -15,22 +15,25 @@ GEM
15
15
  archive-zip (0.12.0)
16
16
  io-like (~> 0.3.0)
17
17
  ast (2.4.1)
18
+ byebug (11.1.3)
18
19
  cloudwalk (1.15.0)
19
20
  bundler
20
21
  rake
21
- cloudwalk_handshake (1.21.3)
22
+ cloudwalk_handshake (2.0.0)
22
23
  funky-simplehttp (~> 0.6)
23
- funky-emv (1.4.1)
24
- funky-tlv (~> 0.2)
24
+ docile (1.3.5)
25
+ funky-emv (2.0.1)
26
+ funky-tlv (~> 1.0)
25
27
  funky-mock (0.1.0)
26
28
  funky-simplehttp (0.6.0)
27
- funky-tlv (0.2.3)
29
+ funky-tlv (1.0.1)
28
30
  io-like (0.3.1)
31
+ minitest (5.14.4)
29
32
  parallel (1.19.2)
30
33
  parser (2.7.2.0)
31
34
  ast (~> 2.4.1)
32
- posxml_parser (2.26.0)
33
- funky-emv (~> 1)
35
+ posxml_parser (3.0.1)
36
+ funky-emv (~> 2)
34
37
  rainbow (3.0.0)
35
38
  rake (13.0.1)
36
39
  regexp_parser (1.8.2)
@@ -47,6 +50,10 @@ GEM
47
50
  rubocop-ast (1.1.0)
48
51
  parser (>= 2.7.1.5)
49
52
  ruby-progressbar (1.10.1)
53
+ simplecov (0.18.5)
54
+ docile (~> 1.1)
55
+ simplecov-html (~> 0.11)
56
+ simplecov-html (0.12.3)
50
57
  unicode-display_width (1.7.0)
51
58
  yard (0.9.25)
52
59
 
@@ -56,12 +63,15 @@ PLATFORMS
56
63
  x86-mingw32
57
64
 
58
65
  DEPENDENCIES
66
+ byebug
59
67
  cloudwalk
60
68
  da_funk!
61
69
  funky-mock
62
70
  funky-simplehttp
71
+ minitest
63
72
  rubocop
73
+ simplecov
64
74
  yard
65
75
 
66
76
  BUNDLED WITH
67
- 2.1.4
77
+ 2.2.7
data/README.md CHANGED
File without changes
data/README_GUIDE.md CHANGED
File without changes
data/RELEASE_NOTES.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # DaFunk
2
2
 
3
+ ### 3.33.1 - 2021-02-19
4
+
5
+ - Fixed argument being passed to hours2seconds method which was nil;
6
+
7
+ ### 3.33.0 - 2021-02-08
8
+
9
+ - Added method Device::IO#get_format_or_touchscreen_action;
10
+ - Added support to images on ParamsDat#download, ParamsDat#update_app and ParamsDat#update_file;
11
+ - Return result of ParamsDat#update_apps call to the caller.
12
+
13
+ ### 3.32.0 - 2021-01-04
14
+
15
+ - Remapped virtual keyboard to add support to new layout;
16
+ - Make timeout of virtual keyboard parametrized;
17
+ - Limit size of string to 20 on virtual keyboard;
18
+ - Refactoring status bar:
19
+ - Check if thread is paused which means communication it's being configured. In this case 'sem sinal' message should be displayed;
20
+ - Do not show media type an media icon if thread is paused;
21
+ - Removed thread pause from attach and scan calls, let the application that is doing the configuration take care of that;
22
+ - Move reload of metadata to communication thread;
23
+ - Added support to check network conn status from time to time, default is each 5 minutes.
24
+
3
25
  ### 3.31.0 - 2020-11-27
4
26
 
5
27
  - Added support to new battery view (Exact percentage);
data/Rakefile CHANGED
@@ -90,3 +90,17 @@ end
90
90
  task "test:all" => :build
91
91
  task "test:unit" => :build
92
92
  task "test:integration" => :build
93
+
94
+ Rake::TestTask.new('test:iso8583') do |t|
95
+ Bundler.require(:default, :test)
96
+ t.libs << File.join("lib", "da_funk", "helper")
97
+ t.libs << File.join("lib","iso8583")
98
+ t.libs << File.join("test", "iso8583")
99
+ t.test_files = FileList['test/iso8583/**/*_test.rb']
100
+ end
101
+
102
+ task "test:iso8583:cov" do
103
+ ENV.store('COV', '1')
104
+ Bundler.require(:default, :test)
105
+ Rake::Task["test:iso8583"].execute
106
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,21 +1,23 @@
1
1
  module DaFunk
2
2
  class ConnectionManagement
3
3
  class << self
4
- attr_accessor :drops, :primary_timeout
4
+ attr_accessor :drops, :primary_timeout, :last_time_check
5
5
  end
6
6
  self.drops = 0
7
7
  DEFAULT_DROP_LIMIT = 2
8
8
 
9
9
  def self.check
10
- if Device::Network.connected?
11
- if primary_try?
12
- :primary_communication
13
- end
14
- else
15
- if fallback?
16
- :fallback_communication
10
+ if must_check?
11
+ if Device::Network.connected?
12
+ if primary_try?
13
+ :primary_communication
14
+ end
17
15
  else
18
- :attach_registration_fail
16
+ if fallback?
17
+ :fallback_communication
18
+ else
19
+ :attach_registration_fail
20
+ end
19
21
  end
20
22
  end
21
23
  end
@@ -125,6 +127,19 @@ module DaFunk
125
127
  def self.schedule_primary_timeout
126
128
  self.primary_timeout = (Time.now + self.conn_fallback_timer)
127
129
  end
130
+
131
+ def self.must_check?
132
+ if self.last_time_check
133
+ if self.last_time_check < Time.now
134
+ self.last_time_check = Time.now + @value
135
+ true
136
+ end
137
+ else
138
+ @value = DaFunk::ParamsDat.file['conn_check_timer']
139
+ @value = @value.nil? ? 300 : @value * 60
140
+ self.last_time_check = Time.now + @value
141
+ true
142
+ end
143
+ end
128
144
  end
129
145
  end
130
-
@@ -52,7 +52,7 @@ module DaFunk
52
52
  end
53
53
 
54
54
  unless config["timestamp"]
55
- config["timestamp"] = hours2seconds(option["interval"])
55
+ config["timestamp"] = hours2seconds(option[:hours])
56
56
  else
57
57
  if config["interval"]["hours"].to_s != option[:hours].to_s
58
58
  config["timestamp"] = hours2seconds(option[:hours])
@@ -61,38 +61,77 @@ module DaFunk
61
61
  end
62
62
  end
63
63
 
64
- def check_download_error(ret, enable_txt_ui = true)
65
- value = true
64
+ def check_download_error(download_ret, enable_txt_ui = true)
65
+ value = false
66
+
67
+ if download_ret == DaFunk::Transaction::Download::FILE_NOT_CHANGE
68
+ if enable_txt_ui
69
+ I18n.pt(:download_file_is_the_same, :args => [download_ret])
70
+ getc(1000)
71
+ end
72
+ value = true
73
+ elsif download_ret == DaFunk::Transaction::Download::SUCCESS
74
+ if enable_txt_ui
75
+ I18n.pt(:download_success, :args => [download_ret])
76
+ getc(1000)
77
+ end
78
+ value = true
79
+ end
80
+ value
81
+ end
82
+
83
+ def show_download_error(download_ret, enable_txt_ui = true)
66
84
  ui = {}
67
85
 
68
- case ret
86
+ case download_ret
69
87
  when DaFunk::Transaction::Download::SERIAL_NUMBER_NOT_FOUND
88
+ unless enable_txt_ui
89
+ Device::Display.print_bitmap('./shared/config_fail.bmp')
90
+ getc(5000)
91
+ end
70
92
  ui[:i18n] = :download_serial_number_not_found
71
- value = false
93
+ ContextLog.info "[I] Download error, serial number not registered"
72
94
  when DaFunk::Transaction::Download::FILE_NOT_FOUND
95
+ unless enable_txt_ui
96
+ Device::Display.print_bitmap('./shared/config_fail.bmp')
97
+ getc(5000)
98
+ end
73
99
  ui[:i18n] = :download_file_not_found
74
- value = false
75
- when DaFunk::Transaction::Download::FILE_NOT_CHANGE
76
- ui[:i18n] = :download_file_is_the_same
77
- when DaFunk::Transaction::Download::SUCCESS
78
- ui[:i18n] = :download_success
100
+ ContextLog.info "[I] Download error, file not found"
79
101
  when DaFunk::Transaction::Download::COMMUNICATION_ERROR
102
+ unless enable_txt_ui
103
+ Device::Display.print_bitmap('./shared/network_system_error.bmp')
104
+ getc(5000)
105
+ end
80
106
  ui[:i18n] = :download_communication_failure
81
- value = false
107
+ ContextLog.info "[I] Download error, connection problem"
82
108
  when DaFunk::Transaction::Download::MAPREDUCE_RESPONSE_ERROR
109
+ unless enable_txt_ui
110
+ Device::Display.print_bitmap('./shared/config_fail.bmp')
111
+ getc(5000)
112
+ end
83
113
  ui[:i18n] = :download_encoding_error
84
- value = false
114
+ ContextLog.info "[I] Download error, encoding problem"
85
115
  when DaFunk::Transaction::Download::IO_ERROR
116
+ unless enable_txt_ui
117
+ Device::Display.print_bitmap('./shared/config_fail.bmp')
118
+ getc(5000)
119
+ end
86
120
  ui[:i18n] = :download_io_error
87
- value = false
121
+ ContextLog.info "[I] Download error, IO error"
88
122
  else
123
+ unless enable_txt_ui
124
+ Device::Display.print_bitmap('./shared/network_system_error.bmp')
125
+ getc(5000)
126
+ end
89
127
  ui[:i18n] = :download_communication_failure
90
- value = false
128
+ ContextLog.info "[I] Download error, connection problem"
91
129
  end
92
130
 
93
- I18n.pt(ui[:i18n], :args => [ret]) if enable_txt_ui
94
-
95
- value
131
+ if enable_txt_ui
132
+ I18n.pt(ui[:i18n], :args => [download_ret])
133
+ getc(5000)
134
+ end
96
135
  end
97
136
 
98
137
  def try(tries, &block)
@@ -18,21 +18,6 @@ module DaFunk
18
18
  SLOT_BATTERY_PERCENTUAL = 6
19
19
  SLOT_BATTERY_LEVEL = 7
20
20
 
21
- SLOT_MESSAGE_CONNECTION = {
22
- true => {
23
- :slot1 => 2,
24
- :slot2 => 3,
25
- :message1 => './shared/conectado_01.png',
26
- :message2 => './shared/conectado_02.png'
27
- },
28
- false => {
29
- :slot1 => 2,
30
- :slot2 => 3,
31
- :message1 => './shared/buscando_01.png',
32
- :message2 => './shared/buscando_02.png'
33
- }
34
- }
35
-
36
21
  # TODO: review the 'print_status_bar' API to reduce the number of files
37
22
  # to eleven?
38
23
  BATTERY_PERCENTAGE_IMAGES = [
@@ -72,6 +57,11 @@ module DaFunk
72
57
  './shared/99%.png', './shared/100%.png'
73
58
  ].freeze
74
59
 
60
+ MEDIA_PATH = {
61
+ :gprs => './shared/3G.png',
62
+ :wifi => './shared/WIFI.png'
63
+ }
64
+
75
65
  BATTERY_CHARGING = [
76
66
  "./shared/battery_charging.png",
77
67
  "./shared/battery_charged.png"
@@ -109,7 +99,8 @@ module DaFunk
109
99
  }
110
100
 
111
101
  class << self
112
- attr_accessor :signal, :battery, :power, :managment, :connected
102
+ attr_accessor :current_signal, :current_message, :battery, :power, :managment
103
+ attr_accessor :current_media
113
104
  end
114
105
 
115
106
  def self.check
@@ -124,51 +115,56 @@ module DaFunk
124
115
  if File.exists?('./shared/system_update')
125
116
  PAX::Display.print_status_bar(SLOT_UPDATE, "./shared/system_update_download.png")
126
117
  PAX::Display.print_status_bar(3, nil)
127
- self.connected = false
128
118
  else
129
119
  self.change_message
130
120
  end
131
121
  end
132
122
 
133
123
  def self.change_message
134
- unless File.exists?('./shared/system_update')
135
- connected = Device::Network.connected?
136
-
137
- if connected != self.connected
138
- self.connected = connected
139
-
140
- slot_message_1 = SLOT_MESSAGE_CONNECTION[self.connected][:slot1]
141
- slot_message_2 = SLOT_MESSAGE_CONNECTION[self.connected][:slot2]
142
-
143
- message_1 = SLOT_MESSAGE_CONNECTION[self.connected][:message1]
144
- message_2 = SLOT_MESSAGE_CONNECTION[self.connected][:message2]
145
-
146
- Device::Display.print_status_bar(slot_message_1, message_1)
147
- Device::Display.print_status_bar(slot_message_2, message_2)
124
+ if ThreadScheduler.pause?(ThreadScheduler::THREAD_EXTERNAL_COMMUNICATION, 200)
125
+ if self.current_message != :pause
126
+ self.current_message = :pause
127
+ Device::Display.print_status_bar(2, './shared/semsinal_01.png')
128
+ Device::Display.print_status_bar(3, './shared/semsinal_02.png')
129
+ end
130
+ elsif Device::Network.connected?
131
+ if self.current_message != :connected
132
+ self.current_message = :connected
133
+ Device::Display.print_status_bar(2, './shared/conectado_01.png')
134
+ Device::Display.print_status_bar(3, './shared/conectado_02.png')
135
+ end
136
+ else
137
+ if self.current_message != :searching
138
+ self.current_message = :searching
139
+ Device::Display.print_status_bar(2, './shared/buscando_01.png')
140
+ Device::Display.print_status_bar(3, './shared/buscando_02.png')
148
141
  end
149
142
  end
150
143
  end
151
144
 
152
145
  def self.change_connection
153
- if Device::Network.connected?
154
- sig = Device::Network.signal
155
-
156
- if self.signal != sig
157
- self.signal = sig
158
-
159
- if Device::Network.gprs?
160
- Device::Display.print_status_bar(SLOT_MEDIA, "./shared/3G.png")
161
- Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
162
- get_image_path(:gprs, self.signal))
163
- elsif Device::Network.wifi?
164
- Device::Display.print_status_bar(SLOT_MEDIA, "./shared/WIFI.png")
165
- Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
166
- self.get_image_path(:wifi, self.signal))
167
- end
146
+ if ThreadScheduler.pause?(ThreadScheduler::THREAD_EXTERNAL_COMMUNICATION, 200)
147
+ Device::Display.print_status_bar(SLOT_MEDIA, nil)
148
+ Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL, nil)
149
+ self.current_media = nil
150
+ self.current_signal = nil
151
+ elsif Device::Network.connected?
152
+ media = Device::Network.gprs? ? :gprs : :wifi
153
+ signal = Device::Network.signal
154
+ if media != self.current_media
155
+ self.current_media = media
156
+ Device::Display.print_status_bar(SLOT_MEDIA, MEDIA_PATH[self.current_media])
157
+ end
158
+ if signal != self.current_signal
159
+ self.current_signal = signal
160
+ Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
161
+ self.get_image_path(self.current_media, self.current_signal))
168
162
  end
169
163
  else
170
164
  Device::Display.print_status_bar(SLOT_MEDIA, nil)
171
165
  Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL, "./shared/searching.png")
166
+ self.current_media = nil
167
+ self.current_signal = nil
172
168
  end
173
169
  end
174
170