Beispiel #1
0
def handle_paired(dongle, remote):
    logger.info("Paired with %s on %s" % (dongle, remote))
    
    record = RemoteBluetoothDevicePairing()
    record.dongle = UploaderBluetoothDongle.objects.get(address=dongle)
    record.setRemoteDevice(remote)
    record.state = RemoteBluetoothDevicePairing.STATES["Passed"]
    record.save()
    found_action(remote, dongle=dongle, record=record)
def handle_paired(dongle, remote):
    logger.info("Paired with %s on %s" % (dongle, remote))

    record = RemoteBluetoothDevicePairing()
    record.dongle = UploaderBluetoothDongle.objects.get(address=dongle)
    record.setRemoteDevice(remote)
    record.state = RemoteBluetoothDevicePairing.STATES["Passed"]
    record.save()
    found_action(remote, dongle=dongle, record=record)
Beispiel #3
0
def handle_addrecord(remote_, dongle):
    from openproximity.rpc.server import OpenProximityService
    address = remote_['address']
    name = smart_unicode(remote_['name']) if remote_['name'] else None

    logger.info("handle_addrecord %s" % address)
    remote=RemoteDevice.getRemoteDevice(
        address=address, 
        name=name, 
        devclass=remote_['devclass']
    )
    record = RemoteBluetoothDeviceFoundRecord()
    record.action = signals.FOUND_DEVICE
    record.dongle = dongle
    record.remote = remote
    record.remote.save() # update last seen
    record.setRSSI(remote_['rssi'])
    
    if not isinstance(dongle, RemoteScannerBluetoothDongle):
        if name is not None and record.remote.name!=name:
            record.remote.name = name
            record.remote.save()
        if remote_['devclass'] != -1 and \
                    record.remote.devclass!=remote_['devclass']:
            record.remote.devclass = remote_['devclass']
            record.remote.save()

    logger.debug(record)
    logger.debug(record.remote)

    record.save() # this will set the time field to now
    
    logl = LogLine()
    logl.content="Found: %s %s %s" % (
        record.remote.address, 
        record.remote.name,
        record.getRSSI())
    logl.save()
    
    if not OpenProximityService.isPending(address):
        return found_action(address, record, dongle=dongle)

    return True
Beispiel #4
0
def handle_addrecord(services, remote_, dongle, pending):
    address = remote_['address']
    name = smart_unicode(remote_['name']) if remote_['name'] else None

    logger.info("handle_addrecord %s" % address)
    remote=RemoteDevice.getRemoteDevice(
                    address=address, 
					name=name, 
					devclass=remote_['devclass']
            )
    record = RemoteBluetoothDeviceFoundRecord()
    record.action = signals.FOUND_DEVICE
    record.dongle = dongle
    record.remote = remote
    record.remote.save() # update last seen
    record.setRSSI(remote_['rssi'])
    
    if not isinstance(dongle, RemoteScannerBluetoothDongle):
        if name is not None and record.remote.name!=name:
            record.remote.name = name
            record.remote.save()
        if remote_['devclass'] != -1 and \
                    record.remote.devclass!=remote_['devclass']:
            record.remote.devclass = remote_['devclass']
            record.remote.save()

    logger.debug(record)
    logger.debug(record.remote)

    record.save() # this will set the time field to now
    
    logl = LogLine()
    logl.content="Found: %s %s %s" % (
	record.remote.address, 
	record.remote.name,
	record.getRSSI())
    logl.save()
    
    if address not in pending:
        return found_action(services, address, record, pending, dongle=dongle)

    return True