aws_iot_device 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/lib/aws_iot_device/version.rb +1 -1
- 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: d5d319369318dfce3364f26a2ecb9638f85cda61
|
4
|
+
data.tar.gz: 332550a1c43a40fe01877c98208bbae5217cb271
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 433a16a24def952385410c134aeebf84052e0c41182d0bf7f325595f935128d8f3049071e801f6dd47f5100e429554156215f768ed98267b31cb7431a45acfa2
|
7
|
+
data.tar.gz: 5d73ec2d5cb2b2cdd6e8809a47c19a1ab78e105e122d459182d0d91111abf2fb4333a68e44d85e880883cad3f8bbaac9f12b0d7001ff34e83e95b9004d16140a
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ The AWS IoT SDK for Ruby is a gems which enables to manage device registered as
|
|
15
15
|
- Update: add, change or remove the attribute value of the shadow
|
16
16
|
- Delete: clear all the attribute value of the shadow
|
17
17
|
|
18
|
-
The client communicates with the AWS IoT platform through the MQTT protocol. An adapter is provided to enable several implementations of the
|
18
|
+
The client communicates with the AWS IoT platform through the MQTT protocol. An adapter is provided to enable several implementations of the MQTT protocol and thus make the client independent form its back-end library implementation. In the current version, the default settings are using a client based on the ruby-mqtt gems. According to the shadow management, the operations are performed by sending message on the dedicated MQTT topics. The answer could be read on the corresponding MQTT topics, then some treatments could be processed thanks to a system of callback.
|
19
19
|
|
20
20
|
## Installation
|
21
21
|
The gem is still in a beta version. There is two way to install it, from the `gem` command or directly from sources.
|
@@ -140,7 +140,7 @@ manager.shadow_topic_unsubscribe(shadow_name, shadow_action)
|
|
140
140
|
```
|
141
141
|
|
142
142
|
### Shadow Action Manager
|
143
|
-
The ShadowActionManager enable to the client to perform the basic action on the shadow, and then execute a default callback with the answer. A callback defined be the user and send as parameter with the action may also been executed. For each operation a task counter is set to hold the number of task which are waiting answer. The ShadowActionManager class could be initialized with two mode, persistent and not-persistent. In the not-persistent case, the client will automatically unsubscribe to action topic when its corresponding task counter go back to 0. The persistent mode will keep the client subscribed to the topic even if the task counter is 0. In the current version, subscribe to a topic require 2 second to assert the subscription is completed.
|
143
|
+
The ShadowActionManager enable to the client to perform the basic action on the shadow, and then execute a default callback with the answer. A callback defined be the user and send as parameter with the action may also been executed. For each operation a task counter is set to hold the number of task which are waiting answer. The ShadowActionManager class could be initialized with two mode, persistent and not-persistent. In the not-persistent case, the client will automatically unsubscribe to action topic when its corresponding task counter go back to 0. The persistent mode will keep the client subscribed to the topic even if the task counter is 0. In the current version, subscribe to a topic require 2 second to assert the subscription is completed. The persistent mode enable to run that waiting timer only one for each operation(for the first one).
|
144
144
|
```ruby
|
145
145
|
### Directly create the ShadowManagerAction
|
146
146
|
### SUBSRIBE_MODE is a boolean, 'true' for persistent mode and (default)'false' for not-persistent
|
@@ -156,7 +156,7 @@ client.shadow_update("UPDATE_PAYLOAD", "YOUR_CALLBACK_OR_NIL", "TIME_OUT")
|
|
156
156
|
client.shadow_delete("YOUR_CALLBACK_OR_NIL", "TIME_OUT")
|
157
157
|
```
|
158
158
|
## The MQTT Manager
|
159
|
-
The
|
159
|
+
The MqttManager class supports the operations related with the MQTT protocol, it is a customized MQTT client. According to the MQTT protocol, the MqttManager may connect, publish, subscribe and disconnect. It holds a callbacks system which are triggered by MQTT events, for exemple when a message is received on a subscribed topic. Currently (September 2016), the callback system only support the message(PUBLISH) event, other events (CONNACK, SUBACK, ...) should be supported in the future version. It is possible to perform the previous AWS Iot operation through the MqttManager, by simply typing the desired topics in the publish request. The following example details how to sent a AWS Iot get request at the MQTT level.
|
160
160
|
```ruby
|
161
161
|
### There two way to initiate the object :
|
162
162
|
# 1) Send parameter when creating the object and connect
|
@@ -176,7 +176,7 @@ client.cert_file = "YOUR_CERT_FILE_PATH"
|
|
176
176
|
client.key_file = "YOUR_KEY_FILE_PATH"
|
177
177
|
client.ca_file = "YOUR_ROOT_CA_FILE_PATH"
|
178
178
|
|
179
|
-
### Then send a
|
179
|
+
### Then send a MQTT connect request
|
180
180
|
client.connect()
|
181
181
|
|
182
182
|
client.subscribe("THING_TOPIC_GET_ACCEPTED")
|
@@ -190,7 +190,7 @@ client.disconnect()
|
|
190
190
|
```
|
191
191
|
|
192
192
|
## MQTT Adapters modules
|
193
|
-
The previously detailed
|
193
|
+
The previously detailed MqttManager class is said to be based on a MQTT client, in this project the MQTT client is implemented as an adapters design pattern named the MqttAdapter. The adapter design pattern enables the client implementation to be independent from the back-end MQTT library. Thanks to this design pattern, the MqttAdapter can work over several implementations of the MQTT protocol. The default implementation used in the project is the [ruby-mqtt](https://github.com/njh/ruby-mqtt) module, where some new features have been added. The adapters defined the method that should be accessible to higher level classes (ex. MqttManager).
|
194
194
|
|
195
195
|
### Ruby MQTT Adapter
|
196
|
-
The [ruby-mqtt](https://github.com/njh/ruby-mqtt) gem provides a client which does the basic MQTT operation(connect, subscribe, publish ....) by reading the packets directly from the sockets. It adapts the method of the [ruby-mqtt](https://github.com/njh/ruby-mqtt) gem in order to match with the definition in the
|
196
|
+
The [ruby-mqtt](https://github.com/njh/ruby-mqtt) gem provides a client which does the basic MQTT operation(connect, subscribe, publish ....) by reading the packets directly from the sockets. It adapts the method of the [ruby-mqtt](https://github.com/njh/ruby-mqtt) gem in order to match with the definition in the MqttAdapter. Inspired by the [Paho](http://www.eclipse.org/paho/) library, a system of (infinite)loop in background is added to this class. This loop system enables a not blocking and automated message reading. Also, a callback system is enabled to make some treatment when message are received on a subscribed MQTT topic. If no specific callback is registered for the topic a default callback is executed.
|