28.6.17

isc-dhcp-server führende 0 fehlt

Ich hatte folgendes eingefügt in die dhcp.conf:

on commit {
        set clip = binary-to-ascii(10, 8, ".", leased-address);
       set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        log(concat("Commit: IP: ", clip, " Mac: ", clhw));
        execute("/home/pi/scripts/dash/dash_action", clip, clhw);
    }
}

Jedoch sorgt die Funktion binary-to-ascii dafür, dass mögliche führenden Nullen abgeschnitten werden. Das sorgt dann z.B. für eine solche Ausgabe:

e0:76:d0:60:3:fc
Abhilfe schafft folgendes:

         set clhw = concat (
            suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), ":",
            suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), ":",
            suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,3,1))),2), ":",
            suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1))),2), ":",
            suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), ":",
            suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2)
            );

Keine Kommentare:

Kommentar veröffentlichen

Openhab und Ecoflow Max - API Anbindung

 Ich wollte die neu erworbene Powerstation in Openhab einbinden, um den aktuellen Status (Ladestand etc.) über Openhab auswerten zu können. ...