Page 1 of 2

Manual force firmware update on stretch 2.0

Posted: Mon Oct 07, 2013 6:55 pm
by Phoenix
*** USE THIS INFO AT YOUR OWN RISK!, IT'S FOR EDUCATIONAL AND LEARNING PURPOSES ***

Hi all,

I did get some mail about that my program PWScli (Stretch 2.0 commandline interface) did not work anymore after stretch firmware 1.0.46 (tested on 1.0.41)!
download PWScli: http://www.domoticaforum.eu/viewtopic.p ... 46&p=63305

Stretch v1.0.41 info screen:
stretch_info_1.0.41.png
stretch_info_1.0.41.png (8.62 KiB) Viewed 25730 times
Ps. to execute the scripts in this topic you need AUTOIT3: http://www.autoitscript.com/site/autoit/

So, with the new 2.0.x firmware plugwise did make some changes, okey knowing that...i still had the old 1.0.41, but downloading the "bleeding edge" PLUGWISE DESKTOP v1.6.7: https://securedownloads.plugwise.com/to ... _1.6.7.exe or the ANDROID APP v1.6.4, I CAN NOT UPDATE THE FIRMWARE ON THE STRETCH!

Ps. as this is written...you can only download v1.6.4 from the site : http://www.plugwise.com/nl/idplugtype-f/node/913#
bleeding_edge.png
bleeding_edge.png (13.22 KiB) Viewed 25751 times
https://securedownloads.plugwise.com/to ... _1.6.4.exe

So, i called plugwise why i cannot update and what is the problem, they say that the new firmware is still some buggy...so thay haven't released it the public yet...only to some "test" users!

But hey....i cannot wait ;-)

So if the apps and desktop software would not update my stretch 1.0.41 to 2.0.14 i had to do it my own!

ps. all firmwares can be downloaded here: http://phoenixinteractive.mine.nu/websi ... f=27&t=129 but there is no possibility to upload them to the stretch 2.0 and patch Linux trough SSH at the moment!

Okey, here are the steps i took:

1) HOW DOES IT WORK?
First is to look (again) how the "check for updates" button in the APPS work..., so i dismantled the DESKTOP APP (v1.6.6), as described here: http://phoenixinteractive.mine.nu/websi ... ?f=26&t=57, and this piece of code had my attention:

Code: Select all

		public function downloadFirmware(param1:Host = null) : void
		{
			if(param1 == null)
			{
				param1 = this.smile;
			}
			if(!param1.connected)
			{
				trace("SmileModel downloadFirmware NO HOST CONNECTION");
				return;
			}
			var _loc_4:getString = resourceManager.getString("resources", "Downloading_firmware_update_for_the_Smile...");
			this.activityText = _loc_4;
			this.errorText = _loc_4;
			this.plugwiseService.headers = {AUTHORIZATION:param1.basicAuthorizationString(), x-connection-override:"close"};
			this.plugwiseService.url = param1.hostURL(param1.port, "update/firmware");
			this.plugwiseService.resultFormat = "e4x";
			this.plugwiseService.contentType = "application/xml";
			this.plugwiseService.method = "POST";
			this.plugwiseService.requestTimeout = 0;
			var _loc_2:XML = new XML("<upgrade>\r\n\t\t\t\t\t\t\t\t\t\t<state>downloading</state>\r\n\t\t\t\t\t\t\t\t\t</upgrade>");
			var _loc_3:AsyncToken = sendHttpService(this.plugwiseService, _loc_2);
			_loc_3.action = "downloadFirmware";
		}

		public function installFirmware(param1:Host = null) : void
		{
			if(param1 == null)
			{
				param1 = this.smile;
			}
			if(!param1.connected)
			{
				trace("SmileModel installFirmware NO HOST CONNECTION");
				return;
			}
			var _loc_4:getString = resourceManager.getString("resources", "Installing_firmware_update_for_the_Smile...");
			this.activityText = _loc_4;
			this.errorText = _loc_4;
			this.plugwiseService.headers = {AUTHORIZATION:param1.basicAuthorizationString(), x-connection-override:"close"};
			this.plugwiseService.url = param1.hostURL(param1.port, "update/firmware");
			this.plugwiseService.resultFormat = "e4x";
			this.plugwiseService.contentType = "application/xml";
			this.plugwiseService.method = "POST";
			this.plugwiseService.requestTimeout = 0;
			var _loc_2:XML = new XML("<upgrade>\r\n\t\t\t\t\t\t\t\t\t\t<state>installing</state>\r\n\t\t\t\t\t\t\t\t\t</upgrade>");
			var _loc_3:AsyncToken = sendHttpService(this.plugwiseService, _loc_2);
			_loc_3.action = "installFirmware";
		}
