@Override
    public void run() {
        while (true) {
            //check session
            if (!checkSession()) {
                log.error(TAG, "Session could not be established! Retrying in " + SLEEP_TIME + "ms.");
            } else {
                DataList<SensedDevice> devices = WifiThread.pullDevices();
                if (!devices.isEmpty()) {
                    Data data = connection.runTask(API.WIFI_SENSOR_UPDATE, devices, session);
                    if (!(data instanceof Success)) {
                        log.log(TAG, "Upload of data failed!");
                    } else {
                        log.log(TAG, "Successfully reported " + devices.size() + " devices.");
                    }
                }
            }
            // sleep
            try {
                Thread.sleep(SLEEP_TIME);
            } catch (InterruptedException e) {
                // todo do the correct thing here (which is... ?)
                log.error(TAG, "Interrupted!!!");
                e.printStackTrace();
                return;
            }
        }
    }