#include #include "wifi-triangulator/core.h" using namespace std; using namespace wifi_triangulator; void on_probe_request(const pb::probe &p) { cout << "PROBE REQUEST" << ", src=" << eth_mac(p.src()).to_string() << ", rssi=" << p.rssi() << flush << endl; } void on_frame(const pb::frame &f) { if (f.type() == pb::frame_type::probe_request) { on_probe_request(f.probe()); } else { // cout << "frame: " << to_string(f.type()) << endl; } } void on_listener_station_info(const pb::listener_station_info &i) { cout << "LISTENER STATION INFO" << " mac=" << eth_mac(i.mac()).to_string() << ", freq=" << i.freq() << flush << endl; } bool on_envelope(const pb::envelope &envelope) { if (envelope.type() == pb::letter_type::frame_lt) { on_frame(envelope.frame()); } else if (envelope.type() == pb::letter_type ::listener_station_info_lt) { on_listener_station_info(envelope.listener_station_info()); } else { cout << "Unknown letter type: " << envelope.type() << endl; } return true; } int main(int argc, char *argv[]) { app_name = argv[0]; GOOGLE_PROTOBUF_VERIFY_VERSION; if (argc != 1) { fprintf(stderr, "usage: %s\n", argv[0]); return EXIT_FAILURE; } launch_reader_envelope(on_envelope); google::protobuf::ShutdownProtobufLibrary(); return EXIT_SUCCESS; }