moved from broadcasting to unicasting
This commit is contained in:
parent
92be21a9c1
commit
e92ecef46f
@ -60,22 +60,22 @@ std::cout << "Set up UDP\n";
|
||||
void ParticipantUDP::GetBroadcastAddress() {
|
||||
// SOMEHOW, THIS FUNCTION RESULTS IN MEMORY CORRUPION...
|
||||
|
||||
// esp_netif_ip_info_t ip_info;
|
||||
// esp_netif_t* esp_netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
||||
esp_netif_ip_info_t ip_info;
|
||||
esp_netif_t* esp_netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
||||
|
||||
// // Get IP information (IP address, netmask, gateway)
|
||||
// if (esp_netif_get_ip_info(esp_netif, &ip_info) != ESP_OK) {
|
||||
// std::cout << "Failed to get IP info\n";
|
||||
// return;
|
||||
// }
|
||||
// Get IP information (IP address, netmask, gateway)
|
||||
if (esp_netif_get_ip_info(esp_netif, &ip_info) != ESP_OK) {
|
||||
std::cout << "Failed to get IP info\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// ip_addr_t broadcast_addr = {};
|
||||
// broadcast_addr.u_addr.ip4.addr =
|
||||
// (ip_info.ip.addr & ip_info.netmask.addr) | ~ip_info.netmask.addr;
|
||||
ip_addr_t broadcast_addr = {};
|
||||
broadcast_addr.u_addr.ip4.addr =
|
||||
(ip_info.ip.addr & ip_info.netmask.addr) | ~ip_info.netmask.addr;
|
||||
|
||||
// snprintf(this->broadcastIpAddress, INET_ADDRSTRLEN, IPSTR,
|
||||
// IP2STR(&broadcast_addr.u_addr.ip4));
|
||||
// std::cout << "Broadcast address: " << this->broadcastIpAddress << "\n";
|
||||
snprintf(this->broadcastIpAddress, INET_ADDRSTRLEN, IPSTR,
|
||||
IP2STR(&broadcast_addr.u_addr.ip4));
|
||||
std::cout << "Broadcast address: " << this->broadcastIpAddress << "\n";
|
||||
}
|
||||
|
||||
void ParticipantUDP::Receive() {
|
||||
@ -152,12 +152,6 @@ bool ParticipantUDP::Publish(IMessage* msg) {
|
||||
sizeof(dest_addr));
|
||||
if (err != 0)
|
||||
std::cout << "Publish error\n";
|
||||
// udp.beginPacket(this->broadcastIpAddress, this->remotePort);
|
||||
// udp.write((unsigned char*)buffer, bufferSize);
|
||||
// udp.endPacket();
|
||||
|
||||
// std::cout << "Publish to " << this->broadcastIpAddress << ":"
|
||||
// << this->remotePort << "\n";
|
||||
#endif
|
||||
return true;
|
||||
};
|
||||
|
@ -28,6 +28,7 @@ namespace RoboidControl {
|
||||
ParticipantUDP::ParticipantUDP(int port) {
|
||||
this->ipAddress = "0.0.0.0";
|
||||
this->port = port;
|
||||
this->remoteSite = nullptr;
|
||||
if (this->port == 0)
|
||||
this->isIsolated = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user