enhance device update check
This commit is contained in:
@@ -428,7 +428,7 @@ def_global_updatecheck_device-payload = {
|
|||||||
},
|
},
|
||||||
"state_topic":"%topic",
|
"state_topic":"%topic",
|
||||||
"name":"%name",
|
"name":"%name",
|
||||||
"value_template":"{%% set my_new = value_json|truncate(255)|regex_replace(find='^[^,]*|, device firmware |,.*| available',replace='') %%}{%% set my_cur = 'old' %%}{%% if my_new == '' %%}{%% set my_new = 'current' %%}{%% set my_cur = 'current' %%}{%% endif %%}{{ {'installed_version':my_cur,'latest_version':my_new,'entity_picture':'https://adapter.ebusd.eu/favicon.ico','release_url':'https://adapter.ebusd.eu/firmware/ChangeLog'} | tojson }}"
|
"value_template":"{%% set my_new = value_json|truncate(255)|regex_replace(find='^[^,]*|, device firmware |,.*| available',replace='') %%}{%% set my_ds = 'v31/firmware/' %%}{%% if my_new is search('up to date') %%}{%% set my_ds = my_new|regex_replace(find=' .*',replace='/') %%}{%% set my_new = 'current' %%}{%% set my_cur = 'current' %%}{%% else %%}{%% set my_cur = 'old' %%}{%% if my_new is search(' ') %%}{%% set my_ds = my_new|regex_replace(find=' .*',replace='/') %%}{%% set my_new = my_new|regex_replace(find='.* ',replace='') %%}{%% else %%}{%% if my_new == '' %%}{%% set my_new = 'current' %%}{%% set my_cur = 'current' %%}{%% endif %%}{%% endif %%}{%% endif %%}{{ {'installed_version':my_cur,'latest_version':my_new,'entity_picture':'https://adapter.ebusd.eu/'+my_ds+'favicon.ico','release_url':'https://adapter.ebusd.eu/'+my_ds+'ChangeLog'} | tojson }}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# the topic and payload to listen to in order to republish all config messages.
|
# the topic and payload to listen to in order to republish all config messages.
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
version=`head -n 1 ../../VERSION`
|
version=`head -n 1 ../../VERSION`
|
||||||
revision=`git describe --always`
|
revision=`git describe --always`
|
||||||
echo "ebusd=${version},${revision}" > versions.txt
|
echo "ebusd=${version},${revision}" > versions.txt
|
||||||
# cp versions.txt > oldversions.txt
|
|
||||||
devver=`curl -s https://adapter.ebusd.eu/v31/firmware/ChangeLog|grep "<h[0-9].*>Version "|head -n 1|sed -e 's#.*<code[^>]*>##' -e 's#<.*##' -e 's# ##'`
|
devver=`curl -s https://adapter.ebusd.eu/v31/firmware/ChangeLog|grep "<h[0-9].*>Version "|head -n 1|sed -e 's#.*<code[^>]*>##' -e 's#<.*##' -e 's# ##'`
|
||||||
devbl=`curl -s https://adapter.ebusd.eu/v31/firmware/ChangeLog|grep "<h[0-9].*>Bootloader version"|head -n 1|sed -e 's#.*<code[^>]*>##' -e 's#<.*##' -e 's# ##'`
|
devbl=`curl -s https://adapter.ebusd.eu/v31/firmware/ChangeLog|grep "<h[0-9].*>Bootloader version"|head -n 1|sed -e 's#.*<code[^>]*>##' -e 's#<.*##' -e 's# ##'`
|
||||||
echo "device=${devver},${devbl}" >> versions.txt
|
echo "device=${devver},${devbl}" >> versions.txt
|
||||||
devver=`curl -s https://adapter.ebusd.eu/v5/ChangeLog|grep "<h[0-9].*>Version "|head -n 1|sed -e 's#.*<code[^>]*>##' -e 's#<.*##' -e 's# ##'`
|
devver=`curl -s https://adapter.ebusd.eu/v5/ChangeLog|grep "<h[0-9].*>Version "|head -n 1|sed -e 's#.*id="\([^"]*\)".*<code[^>]*>\([^<]*\)<.*#\2,\2,\1#'`
|
||||||
echo "device=${devver},${devver}" >> versions.txt
|
echo "device=${devver}" >> versions.txt
|
||||||
cp versions.txt cdnversions.txt
|
cp versions.txt cdnversions.txt
|
||||||
files=`find config/de -type f -or -type l`
|
files=`find config/de -type f -or -type l`
|
||||||
../../src/lib/ebus/test/test_filereader $files|sed -e 's#^config/de/##' -e 's#^\([^ ]*\) #\1=#' -e 's# #,#g'|sort >> versions.txt
|
../../src/lib/ebus/test/test_filereader $files|sed -e 's#^config/de/##' -e 's#^\([^ ]*\) #\1=#' -e 's# #,#g'|sort >> versions.txt
|
||||||
@@ -17,7 +16,6 @@ for filever in $(../../src/lib/ebus/test/test_filereader $files|sed -e 's#^confi
|
|||||||
ver=${filever#*=}
|
ver=${filever#*=}
|
||||||
sed -i -e "s#^$file=\(.*\)\$#$file=\1,$ver#" versions.txt
|
sed -i -e "s#^$file=\(.*\)\$#$file=\1,$ver#" versions.txt
|
||||||
done
|
done
|
||||||
#./oldtest_filereader $files|sed -e 's#^config/##' -e 's#^\([^ ]*\) #\1=#' -e 's# #,#g'|sort >> oldversions.txt
|
|
||||||
curl -sS https://ebus.github.io/en/versions.json -o veren.json
|
curl -sS https://ebus.github.io/en/versions.json -o veren.json
|
||||||
curl -sS https://ebus.github.io/de/versions.json -o verde.json
|
curl -sS https://ebus.github.io/de/versions.json -o verde.json
|
||||||
node -e 'fs=require("fs");e=JSON.parse(fs.readFileSync("veren.json","utf-8"));d=JSON.parse(fs.readFileSync("verde.json","utf-8"));console.log(Object.entries(d).map(([k,de])=>{en=e[k];return `${k}=${de.hash},${de.size},${de.mtime},${en.hash},${en.size},${en.mtime}`;}).join("\n"))'|sort >> cdnversions.txt
|
node -e 'fs=require("fs");e=JSON.parse(fs.readFileSync("veren.json","utf-8"));d=JSON.parse(fs.readFileSync("verde.json","utf-8"));console.log(Object.entries(d).map(([k,de])=>{en=e[k];return `${k}=${de.hash},${de.size},${de.mtime},${en.hash},${en.size},${en.mtime}`;}).join("\n"))'|sort >> cdnversions.txt
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ if (substr($agent, 0, 5)==='ebusd') {
|
|||||||
$r = @file_get_contents('php://input');
|
$r = @file_get_contents('php://input');
|
||||||
header('Content-Type: text/plain');
|
header('Content-Type: text/plain');
|
||||||
$r = @json_decode($r, true);
|
$r = @json_decode($r, true);
|
||||||
echo checkUpdate(@$r['v'], @$r['r'], @$r['a'], @$r['dv'], @$r['l'], @$r['lc'], @$r['cp']);
|
echo checkUpdate(@$r['v'], @$r['r'], @$r['a'], @$r['dv'], @$r['di'], @$r['l'], @$r['lc'], @$r['cp']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
readVersions();
|
readVersions();
|
||||||
@@ -23,7 +23,7 @@ $ref = @file_get_contents('ebusd-configuration/.git/refs/heads/master');
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<p>latest ebusd version: <?=$versions['ebusd'][0]?></p>
|
<p>latest ebusd version: <?=$versions['ebusd'][0]?></p>
|
||||||
<p>latest device firmware: v5=<?=$versions['devicesame'][0]?>, v3*=<?=$versions['device'][0]?></p>
|
<p>latest device firmware: v5*=<?=$versions['devicesame'][0]?>, v3*=<?=$versions['device'][0]?></p>
|
||||||
<p>config files:<table><thead><th>File</th><th>German</th><th>English</th></thead><tbody>
|
<p>config files:<table><thead><th>File</th><th>German</th><th>English</th></thead><tbody>
|
||||||
<?php
|
<?php
|
||||||
$func = function($v, $k) {
|
$func = function($v, $k) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ function readVersions($prefix='') {
|
|||||||
if (count($val)>1) {
|
if (count($val)>1) {
|
||||||
$key = $val[0];
|
$key = $val[0];
|
||||||
$val = explode(',', $val[1]);
|
$val = explode(',', $val[1]);
|
||||||
if ($key==='device' && count($val)===2 && $val[0]===$val[1]) {
|
if ($key==='device' && count($val)>=2 && $val[0]===$val[1]) {
|
||||||
$key = 'devicesame';
|
$key = 'devicesame';
|
||||||
}
|
}
|
||||||
$versions[$key] = $val;
|
$versions[$key] = $val;
|
||||||
@@ -23,7 +23,7 @@ function readVersions($prefix='') {
|
|||||||
array_walk($v, $func);
|
array_walk($v, $func);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
function checkUpdate($ebusdVersion, $ebusdRelease, $architecture, $deviceVersion, $loadedFiles, $language, $cdnPath) {
|
function checkUpdate($ebusdVersion, $ebusdRelease, $architecture, $deviceVersion, $deviceId, $loadedFiles, $language, $cdnPath) {
|
||||||
if (!$ebusdVersion) {
|
if (!$ebusdVersion) {
|
||||||
return 'invalid request';
|
return 'invalid request';
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,12 @@ function checkUpdate($ebusdVersion, $ebusdRelease, $architecture, $deviceVersion
|
|||||||
$ver = strtok('.');
|
$ver = strtok('.');
|
||||||
if ($ver) {
|
if ($ver) {
|
||||||
$key = ($ver===strtok('.')) ? 'devicesame' : 'device';
|
$key = ($ver===strtok('.')) ? 'devicesame' : 'device';
|
||||||
if ($ver!==$versions[$key][0]) {
|
$devTypes = array('00'=>'v5', '01'=>'v5-c6', '00n'=>'v5', '01n'=>'');
|
||||||
|
$devType = $key==='devicesame' && strlen($deviceId)===9*2 && substr($deviceId,-2)==='00' ? $devTypes[substr($deviceId,-4,2).(substr($deviceId,-6,2)==='00'?'n':'')] : '';
|
||||||
|
if ($devType) {
|
||||||
|
$devVer = $versions[$key][0];
|
||||||
|
$ret .= ', device firmware '.$devType.' '.$devVer.($ver===$devVer ? ' up to date' : ' available');
|
||||||
|
} else if ($ver!==$versions[$key][0]) {
|
||||||
$ret .= ', device firmware '.$versions[$key][0].' available';
|
$ret .= ', device firmware '.$versions[$key][0].' available';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class Device {
|
|||||||
* Format device infos in JSON format.
|
* Format device infos in JSON format.
|
||||||
* @param output the @a ostringstream to append the infos to.
|
* @param output the @a ostringstream to append the infos to.
|
||||||
*/
|
*/
|
||||||
virtual void formatInfoJson(ostringstream* output) const {}
|
virtual void formatInfoJson(ostringstream* output) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether the device supports checking for version updates.
|
* @return whether the device supports checking for version updates.
|
||||||
|
|||||||
@@ -159,10 +159,21 @@ void EnhancedDevice::formatInfo(ostringstream* ostream, bool verbose, bool prefi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnhancedDevice::formatInfoJson(ostringstream* ostream) const {
|
void EnhancedDevice::formatInfoJson(ostringstream* ostream) {
|
||||||
string ver = getEnhancedVersion();
|
string ver = getEnhancedVersion();
|
||||||
if (!ver.empty()) {
|
if (!ver.empty()) {
|
||||||
*ostream << ",\"dv\":\"" << ver << "\"";
|
*ostream << ",\"dv\":\"" << ver << "\"";
|
||||||
|
if (m_enhInfoIdRequestNeeded) {
|
||||||
|
if (!m_enhInfoIdRequested) {
|
||||||
|
result_t ret = requestEnhancedInfo(1);
|
||||||
|
if (ret == RESULT_OK) {
|
||||||
|
requestEnhancedInfo(0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!m_enhInfoId.empty()) {
|
||||||
|
*ostream << ",\"di\":\"" << m_enhInfoId << "\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,6 +208,7 @@ result_t EnhancedDevice::requestEnhancedInfo(symbol_t infoId, bool wait) {
|
|||||||
uint8_t buf[] = makeEnhancedSequence(ENH_REQ_INFO, infoId);
|
uint8_t buf[] = makeEnhancedSequence(ENH_REQ_INFO, infoId);
|
||||||
result_t result = m_transport->write(buf, 2);
|
result_t result = m_transport->write(buf, 2);
|
||||||
if (result == RESULT_OK) {
|
if (result == RESULT_OK) {
|
||||||
|
m_enhInfoIdRequested = m_enhInfoIdRequested || (infoId == 1);
|
||||||
m_infoBuf[0] = infoId;
|
m_infoBuf[0] = infoId;
|
||||||
m_infoLen = 1;
|
m_infoLen = 1;
|
||||||
m_infoPos = 1;
|
m_infoPos = 1;
|
||||||
@@ -350,6 +362,9 @@ result_t EnhancedDevice::notifyTransportStatus(bool opened) {
|
|||||||
m_infoLen = 0;
|
m_infoLen = 0;
|
||||||
m_enhInfoVersion = "";
|
m_enhInfoVersion = "";
|
||||||
m_enhInfoIsWifi = false;
|
m_enhInfoIsWifi = false;
|
||||||
|
m_enhInfoIdRequestNeeded = false;
|
||||||
|
m_enhInfoIdRequested = false;
|
||||||
|
m_enhInfoId = "";
|
||||||
m_enhInfoTemperature = "";
|
m_enhInfoTemperature = "";
|
||||||
m_enhInfoSupplyVoltage = "";
|
m_enhInfoSupplyVoltage = "";
|
||||||
m_enhInfoBusVoltage = "";
|
m_enhInfoBusVoltage = "";
|
||||||
@@ -545,6 +560,7 @@ void EnhancedDevice::notifyInfoRetrieved() {
|
|||||||
stream << "[" << setfill('0') << setw(2) << hex << static_cast<unsigned>(data[6])
|
stream << "[" << setfill('0') << setw(2) << hex << static_cast<unsigned>(data[6])
|
||||||
<< setw(2) << static_cast<unsigned>(data[7]) << "]";
|
<< setw(2) << static_cast<unsigned>(data[7]) << "]";
|
||||||
}
|
}
|
||||||
|
m_enhInfoIdRequestNeeded = len >= 8 && data[0] == data[5] && data[2] == data[6] && data[3] == data[7];
|
||||||
m_enhInfoVersion = stream.str();
|
m_enhInfoVersion = stream.str();
|
||||||
stream.str(" ");
|
stream.str(" ");
|
||||||
stream << "firmware " << m_enhInfoVersion;
|
stream << "firmware " << m_enhInfoVersion;
|
||||||
@@ -557,10 +573,13 @@ void EnhancedDevice::notifyInfoRetrieved() {
|
|||||||
case 0x0901:
|
case 0x0901:
|
||||||
case 0x0802:
|
case 0x0802:
|
||||||
case 0x0302:
|
case 0x0302:
|
||||||
stream << (id == 1 ? "ID" : "config");
|
stream << (id == 1 ? "ID " : "config ");
|
||||||
stream << hex << setfill('0');
|
stream << hex << setfill('0');
|
||||||
for (size_t pos = 0; pos < len; pos++) {
|
for (size_t pos = 0; pos < len; pos++) {
|
||||||
stream << " " << setw(2) << static_cast<unsigned>(data[pos]);
|
stream << setw(2) << static_cast<unsigned>(data[pos]);
|
||||||
|
}
|
||||||
|
if (id == 1 && data[8] == 0) {
|
||||||
|
m_enhInfoId = stream.str().substr(3);
|
||||||
}
|
}
|
||||||
if (id == 2 && (data[2]&0x3f) != 0x3f) {
|
if (id == 2 && (data[2]&0x3f) != 0x3f) {
|
||||||
// non-default arbitration delay
|
// non-default arbitration delay
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class BaseDevice : public Device, public TransportListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @copydoc
|
// @copydoc
|
||||||
virtual void formatInfoJson(ostringstream* output) const {}
|
virtual void formatInfoJson(ostringstream* output) {}
|
||||||
|
|
||||||
// @copydoc
|
// @copydoc
|
||||||
virtual result_t notifyTransportStatus(bool opened) {
|
virtual result_t notifyTransportStatus(bool opened) {
|
||||||
@@ -139,14 +139,15 @@ class EnhancedDevice : public BaseDevice, public EnhancedDeviceInterface {
|
|||||||
*/
|
*/
|
||||||
explicit EnhancedDevice(Transport* transport)
|
explicit EnhancedDevice(Transport* transport)
|
||||||
: BaseDevice(transport), EnhancedDeviceInterface(), m_resetTime(0), m_resetRequested(false),
|
: BaseDevice(transport), EnhancedDeviceInterface(), m_resetTime(0), m_resetRequested(false),
|
||||||
m_extraFeatures(0), m_infoReqTime(0), m_infoLen(0), m_infoPos(0), m_enhInfoIsWifi(false) {
|
m_extraFeatures(0), m_infoReqTime(0), m_infoLen(0), m_infoPos(0), m_enhInfoIsWifi(false),
|
||||||
|
m_enhInfoIdRequestNeeded(false), m_enhInfoIdRequested(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// @copydoc
|
// @copydoc
|
||||||
void formatInfo(ostringstream* output, bool verbose, bool prefix) override;
|
void formatInfo(ostringstream* output, bool verbose, bool prefix) override;
|
||||||
|
|
||||||
// @copydoc
|
// @copydoc
|
||||||
void formatInfoJson(ostringstream* output) const override;
|
void formatInfoJson(ostringstream* output) override;
|
||||||
|
|
||||||
// @copydoc
|
// @copydoc
|
||||||
result_t send(symbol_t value) override;
|
result_t send(symbol_t value) override;
|
||||||
@@ -217,6 +218,15 @@ class EnhancedDevice : public BaseDevice, public EnhancedDeviceInterface {
|
|||||||
/** whether the device is known to be connected via WIFI. */
|
/** whether the device is known to be connected via WIFI. */
|
||||||
bool m_enhInfoIsWifi;
|
bool m_enhInfoIsWifi;
|
||||||
|
|
||||||
|
/** whether the device ID request is needed. */
|
||||||
|
bool m_enhInfoIdRequestNeeded;
|
||||||
|
|
||||||
|
/** whether the device ID was already requested. */
|
||||||
|
bool m_enhInfoIdRequested;
|
||||||
|
|
||||||
|
/** a string with the ID of the enhanced device. */
|
||||||
|
string m_enhInfoId;
|
||||||
|
|
||||||
/** a string describing the enhanced device temperature. */
|
/** a string describing the enhanced device temperature. */
|
||||||
string m_enhInfoTemperature;
|
string m_enhInfoTemperature;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user