-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
78 lines (71 loc) · 1.91 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"go.bug.st/serial.v1"
"io/ioutil"
"github.com/olebedev/config"
"log"
)
var port serial.Port
var usb string
var WiFi string
var GPSdata GpsData
var startGPS bool
type GpsData struct {
Timestamp string
Latitude string
Longitute string
GPSRead bool // Were we able to read GPS?
}
// Example scanned data is in docs/example_WiFiScanData
type wifiData struct {
ESSID string `json:"ESSID"` // ESSID
MAC string `json:"MAC"` // Address
Freq string `json:"freq"` // Frequency
SigLvl string `json:"siglvl"` // SignalLevel
Qual string `json:"qual"` // Quality
Enc string `json:"enc"` // Encryption key
Channel int `json:"channel"` // Channel
Mode string `json:"mode"` // Mode
IEEE string `json:"IEEE"` // IEEE
Bitrates string `json:"bitrates"` // bitrates
WPA string `json:"wpa"` // WPA version
}
type webdata struct {
Timestamp string `json:"Timestamp"`
ESSID string `json:"ESSID"` // ESSID
MAC string `json:"MAC"` // Address
Freq string `json:"freq"` // Frequency
SigLvl string `json:"siglvl"` // SignalLevel
Qual string `json:"qual"` // Quality
Enc string `json:"enc"` // Encryption key
Channel int `json:"channel"` // Channel
Mode string `json:"mode"` // Mode
IEEE string `json:"IEEE"` // IEEE
Bitrates string `json:"bitrates"` // bitrates
WPA string `json:"wpa"` // WPA version
Latitude string `json:"Latitude"`
Longitude string `json:"Longitude"`
GPSRead bool
}
func readConfig(pathname string) (err error) {
file, err := ioutil.ReadFile(pathname)
if err != nil {
log.Printf("Couldn't read config file: %v", err)
return err
}
yamlString := string(file)
conf, err := config.ParseYaml(yamlString)
if err != nil {
log.Printf("Couldn't parse config file: %v", err)
return err
}
WiFi, err = conf.String("devices.interface")
if err != nil {
return err
}
usb, err = conf.String("devices.usbport")
if err != nil {
return err
}
return nil
}