humble_rpi 0.1.2 → 0.1.3
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/humble_rpi.rb +7 -7
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41cfe2fe8b95395063bec36af5c1059311993f25
|
4
|
+
data.tar.gz: c786475c516c1f6285feda3b00bfc78c66a61367
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3e0a0da906c1edd9bcbc41bf15de32ab4ca8172212c9ffa8900fbf8e71faafeaa9aac93628feb99a2d5938620ad7c8bd0097bbc1252f128a300d3fa453a303d
|
7
|
+
data.tar.gz: b250f6ba9fc7d648f7f756c9adf9ebf99d40e8f9db9b228728f9569a8ea071a32852265b9b48a08e982e9b239d14149e79c0f688fe3b9905e7b0a027c982750c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/humble_rpi.rb
CHANGED
@@ -12,6 +12,7 @@ class HumbleRPi < RPi
|
|
12
12
|
|
13
13
|
def initialize(options={})
|
14
14
|
|
15
|
+
puts 'inside humble_rpi'
|
15
16
|
default_options = {
|
16
17
|
device_name: 'rpi',
|
17
18
|
led_pins: [],
|
@@ -22,12 +23,11 @@ class HumbleRPi < RPi
|
|
22
23
|
|
23
24
|
@opt = default_options.merge options
|
24
25
|
super @opt[:led_pins]
|
25
|
-
@ws
|
26
|
+
@ws = nil
|
26
27
|
end
|
27
28
|
|
28
29
|
def led_listener(&blk)
|
29
|
-
|
30
|
-
rpi = @rpi
|
30
|
+
rpi = self
|
31
31
|
|
32
32
|
c = WebSocket::EventMachine::Client
|
33
33
|
|
@@ -37,9 +37,8 @@ class HumbleRPi < RPi
|
|
37
37
|
|
38
38
|
@ws = c.connect(uri: "ws://%s:%s" % [@opt[:sps_address], @opt[:sps_port]])
|
39
39
|
|
40
|
-
ws.onopen do
|
40
|
+
@ws.onopen do
|
41
41
|
puts "Client connected"
|
42
|
-
#@ws = ws
|
43
42
|
end
|
44
43
|
|
45
44
|
@ws.onmessage(&blk)
|
@@ -51,6 +50,7 @@ class HumbleRPi < RPi
|
|
51
50
|
EventMachine.next_tick do
|
52
51
|
@ws.send "subscribe to topic: #{@opt[:device_name]}_led"
|
53
52
|
end
|
53
|
+
|
54
54
|
EventMachine.error_handler{ |e|
|
55
55
|
puts "Error raised during event loop: #{e.message}"
|
56
56
|
|
@@ -66,10 +66,10 @@ class HumbleRPi < RPi
|
|
66
66
|
|
67
67
|
t1 = Time.now
|
68
68
|
ws, opt = @ws, @opt
|
69
|
-
|
69
|
+
puts 'inside motion //'
|
70
70
|
after pin: opt[:motion_pin].to_i, goes: :high do
|
71
71
|
|
72
|
-
|
72
|
+
puts Time.now.to_s + ' : motion detected'
|
73
73
|
|
74
74
|
if Time.now > t1 + ChronicDuration.parse('1 minute') then
|
75
75
|
ws.send opt[:device_name] + ': motion detected'
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|