2) Okey, let's check the page/XML output of the stretch on http://192.168.x.x/update/firmware, the result is:
stretch20_firmware_published.png
stretch20_firmware_published.png (16.91 KiB) Viewed 25730 times
Okey, here is says there is a new one available!, still don't get it why i could not download it! :shock:

3) So, it seems we have to do a POST command on http://192.168.x.x/update/firmware AND PUT THE "STATE" in "DOWNLOADING"
Taking this "example" script in Autoit3, wich i wrote for the smile: http://phoenixinteractive.mine.nu/websi ... ?f=26&t=58, wich i altered a little bit so it looks like this:

Autoit3 script to let the Stretch 2.0 download the new firmware that is anounced in: http://192.168.x.x/update/firmware

Code: Select all

; Stretch 2.0 setup
Global $StretchIp = "192.168.1.101" ;The IP adres of the Stretch 2.0, like: 192.168.1.X
Global $StretchId = "abcdfghj" ;The 8 letters of the Stretch 2.0 ID

; Kernel
Global $PostAdres = "http://" & $StretchIp & "/update/firmware"

Global $PostGegevens = "<upgrade>\r\n\t\t\t\t\t\t\t\t\t\t<state>downloading</state>\r\n\t\t\t\t\t\t\t\t\t</upgrade>"

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", $PostAdres, False)
$oHTTP.SetRequestHeader("Connection", "Close")
$oHTTP.SetRequestHeader("Content-Type", "application/xml")
$oHTTP.SetRequestHeader("Host", $StretchIp)
$oHTTP.SetRequestHeader("Authorization", "Basic " & _Base64Encode("stretch:" & $StretchId))
$oHTTP.Send(Linux2WinString($PostGegevens))
Global $PostResponse = $oHTTP.ResponseText

If $oHTTP.Status <> "200" Then
    MsgBox(64, "Error", $PostResponse)
Else
    MsgBox(64, "Done!", $PostResponse)
EndIf
Exit

Func _Base64Encode($sData)
    Local $oXml = ObjCreate("Msxml2.DOMDocument")
    If Not IsObj($oXml) Then
        SetError(1, 1, 0)
    EndIf

    Local $oElement = $oXml.createElement("b64")
    If Not IsObj($oElement) Then
        SetError(2, 2, 0)
    EndIf

    $oElement.dataType = "bin.base64"
    $oElement.nodeTypedValue = Binary($sData)
    Local $sReturn = $oElement.Text

    If StringLen($sReturn) = 0 Then
        SetError(3, 3, 0)
    EndIf

    Return $sReturn
EndFunc

Func Linux2WinString($data)
$data = StringReplace($data, "\r", @CR)   ; \r carriage return
$data = StringReplace($data, "\n", @CRLF) ; \n new line
$data = StringReplace($data, "\t", @TAB)  ; \t horizontal tab
Return $data
EndFunc
4) The script will output OK if all went fine:
stretch20_firmware_script_output.png
stretch20_firmware_script_output.png (10.95 KiB) Viewed 25751 times
5) Okey, now the stretch is downloading the newest firmware that is anounced, just give the stretch 1 minute and look back in http://192.168.x.x/update/firmware
The result when the new firmware is downloaded on the stretch:
stretch20_firmware_downloaded.png
stretch20_firmware_downloaded.png (16.98 KiB) Viewed 25751 times
6) now only one step remains, that is installing the new firmware, so looking this up in the APP the string should be "installing", so we use this code to POST it to the stretch:

