mqtt-sn-ruby 0.0.16 → 0.0.17

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae49a1caf7d6b02dd65610dea876ed01b9db5d17
4
- data.tar.gz: 38b27aa6a3fb222c9a3a04255d20e6c9f9539ed5
3
+ metadata.gz: 36933af1cb091daf1589de7c56e0fd405aa9d498
4
+ data.tar.gz: acfaa8908bd286530b1d2d57ee755401c867820b
5
5
  SHA512:
6
- metadata.gz: 4101dfd846691f436618bc3674560505659287080cf23464d13e6fd49af50e9773ee62f1d8ed0bc6cfe413ac2dd69dd56f1df5bdee3023fdd0f39eb1463348e3
7
- data.tar.gz: 88e4fae98b1be7f2ee5219553ec8ac103e45b83ceda29e1a49bab28bfa6de9b3a87867cba08110bef62e2e7762b8a598657c66871ff5905a005fff21542a04d9
6
+ metadata.gz: 08b91c72b2b0819b9aae457eb7f9c97d38bb3e999b4b8f098191c62f07c69cd1bcbfdba9431d76b05636bac43a1b8702b5628ba5c35ca16702bcd0e3366649ca
7
+ data.tar.gz: a1d0cd9bd2b15a1fd88883dfb82c88cf33a4b2aa1dd1b34de350a225a63f4a774a314554db75e5013a86a37269b19089859f4a30231fbb15bbf77917b07e40b2
data/bin/mqtt-sn-pub.rb CHANGED
@@ -44,14 +44,19 @@ puts "MQTT-SN-PUB: #{options.to_json}"
44
44
  begin
45
45
  sn=MqttSN.new options
46
46
  sent=false
47
- while not sent
48
- sn.connect options[:id] do |s,m|
49
- if s==:ok
50
- sn.publish options[:topic]||"test/message/123", options[:msg]||"test_value", qos: options[:qos]
51
- puts "Sent ok."
52
- sent=true
53
- else
54
- sn.disconnect
47
+ if options[:qos]==-1
48
+ sn.publish options[:topic]||"XX", options[:msg]||"test_value", qos: options[:qos]
49
+ puts "Sent."
50
+ else
51
+ while not sent
52
+ sn.connect options[:id] do |s,m|
53
+ if s==:ok
54
+ sn.publish options[:topic]||"test/message/123", options[:msg]||"test_value", qos: options[:qos]
55
+ puts "Sent ok."
56
+ sent=true
57
+ else
58
+ sn.disconnect
59
+ end
55
60
  end
56
61
  end
57
62
  end
data/lib/mqtt-sn-ruby.rb CHANGED
@@ -290,9 +290,10 @@ class MqttSN
290
290
 
291
291
  def send type,hash={},&block
292
292
  #puts "" if @verbose
293
- if @state!=:connected and type!=:connect and type!=:will_topic and type!=:will_msg and type!=:searchgw
293
+ if @state!=:connected and type!=:connect and type!=:will_topic and type!=:will_msg and type!=:searchgw
294
294
  if type==:disconnect
295
295
  return #already disconnected.. nothing to do
296
+ elsif type==:publish and hash[:qos]==-1
296
297
  else
297
298
  note "Error: Cannot #{type} while unconnected, send :connect first!"
298
299
  return nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mqtt-sn-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Siitonen