Class: Cassia::ResponseHandlers::DiscoverDescriptorOfChar

Inherits:
Object
  • Object
show all
Defined in:
lib/cassia/response_handlers/discover_descriptor_of_char.rb

Instance Method Summary collapse

Constructor Details

#initialize(access_controller, router:, device_mac:, char_uuid:) ⇒ DiscoverDescriptorOfChar

Returns a new instance of DiscoverDescriptorOfChar.



4
5
6
7
8
9
# File 'lib/cassia/response_handlers/discover_descriptor_of_char.rb', line 4

def initialize(access_controller, router: , device_mac: , char_uuid: )
  @access_controller = access_controller
  @router = router
  @device_mac = device_mac
  @char_uuid = char_uuid
end

Instance Method Details

#handle(response) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/cassia/response_handlers/discover_descriptor_of_char.rb', line 11

def handle(response)
  device = @router.connected_devices.detect {|device| device.mac == @device_mac}
  char = device.characteristics.detect {|char| char.uuid == @char_uuid}
  if char
    char.descriptors = response.body
  else
    @access_controller.error = "Desciptors Empty. Characteristic Not Found."
  end
  !(response.body.empty?)
end