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() {
|
void ParticipantUDP::GetBroadcastAddress() {
|
||||||
// SOMEHOW, THIS FUNCTION RESULTS IN MEMORY CORRUPION...
|
// SOMEHOW, THIS FUNCTION RESULTS IN MEMORY CORRUPION...
|
||||||
|
|
||||||
// esp_netif_ip_info_t ip_info;
|
esp_netif_ip_info_t ip_info;
|
||||||
// esp_netif_t* esp_netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
esp_netif_t* esp_netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
||||||
|
|
||||||
// // Get IP information (IP address, netmask, gateway)
|
// Get IP information (IP address, netmask, gateway)
|
||||||
// if (esp_netif_get_ip_info(esp_netif, &ip_info) != ESP_OK) {
|
if (esp_netif_get_ip_info(esp_netif, &ip_info) != ESP_OK) {
|
||||||
// std::cout << "Failed to get IP info\n";
|
std::cout << "Failed to get IP info\n";
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// ip_addr_t broadcast_addr = {};
|
ip_addr_t broadcast_addr = {};
|
||||||
// broadcast_addr.u_addr.ip4.addr =
|
broadcast_addr.u_addr.ip4.addr =
|
||||||
// (ip_info.ip.addr & ip_info.netmask.addr) | ~ip_info.netmask.addr;
|
(ip_info.ip.addr & ip_info.netmask.addr) | ~ip_info.netmask.addr;
|
||||||
|
|
||||||
// snprintf(this->broadcastIpAddress, INET_ADDRSTRLEN, IPSTR,
|
snprintf(this->broadcastIpAddress, INET_ADDRSTRLEN, IPSTR,
|
||||||
// IP2STR(&broadcast_addr.u_addr.ip4));
|
IP2STR(&broadcast_addr.u_addr.ip4));
|
||||||
// std::cout << "Broadcast address: " << this->broadcastIpAddress << "\n";
|
std::cout << "Broadcast address: " << this->broadcastIpAddress << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticipantUDP::Receive() {
|
void ParticipantUDP::Receive() {
|
||||||
@ -152,12 +152,6 @@ bool ParticipantUDP::Publish(IMessage* msg) {
|
|||||||
sizeof(dest_addr));
|
sizeof(dest_addr));
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
std::cout << "Publish error\n";
|
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
|
#endif
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -28,6 +28,7 @@ namespace RoboidControl {
|
|||||||
ParticipantUDP::ParticipantUDP(int port) {
|
ParticipantUDP::ParticipantUDP(int port) {
|
||||||
this->ipAddress = "0.0.0.0";
|
this->ipAddress = "0.0.0.0";
|
||||||
this->port = port;
|
this->port = port;
|
||||||
|
this->remoteSite = nullptr;
|
||||||
if (this->port == 0)
|
if (this->port == 0)
|
||||||
this->isIsolated = true;
|
this->isIsolated = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user