Sunday, 11 March 2018

J2ME FTP class for EHS6 and BGS5 modules

J2ME implementation of FTP class for EHS6 and BGS5 modules.



protected void startApp() throws MIDletStateChangeException {
        log = createLogger(FtpExampleApp.class, ILogger.DEBUG);   
        

    // Create ftp object with your GPRS settings, GPRS_APN, GPRS_USER, GPRS_PASS, GPRS_TIMEOUT
    FtpClient ftp = new FtpClient("internet","gprs_user","gprs_pass",45);
     ftp.setLogger(this.createLogger(FtpClient.class, ILogger.DEBUG));
        

    try {
       // make connection to you ftp server
        ftp.open("ftp.yourserver.nl", (short)21, "ftpuser", "ftppass");
           
      log.log(ILogger.DEBUG, "Uploading file to FTP...");
       // Upload file to ftp server
      ftp.putFile("upload.txt", "uploaded.txt", FtpClient.MODE_ASCII, false);
           
       ftp.changeDir("test");           
           
       log.log(ILogger.DEBUG, "Downloading file from FTP current /test directory ");
        // Download some other file from fto server to EHS6
        ftp.getFile("downloaded.txt", "log.txt", FtpClient.MODE_ASCII);
           
        ftp.close();
    } catch (FtpException e) {
            log.log(ILogger.ERROR, e.getMessage());
    } catch (IOException e) {
            log.log(ILogger.ERROR, e.getMessage());
    }
    destroyApp(true);
}

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I read your blog and find it very interesting. IoT (Internet of Things) SIM cards, also known as M2M (Machine-to-Machine) SIM cards or cellular IoT SIM cards, are specialized SIM cards designed for use in IoT devices. Unlike traditional SIM cards used in smartphones, IoT SIM cards are optimized for low-power, low-bandwidth IoT applications and typically offer features tailored to IoT deployments. If you're ready to take the next step in optimizing your iot sim cards, click this link to access our in-depth guide, packed with strategies, tools, and best practices.

    ReplyDelete