smartware 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ .idea
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
@@ -8,12 +8,6 @@ module Smartware
8
8
  DRb.start_service
9
9
  @device = DRbObject.new_with_uri('druby://localhost:6002')
10
10
 
11
- #def self.configure(port, driver)
12
- # DRb.start_service
13
- # @device = DRbObject.new_with_uri('druby://localhost:6002')
14
- # @device.configure!(port, driver)
15
- #end
16
-
17
11
  def self.error
18
12
  @device.error
19
13
  end
@@ -30,24 +24,6 @@ module Smartware
30
24
  @device.signal_level
31
25
  end
32
26
 
33
- def self.d_model
34
- @device.d_model
35
- end
36
-
37
- def self.d_signal
38
- @device.d_signal
39
- end
40
-
41
- def self.d_balance
42
- @device.d_balance
43
- end
44
-
45
- def self.d_stop
46
- @device.d_stop
47
- end
48
-
49
-
50
-
51
27
  end
52
28
  end
53
29
  end
@@ -8,12 +8,6 @@ module Smartware
8
8
  DRb.start_service
9
9
  @device = DRbObject.new_with_uri('druby://localhost:6005')
10
10
 
11
- #def self.configure(port, driver)
12
- # DRb.start_service
13
- # @device = DRbObject.new_with_uri('druby://localhost:6005')
14
- # @device.configure!(port, driver)
15
- #end
16
-
17
11
  def self.error
18
12
  @device.error
19
13
  rescue => e
@@ -1,4 +1,7 @@
1
1
  # coding: utf-8
2
+ #
3
+ # CCNET protocol driver for CashCode bill validator
4
+ #
2
5
  require 'serialport'
3
6
 
4
7
  module Smartware
@@ -49,7 +49,7 @@ module Smartware
49
49
  port = SerialPort.new(@port, 115200, 8, 1, SerialPort::NONE)
50
50
  port.read_timeout = 3000
51
51
  port.write "AT+CUSD=1,\"#{code}\",15\r\n"
52
- ussd_body = port.read.split(/[\r\n]+/).last.split(",")[1].gsub('"','') # Get only USSD message body
52
+ ussd_body = port.read.split(/[\r\n]+/).last.split(",")[1].gsub('"','') # Parse USSD message body
53
53
  port.close
54
54
  ussd_body.scan(/\w{4}/).map{|i| [i.hex].pack("U") }.join # Encode USSD message from broken ucs2 to utf-8
55
55
  rescue
@@ -45,22 +45,6 @@ module Smartware
45
45
  @status[:signal_level]
46
46
  end
47
47
 
48
- def self.d_model
49
- @device.model
50
- end
51
-
52
- def self.d_signal
53
- @device.signal_level
54
- end
55
-
56
- def self.d_balance
57
- @device.ussd
58
- end
59
-
60
- def self.d_stop
61
- @session.kill
62
- end
63
-
64
48
  private
65
49
  def self.poll_status!
66
50
  t = Thread.new do
@@ -1,3 +1,3 @@
1
1
  module Smartware
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-19 00:00:00.000000000 Z
13
+ date: 2012-12-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: serialport
@@ -67,7 +67,6 @@ files:
67
67
  - lib/smartware/drivers/cash_acceptor/dummy.rb
68
68
  - lib/smartware/drivers/modem/dummy.rb
69
69
  - lib/smartware/drivers/modem/standard.rb
70
- - lib/smartware/drivers/modem/standart.rb
71
70
  - lib/smartware/drivers/printer/dummy.rb
72
71
  - lib/smartware/drivers/printer/tg24xx.rb
73
72
  - lib/smartware/interfaces/cash_acceptor.rb
@@ -1,74 +0,0 @@
1
- # coding: utf-8
2
- require 'serialport'
3
-
4
- module Smartware
5
- module Driver
6
- module Modem
7
-
8
- class Standart
9
-
10
- def initialize(port)
11
- # @port Class variable needs for ussd request
12
- @port = port
13
- @sp = SerialPort.new(@port, 115200, 8, 1, SerialPort::NONE)
14
- end
15
-
16
- def error
17
- false
18
- end
19
-
20
- def model
21
- res = send 'ATI' rescue -1
22
- return -1 unless res.last == "OK"
23
-
24
- res.shift
25
- res.pop
26
- res.join(' ')
27
- rescue
28
- -1
29
- end
30
-
31
- #
32
- # Returns signal level in dbm
33
- #
34
- def signal_level
35
- res = send 'AT+CSQ'
36
- return -1 if res.last != "OK"
37
- value = res[1].gsub("+CSQ: ",'').split(',')[0].to_i
38
- "#{(-113 + value * 2)} dbm"
39
- rescue
40
- -1
41
- end
42
-
43
- #
44
- # Method send ussd to operator and return only valid answer body
45
- # Don`t call with method synchronously from app, method waits USSD answer 3 sec,
46
- # Use some scheduler and buffer for balance value
47
- #
48
- def ussd(code="*100#")
49
- port = SerialPort.new(@port, 115200, 8, 1, SerialPort::NONE)
50
- port.read_timeout = 3000
51
- port.write "AT+CUSD=1,\"#{code}\",15\r\n"
52
- ussd_body = port.read.split(/[\r\n]+/).last.split(",")[1].gsub('"','') # Get only USSD message body
53
- port.close
54
- ussd_body.scan(/\w{4}/).map{|i| [i.hex].pack("U") }.join # Encode USSD message from broken ucs2 to utf-8
55
- rescue
56
- -1
57
- end
58
-
59
- private
60
- def send cmd
61
- @sp.write "#{ cmd }\r\n"
62
- answer = ''
63
- while IO.select [@sp], [], [], 0.25
64
- chr = @sp.getc.chr
65
- answer << chr
66
- end
67
- answer.split(/[\r\n]+/)
68
- end
69
-
70
- end
71
-
72
- end
73
- end
74
- end