This repository has been archived on 2024-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
orion/use.go

57 lines
1.2 KiB
Go
Raw Normal View History

package main
import (
2019-02-12 10:17:06 +01:00
"forge.cadoles.com/Cadoles/owrt"
)
func main() {
2019-02-12 10:17:06 +01:00
uci := owrt.NewUCI()
uci.LoadWirelessConf()
wifaces := uci.GetWifiIfaces()
wDevices := uci.GetWifiDevices()
PyxisDevice := wDevices[0]
ClientDevice := wDevices[1]
for _, iface := range wifaces {
iface.Delete(uci)
}
// Main Pyxis Interface
2019-02-12 10:17:06 +01:00
pyxis := owrt.NewUCIWirelessInterface()
pyxis.Name = "Pyxis-Network"
pyxis.Network = "pyxis"
pyxis.Index = 0
pyxis.Ssid = "Pyxis"
pyxis.SysDevName = "wlan0"
pyxis.Encryption = "psk2"
pyxis.Key = "xxxxxxxxx"
pyxis.Device = PyxisDevice["Device"]
pyxis.DevicePath = PyxisDevice["Path"]
pyxis.Mode = "ap"
_ = pyxis.Create(uci)
_ = pyxis.Save(uci)
// Client Interface
2019-02-12 10:17:06 +01:00
client := owrt.NewUCIWirelessInterface()
client.Name = "Client-Network"
client.Index = 1
client.SysDevName = "wlan1"
client.Device = ClientDevice["Device"]
client.DevicePath = ClientDevice["Path"]
client.Mode = "sta"
_ = client.Create(uci)
_ = client.SysAdd(uci)
_ = client.Up(uci)
scan := client.Scan()
for _, elm := range scan {
if elm.Ssid == "Cadoles" {
client.Connect(uci, elm, "xxxxxx")
}
}
2019-02-12 10:17:06 +01:00
dhcp := owrt.NewDhcpClient(client.SysDevName)
dhcp.AskForIP()
}