balboa_worldwide_app 1.1.0 → 1.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 474d2a26cc4dca552bcb29ff22aa486903d73b7707c40d9c160e77eb2baed5fb
4
- data.tar.gz: f085680c104a2d42e1755cf63a44538a376e875820c12468f0fb955c39f69f07
3
+ metadata.gz: a309cfe60e168cb56a8a95ebdc80c6107428f4a700fc279889f6e27443a6c6f3
4
+ data.tar.gz: 9fcb57e4ea84ea69936eac347256df08af2bb0550efba9933487f7234160b8a7
5
5
  SHA512:
6
- metadata.gz: d6f16d2ae55926e145489f3b61d9df9be692e2a5a3d21920721ef657301d1e099fe28381e8c7eea9711efd2b314079b818e2f33bbda66234423c3be4c0ccacd5
7
- data.tar.gz: d7a6d5640c2902c03e22a6f4b11f447b3f4e3b6c9da757070b7db363b8dbb4e1b77ecfbce1553779f68b077e5ac2eac98f06d5ca7c7abafc9e4433459b211e81
6
+ metadata.gz: 97e1def1e19e8beb851d8a2db516720d3732fc05d36d8ac61b1f2c77c1c62db2b9b5f9aebf9516a2a881ba15f29c0740d94cd7dedcae9d207ca31717e562587c
7
+ data.tar.gz: 236c323cc0fe8e108eb4099ae19a86f9389f5a5b6aa92d0bb89f77ff5f244cbcf9130c6d24631e460ac445fe604e1ac86f470499e886ac29f5b8dd21e1dd58d2
@@ -25,10 +25,15 @@ module BWA
25
25
  message = bytes_read = nil
26
26
  loop do
27
27
  message, bytes_read = Message.parse(@buffer)
28
- # discard how much we read
29
- @buffer = @buffer[bytes_read..-1] if bytes_read
28
+ # discard how much we read
29
+ @buffer = @buffer[bytes_read..-1] if bytes_read
30
30
  unless message
31
- @buffer.concat(@io.readpartial(64 * 1024))
31
+ begin
32
+ @buffer.concat(@io.readpartial(64 * 1024))
33
+ rescue EOFError
34
+ @io.wait_readable
35
+ retry
36
+ end
32
37
  next
33
38
  end
34
39
  break
@@ -11,6 +11,9 @@ module BWA
11
11
  end
12
12
 
13
13
  class Message
14
+ class Unrecognized < Message
15
+ end
16
+
14
17
  class << self
15
18
  def inherited(klass)
16
19
  @messages ||= []
@@ -42,21 +45,26 @@ module BWA
42
45
  puts "discarding invalid data prior to message #{data[0...offset].unpack('H*').first}" unless offset == 0
43
46
  #puts "read #{data.slice(offset, length + 2).unpack('H*').first}"
44
47
 
45
- message_type = data.slice(offset + 2, 3)
48
+ src = data[offset + 2].ord
49
+ message_type = data.slice(offset + 3, 2)
46
50
  klass = @messages.find { |k| k::MESSAGE_TYPE == message_type }
47
51
 
48
52
 
49
53
  return [nil, offset + length + 2] if [
50
- "\xfe\xbf\x00".force_encoding(Encoding::ASCII_8BIT),
51
- "\x10\xbf\xe1".force_encoding(Encoding::ASCII_8BIT),
52
- "\x10\xbf\x07".force_encoding(Encoding::ASCII_8BIT)].include?(message_type)
54
+ "\xbf\x00".force_encoding(Encoding::ASCII_8BIT),
55
+ "\xbf\xe1".force_encoding(Encoding::ASCII_8BIT),
56
+ "\xbf\x07".force_encoding(Encoding::ASCII_8BIT)].include?(message_type)
53
57
 
54
- raise InvalidMessage.new("Unrecognized message #{message_type.unpack("H*").first}", data) unless klass
55
- raise InvalidMessage.new("Unrecognized data length (#{length}) for message #{klass}", data) unless length - 5 == klass::MESSAGE_LENGTH
58
+ if klass
59
+ raise InvalidMessage.new("Unrecognized data length (#{length}) for message #{klass}", data) unless length - 5 == klass::MESSAGE_LENGTH
60
+ else
61
+ klass = Unrecognized
62
+ end
56
63
 
57
64
  message = klass.new
58
65
  message.parse(data.slice(offset + 5, length - 5))
59
66
  message.instance_variable_set(:@raw_data, data.slice(offset, length + 2))
67
+ message.instance_variable_set(:@src, src)
60
68
  [message, offset + length + 2]
61
69
  end
62
70
 
@@ -76,14 +84,19 @@ module BWA
76
84
  end
77
85
  end
78
86
 
79
- attr_reader :raw_data
87
+ attr_reader :raw_data, :src
88
+
89
+ def initialize
90
+ # most messages we're sending come from this address
91
+ @src = 0x0a
92
+ end
80
93
 
81
94
  def parse(_data)
82
95
  end
83
96
 
84
97
  def serialize(message = "")
85
98
  length = message.length + 5
86
- full_message = "#{length.chr}#{self.class::MESSAGE_TYPE}#{message}".force_encoding(Encoding::ASCII_8BIT)
99
+ full_message = "#{length.chr}#{src.chr}#{self.class::MESSAGE_TYPE}#{message}".force_encoding(Encoding::ASCII_8BIT)
87
100
  checksum = CRC.checksum(full_message)
88
101
  "\x7e#{full_message}#{checksum.chr}\x7e".force_encoding(Encoding::ASCII_8BIT)
89
102
  end
@@ -1,7 +1,7 @@
1
1
  module BWA