Autoit3 script to let the Stretch 2.0 install the new firmware that is anounced in: http://192.168.x.x/update/firmware

Code: Select all

; Stretch 2.0 setup
Global $StretchIp = "192.168.1.101" ;The IP adres of the Stretch 2.0, like: 192.168.1.X
Global $StretchId = "abcdfghj" ;The 8 letters of the Stretch 2.0 ID

; Kernel
Global $PostAdres = "http://" & $StretchIp & "/update/firmware"

Global $PostGegevens = "<upgrade>\r\n\t\t\t\t\t\t\t\t\t\t<state>installing</state>\r\n\t\t\t\t\t\t\t\t\t</upgrade>"

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", $PostAdres, False)
$oHTTP.SetRequestHeader("Connection", "Close")
$oHTTP.SetRequestHeader("Content-Type", "application/xml")
$oHTTP.SetRequestHeader("Host", $StretchIp)
$oHTTP.SetRequestHeader("Authorization", "Basic " & _Base64Encode("stretch:" & $StretchId))
$oHTTP.Send(Linux2WinString($PostGegevens))
Global $PostResponse = $oHTTP.ResponseText

If $oHTTP.Status <> "200" Then
    MsgBox(64, "Error", $PostResponse)
Else
    MsgBox(64, "Done!", $PostResponse)
EndIf
Exit

Func _Base64Encode($sData)
    Local $oXml = ObjCreate("Msxml2.DOMDocument")
    If Not IsObj($oXml) Then
        SetError(1, 1, 0)
    EndIf

    Local $oElement = $oXml.createElement("b64")
    If Not IsObj($oElement) Then
        SetError(2, 2, 0)
    EndIf

    $oElement.dataType = "bin.base64"
    $oElement.nodeTypedValue = Binary($sData)
    Local $sReturn = $oElement.Text

    If StringLen($sReturn) = 0 Then
        SetError(3, 3, 0)
    EndIf

    Return $sReturn
EndFunc

Func Linux2WinString($data)
$data = StringReplace($data, "\r", @CR)   ; \r carriage return
$data = StringReplace($data, "\n", @CRLF) ; \n new line
$data = StringReplace($data, "\t", @TAB)  ; \t horizontal tab
Return $data
EndFunc
7) Also this time the script will report OK if all went fine:
stretch20_firmware_script_output.png
stretch20_firmware_script_output.png (10.95 KiB) Viewed 25751 times
*** NOW WAIT CA. 5 MINUTES, THE FIRMWARE IS INSTALLING AND THE STRETCH WILL REBOOT ***
*** DO NOT TURN THE STRETCH OFF, OR DISCONNECT FROM POWER DURING THIS PROCESS ***


Tadaaa, this is how the new Stretch 2.0 firmware looks, now i can get further with PWScli! :D :D
firmware_v2.0.14.png
firmware_v2.0.14.png (70.76 KiB) Viewed 25751 times
Enjoy!

Re: Manual update firmware on stretch 2.0

Posted: Mon Oct 07, 2013 7:05 pm
by RdP
I could update my Stretch using the 'normal' procedure, because I'm in the beta tester list :)

So I can't wait till you find out how to interface with the new firmware, because it looks like a lot has changed..... :(

Good luck and let me know if I need to test it....

/Rien

Re: Manual update firmware on stretch 2.0

Posted: Tue Oct 08, 2013 12:11 am
by Phoenix
RdP wrote:So I can't wait till you find out how to interface with the new firmware, because it looks like a lot has changed..... :(
/Rien
I love wireshark! :lol: :lol: :lol:
Plugwise_switch_circle_firmware_2.0.x_wireshark.png
Plugwise_switch_circle_firmware_2.0.x_wireshark.png (13.28 KiB) Viewed 25725 times
See here: http://www.domoticaforum.eu/viewtopic.php?f=39&t=9007

