diff --git a/sysutils/vep1400-hw/+POST_INSTALL b/sysutils/vep1400-hw/+POST_INSTALL new file mode 100644 index 0000000000..e75e4f094a --- /dev/null +++ b/sysutils/vep1400-hw/+POST_INSTALL @@ -0,0 +1,4 @@ +/usr/local/etc/rc.syshook.d/early/50-vep1400-init +/usr/local/etc/rc.syshook.d/start/99-vep1400-init-complete +/usr/local/etc/rc.configure_plugins POST_INSTALL +service configd restart diff --git a/sysutils/vep1400-hw/Makefile b/sysutils/vep1400-hw/Makefile new file mode 100644 index 0000000000..f59e443956 --- /dev/null +++ b/sysutils/vep1400-hw/Makefile @@ -0,0 +1,8 @@ +PLUGIN_NAME= vep1400-hw +PLUGIN_VERSION= 1.1 +PLUGIN_REVISION= 1 +PLUGIN_COMMENT= Dell EMC VEP1400 initialization scripts +PLUGIN_MAINTAINER= brandontolbird@proton.me +PLUGIN_TIER= 2 + +.include "../../Mk/plugins.mk" diff --git a/sysutils/vep1400-hw/pkg-descr b/sysutils/vep1400-hw/pkg-descr new file mode 100644 index 0000000000..c30858d154 --- /dev/null +++ b/sysutils/vep1400-hw/pkg-descr @@ -0,0 +1,2 @@ +This includes a couple of rc.syshook scripts to handle setting up +the various interfaces and chips on a Dell VEP1400 board. diff --git a/sysutils/vep1400-hw/src/etc/rc.syshook.d/early/50-vep1400-init b/sysutils/vep1400-hw/src/etc/rc.syshook.d/early/50-vep1400-init new file mode 100755 index 0000000000..793ab6b9dc --- /dev/null +++ b/sysutils/vep1400-hw/src/etc/rc.syshook.d/early/50-vep1400-init @@ -0,0 +1,60 @@ +#!/bin/sh + +#ichsmb has to load first, so that ismt is at /dev/smb1 (or adjust the script) +needed_klds="ichsmb ismt smb" + +kldload $needed_klds &> /dev/null +sleep 1 + +ismt_dev=/dev/smb1 + +board_id=$(smbmsg -f $ismt_dev -s 0x62 -c 0x00 -i 1 | cut -c 4-5) + +if [ ! -z $board_id ]; then + + # Disable PIC Watch Dog + smbmsg -f $ismt_dev -s 0x44 -c 0 -o 1 0 + # Set PIC Watch Dog default count to 0 (offset 0x0=LSB; 0x1=MSB) + smbmsg -f $ismt_dev -s 0x48 -c 0x0 -o 1 0x0 + sleep 1 + smbmsg -f $ismt_dev -s 0x48 -c 0x1 -o 1 0x0 + + + + if [ x"$board_id" = x"8" ] || [ x"$board_id" = x"a" ] || [ x"$board_id" = x"b" ]; then + logger -t "vep1400-hw" "VEP1400-X detected, doing init" + # VEP1400-X stuff + # fetch board type + # smbmsg -f $ismt_dev -s 0x62 -c 0x00 -i 1 | cut -c 4-5 + # if 8, 10(a) or 11(b), do the following + # i2cset -y 1 0x31 0x1 0xff + + #enable the i350 GbE ports + smbmsg -f $ismt_dev -s 0x62 -c 0x01 -o 1 0xff + + # more VEP1400-x stuff + # Communicate with CPLD/FPGA to turn off SFP TX disable (DAC cables aren't affected by this) + # for ix1 + smbmsg -f $ismt_dev -s 0x62 -c 0x10 -o 1 0x07 + # for ix0 + smbmsg -f $ismt_dev -s 0x62 -c 0x11 -o 1 0x07 + fi + + if [ x"$board_id" = x"0" ]; then + logger -t "vep1400-hw" "VEP1400 detected, doing init" + #Communicate with CPLD/FPGA to turn off SFP TX disable (DAC cables aren't affected by this) + # for ix3 + smbmsg -f $ismt_dev -s 0x62 -c 0x10 -o 1 0 + # for ix2 + smbmsg -f $ismt_dev -s 0x62 -c 0x11 -o 1 0 + if [ -e /dev/etherswitch0 ]; then + etherswitchcfg config vlan_mode dot1q + etherswitchcfg port1 pvid 2 port2 pvid 2 port3 pvid 2 port4 pvid 2 port5 pvid 2 port6 pvid 3 port9 pvid 3 port10 pvid 2 vlangroup0 vlan 2 members 1,2,3,4,5,10 vlangroup1 vlan 3 members 6,9 + echo "Marvell 88E6190 configured. LAN ports are 1-5 and are connected to ix0. WAN is on port 6 and is connected to ix1." + logger -t "vep1400-hw" "Marvell 88E6190 configured. LAN is on ports 1-5 and is connected to ix0. WAN is on port 6 and is connected to ix1." + else + logger -t "vep1400-hw" "VEP1400 detected, but no etherswitch dev found. Is patched kernel installed?" + fi + fi +fi + diff --git a/sysutils/vep1400-hw/src/etc/rc.syshook.d/start/99-vep1400-init-complete b/sysutils/vep1400-hw/src/etc/rc.syshook.d/start/99-vep1400-init-complete new file mode 100755 index 0000000000..7842cb0af6 --- /dev/null +++ b/sysutils/vep1400-hw/src/etc/rc.syshook.d/start/99-vep1400-init-complete @@ -0,0 +1,41 @@ +#!/bin/sh + +board_id=$(smbmsg -f /dev/smb1 -s 0x62 -c 0x00 -i 1 | cut -c 4-5) +conf_file=/usr/local/etc/vep1400/vep1400.conf + +if [ -f $conf_file ]; then + . $conf_file +else + RED=0x00 + GREEN=0xff + BLUE=0x00 + FANCONTROL=0 + FANDUTY=0 +fi + +if [ -z "$RED" ]; then + RED=0x00 + GREEN=0xff + BLUE=0x00 + FANCONTROL=0 + FANDUTY=0 +fi + +if [ ! -z "$board_id" ]; then + # set front LED to green (or custom color if settings have been saved) + # format is -c (red) -o 2 (green) (blue) (some models lack a blue led) + smbmsg -f /dev/smb1 -s 0x40 -c $RED -o 2 $GREEN $BLUE + + if [ x"$board_id" != x"0" ] && [ x"$board_id" != x"1" ]; then + # set fan speed. At address 36 is a TC654 + # set control register to allow SMBus control of duty cycle + if [ "$FANCONTROL" == "0" ]; then + smbmsg -f $ismt_dev -s 0x36 -c 0x04 -o 1 0x14 + elif [ "$FANCONTROL" == "1" ]; then + smbmsg -f $ismt_dev -s 0x36 -c 0x04 -o 1 0x34 + # set duty cycle, range is 0x00 to 0x0f + # 0x0d is 90.67% duty cycle per datasheet + smbmsg -f $ismt_dev -s 0x36 -c 0x06 -o 1 $FANDUTY + fi + fi +fi \ No newline at end of file diff --git a/sysutils/vep1400-hw/src/opnsense/mvc/app/controllers/OPNsense/vep1400hw/Api/InfoController.php b/sysutils/vep1400-hw/src/opnsense/mvc/app/controllers/OPNsense/vep1400hw/Api/InfoController.php new file mode 100644 index 0000000000..853e7619a4 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/mvc/app/controllers/OPNsense/vep1400hw/Api/InfoController.php @@ -0,0 +1,76 @@ + "failed"]; + $status = parse_ini_string((new Backend())->configdRun('vep1400hw getfan')); + + if (!empty($status)) { + $result["status"] = "OK"; + $result = array_merge($result, $status); + } + + return $result; + } + + public function tempStatusAction() + { + $result = ["status" => "failed"]; + $status = trim((new Backend())->configdRun('vep1400hw gettemp')); + + if (!empty($status)) { + $result["status"] = "OK"; + $temp["temp"] = $status; + $result = array_merge($result, $temp); + } + + return $result; + } + + public function boardIdAction() + { + $result = ["status" => "failed"]; + $status = trim((new Backend())->configdRun('vep1400hw getid')); + + if (!empty($status)) { + $result["status"] = "OK"; + $id["boardid"] = $status; + $result = array_merge($result, $id); + } + + return $result; + } +} diff --git a/sysutils/vep1400-hw/src/opnsense/mvc/app/controllers/OPNsense/vep1400hw/Api/ServiceController.php b/sysutils/vep1400-hw/src/opnsense/mvc/app/controllers/OPNsense/vep1400hw/Api/ServiceController.php new file mode 100644 index 0000000000..c911465961 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/mvc/app/controllers/OPNsense/vep1400hw/Api/ServiceController.php @@ -0,0 +1,84 @@ +request->isPost()) { + $status = strtolower(trim((new Backend())->configdRun('template reload ' . self::$internalServiceTemplate))); + } + return ["status" => $status]; + }//*/ + + /** + * apply + */ + public function applyAction() + { + if ($this->request->isPost()) { + $mdl = $this->getModel(); + $boardtype = trim((new Backend())->configdRun('vep1400hw getid')); + $boardnibble = substr($boardtype, -1); + if ($boardnibble != "0" && $boardnibble != "1"){ + $fanc_enabled = $mdl->general->FanControl; + $fan_dc = $mdl->general->FanDutyCycle; + $fanresult = trim((new Backend())->configdRun(sprintf("vep1400hw setfan %s %s", $fanc_enabled, $fan_dc))); + } + else { + $fanresult = "OK"; //we can't set fan settings on boards without them so fake an OK + } + $ledr = $mdl->led->red; $ledg = $mdl->led->green; $ledb = $mdl->led->blue; + $ledresult = trim((new Backend())->configdRun(sprintf("vep1400hw setled %s %s %s", $ledr, $ledg, $ledb))); + if ($fanresult == "OK" && $ledresult == "OK") { + // only return valid json type responses + return ["message" => "Hardware settings applied successfully"]; + } + } + return ["message" => "Hardware settings weren't applied."]; + } +} diff --git a/sysutils/vep1400-hw/src/opnsense/mvc/app/controllers/OPNsense/vep1400hw/Api/SettingsController.php b/sysutils/vep1400-hw/src/opnsense/mvc/app/controllers/OPNsense/vep1400hw/Api/SettingsController.php new file mode 100644 index 0000000000..f4f10a7969 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/mvc/app/controllers/OPNsense/vep1400hw/Api/SettingsController.php @@ -0,0 +1,43 @@ +view->pick('OPNsense/vep1400hw/index'); + // fetch form data "general" in + $this->view->generalForm = $this->getForm("general"); + } +} diff --git a/sysutils/vep1400-hw/src/opnsense/mvc/app/controllers/OPNsense/vep1400hw/forms/general.xml b/sysutils/vep1400-hw/src/opnsense/mvc/app/controllers/OPNsense/vep1400hw/forms/general.xml new file mode 100644 index 0000000000..5e288a5a0c --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/mvc/app/controllers/OPNsense/vep1400hw/forms/general.xml @@ -0,0 +1,40 @@ +
+ + vep1400hw.general.enabled + + checkbox + Allow the plugin to restore the below settings on system startup or restart + + + vep1400hw.general.FanControl + + checkbox + Enable manual fan control, if disabled the fan will be + automatically controlled by the TC654 + + + + vep1400hw.general.FanDutyCycle + + dropdown + Set fan duty cycle, if available + + + vep1400hw.led.red + + text + Set LED color - red channel intensity + + + vep1400hw.led.green + + text + Set LED color - green channel intensity + + + vep1400hw.led.blue + + text + Set LED color - blue channel intensity. NOTE: Some systems don't have a blue LED. + +
diff --git a/sysutils/vep1400-hw/src/opnsense/mvc/app/models/OPNsense/vep1400hw/ACL/ACL.xml b/sysutils/vep1400-hw/src/opnsense/mvc/app/models/OPNsense/vep1400hw/ACL/ACL.xml new file mode 100644 index 0000000000..d2b0de3eb4 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/mvc/app/models/OPNsense/vep1400hw/ACL/ACL.xml @@ -0,0 +1,9 @@ + + + System: VEP1400 Hardware Settings + + ui/vep1400hw/* + api/vep1400hw/* + + + diff --git a/sysutils/vep1400-hw/src/opnsense/mvc/app/models/OPNsense/vep1400hw/Menu/Menu.xml b/sysutils/vep1400-hw/src/opnsense/mvc/app/models/OPNsense/vep1400hw/Menu/Menu.xml new file mode 100644 index 0000000000..c88c331c85 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/mvc/app/models/OPNsense/vep1400hw/Menu/Menu.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/sysutils/vep1400-hw/src/opnsense/mvc/app/models/OPNsense/vep1400hw/vep1400hw.php b/sysutils/vep1400-hw/src/opnsense/mvc/app/models/OPNsense/vep1400hw/vep1400hw.php new file mode 100644 index 0000000000..300f97e306 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/mvc/app/models/OPNsense/vep1400hw/vep1400hw.php @@ -0,0 +1,37 @@ + + //OPNsense/vep1400hw + VEP1400 Hardware Settings + + + + + + 1 + Y + + + 0 + Y + + + 0x0b + Y + + 30% + 34.67% + 39.33% + 44% + 48.67% + 53.33% + 58% + 62.67% + 67.33% + 72% + 76.67% + 81.33% + 86% + 90.67% + 95.33% + 100% + + + + + + 0 + Y + Must be between 0-255. + 0 + 255 + + + 255 + Y + Must be between 0-255. + 0 + 255 + + + 0 + Y + Must be between 0-255. + 0 + 255 + + + + diff --git a/sysutils/vep1400-hw/src/opnsense/mvc/app/views/OPNsense/vep1400hw/index.volt b/sysutils/vep1400-hw/src/opnsense/mvc/app/views/OPNsense/vep1400hw/index.volt new file mode 100644 index 0000000000..2dab0a7230 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/mvc/app/views/OPNsense/vep1400hw/index.volt @@ -0,0 +1,65 @@ +{# + +OPNsense® is Copyright © 2014 – 2015 by Deciso B.V. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +#} + + + + + +
+ {{ partial("layout_partials/base_form",['fields':generalForm,'id':'frm_GeneralSettings'])}} +
+ +
+ + +
diff --git a/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_get_fan_speed.sh b/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_get_fan_speed.sh new file mode 100755 index 0000000000..3b62e0559d --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_get_fan_speed.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +board_id=$(smbmsg -f /dev/smb1 -s 0x62 -c 0x00 -i 1 | cut -c 4-5) + +if [ ! -z $board_id ]; then + for fan in 0 1; do + fan_speed_in_steps=$(smbmsg -f /dev/smb1 -s 0x36 -c $fan -i 1 -F "%d") + echo fan$((fan + 1))=$(($fan_speed_in_steps * 50)) + done +fi \ No newline at end of file diff --git a/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_get_id.sh b/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_get_id.sh new file mode 100755 index 0000000000..ad3ed8f394 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_get_id.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +board_id=$(smbmsg -f /dev/smb1 -s 0x62 -c 0x00 -i 1) + +echo $board_id \ No newline at end of file diff --git a/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_get_temp.sh b/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_get_temp.sh new file mode 100755 index 0000000000..29317ed988 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_get_temp.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +#Check CPLD first to make sure we are on a VEP board +board_id=$(smbmsg -f /dev/smb1 -s 0x62 -c 0x00 -i 1 | cut -c 4-5) + +if [ ! -z $board_id ]; then + smbmsg -f /dev/smb1 -s 0x94 -c 0 -i 1 -F "%0d" +fi \ No newline at end of file diff --git a/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_set_fan_speed.sh b/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_set_fan_speed.sh new file mode 100755 index 0000000000..1786239ba7 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_set_fan_speed.sh @@ -0,0 +1,30 @@ +#!/bin/sh + + +if [ ! -z $1 ]; then + #Check CPLD first to make sure we are on a VEP board + board_id=$(smbmsg -f /dev/smb1 -s 0x62 -c 0x00 -i 1 | cut -c 4-5) + mode=$1 + current_control_reg=$(smbmsg -f /dev/smb1 -s 0x36 -c 0x04 -i 1) + if [ x"$mode" == x"0" ]; then #auto mode + if [ "$current_control_reg" != "0x14" ]; then + # if we are not already in auto mode, then switch + smbmsg -f /dev/smb1 -s 0x36 -c 0x04 -o 1 0x14 + fi + elif [ x"$mode" == x"1" ]; then #manual mode + if [ "$current_control_reg" != "0x34" ]; then + # if we are not already in manual mode, then switch + smbmsg -f /dev/smb1 -s 0x36 -c 0x04 -o 1 0x34 + fi + if [ ! -z $2 ]; then + dc=$(( $2 & 0x0f )) #keep only the lowest nibble, the register only goes up to 0x0f + + if [ x"$board_id" != x"0" ] && [ x"$board_id" != x"1" ]; then + smbmsg -f /dev/smb1 -s 0x36 -c 0x06 -o 1 $dc + fi + else + echo "No duty cycle specified. Using previous." + fi + fi +fi + diff --git a/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_set_led.sh b/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_set_led.sh new file mode 100755 index 0000000000..5d39eba1ca --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/scripts/vep1400hw/vep1400_set_led.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +board_id=$(smbmsg -f /dev/smb1 -s 0x62 -c 0x00 -i 1 | cut -c 4-5) + +if [ ! -z $board_id ] && [ ! -z $1 ] && [ ! -z $2 ] && [ ! -z $3 ]; then + red=$(( $1 & 0xff )) + green=$(( $2 & 0xff )) + blue=$(( $3 & 0xff )) + # set front LED to green + # format is -c (red) -o 2 (green) (blue) (some models lack a blue led) + smbmsg -f /dev/smb1 -s 0x40 -c $red -o 2 $green $blue +fi diff --git a/sysutils/vep1400-hw/src/opnsense/service/conf/actions.d/actions_vep1400hw.conf b/sysutils/vep1400-hw/src/opnsense/service/conf/actions.d/actions_vep1400hw.conf new file mode 100644 index 0000000000..93c2201b6f --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/service/conf/actions.d/actions_vep1400hw.conf @@ -0,0 +1,29 @@ +[getfan] +command:/usr/local/opnsense/scripts/vep1400hw/vep1400_get_fan_speed.sh +parameters: +type:script_output +message:Get VEP Fan speed + +[setfan] +command:/usr/local/opnsense/scripts/vep1400hw/vep1400_set_fan_speed.sh +parameters:%s %s +type:script +message:Set VEP Fan speed + +[gettemp] +command:/usr/local/opnsense/scripts/vep1400hw/vep1400_get_temp.sh +parameters: +type:script_output +message:Get VEP board temp + +[getid] +command:/usr/local/opnsense/scripts/vep1400hw/vep1400_get_id.sh +parameters: +type:script_output +message:Get VEP board id + +[setled] +command:/usr/local/opnsense/scripts/vep1400hw/vep1400_set_led.sh +parameters:%s %s %s +type:script +message:Set VEP front LED color \ No newline at end of file diff --git a/sysutils/vep1400-hw/src/opnsense/service/templates/OPNsense/vep1400hw/+TARGETS b/sysutils/vep1400-hw/src/opnsense/service/templates/OPNsense/vep1400hw/+TARGETS new file mode 100644 index 0000000000..115c2090f8 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/service/templates/OPNsense/vep1400hw/+TARGETS @@ -0,0 +1 @@ +vep1400.conf:/usr/local/etc/vep1400/vep1400.conf \ No newline at end of file diff --git a/sysutils/vep1400-hw/src/opnsense/service/templates/OPNsense/vep1400hw/vep1400.conf b/sysutils/vep1400-hw/src/opnsense/service/templates/OPNsense/vep1400hw/vep1400.conf new file mode 100644 index 0000000000..f47eea332d --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/service/templates/OPNsense/vep1400hw/vep1400.conf @@ -0,0 +1,7 @@ +{% if not helpers.empty('OPNsense.vephw.general.enabled') %} +RED={{ OPNsense.vephw.led.red|default("0x00") }} +GREEN={{ OPNsense.vephw.led.green|default("0xff") }} +BLUE={{ OPNsense.vephw.led.blue|default("0x00") }} +FANCONTROL={{ OPNsense.vephw.general.FanControl|default("0") }} +FANDUTY={{ OPNsense.vephw.general.FanDutyCycle|default("0") }} +{% endif %} diff --git a/sysutils/vep1400-hw/src/opnsense/www/js/widgets/Metadata/Vep1400HW.xml b/sysutils/vep1400-hw/src/opnsense/www/js/widgets/Metadata/Vep1400HW.xml new file mode 100644 index 0000000000..61a9bdd8c2 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/www/js/widgets/Metadata/Vep1400HW.xml @@ -0,0 +1,16 @@ + + + Vep1400HW.js + + /api/vep1400hw/info/fanstatus + + + VEP1400 Hardware Information + Fan speed not available. + Fan + Temperature + Board ID + Not a VEP1400 board or unable to read CPLD. + + + diff --git a/sysutils/vep1400-hw/src/opnsense/www/js/widgets/Vep1400HW.js b/sysutils/vep1400-hw/src/opnsense/www/js/widgets/Vep1400HW.js new file mode 100644 index 0000000000..9d60891853 --- /dev/null +++ b/sysutils/vep1400-hw/src/opnsense/www/js/widgets/Vep1400HW.js @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2024 Deciso B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +export default class Vep1400Hw extends BaseTableWidget { + constructor() { + super(); + } + + getMarkup() { + let $container = $('
'); + let $sysinfotable = this.createTable('vepinfo-table', { + headerPosition: 'left', + }); + $container.append($sysinfotable); + return $container; + } + + async onWidgetTick() { + let data = await this.ajaxCall('/api/vep1400hw/info/boardid'); + let boardid = data['boardid']; + if ( boardid != null) { + let lower_nibble = boardid.substring(3); + if (lower_nibble != '0' && lower_nibble != '1' ) { + + let fandata = await this.ajaxCall('/api/vep1400hw/info/fanstatus'); + + if (fandata['status'] != 'failed') { + $('#fan1').text(fandata['fan1'] + ' RPM'); + $('#fan2').text(fandata['fan2'] + ' RPM'); + } + } + } + let tempdata = await this.ajaxCall('/api/vep1400hw/info/tempstatus'); + + $('#temp').text(tempdata['temp'] + '℃'); + } + + async onMarkupRendered() { + let rows = []; + let data = await this.ajaxCall('/api/vep1400hw/info/boardid'); + let boardid = data['boardid']; + + if (!boardid || boardid != null) { + rows.push([[this.translations['boardid']], boardid]); + let lower_nibble = boardid.substring(3); + if (lower_nibble != '0' && lower_nibble != '1' ) { + rows.push([[this.translations['fan']] + ' 1', $('').prop('outerHTML')]); + rows.push([[this.translations['fan']] + ' 2', $('').prop('outerHTML')]); + } + rows.push([[this.translations['temp']], $('').prop('outerHTML')]); + + } + else { + rows.push([[this.translations['boarderror']]]); + } + super.updateTable('vepinfo-table', rows); + } +} \ No newline at end of file