Преглед изворни кода

test enable|disable poe for tplink

rajven пре 3 година
родитељ
комит
ca402b2d5f
2 измењених фајлова са 25 додато и 7 уклоњено
  1. 18 6
      html/inc/common.php
  2. 7 1
      html/inc/consts.php

+ 18 - 6
html/inc/common.php

@@ -2275,12 +2275,12 @@ function get_port_poe_state($vendor_id, $port, $port_snmp_index, $ip, $community
         if ($vendor_id == 9) {
             if ($p_state == 1) { return 2; }
             if ($p_state > 1) { return 1; }
-        }
+            }
         //patch for tplink
         if ($vendor_id == 69) {
             if ($p_state == 0) { return 2; }
-            if ($p_state > 1) { return 1; }
-        }
+            if ($p_state >= 1) { return 1; }
+            }
         return $p_state;
     }
     return;
@@ -2293,8 +2293,13 @@ function set_port_poe_state($vendor_id, $port, $port_snmp_index, $ip, $community
     if (! isset($community)) { $community = 'public'; }
     if (! isset($version)) { $version = '2'; }
 
+    //default poe status
+    $poe_enable = 1;
+    $poe_disable = 2;
+
     // default poe oid
     $poe_status = PETH_PSE_PORT_ADMIN_ENABLE . "." . $port_snmp_index;
+
     if ($vendor_id == 3) { $poe_status = HUAWEI_POE_OID . "." . $port_snmp_index; }
 
     if ($vendor_id == 8) { $poe_status = ALLIED_POE_OID . "." . $port_snmp_index; }
@@ -2303,15 +2308,19 @@ function set_port_poe_state($vendor_id, $port, $port_snmp_index, $ip, $community
 
     if ($vendor_id == 10) { $poe_status = NETGEAR_POE_OID . "." . $port_snmp_index; }
 
-    if ($vendor_id == 69) { $poe_status = TPLINK_POE_OID . "." . $port; }
+    if ($vendor_id == 69) { 
+        $poe_status = TPLINK_POE_OID . "." . $port; 
+        $poe_enable = 1; 
+        $poe_disable = 0; 
+        }
 
     if ($state) {
         // enable port
-        $c_state = set_snmp($ip, $community, $version, $poe_status, 'i', 1);
+        $c_state = set_snmp($ip, $community, $version, $poe_status, 'i', $poe_enable);
         return $c_state;
     } else {
         // disable port
-        $c_state = set_snmp($ip, $community, $version, $poe_status, 'i', 2);
+        $c_state = set_snmp($ip, $community, $version, $poe_status, 'i', $poe_disable);
         return $c_state;
     }
 }
@@ -2325,6 +2334,8 @@ function get_port_poe_detail($vendor_id, $port, $port_snmp_index, $ip, $communit
 
     $result = '';
 
+    $poe_class = PETH_PSE_PORT_POE_CLASS . $port_snmp_index;
+
     // eltex
     if ($vendor_id == 2) {
         $poe_power = ELTEX_POE_USAGE . '.' . $port_snmp_index;
@@ -2371,6 +2382,7 @@ function get_port_poe_detail($vendor_id, $port, $port_snmp_index, $ip, $communit
         $poe_power = TPLINK_POE_USAGE . '.' . $port;
         $poe_current = TPLINK_POE_CURRENT .'.' . $port;
         $poe_volt = TPLINK_POE_VOLT . '.' . $port;
+        $poe_class = TPLINK_POE_CLASS . "." . $port;
     }
 
     if (isset($poe_power)) {

+ 7 - 1
html/inc/consts.php

@@ -108,8 +108,14 @@ define("MIKROTIK_POE_CURRENT",".1.3.6.1.4.1.14988.1.1.15.1.1.5");
 define("MIKROTIK_POE_USAGE",".1.3.6.1.4.1.14988.1.1.15.1.1.6");
 
 //TP-Link
+// index port in poe tables
+define("TPLINK_POE_PORT_INDEX",".1.3.6.1.4.1.11863.6.56.1.1.2.1.1.1");
 // INTEGER {off(0), turning-on(1), on(2), overload(3), short(4), nonstandard-pd(5),voltage-high(6), voltage-low(7),hardware-fault(8),overtemperature(9)
-define("TPLINK_POE_OID",".1.3.6.1.4.1.11863.6.56.1.1.2.1.1.11");
+define("TPLINK_POE_STATUS",".1.3.6.1.4.1.11863.6.56.1.1.2.1.1.11");
+//POE class -  INTEGER {class0(0),class1(1),class2(2),class3(3),class4(4),class-not-defined(7)}
+define("TPLINK_POE_CLASS",".1.3.6.1.4.1.11863.6.56.1.1.2.1.1.10");
+//POE Port Config - enable - 1, disable 0
+define("TPLINK_POE_OID",".1.3.6.1.4.1.11863.6.56.1.1.2.1.1.2");    
 //POE POWER, Displays the port's real time power supply in 0.1W.
 define("TPLINK_POE_USAGE",".1.3.6.1.4.1.11863.6.56.1.1.2.1.1.7");
 //POE CURRENT, Displays the port's real time current in 1mA.