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: 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# 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";
}

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
The result when the new firmware is downloaded on the stretch: 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
*** 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!

