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/cmd/server/jsonrpc/scan_wifi.go

33 lines
684 B
Go
Raw Normal View History

2019-02-12 10:17:06 +01:00
package jsonrpc
import (
"net/http"
"forge.cadoles.com/Cadoles/owrt"
"github.com/davecgh/go-spew/spew"
)
type ScanWifiArgs struct{}
type ScanWifiReply struct {
AccessPoints []*owrt.WifiCell
}
// ScanWifi starts a WiFi scan and returns available access points
func (o *OrionService) ScanWifi(r *http.Request, args *ScanWifiArgs, reply *ScanWifiReply) error {
o.UCI.LoadWirelessConf()
ifaces := o.UCI.GetWifiIfaces()
reply.AccessPoints = make([]*owrt.WifiCell, 0)
for _, iface := range ifaces {
scanner := owrt.NewWifiScanner(iface.Name)
cells := scanner.Scan()
spew.Dump(iface, cells)
reply.AccessPoints = append(reply.AccessPoints, cells...)
}
return nil
}