lib/ligo/device.rb in ligo-0.1.1 vs lib/ligo/device.rb in ligo-0.1.2
- old
+ new
@@ -180,11 +180,11 @@
# @return [true, false] true for success, false otherwise.
def start_accessory_mode
logger.debug 'start_accessory_mode'
sn = self.serial_number
- self.open_interface(0) do |handle|
+ self.open do |handle|
@handle = handle
send_accessory_id
send_start
@handle = nil
end
@@ -218,20 +218,25 @@
# Check if the current {Device} is in accessory mode
# @return [true, false] true if the {Device} is in accessory mode, false
# otherwise.
def accessory_mode?
- self.idVendor == GOOGLE_VID
+ (self.idVendor == GOOGLE_VID) && (GOOGLE_PIDS.include? self.idProduct)
end
# Check if the current {Device} supports AOAP
# @return [true, false] true if the {Ligo::Device} supports AOAP, false
# otherwise.
def aoap?
@aoap_version = self.get_protocol
- logger.info "#{self.inspect} supports AOAP version #{@aoap_version}."
- @aoap_version >= 1
+ aoap_supported = (@aoap_version >= 1)
+ if aoap_supported
+ logger.info "#{self.inspect} supports AOA Protocol version #{@aoap_version}."
+ else
+ logger.info "#{self.inspect} doesn't support AOA Protocol."
+ end
+ aoap_supported
end
# Check if the current {Device} is in UMS mode
# @return [true, false] true if the {Device} is in UMS mode, false otherwise
def uas?
@@ -264,9 +269,11 @@
version = res.unpack('S')[0]
end
(res.size == 2 && version >= 1 ) ? version : 0
+ rescue LIBUSB::ERROR_NOT_SUPPORTED, LIBUSB::ERROR_PIPE
+ 0
end
# Sends identifying string information to the device
#
# We assume here that the device has already been opened.