| 867 | } |
| 868 | |
| 869 | void Emotibit::ping_thread () |
| 870 | { |
| 871 | int sleep_time = 1; |
| 872 | int package_num = 1; |
| 873 | while (initialized) |
| 874 | { |
| 875 | #ifdef _WIN32 |
| 876 | Sleep (sleep_time * 1000); |
| 877 | #else |
| 878 | usleep (sleep_time * 1000000); |
| 879 | #endif |
| 880 | std::vector<std::string> payload; |
| 881 | payload.push_back (DATA_PORT); |
| 882 | payload.push_back (std::to_string (data_port)); |
| 883 | std::string package = create_package (PING, package_num++, payload); |
| 884 | // safe_logger (spdlog::level::trace, "sending package: {}", package.c_str ()); |
| 885 | int bytes_send = adv_socket->send (package.c_str (), (int)package.size ()); |
| 886 | if (bytes_send != (int)package.size ()) |
| 887 | { |
| 888 | safe_logger (spdlog::level::err, "failed to send adv package, res is {}", bytes_send); |
| 889 | } |
| 890 | } |
| 891 | } |