| @@ -51,6 +51,7 @@ func main() { | |||||
| switch msg.Method { | switch msg.Method { | ||||
| case "POST": | case "POST": | ||||
| id := msg.Beacon.ID | id := msg.Beacon.ID | ||||
| fmt.Println("Beacon added to lookup: ", id) | |||||
| appState.AddBeaconToLookup(id) | appState.AddBeaconToLookup(id) | ||||
| case "DELETE": | case "DELETE": | ||||
| fmt.Println("Incoming delete message") | fmt.Println("Incoming delete message") | ||||
| @@ -76,6 +77,7 @@ func getLikelyLocations(appState *appcontext.AppState, writer *kafka.Writer) { | |||||
| mSize := len(beacon.BeaconMetrics) | mSize := len(beacon.BeaconMetrics) | ||||
| if (int64(time.Now().Unix()) - (beacon.BeaconMetrics[mSize-1].Timestamp)) > settings.LastSeenThreshold { | if (int64(time.Now().Unix()) - (beacon.BeaconMetrics[mSize-1].Timestamp)) > settings.LastSeenThreshold { | ||||
| fmt.Println("Beacon is too old") | |||||
| continue | continue | ||||
| } | } | ||||
| @@ -109,7 +111,8 @@ func getLikelyLocations(appState *appcontext.AppState, writer *kafka.Writer) { | |||||
| if beacon.LocationConfidence == settings.LocationConfidence && beacon.PreviousConfidentLocation != bestLocName { | if beacon.LocationConfidence == settings.LocationConfidence && beacon.PreviousConfidentLocation != bestLocName { | ||||
| beacon.LocationConfidence = 0 | beacon.LocationConfidence = 0 | ||||
| // Who do I need this if I am sending entire structure anyways? who knows | |||||
| // Why do I need this if I am sending entire structure anyways? who knows | |||||
| fmt.Println("this is called") | |||||
| js, err := json.Marshal(model.LocationChange{ | js, err := json.Marshal(model.LocationChange{ | ||||
| Method: "LocationChange", | Method: "LocationChange", | ||||
| BeaconRef: beacon, | BeaconRef: beacon, | ||||
| @@ -120,6 +123,7 @@ func getLikelyLocations(appState *appcontext.AppState, writer *kafka.Writer) { | |||||
| }) | }) | ||||
| if err != nil { | if err != nil { | ||||
| fmt.Println("This error happens: ", err) | |||||
| beacon.PreviousConfidentLocation = bestLocName | beacon.PreviousConfidentLocation = bestLocName | ||||
| beacon.PreviousLocation = bestLocName | beacon.PreviousLocation = bestLocName | ||||
| appState.UpdateBeacon(beacon.ID, beacon) | appState.UpdateBeacon(beacon.ID, beacon) | ||||
| @@ -141,6 +145,7 @@ func getLikelyLocations(appState *appcontext.AppState, writer *kafka.Writer) { | |||||
| js, err := json.Marshal(r) | js, err := json.Marshal(r) | ||||
| if err != nil { | if err != nil { | ||||
| fmt.Println("Error in marshaling location: ", err) | |||||
| continue | continue | ||||
| } | } | ||||
| @@ -150,7 +155,7 @@ func getLikelyLocations(appState *appcontext.AppState, writer *kafka.Writer) { | |||||
| err = writer.WriteMessages(context.Background(), msg) | err = writer.WriteMessages(context.Background(), msg) | ||||
| if err != nil { | if err != nil { | ||||
| fmt.Println("Error in sending Kafka message") | |||||
| fmt.Println("Error in sending Kafka message: ", err) | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -168,6 +173,7 @@ func assignBeaconToList(adv model.BeaconAdvertisement, appState *appcontext.AppS | |||||
| settings := appState.GetSettingsValue() | settings := appState.GetSettingsValue() | ||||
| if settings.RSSIEnforceThreshold && (int64(adv.RSSI) < settings.RSSIMinThreshold) { | if settings.RSSIEnforceThreshold && (int64(adv.RSSI) < settings.RSSIMinThreshold) { | ||||
| fmt.Println("Settings returns") | |||||
| return | return | ||||
| } | } | ||||