Reprograming Error and the code is not updated

Using OTA functions with Waspmote
DonMehdi
Posts: 34
Joined: Thu Jan 18, 2018 11:04 am
Company: S2f Network

Reprograming Error and the code is not updated

Post by DonMehdi » Fri May 04, 2018 9:58 am

Hi,
I have succefuly configured the mehslium ftp with the p&s but the program stays the same and i have a reprograming error.

Code: Select all

// include WiFi library
#include <WaspWIFI_PRO.h>


// choose socket (SELECT USER'S SOCKET)
///////////////////////////////////////
uint8_t socket = SOCKET0;
///////////////////////////////////////

// FTP server settings 
/////////////////////////////////
char server[] = "192.168.1.69";
char port[] = "21";
char user[] = "ota";
char password[] = "libelium";
/////////////////////////////////


// WiFi AP settings (CHANGE TO USER'S AP)
///////////////////////////////////////
char ESSID[] = "Capit";
char PASSW[] = "password";


// define variables
uint8_t error;
uint8_t status;
unsigned long previous;
int8_t answer;
char programID[10];

void setup()
{
  USB.ON();
  USB.println(F("Start program"));  
  USB.println(F("***************************************"));  
  USB.println(F("Once the module is set with one or more"));
  USB.println(F("AP settings, it attempts to join the AP"));
  USB.println(F("automatically once it is powered on"));    
  USB.println(F("Refer to example 'WIFI_PRO_01' to configure"));  
  USB.println(F("the WiFi module with proper settings"));
  USB.println(F("***************************************"));
  
  //////////////////////////////////////////////////
  // 1. Check if the program has been programmed ok
  //////////////////////////////////////////////////
  answer = Utils.checkNewProgram();   
 
  switch (answer)
  {
  case 0:  
    USB.print(F("REPROGRAMMING ERROR"));
    Utils.blinkRedLED(300, 3);
    break;   

  case 1:  
    USB.println(F("REPROGRAMMING OK"));
    Utils.blinkGreenLED(300, 3);
    break; 

  default: 
    USB.println(F("RESTARTING"));
    Utils.blinkGreenLED(500, 1);
  }      


  // show program ID 
  Utils.getProgramID(programID);
  USB.println(F("-------------------------------"));
  USB.print(F("Program id: "));
  USB.println(programID);

  // show program version number
  USB.print(F("Program version: "));
  USB.println(Utils.getProgramVersion(),DEC);
  USB.println(F("-------------------------------"));
  

  //////////////////////////////////////////////////
  // 2. User setup
  //////////////////////////////////////////////////

  // Put your setup code here, to run once:


   //////////////////////////////////////////////////
  // 1. Switch ON the WiFi module
  //////////////////////////////////////////////////
  error = WIFI_PRO.ON(socket);

  if (error == 0)
  {    
    USB.println(F("1. WiFi switched ON"));
  }
  else
  {
    USB.println(F("1. WiFi did not initialize correctly"));
  }


  //////////////////////////////////////////////////
  // 2. Reset to default values
  //////////////////////////////////////////////////
  error = WIFI_PRO.resetValues();

  if (error == 0)
  {    
    USB.println(F("2. WiFi reset to default"));
  }
  else
  {
    USB.println(F("2. WiFi reset to default ERROR"));
  }


  //////////////////////////////////////////////////
  // 3. Set ESSID
  //////////////////////////////////////////////////
  error = WIFI_PRO.setESSID(ESSID);

  if (error == 0)
  {    
    USB.println(F("3. WiFi set ESSID OK"));
  }
  else
  {
    USB.println(F("3. WiFi set ESSID ERROR"));
  }


  //////////////////////////////////////////////////
  // 4. Set password key (It takes a while to generate the key)
  // Authentication modes:
  //    OPEN: no security
  //    WEP64: WEP 64
  //    WEP128: WEP 128
  //    WPA: WPA-PSK with TKIP encryption
  //    WPA2: WPA2-PSK with TKIP or AES encryption
  //////////////////////////////////////////////////
  error = WIFI_PRO.setPassword(WPA2, PASSW);

  if (error == 0)
  {    
    USB.println(F("4. WiFi set AUTHKEY OK"));
  }
  else
  {
    USB.println(F("4. WiFi set AUTHKEY ERROR"));
  }


  //////////////////////////////////////////////////
  // 5. Software Reset 
  // Parameters take effect following either a 
  // hardware or software reset
  //////////////////////////////////////////////////
  error = WIFI_PRO.softReset();

  if (error == 0)
  {    
    USB.println(F("5. WiFi softReset OK"));
  }
  else
  {
    USB.println(F("5. WiFi softReset ERROR"));
  }


}


void loop()
{   
  //////////////////////////////////////////////////
  // 3. User loop program
  //////////////////////////////////////////////////

  // put your main code here, to run repeatedly:



  //////////////////////////////////////////////////
  // 4. OTA request
  //////////////////////////////////////////////////

  //////////////////////////////
  // 4.1. Switch ON
  //////////////////////////////
  error = WIFI_PRO.ON(socket);

  if (error == 0)
  {    
    USB.println(F("1. WiFi switched ON"));
  }
  else
  {
    USB.println(F("1. WiFi did not initialize correctly"));
  }


  //////////////////////////////
  // 4.2. Check if connected
  //////////////////////////////
  // get actual time
  previous = millis();

  // check connectivity
  status =  WIFI_PRO.isConnected();

  // Check if module is connected
  if (status == true)
  {    
    USB.print(F("2. WiFi is connected OK"));
    USB.print(F(" Time(ms):"));    
    USB.println(millis()-previous);
      

    USB.println(F("2.1. Connection Status:"));
    USB.println(F("-------------------------------"));
    USB.print(F("Rate (Mbps):"));
    USB.println(WIFI_PRO._rate);
    USB.print(F("Signal Level (%):"));
    USB.println(WIFI_PRO._level);
    USB.print(F("Link Quality(%):"));
    USB.println(WIFI_PRO._quality);
    USB.println(F("-------------------------------"));

    //////////////////////////////
    // 4.3. Request OTA
    //////////////////////////////    
    USB.println(F("2.2. Request OTA..."));
    error = WIFI_PRO.requestOTA(server, port, user, password);

    // If OTA fails, show the error code     
    WIFI_PRO.printErrorCode();
    Utils.blinkRedLED(300, 3);

  }
  else
  {
    USB.print(F("2. WiFi is connected ERROR")); 
    USB.print(F(" Time(ms):"));    
    USB.println(millis()-previous);
    Utils.blinkRedLED(100, 10);
  }


  //////////////////////////////////////////////////
  // 5. Switch OFF
  //////////////////////////////////////////////////  
  WIFI_PRO.OFF(socket);
  USB.println(F("3. WiFi switched OFF"));
  USB.println(F("Wait...\n\n"));
  delay(10000);


}
and the output:

H#
Start program
***************************************
Once the module is set with one or more
AP settings, it attempts to join the AP
automatically once it is powered on
Refer to example 'WIFI_PRO_01' to configure
the WiFi module with proper settings
***************************************
RESTARTING
-------------------------------
Program id: PROG003
Program version: 10
-------------------------------
1. WiFi switched ON
2. WiFi reset to default
3. WiFi set ESSID OK
4. WiFi set AUTHKEY OK
5. WiFi softReset OK
1. WiFi switched ON
2. WiFi is connected OK Time(ms):4492
2.1. Connection Status:
-------------------------------
Rate (Mbps):54
Signal Level (%):70
Link Quality(%):58
-------------------------------
2.2. Request OTA...
--------------------------------
[WIFI] FILE:PROG003
[WIFI] PATH:/
[WIFI] SIZE:9906
[WIFI] VERSION:12
--------------------------------
H#
[dbg] Enter OTA
[dbg] boot_start()
H#
[dbg] Enter OTA
[dbg] boot_start()
H#
[dbg] Enter OTA
[dbg] app_start()
Start program
***************************************
Once the module is set with one or more
AP settings, it attempts to join the AP
automatically once it is powered on
Refer to example 'WIFI_PRO_01' to configure
the WiFi module with proper settings
***************************************
REPROGRAMMING ERROR-------------------------------
Program id: PROG003
Program version: 10
-------------------------------
1. WiFi switched ON
2. WiFi reset to default
3. WiFi set ESSID OK
4. WiFi set AUTHKEY OK
5. WiFi softReset OK
1. WiFi switched ON
2. WiFi is connected OK Time(ms):2823
2.1. Connection Status:
-------------------------------
Rate (Mbps):54
Signal Level (%):70
Link Quality(%):58
-------------------------------
2.2. Request OTA...
--------------------------------
[WIFI] FILE:PROG003
[WIFI] PATH:/
[WIFI] SIZE:9906
[WIFI] VERSION:12
--------------------------------

