Module: Flic::Client::Features::GetButtonUuid

Included in:
Flic::Client
Defined in:
lib/flic/client/features/get_button_uuid.rb

Instance Method Summary collapse

Instance Method Details

#get_button_uuid(button_bluetooth_address, callback = Proc.new) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/flic/client/features/get_button_uuid.rb', line 16

def get_button_uuid(button_bluetooth_address, callback = Proc.new)
  command = Protocol::Commands::GetButtonUuid.new(bluetooth_address: button_bluetooth_address)

  @button_bluetooth_address_callbacks_semaphore.synchronize do
    @button_bluetooth_address_callbacks[command.bluetooth_address] << callback
  end

  send_command command
end

#initializeObject



9
10
11
12
13
14
# File 'lib/flic/client/features/get_button_uuid.rb', line 9

def initialize(*)
  @button_bluetooth_address_callbacks_semaphore = Mutex.new
  @button_bluetooth_address_callbacks = Hash.new { [] }

  super
end