Thanks, I have modified the code as follows and tested it:
Still no update but I got a bit further, now the debug serial output shows a message "sleep disable" when the transfer starts and this is like it does when run from the browser too.
I will start by downloading a more recent version in any case.
PS: I do have the C++ source code for the WebUpdater in the IoT device, only I am not a C++ coder so I cannot make much out of it. DS
Code:
function TConfigCommHandler.UploadFirmware(FileName: string; URL: string): boolean;
var
HTTP: TIdHTTP;
Src: TIdMultipartFormDataStream;
begin
Result := false;
if not FileExists(FileName) then exit;
HTTP := TIdHTTP.Create;
try
Src := TIdMultipartFormDataStream.Create;
try
Src.AddFile('update', FileName);
try
HTTP.Request.Username := FUserName;
HTTP.Request.Password := FPassword;
HTTP.AllowCookies := true; // * Added to try make the server accept update
HTTP.Get(URL); // * Added to read back form to simulate the action of a web browser
HTTP.Post(URL, Src); //Send the update file
HTTP.Get(URL); // * Added to retrieve the response
Result := true;
except
on E: Exception do
FLastError := 'Exception: ' + E.Message;
end;
finally
Src.Free;;
end;
finally
HTTP.Free;
end;
end;
Quote:I suggest you run a packet sniffer (such as Wireshark) on your client machine and look at the actual HTTP traffic that a web browser generates vs what TIdHTTP generates when communicating with your IoT device. There is obviously going to be a difference between the two, but you are not going to see that just looking at code.I have not used Wireshark to do any analysis. Many years ago I installed it but I did not really understand how to use it. There simply was too much stuff being shown. Is there a way to set it up to ONLY show traffic to and from a specific IP address?
I will start by downloading a more recent version in any case.
PS: I do have the C++ source code for the WebUpdater in the IoT device, only I am not a C++ coder so I cannot make much out of it. DS