Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 7ac99bf

Browse files
committed
Add endpoint to configure wired connection
1 parent f62b0f4 commit 7ac99bf

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

handlers_stats.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ func (s *Status) WiFiEvent(client mqtt.Client, msg mqtt.Message) {
4444
net.AddWirelessConnection(info.SSID, info.Password)
4545
}
4646

47+
// EthEvent tries to change IP/Netmask/DNS configuration of the wired connection
48+
func (s *Status) EthEvent(client mqtt.Client, msg mqtt.Message) {
49+
// try registering a new wifi network
50+
var info net.IpProxyConfig
51+
err := json.Unmarshal(msg.Payload(), &info)
52+
if err != nil {
53+
s.Error("/ethernet", errors.Wrapf(err, "unmarshal %s", msg.Payload()))
54+
return
55+
}
56+
net.AddWiredConnection(info)
57+
}
58+
4759
// StatsEvent sends statistics about resource used in the system (RAM, Disk, Network, etc...)
4860
func (s *Status) StatsEvent(client mqtt.Client, msg mqtt.Message) {
4961
// Gather all system data metrics

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ func subscribeTopics(mqttClient mqtt.Client, id string, status *Status) {
232232
mqttClient.Subscribe("$aws/things/"+id+"/update/post", 1, status.UpdateEvent)
233233
mqttClient.Subscribe("$aws/things/"+id+"/stats/post", 1, status.StatsEvent)
234234
mqttClient.Subscribe("$aws/things/"+id+"/wifi/post", 1, status.WiFiEvent)
235+
mqttClient.Subscribe("$aws/things/"+id+"/ethernet/post", 1, status.EthEvent)
235236

236237
mqttClient.Subscribe("$aws/things/"+id+"/apt/list/post", 1, status.AptListEvent)
237238
mqttClient.Subscribe("$aws/things/"+id+"/apt/install/post", 1, status.AptInstallEvent)

0 commit comments

Comments
 (0)