def bt_ctrl_ispowered():
    # this method will return available bluetooth devices as a list for the web template output
    import bluew
    #return len(bluew.controllers())
    bt_ctrl_powered = False

    for dev in bluew.controllers():
        if dev.Powered == True:
            bt_ctrl_powered = True

    return bt_ctrl_powered

def bt_getDevices():
    import bluew
    #return len(bluew.devices())
    if bt_ctrl_ispowered() == True:
        retdevs = bluew.devices()
    else:
        retdevs = []    

    return retdevs

def bt_getControllers():
    import bluew
    retctrl = bluew.controllers()
    return retctrl

