private int connectFTP() {
    // create client

    try {
      ftp = new FileTransferClient();

      ftp.setRemoteHost(REMOTE_FTP_IP);
      ftp.setRemotePort(REMOTE_FTP_PORT);

      ftp.connect();

      if (ftp.isConnected()) {
        Log.d(DroneConsts.DroneLogTag, "FTP Connected");
      }

      if (ftp.exists("version.txt")) {
        Log.d(DroneConsts.DroneLogTag, "version.txt exists => right directory!");
      }
    } catch (Exception e) {
      Log.d(DroneConsts.DroneLogTag, "Error: FTP NOT Connected!");
      e.printStackTrace();
      return -1;
    }
    return 0;
  }
Пример #2
0
 public static void Upload(String src, int team) throws FTPException, IOException {
   FileTransferClient ftp = new FileTransferClient();
   ftp.setRemoteHost("10." + (team / 100) + "." + (team % 100) + ".2");
   ftp.connect();
   // (project)/PPC603gnu/projectname/Debug/projectname.out
   ftp.uploadFile(src, "/ni-rt/system/FRC_UserProgram.out");
   ftp.disconnect();
 }
  public String getFirmwareVersion() {
    if (true) return "2.1.18";
    connectFTP();

    String version = null;

    try {
      ftp.downloadFile(DL_PATH + DL_VERSIONFILE, DL_VERSIONFILE);

      FileInputStream fstream = new FileInputStream(DL_PATH + DL_VERSIONFILE);
      DataInputStream in = new DataInputStream(fstream);
      BufferedReader br = new BufferedReader(new InputStreamReader(in));

      version = br.readLine();
      Log.d(DroneConsts.DroneLogTag, version);

      in.close();

    } catch (Exception e) {
      Log.d(DroneConsts.DroneLogTag, "Something went wrong while reading the Drone Version");
      e.printStackTrace();
      return version;
    }
    disconnectFTP();
    return version;
  }
 private int disconnectFTP() {
   try {
     ftp.disconnect();
     Log.d(DroneConsts.DroneLogTag, "FTP Disconnected");
   } catch (Exception e) {
     e.printStackTrace();
     Log.d(DroneConsts.DroneLogTag, "FTP Disconnection Failed");
     return -1;
   }
   return 0;
 }