newdevice: Added better hardware and version identification for SAF (#7378)

* Proper hardware and version identification

* Replaced str_replace with preg_match
This commit is contained in:
noaheroufus
2017-09-27 13:41:19 -06:00
committed by Neil Lathwood
parent 0713963ed4
commit 554b40eb3f
3 changed files with 13 additions and 7 deletions

View File

@ -23,6 +23,8 @@
* @author Neil Lathwood <gh+n@laf.io>
*/
$saf_integra = preg_split('/;/', $poll_device['sysDescr']);
preg_match('/Prod: ([A-Za-z-_]+);Vers: ([0-9.]+);.*;S\/N: ([0-9]+)/', $poll_device['sysDescr'], $matches);
$serial = str_replace('S/N: ', '', $saf_integra[8]);
$hardware = $matches[1];
$version = $matches[2];
$serial = $matches[3];

View File

@ -23,6 +23,8 @@
* @author Neil Lathwood <gh+n@laf.io>
*/
$saf_integra = preg_split('/;/', $poll_device['sysDescr']);
preg_match('/Prod: ([A-Za-z-_]+);Vers: ([0-9.]+-(mux|esw));.*;S\/N: ([0-9]+)/', $poll_device['sysDescr'], $matches);
$serial = str_replace('S/N: ', '', $saf_integra[8]);
$hardware = $matches[1];
$version = $matches[2];
$serial = $matches[4];

View File

@ -12,6 +12,8 @@
* the source code distribution for details.
*/
list(,$version,,$hardware,$serial,,) = explode(";", $poll_device['sysDescr']);
list(,$hardware) = explode(":", $hardware);
list(,$serial) = explode(":", $serial);
preg_match('/ radio;(.*) v([0-9.]*);.*;SN: ([0-9]+);/', $poll_device['sysDescr'], $matches);
$hardware = $matches[1];
$version = $matches[2];
$serial = $matches[3];