m2x 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63431ca3ec1edae2c7f4491f09c7d67ead03aca9
4
- data.tar.gz: a406bd26039de6751d50678e520d33053f127a5f
3
+ metadata.gz: a9b3171048b83b4ed8005c46ea14d79d14e5c4ca
4
+ data.tar.gz: f60bfea82d2192e0cae29ec6d3108aba5c1d74e7
5
5
  SHA512:
6
- metadata.gz: b14e5c49984d52731e227a77d63be170b16895cb4c2803777f423d973385372d7b1555700bbe643ceb8249b6710973274668fac879733af953581ac4ec027ebe
7
- data.tar.gz: b613ba7f2984f35b8c21a2fb1eee606fb6e176bdb031e63aa7517e00574343911c6ee66f08841f05ca4581b51d26a772caf951585116e65a76024fa4a411133a
6
+ metadata.gz: 092ef245aaec30611adc11997565d669797e303204dd1b28db883c55fcc9feb5a4c29b8c1627869beec68b819a0e69a76d5637a202cb5eca30eb7673762fee5e
7
+ data.tar.gz: b1bf2a416fea48dd56146385c75c012b9eee7eaef12668012a9328f2900313778eacafeb285a42ebf2715ec93368d7f04b46656d9cd96c6bd91cb6e79823c910
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
- # AT&T's M2X Ruby Client
1
+ # AT&T M2X Ruby Client
2
2
 
