Beispiel #1
0
def get_bluetooth_devices(request):
    '''
    Help to asynchronically show all available bluetooth devices
    This method is used by bluetooth.js
    '''
    response_dict = {}
    devices_list = []    
    
    try:
        devices = bluetooth.get_discovered_devices(request.META["REMOTE_ADDR"])
        for device in devices.items():
            device_dict = {}
            device_dict["name"] = device[1]
            device_dict["mac"] = device[0]
            devices_list.append(device_dict)
        response_dict["devices"] = devices_list
        
        logger.debug("Got Bluetooth Devices: %s"% str(devices_list))
        
        return HttpResponse(content = simplejson.dumps(response_dict),
                            content_type = "application/json")
    except Exception, e:
        logger.error("get_bluetooth_devices from %s failed: %s" %
                        (request.META["REMOTE_ADDR"], str(e)))
        return HttpResponse(status = 500)
Beispiel #2
0
    def get_data_for_bluetooth(self):
        """
        Prepare OutputData for voice.
        Generate the message for a Notification.
        Return BluetoothOutputData for sending.

        """
        logger.info("starting get_data_for_bluetooth() in Notification")
        
        data = BluetoothOutputData()
        data.bluetooth_mac_address = self.bluetooth_mac_address
        data.server_address = self.bluetooth_server_address
        
        logger.info("Sending to Bluetooth Mac Address " + data.bluetooth_mac_address +
                    " and Bluetooth Server " + data.server_address)
        
        try:
            self.hospital
        except Hospital.DoesNotExist:
            self.hospital = Hospital.get_current_hospital()
        
        content = self.reminder_text()

        uid = vcal.get_uid()
        data.data = vcal.create_vcal_string(self.date, 
                                            self.hospital, 
                                            content,
                                            uid)
                                            
        logger.info("Created vCal with uid %s" % str(uid))
        logger.debug("Created vCal: " + data.data)
        
        return data