flic 0.0.1 → 0.0.2
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/flic.rb +2 -1
- data/lib/flic/callbacks.rb +36 -0
- data/lib/flic/client.rb +52 -203
- data/lib/flic/client/connection_channel.rb +21 -0
- data/lib/flic/client/features.rb +15 -0
- data/lib/flic/client/features/connection_channel.rb +175 -0
- data/lib/flic/client/features/force_disconnect.rb +13 -0
- data/lib/flic/client/features/get_button_uuid.rb +43 -0
- data/lib/flic/client/features/get_info.rb +52 -0
- data/lib/flic/client/features/ping.rb +55 -0
- data/lib/flic/client/features/scan.rb +112 -0
- data/lib/flic/client/features/scan_wizard.rb +131 -0
- data/lib/flic/client/scan_wizard.rb +14 -0
- data/lib/flic/client/scanner.rb +12 -0
- data/lib/flic/client/server_info.rb +16 -0
- data/lib/flic/protocol.rb +1 -0
- data/lib/flic/protocol/commands/change_mode_parameters.rb +3 -2
- data/lib/flic/protocol/commands/create_connection_channel.rb +3 -2
- data/lib/flic/protocol/commands/remove_connection_channel.rb +1 -1
- data/lib/flic/{client → protocol}/connection.rb +20 -26
- data/lib/flic/protocol/events/button_click_or_hold.rb +1 -1
- data/lib/flic/protocol/events/button_single_or_double_click.rb +1 -1
- data/lib/flic/protocol/events/button_single_or_double_click_or_hold.rb +1 -1
- data/lib/flic/protocol/events/button_up_or_down.rb +1 -1
- data/lib/flic/protocol/events/connection_channel_removed.rb +2 -2
- data/lib/flic/protocol/events/connection_status_changed.rb +1 -1
- data/lib/flic/protocol/events/create_connection_channel_response.rb +1 -1
- data/lib/flic/protocol/events/get_info_response.rb +3 -2
- data/lib/flic/protocol/primitives.rb +1 -0
- data/lib/flic/protocol/primitives/disconnect_time.rb +29 -0
- data/lib/flic/simple_client.rb +116 -0
- data/lib/flic/version.rb +1 -1
- metadata +18 -6
- data/lib/flic/event_bus.rb +0 -81
- data/lib/flic/event_bus/driver.rb +0 -23
- data/lib/flic/event_bus/subscription.rb +0 -66
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'flic/event_bus'
|
2
|
-
|
3
|
-
require 'thread'
|
4
|
-
|
5
|
-
module Flic
|
6
|
-
class EventBus
|
7
|
-
class Driver < Thread
|
8
|
-
attr_reader :event_bus
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@event_bus = EventBus.new
|
12
|
-
|
13
|
-
super() do
|
14
|
-
begin
|
15
|
-
yield(event_bus)
|
16
|
-
ensure
|
17
|
-
event_bus.shutdown
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'flic/event_bus'
|
2
|
-
|
3
|
-
require 'thread'
|
4
|
-
|
5
|
-
module Flic
|
6
|
-
class EventBus
|
7
|
-
class Subscription
|
8
|
-
class SubscriptionDestroyed < Error
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@queue = Queue.new
|
13
|
-
@semaphore = Mutex.new
|
14
|
-
@is_destroyed = false
|
15
|
-
end
|
16
|
-
|
17
|
-
def listen
|
18
|
-
loop do
|
19
|
-
yield *next_event!
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def next_event_nonblock
|
24
|
-
next_event unless @queue.empty?
|
25
|
-
end
|
26
|
-
|
27
|
-
def next_event
|
28
|
-
@semaphore.synchronize do
|
29
|
-
unless destroyed?
|
30
|
-
control, event = @queue.pop
|
31
|
-
|
32
|
-
case control
|
33
|
-
when :event
|
34
|
-
event
|
35
|
-
when :destroy
|
36
|
-
@is_destroyed = true
|
37
|
-
|
38
|
-
nil
|
39
|
-
else
|
40
|
-
raise NotImplementedError
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def next_event!
|
47
|
-
event = next_event
|
48
|
-
raise SubscriptionDestroyed if destroyed?
|
49
|
-
event
|
50
|
-
end
|
51
|
-
|
52
|
-
def publish(*args)
|
53
|
-
raise SubscriptionDestroyed if destroyed?
|
54
|
-
@queue.push [:event, *args]
|
55
|
-
end
|
56
|
-
|
57
|
-
def destroyed?
|
58
|
-
@is_destroyed
|
59
|
-
end
|
60
|
-
|
61
|
-
def destroy
|
62
|
-
@queue.push [:destroy] unless destroyed?
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|