device matching via mac instead of ip address
This commit is contained in:
@@ -106,6 +106,24 @@ class GenieACS {
|
||||
return $this->_request('GET', '/api/devices');
|
||||
}
|
||||
|
||||
public function getDeviceByMac($mac) {
|
||||
$mac = strtolower(preg_replace('/[^A-Fa-f0-9]/', '', $mac));
|
||||
$mac = implode(':', str_split($mac, 2));
|
||||
|
||||
$paths = [
|
||||
'InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress',
|
||||
'InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.2.MACAddress',
|
||||
];
|
||||
|
||||
foreach ($paths as $path) {
|
||||
$filter = urlencode($path . ' = "' . $mac . '"');
|
||||
$result = $this->_request('GET', '/api/devices/?filter=' . $filter . '&limit=1');
|
||||
if ($result && is_array($result) && count($result) > 0) return $result[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getDevice($deviceId) {
|
||||
return $this->_request('GET', '/api/devices/' . rawurlencode($deviceId));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user