Skip to content

Commit

Permalink
Need to do calculations on filtered fingerprint, but insert full fing…
Browse files Browse the repository at this point in the history
…erprint
  • Loading branch information
root authored and root committed Dec 3, 2016
1 parent a59a539 commit c562475
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions fingerprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ func loadFingerprint(jsonByte []byte) Fingerprint {
res := Fingerprint{}
//json.Unmarshal(decompressByte(jsonByte), res)
res.UnmarshalJSON(decompressByte(jsonByte))
filterFingerprint(&res)
return res
}

func filterFingerprint(res *Fingerprint) {
if RuntimeArgs.Filtering {
newFingerprint := make([]Router, len(res.WifiFingerprint))
curNum := 0
Expand All @@ -81,7 +86,6 @@ func loadFingerprint(jsonByte []byte) Fingerprint {
newFingerprint = newFingerprint[0:curNum]
res.WifiFingerprint = newFingerprint
}
return res
}

func cleanFingerprint(res *Fingerprint) {
Expand Down Expand Up @@ -173,6 +177,10 @@ func learnFingerprint(jsonFingerprint Fingerprint) (string, bool) {
}

func trackFingerprint(jsonFingerprint Fingerprint) (string, bool, string, map[string]float64, map[string]float64) {
// Classify with filter fingerprint
fullFingerprint := jsonFingerprint
filterFingerprint(&jsonFingerprint)

bayes := make(map[string]float64)
svmData := make(map[string]float64)
cleanFingerprint(&jsonFingerprint)
Expand Down Expand Up @@ -214,7 +222,9 @@ func trackFingerprint(jsonFingerprint Fingerprint) (string, bool, string, map[st
percentGuess1 = math.Exp(bayes[locationGuess1]) / total * 100.0

jsonFingerprint.Location = locationGuess1
putFingerprintIntoDatabase(jsonFingerprint, "fingerprints-track")

// Insert full fingerprint
putFingerprintIntoDatabase(fullFingerprint, "fingerprints-track")

Debug.Println("Tracking fingerprint containing " + strconv.Itoa(len(jsonFingerprint.WifiFingerprint)) + " APs for " + jsonFingerprint.Username + " (" + jsonFingerprint.Group + ") at " + jsonFingerprint.Location + " (guess)")
message := "Current location: " + locationGuess1 //+ " (" + strconv.Itoa(int(percentGuess1)) + "% confidence)"
Expand Down

0 comments on commit c562475

Please sign in to comment.