orion/cmd/server/jsonrpc/scan_wifi.go

33 lines
684 B
Go

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
}