module CMusBt::Device::Bluetooth

Public Class Methods

list() click to toggle source
# File lib/cmus-bt/device/bluetooth.rb, line 41
def list
  ret = []
  dir = objman.GetManagedObjects()

  dir.each { |path, hash|
    next if not hash.keys.include?("org.bluez.Device1")

    iface = hash["org.bluez.Device1"]

    next if iface["UUIDs"].none? {|id| /^0000110e-/ =~ id}
    next if not iface["Connected"]
    next if not iface["ServicesResolved"]

    ret << {:address => iface["Address"], :name => iface["Name"]}
  }

  return ret
end

Private Class Methods

objman() click to toggle source
# File lib/cmus-bt/device/bluetooth.rb, line 36
def objman
  return @objman ||= root["org.freedesktop.DBus.ObjectManager"]
end
root() click to toggle source
# File lib/cmus-bt/device/bluetooth.rb, line 26
def root
  if not @root
    @root = service["/"]
    @root.introspect
  end

  return @root
end
service() click to toggle source
# File lib/cmus-bt/device/bluetooth.rb, line 16
def service
  if not @service
    @service = DBus.system_bus.service("org.bluez")
    @service.introspect
  end

  return @service 
end