Skip to content

Commit

Permalink
Printing RSSI values to screen
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomicera committed Nov 23, 2019
1 parent 256330b commit 5d17c5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/server/src/statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Point statistics::getDevicePosition(std::unordered_map<std::string, followifier:
// Interception points
double r1 = statistics::estimatedDistance(i->second.rsi());
double r2 = statistics::estimatedDistance(j->second.rsi());
logDeviceDistanceAnnouncement(i->first, i->second.apmac(), r1);
logDeviceDistanceAnnouncement(j->first, j->second.apmac(), r2);
logDeviceDistanceAnnouncement(i->first, i->second, r1);
logDeviceDistanceAnnouncement(j->first, j->second, r2);

// d = sqrt((x1-x2)^2 + (y1-y2)^2)
double d = std::sqrt(std::pow(x1 - x2, 2) + std::pow(y1 - y2, 2));
Expand Down
13 changes: 9 additions & 4 deletions core/server/src/statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,19 @@ class statistics {
* debug mode is active (`DEBUG_ONE_DEVICE_TRACKING` set to true).
*
* @param boardMac the board MAC address which is announcing the distance.
* @param deviceMac the device distance with respect to the announcing board.
* @param metadata TODO
* @param deviceDistance the distance announced by the board.
*/
static void
logDeviceDistanceAnnouncement(const std::string &boardMac, const std::string &deviceMac, double deviceDistance) {
logDeviceDistanceAnnouncement(const std::string &boardMac, const followifier::ESP32Metadata &metadata,
double deviceDistance) {

std::string deviceMac = metadata.apmac();
int rssi = metadata.rsi();

if (!DEBUG_ONE_DEVICE_TRACKING || (DEBUG_ONE_DEVICE_TRACKING && deviceMac == DEBUG_TRACKED_DEVICE_MAC)) {
std::cout << "Board " << boardMac << " announced device " << deviceMac << " at a distance of "
<< deviceDistance << " cm." << std::endl;
<< deviceDistance << " cm (RSSI: " << rssi << ")." << std::endl;
}
}

Expand Down Expand Up @@ -77,7 +82,7 @@ class statistics {
static void
logInvalidDeviceLocation(const std::string &frameHash, const std::string deviceMac, const Point &deviceLocation) {
if (!DEBUG_ONE_DEVICE_TRACKING || (DEBUG_ONE_DEVICE_TRACKING && deviceMac == DEBUG_TRACKED_DEVICE_MAC)) {
std::cerr << "Frame" << frameHash << " discarded since announcing device " << deviceMac
std::cerr << "Frame " << frameHash << " discarded since announcing device " << deviceMac
<< " is located in an invalid position (" << deviceLocation << ")." << std::endl;
}
}
Expand Down

0 comments on commit 5d17c5e

Please sign in to comment.