Advertisement
soloincc

ftp example

Dec 19th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.45 KB | None | 0 0
  1. /*
  2.  *  ------Waspmote GPRS_Pro Uploading & Downloading FIles Example--------
  3.  *
  4.  *  Explanation: This example shows how to upload and download files to a FTP
  5.  *  server
  6.  *
  7.  * Note: The input parameters for the functions 'uploadFIle' and 'downloadFile'
  8.  * should be filled properly with your correct accounts and servers
  9.  *
  10.  * Note2: The SD card should be inserted in the slot. The file to upload should be
  11.  * stored in the SD card
  12.  *
  13.  *  Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
  14.  *  http://www.libelium.com
  15.  *
  16.  *  This program is free software: you can redistribute it and/or modify
  17.  *  it under the terms of the GNU General Public License as published by
  18.  *  the Free Software Foundation, either version 2 of the License, or
  19.  *  (at your option) any later version.
  20.  *
  21.  *  This program is distributed in the hope that it will be useful,
  22.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  23.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24.  *  GNU General Public License for more details.
  25.  *
  26.  *  You should have received a copy of the GNU General Public License
  27.  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  28.  *
  29.  *  Version:                0.1
  30.  *  Design:                 David Gascón
  31.  *  Implementation:         Alejandro Gállego
  32.  */
  33.  
  34. void setup()
  35. {
  36.   USB.begin();
  37.   USB.println("USB port started...");
  38.  
  39.   // setup for GPRS_Pro serial port
  40.   GPRS_Pro.ON();
  41.   USB.println("GPRS_Pro module ready...");
  42.  
  43.   while(!GPRS_Pro.setPIN("6785"));
  44.   USB.println("GPRS Pro PIN set.");
  45.   // waiting while GPRS_Pro connects to the network
  46.   while(!GPRS_Pro.check());
  47.   USB.println("GPRS_Pro connected to the network");
  48.  
  49.   // configure SMS and Incoming Calls
  50.   //if(GPRS_Pro.setInfoIncomingCall()) USB.println("Info Incoming Call OK");
  51.   //if(GPRS_Pro.setInfoIncomingSMS()) USB.println("Info Incoming SMS OK");
  52.   //if(GPRS_Pro.setTextModeSMS()) USB.println("Text Mode SMS OK");
  53.  
  54.   if(GPRS_Pro.configureGPRS_HTTP_FTP(1)){
  55.       USB.println("Configuration OK");
  56.   }else{
  57.       USB.println("Configuration failed");
  58.   }
  59. }
  60.  
  61. void loop()
  62. {
  63.  
  64.   USB.println("Uploading file");
  65.   USB.println(GPRS_Pro.uploadFile("raw_data9.txt", "raw_data9.txt", "username", "password", "ip-address", "20",1),DEC);
  66.   USB.println("Downloading file");
  67.   USB.println(GPRS_Pro.downloadFile("copy_past.txt", "past.txt", "username", "password", "ip-address", "20",1),DEC);
  68.  
  69.   delay(5000);
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement