Problem witho OTA GPRS

Using OTA functions with Waspmote
vinche84
Posts: 40
Joined: Mon Sep 26, 2016 9:59 am

Re: Problem witho OTA GPRS

Post by vinche84 » Thu Jan 12, 2017 11:41 am

What code are you uploading through OTA?
The same uploaded with IDE. I changed only version (17) and generate binary file
"REPROGRAMMING ERROR" is obtained when the program version is different from the program version of the last code upload by OTA. In this case, you are setting the version in 16 but the OTA version is 10 (by default).
Without perform OTA, when I turn off and turn on P&S Utils.checkNewProgram() in void setup() loop should returns "RESTARTING".. I obtain always "REPROGRAMMING ERROR"
Also answer = Utils.checkNewProgram(); should be done at the beginning of the code. Then you should include your setup parameters.
In void setup() in order I:
1) set program version by Utils.setProgramVersion(Version)
2) check program by Utils.checkNewProgram()
3) get program version by Utils.getProgramVersion() and print it
This code was ok with previous IDE/API

Thanks in advance,
Vincenzo

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

Re: Problem witho OTA GPRS

Post by libelium-dev » Thu Jan 12, 2017 12:07 pm

Hi,

The function Utils.checkNewProgram(); was modified in the last API. You get this because you change the value of EEPROM_PROG_VERSION to 16 with setProgramVersion function but EEPROM_PROG_VERSION_BACKUP is 10. EEPROM_PROG_VERSION_BACKUP value change when OTA is succesfully by the value you are set in the UPGRADE.TXT file.

Otherwise, It isn't no necessary change the version in the code that will be uploaded by OTA. You must change version in the UPGRADE.TXT

Please try with the example code without any modification.

Regards.

vinche84
Posts: 40
Joined: Mon Sep 26, 2016 9:59 am

Re: Problem witho OTA GPRS

Post by vinche84 » Thu Jan 12, 2017 12:31 pm

Just to understand:
Utils.setProgramVersion() modifies EEPROM_PROG_VERSION
Utils.checkNewProgram() reads EEPROM_PROG_VERSION_BACKUP
Utils.getProgramVersion() reads EEPROM_PROG_VERSION_BACKUP (I supposed, because I obtain always 10)

So Utils.setProgramVersion() is a useless function? or I can read EEPROM_PROG_VERSION with another specific function?

Thanks in advance,
Vincenzo

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

Re: Problem witho OTA GPRS

Post by libelium-dev » Thu Jan 12, 2017 2:17 pm

Hi,

Please take a look at the function checkNewProgram() in the Utils library. Surely you will understand it better seeing the function.

Utils.setProgramVersion() modifies EEPROM_PROG_VERSION

Utils.getProgramVersion() reads EEPROM_PROG_VERSION

but if you use Utils.checkNewProgram() and the version of EEPROM_PROG_VERSION and EEPROM_PROG_VERSION is different, this function does EEPROM_PROG_VERSION=EEPROM_PROG_VERSION

So, you can use setProgramVersion() and getProgramVersion() but you should do it after checkNewProgram().

Regards.

vinche84
Posts: 40
Joined: Mon Sep 26, 2016 9:59 am

Re: Problem witho OTA GPRS

Post by vinche84 » Thu Jan 12, 2017 2:26 pm

Ok!
Thank for your patient. :oops:
I will try what you suggest.
I hope this modification could have affect also on OTA success.

Regards,
Vincenzo

vinche84
Posts: 40
Joined: Mon Sep 26, 2016 9:59 am

Re: Problem witho OTA GPRS

Post by vinche84 » Fri Jan 13, 2017 8:24 am

Dear libelium-dev,
OTA successfully performed! :D :D :D
Thank you very much!!!

Regards,
Vincenzo

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

Re: Problem witho OTA GPRS

Post by libelium-dev » Fri Jan 13, 2017 8:31 am

Nice! Let us know if you have more doubts.

Regards

koki
Posts: 84
Joined: Sun Sep 18, 2016 11:02 am

Re: Problem witho OTA GPRS

Post by koki » Thu Jul 13, 2017 7:09 pm

Hi,
Please let me ask a few related questions here.

I don't understand some terms and conditions for OTA programming.

1. I don't understand what the Utils.checkNewProgram() function tries to do. Could you please explain the followings?
1.1 What are "program ID" and "current ID"?
1.2 Are these something to be defined by the programmer?

2. What are the minimum condition that requestOTA() determines to update the firmware?
2.1 Should the VERSION set in the UPGRADE.TXT file match with the program_version of the corresponding binary?
2.2 If you don't have to set program_version, as is explained some comments above, what is it for then?

My current problem is, even though I gave different versions to the new binary and UPGRADE.TXT file, requestOTA() issues the following message. (debug_mode is set to 1)

Code: Select all

E#
Beginning of setup() - PROG_AA
Program version: 1
...
End of setup()

Beginning of loop()
...
OTA file: PROG_BB
File path: /
Version: 2
Downloading OTA FILE
Same program version, no OTA required
...
I need some help on this.

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

Re: Problem witho OTA GPRS

Post by libelium-dev » Fri Jul 14, 2017 12:00 pm

Hi,

checkNewProgram() function checks if OTA has just been performed or there was an error. Program ID and Current ID are variables used in the library internally, you don have to set them. You could define the program version but it isn't necessary.

requestOTA() function checks if the version saved in the EEPROM is minus than the version set in the UPGRADE.TXT file and then it upload the new code.

Please try with the example code without modifications and copy here the output you get.

Regards