3
- [AT&T’s M2X](https://m2x.att.com/) is a cloud-based fully managed data storage service for network connected machine-to-machine (M2M) devices. From trucks and turbines to vending machines and freight containers, M2X enables the devices that power your business to connect and share valuable data.
4
-
5
- This library aims to provide a simple wrapper to interact with the [AT&T M2X API](https://m2x.att.com/developer/documentation/overview) for [Ruby](https://www.ruby-lang.org/en/). Refer to the [Glossary of Terms](https://m2x.att.com/developer/documentation/glossary) to understand the nomenclature used throughout this documentation.
3
+ [AT&T M2X](http://m2x.att.com) is a cloud-based fully managed time-series data storage service for network connected machine-to-machine (M2M) devices and the Internet of Things (IoT).
6
4
 
5
+ The [AT&T M2X API](https://m2x.att.com/developer/documentation/overview) provides all the needed operations and methods to connect your devices to AT&T's M2X service. This library aims to provide a simple wrapper to interact with the AT&T M2X API for [Ruby](https://www.ruby-lang.org/en/). Refer to the [Glossary of Terms](https://m2x.att.com/developer/documentation/glossary) to understand the nomenclature used throughout this documentation.
7
6
 
8
7
  Getting Started
9
8
  ==========================
@@ -65,8 +64,7 @@ API_KEY=<YOUR-API-KEY> DEVICE=<YOUR-DEVICE-ID> ./m2x-uptime.rb
65
64
  #! /usr/bin/env ruby
66
65
 
67
66
  #
68
- # See https://github.com/attm2x/m2x-ruby/blob/master/README.md#example-usage
69
- # for instructions
67
+ # See https://github.com/attm2x/m2x-ruby#example for instructions
70
68
  #
71
69
 
72
70
  require "time"
@@ -71,13 +71,13 @@ class M2X::Client::Stream < M2X::Client::Resource
71
71
  end
72
72
 
73
73
  # Update the current value of the stream. The timestamp
74
- # is optional. If ommited, the current server time will be used
74
+ # is optional. If omitted, the current server time will be used
75
75
  #
76
76
  # https://m2x.att.com/developer/documentation/v2/device#Update-Data-Stream-Value
77
77
  def update_value(value, timestamp=nil)
78
78
  params = { value: value }
79
79
 
80
- params[:at] = timestamp if timestamp
80
+ params[:timestamp] = timestamp if timestamp
81
81
 
82
82
  @client.put("#{path}/value", nil, params, "Content-Type" => "application/json")
83
83
  end
@@ -1,5 +1,5 @@
1
1
  module M2X
2
2
  class Client
3
- VERSION = "2.0.1"
3
+ VERSION = "2.0.2"
4
4
  end
5
5
  end
@@ -3,8 +3,8 @@
3
3
  require "time"
4
4
  require "pp"
5
5
 
6
- require "m2x"
7
- # require_relative "./m2x"
6
+ # require "m2x"
7
+ require_relative "./m2x"
8
8
 
9
9
  $m2x = M2X::Client.new("cdc032a8d7bfbf1ce5948a8c474eaa25")
10
10
  $running = true
@@ -14,11 +14,11 @@ stop = Proc.new { $running = false }
14
14
  trap(:INT, &stop)
15
15
  trap(:TERM, &stop)
16
16
 
17
- 1.times do |i|
17
+ 5.times do |i|
18
18
  break unless $running
19
19
  puts "Creating device #{i}"
20
20
 
21
- device = $m2x.create_device(name: "Test Device #{i}", description: "Some test device", visibility: "public")
21
+ device = $m2x.create_device(name: "Test Device #{i}", description: "Some test device", visibility: "private")
22
22
  fail $m2x.last_response.inspect if $m2x.last_response.error?
23
23
 
24
24
  device = $m2x.device(device["id"])
@@ -37,48 +37,45 @@ end
37
37
 
38
38
  puts "All devices created"
39
39
 
40
+ arduino = $m2x.create_device(name: "My Arduinos", description: "Some test device", visibility: "private")
41
+ puts arduino.create_stream("temperature")
42
+ puts arduino.create_stream("humidity")
43
+ puts arduino.create_stream("loudness")
40
44
 
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")
45
+ arduino.post_updates({
46
+ values: {
47
+ temperature: [
48
+ { timestamp: (Time.now - 2).iso8601, value: rand(0..37) },
49
+ { timestamp: (Time.now + 2).iso8601, value: rand(0..37) }
50
+ ],
51
+ humidity: [
52
+ { timestamp: (Time.now - 3).iso8601, value: rand(0..100) },
53
+ { timestamp: (Time.now + 3).iso8601, value: rand(0..100) }
54
+ ]
55
+ },
56
+ location: { latitude: 80.3712, longitude: 100, elevation: 300 }
57
+ })
47
58
 
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
- # })
59
+ loudness = arduino.stream("loudness")
61
60
 
62
- # loudness = arduino.stream("loudness")
61
+ loudness.post_values(1000.times.map{ |i| { timestamp: (Time.now + i).iso8601, value: rand(0..120) } })
63
62
 
64
- # loudness.post_values(1000.times.map{ |i| { timestamp: (Time.now + i).iso8601, value: rand(0..120) } })
63
+ loudness.update_value(rand(90..9999))
65
64
 
66
- # loudness.update_value(rand(90..9999))
65
+ raspberries = $m2x.create_distribution(name: "Raspberries", description: "Group of raspberries", visibility: "private")
67
66
 
68
- # raspberries = m2x.create_distribution(name: "Raspberries", description: "Group of raspberries", visibility: "private")
67
+ all_raspberries = 10.times.map{ |i| raspberries.add_device(i.to_s) }
69
68
 
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
69
+ all_raspberries.each do |device|
70
+ device.update_location(latitude: rand(-90..90), longitude: rand(-180..180), elevation: rand(0..7000))
71
+ end
75
72
 
76
- # pp loudness.stats.json
77
- # pp loudness.sampling(interval: 1).json
78
- # pp loudness.values.json
73
+ pp loudness.stats.json
74
+ pp loudness.sampling(interval: 1).json
75
+ pp loudness.values.json
79
76
 
80
- # loudness.delete_values!((Time.now - 3600).iso8601, Time.now.iso8601)
77
+ loudness.delete_values!((Time.now - 3600).iso8601, Time.now.iso8601)
81
78
 
82
- # loudness.delete!
83
- # arduino.delete!
84
- # raspberries.delete!
79
+ loudness.delete!
80
+ arduino.delete!
81
+ raspberries.delete!
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.1
4
+ version: 2.0.2
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-12-30 00:00:00.000000000 Z
13
+ date: 2015-03-17 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
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  version: '0'
59
59
  requirements: []
60
60
  rubyforge_project:
61
- rubygems_version: 2.4.4
61
+ rubygems_version: 2.4.5
62
62
  signing_key:
63
63
  specification_version: 4
64
64
  summary: Ruby client for AT&T M2X