Re: Manual force firmware update on stretch 2.0

Posted: Sat Oct 12, 2013 5:06 pm
by Akatar
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <update>
- <firmware>
- <current>
<version>1.0.46</version>
</current>
- <upgrade>
<state>no_upgrade</state>
</upgrade>
</firmware>
</update>

no update for me?

Re: Manual force firmware update on stretch 2.0

Posted: Sat Oct 12, 2013 5:11 pm
by RdP
And you better hurry up, because the Plugwise Plugin for Homeseer is nearly ready to be tested with 2 Stretch devices :D :D

Re: Manual force firmware update on stretch 2.0

Posted: Sat Oct 12, 2013 5:22 pm
by Akatar
but without an update..... someone trade 2 stretchen with 1.64 for 2.xxxx :D

Re: Manual force firmware update on stretch 2.0

Posted: Sun Oct 13, 2013 2:30 pm
by Akatar
RdP wrote:And you better hurry up, because the Plugwise Plugin for Homeseer is nearly ready to be tested with 2 Stretch devices :D :D
i will call plugwise tomorow to add my 2 stretches to their beta program

Re: Manual force firmware update on stretch 2.0

Posted: Sun Oct 13, 2013 2:53 pm
by RdP
Good idea

For the Smile P1 is currently also a beta 2.x, may be you can ask for that also...

Let me know when it succeeds.

Gr,
Rien

Re: Manual force firmware update on stretch 2.0

Posted: Mon Oct 14, 2013 4:10 pm
by Akatar
so i called plugwise today for the beta program
i have to mail....

Re: Manual force firmware update on stretch 2.0

Posted: Mon Oct 14, 2013 5:16 pm
by Akatar
that went fast
updated both, and both are not working at the moment. normal leds are on, lan is flashing but can't connect

<?xml version="1.0" encoding="UTF-8" ?>
<system />

and thats it
to be continued

<?xml version="1.0" encoding="UTF-8"?>
-<system>-<gateway><product>stretch</product><hostname>stretch002d35</hostname><firmware>2.0.16</firmware><upgrade/></gateway><wlan0/>-<eth0><mac>78:25:44:00:2D:35</mac><ip>192.168.1.20</ip><bcast>192.168.1.255</bcast><mask>255.255.255.0</mask><proto>dhcp</proto><gateway>192.168.1.1</gateway></eth0><time>2013-10-14T17:23:02.694+02:00</time>-<timezone>
<![CDATA[Europe/Amsterdam]]>
</timezone></system>

Re: Manual force firmware update on stretch 2.0

Posted: Mon Oct 14, 2013 6:12 pm
by RdP
How do you connect? Using an app or webinterface.

In case you didn't try, download the latest app for Windows, iOS etc. and try to configure the Stretch.

/Rien

Re: Manual force firmware update on stretch 2.0

Posted: Mon Oct 14, 2013 6:45 pm
by Akatar
with the app on my laptop i can connect,
i can't connect with my iphone app, with explorer or the beta plugin

Re: Manual force firmware update on stretch 2.0

Posted: Mon Oct 14, 2013 7:06 pm
by Akatar
tried a bit more
you can't acces the stretch with explorer anymore,
Firefox etc works.

Re: Manual force firmware update on stretch 2.0

Posted: Mon Oct 14, 2013 8:11 pm
by Phoenix
Akatar wrote:tried a bit more
you can't acces the stretch with explorer anymore,
Firefox etc works.
True, i think it's IE9 that's having trouble, don't know about IE10 :roll: , but you can access the stretch with firmware 2.0.x in google chrome or firefox! :)

Not a good move from plugwise in my opinion, most people are still using Internet Explorer! :shock:

Re: Manual force firmware update on stretch 2.0

Posted: Mon Oct 14, 2013 11:34 pm
by RdP
Safari works too, I will report the IE issue to Plugwise tomorrow :x