Merge pull request #3479 from jroweboy/dont-log-on-no-input

Minor fixes for udp input
This commit is contained in:
bunnei 2020-03-05 15:09:48 -05:00 committed by GitHub
commit 4a8fe67964
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 6 deletions

View File

@ -32,8 +32,16 @@ public:
SocketCallback callback) SocketCallback callback)
: callback(std::move(callback)), timer(io_service), : callback(std::move(callback)), timer(io_service),
socket(io_service, udp::endpoint(udp::v4(), 0)), client_id(client_id), socket(io_service, udp::endpoint(udp::v4(), 0)), client_id(client_id),
pad_index(pad_index), pad_index(pad_index) {
send_endpoint(udp::endpoint(boost::asio::ip::make_address_v4(host), port)) {} boost::system::error_code ec{};
auto ipv4 = boost::asio::ip::make_address_v4(host, ec);
if (ec.failed()) {
LOG_ERROR(Input, "Invalid IPv4 address \"{}\" provided to socket", host);
ipv4 = boost::asio::ip::address_v4{};
}
send_endpoint = {udp::endpoint(ipv4, port)};
}
void Stop() { void Stop() {
io_service.stop(); io_service.stop();
@ -85,17 +93,18 @@ private:
} }
void HandleSend(const boost::system::error_code& error) { void HandleSend(const boost::system::error_code& error) {
boost::system::error_code _ignored{};
// Send a request for getting port info for the pad // Send a request for getting port info for the pad
Request::PortInfo port_info{1, {pad_index, 0, 0, 0}}; Request::PortInfo port_info{1, {pad_index, 0, 0, 0}};
const auto port_message = Request::Create(port_info, client_id); const auto port_message = Request::Create(port_info, client_id);
std::memcpy(&send_buffer1, &port_message, PORT_INFO_SIZE); std::memcpy(&send_buffer1, &port_message, PORT_INFO_SIZE);
socket.send_to(boost::asio::buffer(send_buffer1), send_endpoint); socket.send_to(boost::asio::buffer(send_buffer1), send_endpoint, {}, _ignored);
// Send a request for getting pad data for the pad // Send a request for getting pad data for the pad
Request::PadData pad_data{Request::PadData::Flags::Id, pad_index, EMPTY_MAC_ADDRESS}; Request::PadData pad_data{Request::PadData::Flags::Id, pad_index, EMPTY_MAC_ADDRESS};
const auto pad_message = Request::Create(pad_data, client_id); const auto pad_message = Request::Create(pad_data, client_id);
std::memcpy(send_buffer2.data(), &pad_message, PAD_DATA_SIZE); std::memcpy(send_buffer2.data(), &pad_message, PAD_DATA_SIZE);
socket.send_to(boost::asio::buffer(send_buffer2), send_endpoint); socket.send_to(boost::asio::buffer(send_buffer2), send_endpoint, {}, _ignored);
StartSend(timer.expiry()); StartSend(timer.expiry());
} }

View File

@ -31,7 +31,6 @@ namespace Response {
*/ */
std::optional<Type> Validate(u8* data, std::size_t size) { std::optional<Type> Validate(u8* data, std::size_t size) {
if (size < sizeof(Header)) { if (size < sizeof(Header)) {
LOG_DEBUG(Input, "Invalid UDP packet received");
return std::nullopt; return std::nullopt;
} }
Header header{}; Header header{};

View File

@ -84,7 +84,7 @@ touch_device=
# from any cemuhook compatible motion program. # from any cemuhook compatible motion program.
# IPv4 address of the udp input server (Default "127.0.0.1") # IPv4 address of the udp input server (Default "127.0.0.1")
udp_input_address= udp_input_address=127.0.0.1
# Port of the udp input server. (Default 26760) # Port of the udp input server. (Default 26760)
udp_input_port= udp_input_port=