teletask 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/request.rb +2 -2
- data/lib/response.rb +7 -7
- data/lib/teletask.rb +0 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e61a169dc5d6902cedcee9792dfd3bbafc297d1
|
4
|
+
data.tar.gz: 89dc4834ac52e46ae058d63d1fadff6d06c62b5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e65820ac75cb5432b429d0adc45ef7d6bfc9f56bbf33cc3e9ff5d80ee94c6b7a6083b5a6b704aecbdae83aa8a8c9641aacc0acbd2df468ff8dbeb3bdef5530b
|
7
|
+
data.tar.gz: 5aabb8df4e505bb6223be764f07f0c1699a203e4f7f9151af2bc215e8f48285da90d0bcfa44998d9f692dfd3f5296937f431bedfc870625a607ad2b880856db1
|
data/lib/request.rb
CHANGED
data/lib/response.rb
CHANGED
@@ -20,12 +20,12 @@ module TeletaskApi
|
|
20
20
|
calculatedChecksum = data[startindex..startindex+length-1].inject{|sum,x| sum + x } % 256
|
21
21
|
checksum = data[startindex+length]
|
22
22
|
raise "Checksum mismatch. Expecting #{checksum}, but calculated #{calculatedChecksum}" unless checksum == calculatedChecksum
|
23
|
-
raise "Not an response." unless data[startindex+2] ==
|
23
|
+
raise "Not an response." unless data[startindex+2] == Command::EVENTREPORT
|
24
24
|
central = data[startindex+3]
|
25
25
|
function = data[startindex+4]
|
26
26
|
number = data[startindex+5..startindex+6].pack("c*").unpack("n").first
|
27
27
|
case function
|
28
|
-
when
|
28
|
+
when Function::SENSOR
|
29
29
|
parameters =data[startindex+8..startindex+9]
|
30
30
|
else
|
31
31
|
parameters =data[startindex+8]
|
@@ -42,15 +42,15 @@ module TeletaskApi
|
|
42
42
|
def to_hash
|
43
43
|
hash = Hash.new
|
44
44
|
hash[:function] = function
|
45
|
-
hash[:function_name] =
|
45
|
+
hash[:function_name] = Function.name function
|
46
46
|
hash[:number] = number
|
47
47
|
hash[:parameters] = parameters
|
48
48
|
case function
|
49
|
-
when
|
50
|
-
hash[:temperature] =
|
51
|
-
when
|
49
|
+
when Function::SENSOR
|
50
|
+
hash[:temperature] = Converter.short_to_temperature parameters
|
51
|
+
when Function::RELAY
|
52
52
|
hash[:state] = parameters
|
53
|
-
hash[:state_name] =
|
53
|
+
hash[:state_name] = Setting.name parameters
|
54
54
|
end
|
55
55
|
hash
|
56
56
|
end
|
data/lib/teletask.rb
CHANGED
@@ -6,10 +6,8 @@ require_relative './constants'
|
|
6
6
|
require_relative './request'
|
7
7
|
require_relative './response'
|
8
8
|
|
9
|
-
include TeletaskApi
|
10
9
|
|
11
10
|
module TeletaskApi
|
12
|
-
|
13
11
|
class Teletask
|
14
12
|
include Observable
|
15
13
|
|
@@ -88,5 +86,3 @@ module TeletaskApi
|
|
88
86
|
end
|
89
87
|
|
90
88
|
end
|
91
|
-
|
92
|
-
Teletask = TeletaskApi::Teletask
|