#include #include #include "wifi-triangulator/core.h" using namespace std; using namespace wifi_triangulator; void send_info(uint64_t freq) { pb::envelope envelope; pb::listener_station_info *i = envelope.mutable_listener_station_info(); i->set_freq(freq); write_envelope(pb::letter_type::listener_station_info_lt, envelope); } int main(int argc, char *argv[]) { app_name = argv[0]; if (argc != 2) { fprintf(stderr, "usage: %s [interface]\n", argv[0]); return EXIT_FAILURE; } string dev = argv[1]; GOOGLE_PROTOBUF_VERIFY_VERSION; int iw; if ((iw = iw_sockets_open()) < 0) { perror("Could not open iw sockets"); return EXIT_FAILURE; } wireless_config wc; if (iw_get_basic_config(iw, dev.c_str(), &wc) < 0) { perror("iw_get_basic_config"); return EXIT_FAILURE; } auto freq = static_cast(wc.freq); send_info(freq); int ret = launch_capture(dev, [&](const data &data) { pb::envelope envelope; envelope.set_time_s(data.sec); envelope.set_time_us(data.usec); pb::frame *frame = envelope.mutable_frame(); frame->set_type(data.type); if (data.type == pb::frame_type ::probe_request) { pb::probe *probe = frame->mutable_probe(); probe->set_src(data.src); if (data.rssi) { probe->set_rssi(data.rssi); } } write_envelope(pb::letter_type::frame_lt, envelope); // static int count = 0; // cerr << "count=" << count << "!\r" << flush; // count++; }); google::protobuf::ShutdownProtobufLibrary(); cerr << app_name << " exiting" << endl; cout.flush(); return ret; }