somfy_sdn 1.0.9 → 1.0.10
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/lib/sdn/mqtt_bridge.rb +16 -10
- data/lib/sdn/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57ade06be997d5f36fa76aa13c87aa00e26b1bfe07de7a7fd29b9015f249a1a3
|
4
|
+
data.tar.gz: '03462586cabf999666ac43e83036811b8a10df15515ea17d7bfd7b4d2e421e3a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '00080b23f47bd5c11c13406d818feec587c744b132cb1b1f4cbd57f3a64cd002c0747e4bccb575315e996b7ec7b92d736a5892116c31b277f85fcbf83fd36c6f'
|
7
|
+
data.tar.gz: '01700481ff1ed2966a00287c5c9f1193b600b56518ce36da8a06dae4768daa51fac0da4635993b9eb3daf6ea8a0f068f3e8fd7aee5bd9977e3350eb46aa58d6a'
|
data/lib/sdn/mqtt_bridge.rb
CHANGED
@@ -270,6 +270,7 @@ module SDN
|
|
270
270
|
@mutex.synchronize do
|
271
271
|
# got woken up early by another command getting queued; spin
|
272
272
|
if @response_pending
|
273
|
+
puts "another message queued, but we're still waiting"
|
273
274
|
while @response_pending
|
274
275
|
remaining_wait = @response_pending - Time.now.to_f
|
275
276
|
if remaining_wait < 0
|
@@ -282,17 +283,20 @@ module SDN
|
|
282
283
|
@prior_message = nil
|
283
284
|
end
|
284
285
|
else
|
286
|
+
puts "waiting #{remaining_wait} more..."
|
285
287
|
@cond.wait(@mutex, remaining_wait)
|
286
288
|
end
|
287
289
|
end
|
288
290
|
else
|
289
291
|
# minimum time between messages
|
292
|
+
puts "waiting between messages"
|
290
293
|
sleep 0.1
|
291
294
|
end
|
292
295
|
|
296
|
+
puts "looking for next message to write"
|
293
297
|
@queues.find { |q| message_and_retries = q.shift }
|
294
298
|
if message_and_retries
|
295
|
-
if message_and_retries.message.ack_requested || message_and_retries.class.name =~ /^SDN::Message::Get/
|
299
|
+
if message_and_retries.message.ack_requested || message_and_retries.message.class.name =~ /^SDN::Message::Get/
|
296
300
|
@response_pending = Time.now.to_f + WAIT_TIME
|
297
301
|
if message_and_retries.message.dest == BROADCAST_ADDRESS || SDN::Message::is_group_address?(message_and_retries.message.src) && message_and_retries.message.is_a?(SDN::Message::GetNodeAddr)
|
298
302
|
@broadcast_pending = Time.now.to_f + BROADCAST_WAIT
|
@@ -301,22 +305,24 @@ module SDN
|
|
301
305
|
end
|
302
306
|
|
303
307
|
# wait until there is a message
|
304
|
-
@
|
308
|
+
if @response_pending
|
309
|
+
message_and_retries.remaining_retries -= 1
|
310
|
+
@prior_message = message_and_retries
|
311
|
+
elsif message_and_retries
|
312
|
+
@prior_message = nil
|
313
|
+
else
|
314
|
+
@cond.wait(@mutex)
|
315
|
+
end
|
305
316
|
end
|
306
317
|
next unless message_and_retries
|
307
318
|
|
308
319
|
message = message_and_retries.message
|
309
320
|
puts "writing #{message.inspect}"
|
321
|
+
puts "(and waiting for response)" if @response_pending
|
310
322
|
serialized = message.serialize
|
311
323
|
@sdn.write(serialized)
|
312
324
|
@sdn.flush
|
313
325
|
puts "wrote #{serialized.unpack("C*").map { |b| '%02x' % b }.join(' ')}"
|
314
|
-
if @response_pending
|
315
|
-
message_and_retries.remaining_retries -= 1
|
316
|
-
@prior_message = message_and_retries
|
317
|
-
else
|
318
|
-
@prior_message = nil
|
319
|
-
end
|
320
326
|
end
|
321
327
|
rescue => e
|
322
328
|
puts "failure writing: #{e}"
|
@@ -416,9 +422,9 @@ module SDN
|
|
416
422
|
nil
|
417
423
|
end
|
418
424
|
if message
|
419
|
-
message.ack_requested = true if
|
425
|
+
message.ack_requested = true if message.class.name !~ /^SDN::Message::Get/
|
420
426
|
@mutex.synchronize do
|
421
|
-
@queues[0].push(MessageAndRetries.new(message,
|
427
|
+
@queues[0].push(MessageAndRetries.new(message, 5, 0))
|
422
428
|
@queues[1].push(MessageAndRetries.new(follow_up, 5, 1)) unless @queues[1].any? { |mr| mr.message == follow_up }
|
423
429
|
@cond.signal
|
424
430
|
end
|
data/lib/sdn/version.rb
CHANGED