# Path: sendinel/logger.py
# LOG_MSG_FORMAT = '%(asctime)s %(levelname)s %(filename)s#%(lineno)d %(message)s'
# def log_request(viewfunc):
#     def do_log_request(*args, **kwargs):


import xmlrpclib
from sendinel.logger import logger
def get_discovered_devices(server_address):
    """
        Get a list of discovered bluetooth devices from the server
        
        @param  server_address:  FQDN or IP address of the remote host
        @type   server_address:  String
        
        @return:    Dictionary (MAC-Address -> Name)
    """
    
    conn = set_connection_to_bluetooth(server_address)
    return conn.Actions.getDiscoveredDevices()

def send_vcal(server_address, mac, data):
    """
        Send a ical/vcal file to a bluetooth device
    
        @param  serverAddress:  FQDN or IP address of the remote host
        @type   serverAddress:  String
        
        @param  mac:    MAC Address of the target bluetooth device
        @type   mac:    String
        
        @param  data:   plain text vcal data to be sent
        @type   data:   String
    """
    
    conn = set_connection_to_bluetooth(server_address)
    logger.info("Sending vCal via Bluetooth to: " + mac)
    result = conn.Actions.sendVCalFile(mac, data, "reminder.vcs")

# Path: sendinel/logger.py
# LOG_MSG_FORMAT = '%(asctime)s %(levelname)s %(filename)s#%(lineno)d %(message)s'
# def log_request(viewfunc):
#     def do_log_request(*args, **kwargs):


# Path: sendinel/backend/bluetooth.py
import xmlrpclib
from sendinel.logger import logger

def get_discovered_devices(server_address):
    """
        Get a list of discovered bluetooth devices from the server
        
        @param  server_address:  FQDN or IP address of the remote host
        @type   server_address:  String
        
        @return:    Dictionary (MAC-Address -> Name)
    """
    
    conn = set_connection_to_bluetooth(server_address)
    return conn.Actions.getDiscoveredDevices()

def send_vcal(server_address, mac, data):
    """
        Send a ical/vcal file to a bluetooth device
    
        @param  serverAddress:  FQDN or IP address of the remote host
        @type   serverAddress:  String
        
        @param  mac:    MAC Address of the target bluetooth device
        @type   mac:    String
        
        @param  data:   plain text vcal data to be sent
        @type   data:   String
    """
    
    conn = set_connection_to_bluetooth(server_address)
    logger.info("Sending vCal via Bluetooth to: " + mac)
    result = conn.Actions.sendVCalFile(mac, data, "reminder.vcs")

    logger.info("Result of Sending: " + str(result))