2
2
  module Messages
3
3
  class Configuration < Message
4
- MESSAGE_TYPE = "\x0a\xbf\x94".force_encoding(Encoding::ASCII_8BIT)
4
+ MESSAGE_TYPE = "\xbf\x94".force_encoding(Encoding::ASCII_8BIT)
5
5
  MESSAGE_LENGTH = 25
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module BWA
2
2
  module Messages
3
3
  class ConfigurationRequest < Message
4
- MESSAGE_TYPE = "\x0a\xbf\x04".force_encoding(Encoding::ASCII_8BIT)
4
+ MESSAGE_TYPE = "\xbf\x04".force_encoding(Encoding::ASCII_8BIT)
5
5
  MESSAGE_LENGTH = 0
6
6
 
7
7
  def inspect
@@ -1,7 +1,7 @@
1
1
  module BWA
2
2
  module Messages
3
3
  class ControlConfiguration < Message
4
- MESSAGE_TYPE = "\x0a\xbf\x24".force_encoding(Encoding::ASCII_8BIT)
4
+ MESSAGE_TYPE = "\xbf\x24".force_encoding(Encoding::ASCII_8BIT)
5
5
  MESSAGE_LENGTH = 21
6
6
 
7
7
  attr_accessor :model, :version
@@ -20,13 +20,9 @@ module BWA
20
20
  "#<BWA::Messages::ControlConfiguration #{model} #{version}>"
21
21
  end
22
22
  end
23
- end
24
- end
25
23
 
26
- module BWA
27
- module Messages
28
24
  class ControlConfiguration2 < Message
29
- MESSAGE_TYPE = "\x0a\xbf\x2e".force_encoding(Encoding::ASCII_8BIT)
25
+ MESSAGE_TYPE = "\xbf\x2e".force_encoding(Encoding::ASCII_8BIT)
30
26
  MESSAGE_LENGTH = 6
31
27
 
32
28
  attr_accessor :pumps, :lights, :circ_pump, :blower, :mister, :aux
@@ -1,7 +1,7 @@
1
1
  module BWA
2
2
  module Messages
3
3
  class ControlConfigurationRequest < Message
4
- MESSAGE_TYPE = "\x0a\xbf\x22".force_encoding(Encoding::ASCII_8BIT)
4
+ MESSAGE_TYPE = "\xbf\x22".force_encoding(Encoding::ASCII_8BIT)
5
5
  MESSAGE_LENGTH = 3
6
6
 
7
7
  attr_accessor :type
@@ -5,7 +5,7 @@ module BWA
5
5
  :filter2_enabled,
6
6
  :filter2_hour, :filter2_minute, :filter2_duration_hours, :filter2_duration_minutes
7
7
 
8
- MESSAGE_TYPE = "\x0a\xbf\x23".force_encoding(Encoding::ASCII_8BIT)
8
+ MESSAGE_TYPE = "\xbf\x23".force_encoding(Encoding::ASCII_8BIT)
9
9
  MESSAGE_LENGTH = 8
10
10
 
11
11
  def parse(data)
@@ -1,7 +1,7 @@
1
1
  module BWA
2
2
  module Messages
3
3
  class Ready < Message
4
- MESSAGE_TYPE = "\x10\xbf\06".force_encoding(Encoding::ASCII_8BIT)
4
+ MESSAGE_TYPE = "\xbf\06".force_encoding(Encoding::ASCII_8BIT)
5
5
  MESSAGE_LENGTH = 0
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module BWA
2
2
  module Messages
3
3
  class SetTemperatureScale < Message
4
- MESSAGE_TYPE = "\x0a\xbf\x27".force_encoding(Encoding::ASCII_8BIT)
4
+ MESSAGE_TYPE = "\xbf\x27".force_encoding(Encoding::ASCII_8BIT)
5
5
  MESSAGE_LENGTH = 2
6
6
 
7
7
  attr_accessor :scale
@@ -17,10 +17,11 @@ module BWA
17
17
  :aux,
18
18
  :current_temperature, :set_temperature
19
19
 
20
- MESSAGE_TYPE = "\xff\xaf\x13".force_encoding(Encoding::ASCII_8BIT)
20
+ MESSAGE_TYPE = "\xaf\x13".force_encoding(Encoding::ASCII_8BIT)
21
21
  MESSAGE_LENGTH = 24
22
22
 
23
23
  def initialize
24
+ @src = 0xff
24
25
  self.priming = false
25
26
  self.heating_mode = :ready
26
27
  @temperature_scale = :fahrenheit
@@ -1,7 +1,7 @@
1
1
  module BWA
2
2
  module Messages
3
3
  class ToggleItem < Message
4
- MESSAGE_TYPE = "\x0a\xbf\x11".force_encoding(Encoding::ASCII_8BIT)
4
+ MESSAGE_TYPE = "\xbf\x11".force_encoding(Encoding::ASCII_8BIT)
5
5
  MESSAGE_LENGTH = 2
6
6
 
7
7
  attr_accessor :item
@@ -15,8 +15,10 @@ module BWA
15
15
  when 0x04; :pump1
16
16
  when 0x05; :pump2
17
17
  when 0x11; :light1
18
+ when 0x3c; :hold
18
19
  when 0x50; :temperature_range
19
20
  when 0x51; :heating_mode
21
+ else; data[0].ord
20
22
  end
21
23
  end
22
24
 
@@ -1,3 +1,3 @@
1
1
  module BWA
2
- VERSION = '1.1.0'
3
- end
2
+ VERSION = '1.1.1'
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: balboa_worldwide_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-09 00:00:00.000000000 Z
11
+ date: 2020-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: digest-crc