m2x 2.0.0 → 2.0.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/README.md +4 -4
- data/lib/m2x/cacert.pem +3554 -0
- data/lib/m2x/version.rb +1 -1
- data/lib/megatest.rb +65 -33
- data/m2x.gemspec +1 -0
- metadata +4 -3
data/lib/m2x/version.rb
CHANGED
data/lib/megatest.rb
CHANGED
@@ -3,50 +3,82 @@
|
|
3
3
|
require "time"
|
4
4
|
require "pp"
|
5
5
|
|
6
|
-
|
6
|
+
require "m2x"
|
7
|
+
# require_relative "./m2x"
|
7
8
|
|
8
|
-
m2x = M2X::Client.new("cdc032a8d7bfbf1ce5948a8c474eaa25")
|
9
|
+
$m2x = M2X::Client.new("cdc032a8d7bfbf1ce5948a8c474eaa25")
|
10
|
+
$running = true
|
9
11
|
|
10
|
-
|
12
|
+
stop = Proc.new { $running = false }
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
arduino.create_stream("loudness")
|
14
|
+
trap(:INT, &stop)
|
15
|
+
trap(:TERM, &stop)
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
{ timestamp: (Time.now - 2).iso8601, value: rand(0..37) },
|
20
|
-
{ timestamp: (Time.now + 2).iso8601, value: rand(0..37) }
|
21
|
-
],
|
22
|
-
humidity: [
|
23
|
-
{ timestamp: (Time.now - 3).iso8601, value: rand(0..100) },
|
24
|
-
{ timestamp: (Time.now + 3).iso8601, value: rand(0..100) }
|
25
|
-
]
|
26
|
-
},
|
27
|
-
location: { latitude: 80.3712, longitude: 100, elevation: 300 }
|
28
|
-
})
|
17
|
+
1.times do |i|
|
18
|
+
break unless $running
|
19
|
+
puts "Creating device #{i}"
|
29
20
|
|
30
|
-
|
21
|
+
device = $m2x.create_device(name: "Test Device #{i}", description: "Some test device", visibility: "public")
|
22
|
+
fail $m2x.last_response.inspect if $m2x.last_response.error?
|
31
23
|
|
32
|
-
|
24
|
+
device = $m2x.device(device["id"])
|
25
|
+
fail $m2x.last_response.inspect if $m2x.last_response.error?
|
33
26
|
|
34
|
-
|
27
|
+
device.create_stream("testdevicestream", type: "numeric", unit: { label: "points", symbol: "pt" })
|
28
|
+
fail $m2x.last_response.inspect if $m2x.last_response.error?
|
35
29
|
|
36
|
-
|
30
|
+
stream = device.stream("testdevicestream")
|
37
31
|
|
38
|
-
|
32
|
+
values = 2.times.map{ sleep 0.001; { timestamp: Time.now.utc.iso8601(3), value: rand(0..999999) } }
|
39
33
|
|
40
|
-
|
41
|
-
|
34
|
+
stream.post_values(values)
|
35
|
+
fail $m2x.last_response.inspect if $m2x.last_response.error?
|
42
36
|
end
|
43
37
|
|
44
|
-
|
45
|
-
pp loudness.sampling(interval: 1).json
|
46
|
-
pp loudness.values.json
|
38
|
+
puts "All devices created"
|
47
39
|
|
48
|
-
loudness.delete_values!((Time.now - 3600).iso8601, Time.now.iso8601)
|
49
40
|
|
50
|
-
|
51
|
-
arduino.
|
52
|
-
|
41
|
+
# m2x.api_base = SQL1
|
42
|
+
# puts arduino.create_stream("temperature")
|
43
|
+
# m2x.api_base = EWR2
|
44
|
+
# puts arduino.create_stream("humidity")
|
45
|
+
# m2x.api_base = DPA1
|
46
|
+
# puts arduino.create_stream("loudness")
|
47
|
+
|
48
|
+
# arduino.post_updates({
|
49
|
+
# values: {
|
50
|
+
# temperature: [
|
51
|
+
# { timestamp: (Time.now - 2).iso8601, value: rand(0..37) },
|
52
|
+
# { timestamp: (Time.now + 2).iso8601, value: rand(0..37) }
|
53
|
+
# ],
|
54
|
+
# humidity: [
|
55
|
+
# { timestamp: (Time.now - 3).iso8601, value: rand(0..100) },
|
56
|
+
# { timestamp: (Time.now + 3).iso8601, value: rand(0..100) }
|
57
|
+
# ]
|
58
|
+
# },
|
59
|
+
# location: { latitude: 80.3712, longitude: 100, elevation: 300 }
|
60
|
+
# })
|
61
|
+
|
62
|
+
# loudness = arduino.stream("loudness")
|
63
|
+
|
64
|
+
# loudness.post_values(1000.times.map{ |i| { timestamp: (Time.now + i).iso8601, value: rand(0..120) } })
|
65
|
+
|
66
|
+
# loudness.update_value(rand(90..9999))
|
67
|
+
|
68
|
+
# raspberries = m2x.create_distribution(name: "Raspberries", description: "Group of raspberries", visibility: "private")
|
69
|
+
|
70
|
+
# all_raspberries = 10.times.map{ |i| raspberries.add_device(i.to_s) }
|
71
|
+
|
72
|
+
# all_raspberries.each do |device|
|
73
|
+
# device.update_location(latitude: rand(-90..90), longitude: rand(-180..180), elevation: rand(0..7000))
|
74
|
+
# end
|
75
|
+
|
76
|
+
# pp loudness.stats.json
|
77
|
+
# pp loudness.sampling(interval: 1).json
|
78
|
+
# pp loudness.values.json
|
79
|
+
|
80
|
+
# loudness.delete_values!((Time.now - 3600).iso8601, Time.now.iso8601)
|
81
|
+
|
82
|
+
# loudness.delete!
|
83
|
+
# arduino.delete!
|
84
|
+
# raspberries.delete!
|
data/m2x.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: m2x
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro López
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: AT&T’s M2X is a cloud-based fully managed data storage service for network
|
16
16
|
connected machine-to-machine (M2M) devices. From trucks and turbines to vending
|
@@ -27,6 +27,7 @@ files:
|
|
27
27
|
- LICENSE
|
28
28
|
- README.md
|
29
29
|
- lib/m2x.rb
|
30
|
+
- lib/m2x/cacert.pem
|
30
31
|
- lib/m2x/client.rb
|
31
32
|
- lib/m2x/device.rb
|
32
33
|
- lib/m2x/distribution.rb
|
@@ -57,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
58
|
version: '0'
|
58
59
|
requirements: []
|
59
60
|
rubyforge_project:
|
60
|
-
rubygems_version: 2.
|
61
|
+
rubygems_version: 2.4.4
|
61
62
|
signing_key:
|
62
63
|
specification_version: 4
|
63
64
|
summary: Ruby client for AT&T M2X
|