Add Wifi Station API

This commit is contained in:
alphayax 2016-06-05 22:15:02 +02:00
parent f0030c3b68
commit 5d57a5fd82
7 changed files with 336 additions and 0 deletions

View File

@ -80,6 +80,9 @@ Jusqu'a présent, les fonctionalités suivantes ont été implémentées :
- WiFi
- Config (core)
- Access Points
- AP (core)
- Allowed Comb
- Stations
## Utilisation

View File

@ -16,8 +16,13 @@ print_r( $a);
$WiFiAccessPointService = new \alphayax\freebox\api\v3\services\config\WiFi\AccessPoint( $App);
$AccessPoints = $WiFiAccessPointService->getAll();
/*
print_r( $AccessPoints);
$AllowedComb = $WiFiAccessPointService->getAllowedCombFromId( $AccessPoints[0]->getId());
print_r( $AllowedComb);
*/
$Stations = $WiFiAccessPointService->getStationsFromId( $AccessPoints[1]->getId());
print_r( $Stations);

View File

@ -0,0 +1,51 @@
<?php
namespace alphayax\freebox\api\v3\models\WiFi\APStation;
use alphayax\freebox\api\v3\Model;
/**
* Class Flags
* @package alphayax\freebox\api\v3\models\WiFi\APStation
*/
class Flags extends Model {
/** @var bool (Read-only) : does station uses legacy wifi (802.11a, 802.11b) */
protected $legacy;
/** @var bool (Read-only) : does station support ht (802.11n) */
protected $ht;
/** @var bool (Read-only) : does station support vht (802.11ac) */
protected $vht;
/** @var bool (Read-only) : is the station authenticated */
protected $authorized;
/**
* @return boolean
*/
public function isLegacy() {
return $this->legacy;
}
/**
* @return boolean
*/
public function isHt() {
return $this->ht;
}
/**
* @return boolean
*/
public function isVht() {
return $this->vht;
}
/**
* @return boolean
*/
public function isAuthorized() {
return $this->authorized;
}
}

View File

@ -0,0 +1,187 @@
<?php
namespace alphayax\freebox\api\v3\models\WiFi\APStation;
use alphayax\freebox\api\v3\Model;
use alphayax\freebox\api\v3\models\LAN\LanHost;
/**
* Class Station
* @package alphayax\freebox\api\v3\models\WiFi\APStation
*/
class Station extends Model {
/** @var string (Read-only) : station id */
protected $id;
/** @var string (Read-only) : client MAC address */
protected $mac;
/** @var string (Read-only) : bssid on which the client is associated */
protected $bssid;
/** @var string (Read-only) : client host name */
protected $hostname;
/** @var \alphayax\freebox\api\v3\models\LAN\LanHost (Read-only) : client host information */
protected $host;
/**
* @var string (Read-only)
* @see State
**/
protected $state;
/** @var int (Read-only) : inactive duration (in seconds) */
protected $inactive;
/** @var int (Read-only) : connection duration (in seconds) */
protected $conn_duration;
/** @var int (Read-only) : received bytes (from station to Freebox) */
protected $rx_bytes;
/** @var int (Read-only) : transmitted bytes (from Freebox to station) */
protected $tx_bytes;
/** @var int (Read-only) : reception data rate (in bytes/s) */
protected $tx_rate;
/** @var int (Read-only) : transmission data rate (in bytes/s) */
protected $rx_rate;
/** @var int (Read-only) : signal attenuation (in dB) */
protected $signal;
/** @var Flags (Read-only) : station flags */
protected $flags;
/** @var Stats (Read-only) : last rx stats */
protected $last_rx;
/** @var Stats (Read-only) : last tx stats */
protected $last_tx;
/**
* Station constructor.
* @param array $properties_x
*/
public function __construct( array $properties_x){
parent::__construct( $properties_x);
$this->initProperty( 'host' , LanHost::class);
$this->initProperty( 'flags' , Flags::class);
$this->initProperty( 'last_rx', Stats::class);
$this->initProperty( 'last_tx', Stats::class);
}
/**
* @return string
*/
public function getId() {
return $this->id;
}
/**
* @return string
*/
public function getMac() {
return $this->mac;
}
/**
* @return string
*/
public function getBssid() {
return $this->bssid;
}
/**
* @return string
*/
public function getHostname() {
return $this->hostname;
}
/**
* @return \alphayax\freebox\api\v3\models\LAN\LanHost
*/
public function getHost() {
return $this->host;
}
/**
* @return string
*/
public function getState() {
return $this->state;
}
/**
* @return int
*/
public function getInactive() {
return $this->inactive;
}
/**
* @return int
*/
public function getConnDuration() {
return $this->conn_duration;
}
/**
* @return int
*/
public function getRxBytes() {
return $this->rx_bytes;
}
/**
* @return int
*/
public function getTxBytes() {
return $this->tx_bytes;
}
/**
* @return int
*/
public function getTxRate() {
return $this->tx_rate;
}
/**
* @return int
*/
public function getRxRate() {
return $this->rx_rate;
}
/**
* @return int
*/
public function getSignal() {
return $this->signal;
}
/**
* @return Flags
*/
public function getFlags() {
return $this->flags;
}
/**
* @return Stats
*/
public function getLastRx() {
return $this->last_rx;
}
/**
* @return Stats
*/
public function getLastTx() {
return $this->last_tx;
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace alphayax\freebox\api\v3\models\WiFi\APStation;
/**
* Class Stats
* @package alphayax\freebox\api\v3\models\WiFi\APStation
*/
class Stats {
/** @var int (Read-only) : physical link rate (in 1/10th of MBit/s), -1 if unknown */
protected $bitrate;
/** @var int (Read-only) : current link mcs, -1 if not used */
protected $mcs;
/** @var int (Read-only) : current link vht mcs, -1 if not used */
protected $vht_mcs;
/** @var string (Read-only) : current channel width */
protected $width;
/** @var bool (Read-only) : is shortgi enabled */
protected $shortgi;
/**
* @return int
*/
public function getBitrate() {
return $this->bitrate;
}
/**
* @return int
*/
public function getMcs() {
return $this->mcs;
}
/**
* @return int
*/
public function getVhtMcs() {
return $this->vht_mcs;
}
/**
* @return string
*/
public function getWidth() {
return $this->width;
}
/**
* @return boolean
*/
public function isShortgi() {
return $this->shortgi;
}
}

View File

@ -11,6 +11,7 @@ class AccessPoint extends Service {
const API_WIFI_AP = '/api/v3/wifi/ap/';
const API_WIFI_AP_ALLOWED_COMB = '/api/v3/wifi/ap/%u/allowed_channel_comb';
const API_WIFI_AP_STATIONS = '/api/v3/wifi/ap/%u/stations/';
/**
* @return \alphayax\freebox\api\v3\models\WiFi\AccessPoint\AP[]
@ -46,6 +47,19 @@ class AccessPoint extends Service {
return $rest->getResultAsArray( models\WiFi\AccessPoint\AllowedComb::class);
}
/**
* To be able to allow user to pick a valid channel combination for a given AP you should use the following api to retrieve the list of allowed channel combination.
* @param int $accessPointId
* @return models\WiFi\AccessPoint\AllowedComb[]
*/
public function getStationsFromId( $accessPointId) {
$service = sprintf( self::API_WIFI_AP_STATIONS, $accessPointId);
$rest = $this->getAuthService( $service);
$rest->GET();
return $rest->getResultAsArray( models\WiFi\APStation\Station::class);
}
/**
* @param $accessPoint
* @return \alphayax\freebox\api\v3\models\WiFi\AccessPoint\AP

View File

@ -0,0 +1,16 @@
<?php
namespace alphayax\freebox\api\v3\symbols\WiFi\Station;
/**
* Symbol State
* @package alphayax\freebox\api\v3\symbols\WiFi\Station
* @see alphayax\freebox\api\v3\models\WiFi\APStation\Station
*/
interface State {
/** station is associated */
const ASSOCIATED = 'associated';
/** station is authenticated */
const AUTHENTICATED = 'authenticated';
}