koki
Posts: 84
Joined: Sun Sep 18, 2016 11:02 am

Re: Problem witho OTA GPRS

Post by koki » Fri Jul 14, 2017 1:06 pm

Hi,

I ran the example code GPRS_24_OTA but with proper modifications of set_APN() and requestOTA(). And below is a copy of the USB monitor message for one loop.
Since I had found that GPRS_Pro.requestOTA() tried to look for .gprs/ directory for the files, I put the files (CLEARSD and UPGRADE.TXT) under the .gprs directory. As you can see below, file access seems to have succeeded with this configuration. The new program version is recognized as 2, as was expected, but it resulted in "Same program version, no OTA required", and so, no OTA happened.

By the way, I tried also version numbers of 255 and 128, and they were recognized as "Version: -1" and "Version: -128", respectively. They look like being treated as int8_t but not uint8_t. It might be a problem in just printing. I did not take time to look into the source code in detail though.

Code: Select all

E#
RESTARTING
Program version: 1
Debug mode 1
not_ready: 1
not_ready: 1
not_ready: 0
Send command with 2 answers: AT+CMEE=1
Answer received: 1
Send command with 2 answers: ATE0
Answer received: 1
Send command with 2 answers: AT+CSCLK=0
Answer received: 1
Send command with 2 answers: AT+CFUN=1
Answer received: 1
GPRS_Pro module ready...
Connecting to the network
Send command with 1 answer: AT+CREG?
Answer received: 1
Send command with 1 answer: AT+CREG?
Answer received: 1
Send command with 1 answer: AT+CREG?
Answer received: 1
Send command with 1 answer: AT+CREG?
Answer received: 1
Send command with 1 answer: AT+CREG?
Answer received: 1
Send command with 1 answer: AT+CREG?
Answer received: 1
Send command with 1 answer: AT+CREG?
Answer received: 1
Send command with 1 answer: AT+CREG?
Answer received: 1
Send command with 1 answer: AT+CREG?
Answer received: 1
Send command with 1 answer: AT+CREG?
Answer received: 1
Send command with 1 answer: AT+CREG?
Answer received: 1
Send command with 1 answer: AT+CREG?
Answer received: 1
Send command with 1 answer: AT+CREG?
Answer received: 1
Network status: 1
GPRS_Pro module connected to the network
Starting OTA process
Send command with 1 answer: AT+SAPBR=3,1,"CONTYPE","GPRS"
Answer received: 1
Send command with 1 answer: AT+SAPBR=3,1,"APN","internet"
Answer received: 1
Send command with 1 answer: AT+SAPBR=3,1,"USER",""
Answer received: 1
Send command with 1 answer: AT+SAPBR=3,1,"PWD",""
Answer received: 1
Send command with 1 answer: AT+SAPBR=5,1
Answer received: 1
Downloading OTA VER FILE
Send command with 1 answer: AT+CGREG?
Answer received: 1
Send command with 1 answer: AT+CGREG?
Answer received: 1
Send command with 1 answer: AT+CGREG?
Answer received: 1
GPRS status: 1
Send command with 2 answers: AT+SAPBR=1,1
Answer received: 1
Send command with 1 answer: AT+SAPBR=2,1
Answer received: 1
Send command with 2 answers: AT+FTPCID=1
Answer received: 1
Send command with 2 answers: AT+FTPMODE=1
Answer received: 1
Send command with 2 answers: AT+FTPTYPE="I"
Answer received: 1
Send command with 2 answers: AT+FTPSERV="ftp.domainname.com"
Answer received: 1
Send command with 2 answers: AT+FTPPORT=21
Answer received: 1
Send command with 2 answers: AT+FTPUN="username@domainname.com"
Answer received: 1
Send command with 2 answers: AT+FTPPW="xxxxxxxx"
Answer received: 1
Inside readDataFTP
FTP file: .gprs/UPGRADE.TXT
SD file:/UPGRADE.TXT
Send command with 2 answers: AT+FTPSTATE
Answer received: 1
Inside FTPsize
Send command with 2 answers: AT+FTPSTATE
Answer received: 1
Send command with 2 answers: AT+FTPGETNAME="/UPGRADE.TXT"
Answer received: 1
Send command with 2 answers: AT+FTPGETPATH=".gprs"
Answer received: 1
Send command with 2 answers: AT+FTPSIZE
Answer received: 1
Size in FTP: 42
Send command with 2 answers: AT+FTPGETNAME="/UPGRADE.TXT"
Answer received: 1
Send command with 2 answers: AT+FTPGETPATH=".gprs"
Answer received: 1
Send command with 2 answers: AT+FTPGET=1
Answer received: 1
Send command with 2 answers: AT+FTPGET=2,250
Answer received: 1
FTP data: 42
Bytes stored: 42/42
Send command with 2 answers: AT+FTPGET=2,250
Answer received: 1
FTP data: 0
Inside FTPsize
Send command with 2 answers: AT+FTPSTATE
Answer received: 1
Send command with 2 answers: AT+FTPGETNAME="/UPGRADE.TXT"
Answer received: 1
Send command with 2 answers: AT+FTPGETPATH=".gprs"
Answer received: 1
Send command with 2 answers: AT+FTPSIZE
Answer received: 1
Size in FTP: 42
Return from readDataFTP: 1
ftp_size: 42
ftp_retries: 3
file size SD: 42
Send command with 2 answers: AT+SAPBR=0,1
Answer received: 1
OTA file: CLEARSD
File path: /
Version: 2
Downloading OTA FILE
Same program version, no OTA required
RESTARTING
...
Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest