station: Surface signal, traffic and connection time in API and UI
Hostapd already parsed signal strength and rx/tx counters but the station -> ConnectedDevice conversion threw them away. Add signalDbm, rxBytes, txBytes and connectedAt to the OpenAPI schema and the ConnectedDevice model, and centralise the conversion in station.ToConnectedDevice so handlers, the periodic refresh and the event callbacks all serialise the same shape. Two follow-on bugs surfaced while wiring this up: - The hostapd backend only stored station entries on first contact. Subsequent polls were dropped, so signal and byte counters never refreshed. Reconcile updates in checkStationChanges. - ConnectedAt was reset to time.Now() on every conversion. Track FirstSeen on HostapdStation when the station joins, and preserve the timestamp across periodic refreshes in app.go so the UI's "connected since" badge is stable. Frontend gains a metrics row on each device card with signal bars, total traffic and a live duration. Falls back gracefully when a backend (DHCP, ARP) doesn't expose these fields.
This commit is contained in:
parent
a758c331c0
commit
950f73371c
8 changed files with 231 additions and 37 deletions
|
|
@ -13,10 +13,15 @@ type WiFiNetwork struct {
|
|||
|
||||
// ConnectedDevice represents a device connected to the hotspot
|
||||
type ConnectedDevice struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
MAC string `json:"mac"`
|
||||
IP string `json:"ip"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
MAC string `json:"mac"`
|
||||
IP string `json:"ip"`
|
||||
Vendor string `json:"vendor,omitempty"`
|
||||
SignalDbm int32 `json:"signalDbm,omitempty"`
|
||||
RxBytes uint64 `json:"rxBytes,omitempty"`
|
||||
TxBytes uint64 `json:"txBytes,omitempty"`
|
||||
ConnectedAt time.Time `json:"connectedAt,omitzero"`
|
||||
}
|
||||
|
||||
// HotspotConfig represents hotspot configuration
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue