losant_mqtt 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/.travis.yml +3 -2
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/lib/losant_mqtt.rb +22 -0
- data/lib/losant_mqtt/device.rb +22 -0
- data/lib/losant_mqtt/device_connection.rb +22 -0
- data/lib/losant_mqtt/utils.rb +22 -0
- data/lib/losant_mqtt/version.rb +23 -1
- data/losant_mqtt.gemspec +7 -5
- metadata +15 -16
- data/.rbenv-version +0 -1
- data/testing.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c87e33d018c821a2029fba40648c908dfe95fd49
|
4
|
+
data.tar.gz: 04366bd1c0d8b4ae7589752b36964835ca726cc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad56b84c3baabbc3f26b3087f95147e3f0e593cc8118179237361a368816ae8211412622bcbeded2fe549164cc1a35acbb2a8818b1667d171125db9e15e5bd4d
|
7
|
+
data.tar.gz: 8aa800f635ad40098281e50198798c2392f1ef80e0a0bda9b0adffdca8debb0a942253b5de8d9ddcc9ebac35bf3febe882c6ee1d67397b1c7210a2c53694df7a
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.0
|
data/.travis.yml
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Losant Ruby MQTT Client
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/Losant/losant-mqtt-ruby.svg?branch=master)](https://travis-ci.org/Losant/losant-mqtt-ruby)
|
3
|
+
[![Build Status](https://travis-ci.org/Losant/losant-mqtt-ruby.svg?branch=master)](https://travis-ci.org/Losant/losant-mqtt-ruby) [![Gem Version](https://badge.fury.io/rb/losant_mqtt.svg)](https://badge.fury.io/rb/losant_mqtt)
|
4
4
|
|
5
5
|
The [Losant](https://www.losant.com) MQTT client provides a simple way for
|
6
6
|
custom things to communicate with the Losant platform over MQTT. You can
|
@@ -243,6 +243,6 @@ The proc that should be removed.
|
|
243
243
|
|
244
244
|
*****
|
245
245
|
|
246
|
-
Copyright (c)
|
246
|
+
Copyright (c) 2017 Losant IoT, Inc
|
247
247
|
|
248
248
|
<https://www.losant.com>
|
data/lib/losant_mqtt.rb
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2017 Losant IoT, Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
1
23
|
require "openssl"
|
2
24
|
require "date"
|
3
25
|
require "json"
|
data/lib/losant_mqtt/device.rb
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2017 Losant IoT, Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
1
23
|
module LosantMqtt
|
2
24
|
class Device
|
3
25
|
include Events::Emitter
|
@@ -1,3 +1,25 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2017 Losant IoT, Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
1
23
|
module LosantMqtt
|
2
24
|
CA_FILE_PATH = File.expand_path(File.join(File.dirname(__FILE__), "RootCA.crt"))
|
3
25
|
|
data/lib/losant_mqtt/utils.rb
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2017 Losant IoT, Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
1
23
|
module LosantMqtt
|
2
24
|
module Utils
|
3
25
|
|
data/lib/losant_mqtt/version.rb
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2017 Losant IoT, Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
1
23
|
module LosantMqtt
|
2
|
-
VERSION = "1.0.
|
24
|
+
VERSION = "1.0.1"
|
3
25
|
end
|
data/losant_mqtt.gemspec
CHANGED
@@ -15,10 +15,12 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.version = LosantMqtt::VERSION
|
16
16
|
gem.licenses = ["MIT"]
|
17
17
|
|
18
|
-
gem.
|
19
|
-
gem.add_runtime_dependency "mqtt", "~> 0.3.0"
|
20
|
-
gem.add_runtime_dependency "events", "~> 0.9.0"
|
18
|
+
gem.required_ruby_version = ">= 2.1"
|
21
19
|
|
22
|
-
gem.
|
23
|
-
gem.
|
20
|
+
gem.add_runtime_dependency "eventmachine", "~> 1.2"
|
21
|
+
gem.add_runtime_dependency "mqtt", "~> 0.4"
|
22
|
+
gem.add_runtime_dependency "events", "~> 0.9"
|
23
|
+
|
24
|
+
gem.add_development_dependency "rspec", "~> 3.5"
|
25
|
+
gem.add_development_dependency "rake", "~> 12"
|
24
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: losant_mqtt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Kuehl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -16,70 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.2
|
19
|
+
version: '1.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.2
|
26
|
+
version: '1.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mqtt
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: '0.4'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: '0.4'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: events
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.9
|
47
|
+
version: '0.9'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.9
|
54
|
+
version: '0.9'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
61
|
+
version: '3.5'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
68
|
+
version: '3.5'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '12'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '12'
|
83
83
|
description: Easily use the Losant IoT Platform through its MQTT Broker with Ruby
|
84
84
|
email:
|
85
85
|
- hello@losant.com
|
@@ -88,7 +88,7 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
|
-
- ".
|
91
|
+
- ".ruby-version"
|
92
92
|
- ".travis.yml"
|
93
93
|
- Gemfile
|
94
94
|
- LICENSE
|
@@ -102,7 +102,6 @@ files:
|
|
102
102
|
- lib/losant_mqtt/version.rb
|
103
103
|
- losant_mqtt.gemspec
|
104
104
|
- spec/device_spec.rb
|
105
|
-
- testing.rb
|
106
105
|
homepage: https://www.losant.com
|
107
106
|
licenses:
|
108
107
|
- MIT
|
@@ -115,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
114
|
requirements:
|
116
115
|
- - ">="
|
117
116
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
117
|
+
version: '2.1'
|
119
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
119
|
requirements:
|
121
120
|
- - ">="
|
@@ -123,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
122
|
version: '0'
|
124
123
|
requirements: []
|
125
124
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.6.
|
125
|
+
rubygems_version: 2.6.8
|
127
126
|
signing_key:
|
128
127
|
specification_version: 4
|
129
128
|
summary: An MQTT client for the Losant MQTT Broker
|
data/.rbenv-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.3.1
|
data/testing.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
$LOAD_PATH.push(File.expand_path("../lib", __FILE__));
|
2
|
-
require "losant_mqtt"
|
3
|
-
|
4
|
-
EventMachine.run do
|
5
|
-
device = LosantMqtt::Device.new(
|
6
|
-
key: "0bbdc673-77ea-423f-9241-976db4776f8b",
|
7
|
-
secret: "191bcd2c2512a770a880460f04f46ccf295c414a44b41742c9f3fe0746245fa8",
|
8
|
-
device_id: "57615f0ac035bd0100cb964b")
|
9
|
-
|
10
|
-
EventMachine::PeriodicTimer.new(10.0) do
|
11
|
-
temp = 10
|
12
|
-
device.send_state({ temperature: temp })
|
13
|
-
puts "#{device.device_id}: Sent state"
|
14
|
-
end
|
15
|
-
|
16
|
-
device.on(:command) do |d, command|
|
17
|
-
puts "#{d.device_id}: Command received."
|
18
|
-
puts command["name"]
|
19
|
-
puts command["payload"]
|
20
|
-
end
|
21
|
-
|
22
|
-
device.on(:connect) do |d|
|
23
|
-
puts "#{d.device_id}: Connected"
|
24
|
-
end
|
25
|
-
|
26
|
-
device.on(:reconnect) do |d|
|
27
|
-
puts "#{d.device_id}: Reconnected"
|
28
|
-
end
|
29
|
-
|
30
|
-
device.on(:close) do |d, reason|
|
31
|
-
puts "#{d.device_id}: Lost connection (#{reason})"
|
32
|
-
end
|
33
|
-
|
34
|
-
device.connect
|
35
|
-
end
|