Files
cariflex/tools/EVerest-main/lib/everest/io/examples/test_udp_server.cpp
Eric F d398a6ced2 Add extracted tools: CitrineOS, OpenOCPP, ShapeShifter
- CitrineOS core extracted (CSMS OCPP 2.0.1)
- OpenOCPP extracted (firmware OCPP 1.6J/2.0.1)
- ShapeShifter library installed (pip install -e)
- ShapeShifter specification extracted
- EVerest extracted

TODO updated with progress
2026-06-08 00:38:27 -04:00

42 lines
1.0 KiB
C++

// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
#include <everest/io/udp/udp_socket.hpp>
#include <iostream>
#include <thread>
using namespace everest::lib::io::udp;
using namespace std::chrono_literals;
auto to_string_data(const udp_payload& d) {
return std::string(d.buffer.begin(), d.buffer.end());
}
std::ostream& operator<<(std::ostream& os, udp_payload const& p) {
os << "[UDP ( " << p.size() << " )]: " << to_string_data(p) << " ";
return os;
}
int main() {
std::cout << "udp server" << std::endl;
udp_client_socket socket;
socket.open_as_server(7766);
std::cout << "UDP socket open? -> " << socket.is_open() << std::endl;
while (socket.is_open()) {
udp_payload payload;
auto source = socket.rx(payload);
if (source) {
std::cout << payload << std::endl;
socket.tx(payload);
} else {
std::cout << "no value" << std::endl;
}
std::this_thread::sleep_for(500ms);
}
return 0;
}