SensorStream 0.2.0 → 0.2.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 +4 -4
- data/lib/SensorStream.rb +27 -12
- 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: fb098ddfd37fabf24bf24a65d53d144d6a5449c7
|
4
|
+
data.tar.gz: bf9330e4121f5da1aa791875c69b1a1b000fef86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb5ee40a24e7af1c5dd679125eb2dbbb107691496ab7bf3a5509fc5b9c24fb5d43c189eb8b2f59348db86e1221f61b38b57568a9563d82936d8009f5ecf75304
|
7
|
+
data.tar.gz: 2862a3e185201f18f813c7afbafeabd1ba8d6436d1842466d6337939aca92c0597028575ff57b8292a5d7256bb0d97b66e0d11ec59d485f32a97b7dbb0d90baf
|
data/lib/SensorStream.rb
CHANGED
@@ -28,7 +28,7 @@ module SensorStream
|
|
28
28
|
|
29
29
|
# Allows the SensorStream server to be overridden
|
30
30
|
def self.set_default_server
|
31
|
-
@host_name = "sensorstream.
|
31
|
+
@host_name = "sensorstream.coas.oregonstate.edu"
|
32
32
|
@port_number = 80
|
33
33
|
end
|
34
34
|
|
@@ -49,10 +49,16 @@ module SensorStream
|
|
49
49
|
|
50
50
|
http = Net::HTTP.new(@host_name, @port_number);
|
51
51
|
http.read_timeout = timeout; # 10 minute default timeout
|
52
|
-
http.post(uri.request_uri, JSON.generate(body_dict), header_dict);
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
retval = http.post(uri.request_uri, JSON.generate(body_dict), header_dict);
|
53
|
+
|
54
|
+
rescue Errno::ETIMEDOUT => e
|
55
|
+
puts "Timed out while waiting for SensorStream."
|
56
|
+
return nil
|
57
|
+
end
|
58
|
+
|
59
|
+
return retval
|
60
|
+
end
|
61
|
+
|
56
62
|
# Internally used to wrap HTTP gets with the required headers
|
57
63
|
def self.make_http_get(request = "", header_dict = {}, timeout = 600, debug = false)
|
58
64
|
# Ensure that the hostname and port are set
|
@@ -67,8 +73,14 @@ module SensorStream
|
|
67
73
|
|
68
74
|
http = Net::HTTP.new(@host_name, @port_number);
|
69
75
|
http.read_timeout = 600; # 10 minute timeout
|
70
|
-
http.get(uri.request_uri, header_dict);
|
71
|
-
|
76
|
+
retval = http.get(uri.request_uri, header_dict);
|
77
|
+
|
78
|
+
rescue Errno::ETIMEDOUT => e
|
79
|
+
puts "Timed out while waiting for SensorStream."
|
80
|
+
return nil
|
81
|
+
end
|
82
|
+
|
83
|
+
return retval
|
72
84
|
end
|
73
85
|
|
74
86
|
# create a new device on the server
|
@@ -125,12 +137,15 @@ module SensorStream
|
|
125
137
|
return nil;
|
126
138
|
else
|
127
139
|
devices = [];
|
140
|
+
|
141
|
+
if (resp.body.empty?)
|
142
|
+
return nil
|
143
|
+
end
|
144
|
+
|
128
145
|
JSON.parse(resp.body).each { |device|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
#devices.last.get_streams
|
133
|
-
}
|
146
|
+
devices << SensorStream::Device.new(device["username"],
|
147
|
+
device["devicename"],
|
148
|
+
device["description"]) }
|
134
149
|
return devices;
|
135
150
|
end
|
136
151
|
end
|