DonMehdi
Posts: 34
Joined: Thu Jan 18, 2018 11:04 am
Company: S2f Network

Re: Reprograming Error and the code is not updated

Post by DonMehdi » Fri May 04, 2018 3:33 pm

Another thing is if we have two p&s and each one has a nodeId in the code, how can we perform an ota only for one device.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Reprograming Error and the code is not updated

Post by libelium-dev » Mon May 07, 2018 10:12 am

Hi,

Could you share with us the codes uploaded to the FTP served to try to replicate the issue here?

Please enable debug mode 1 in WaspWIFI_PRO.h file, upload the code to the node again and share with us the output of the code.

Code: Select all

#define DEBUG_WIFI_PRO 	1
viewtopic.php?f=51&t=22542

About second question, you must create the 2 user account in the FTP server. Or you can try to modify the library as is explained in this topic
viewtopic.php?f=56&t=23984&p=78579&hilit=UPGRADE#p78579

Regards

DonMehdi
Posts: 34
Joined: Thu Jan 18, 2018 11:04 am
Company: S2f Network

Re: Reprograming Error and the code is not updated

Post by DonMehdi » Wed May 16, 2018 10:42 am

For the first question, i found where the problem came from, it was the file that i was uploading in the ftp that wasnt in the right format. I havent exported it with the IDE functionnality (export as ota file).

For the second question, i'll try your solution and give you feedback if it is working as we want, thanks.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Reprograming Error and the code is not updated

Post by libelium-dev » Thu May 17, 2018 11:05 am

Hope you succeed in your development.

DonMehdi
Posts: 34
Joined: Thu Jan 18, 2018 11:04 am
Company: S2f Network

Re: Reprograming Error and the code is not updated

Post by DonMehdi » Thu May 17, 2018 4:39 pm

I followed the link you gave me, but i couldnt find the static char LE910_OTA_FILE[] = "UPGRADE.TXT"; in the WaspWIFI_PRO.h file, since i am using the wifi module. please guide me on the subject.

DonMehdi
Posts: 34
Joined: Thu Jan 18, 2018 11:04 am
Company: S2f Network

Re: Reprograming Error and the code is not updated

Post by DonMehdi » Thu May 17, 2018 5:58 pm

For any one having the same issue, the varibale for the upgrade file is in the ati_generator file under waspmote-pro-ide-v06.04\libraries\WIFI_PRO\utility.
I created two upgarde files for my two sensors, and defined a variable for the upgrade file in the library of each sensor.

Thank libelium-dev for your help.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Reprograming Error and the code is not updated

Post by libelium-dev » Fri May 18, 2018 10:38 am

Sorry, the link is for 4G but the procedure to modify the files is similar than with WiFi.

Regards

DonMehdi
Posts: 34
Joined: Thu Jan 18, 2018 11:04 am
Company: S2f Network

Re: Reprograming Error and the code is not updated

Post by DonMehdi » Wed May 23, 2018 7:44 pm

Thanks, i got it working. I hava a question about the ftp server, can we do SFTP to be more secure ?

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Reprograming Error and the code is not updated

Post by libelium-dev » Thu May 24, 2018 9:46 am

Hi,

You can use ftpSecureOpenSession() function instead of ftpOpenSession()function. iIt opens a secure FTP link to a secure FTP server.

Hope this helps.
Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest