Fix namespace issues
This commit is contained in:
parent
1916478494
commit
7344fa676b
@ -3,8 +3,10 @@
|
|||||||
#if defined(ARDUINO)
|
#if defined(ARDUINO)
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
|
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -12,7 +14,7 @@ namespace RoboidControl {
|
|||||||
namespace Arduino {
|
namespace Arduino {
|
||||||
|
|
||||||
void Participant::Setup(int localPort, const char* remoteIpAddress, int remotePort) {
|
void Participant::Setup(int localPort, const char* remoteIpAddress, int remotePort) {
|
||||||
#if ARDUINO
|
#if defined(ARDUINO)
|
||||||
this->remoteIpAddress = remoteIpAddress;
|
this->remoteIpAddress = remoteIpAddress;
|
||||||
this->remotePort = remotePort;
|
this->remotePort = remotePort;
|
||||||
GetBroadcastAddress();
|
GetBroadcastAddress();
|
||||||
@ -28,7 +30,7 @@ void Participant::Setup(int localPort, const char* remoteIpAddress, int remotePo
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Participant::GetBroadcastAddress() {
|
void Participant::GetBroadcastAddress() {
|
||||||
#if ARDUINO
|
#if defined(ARDUINO)
|
||||||
IPAddress broadcastAddress = WiFi.localIP();
|
IPAddress broadcastAddress = WiFi.localIP();
|
||||||
broadcastAddress[3] = 255;
|
broadcastAddress[3] = 255;
|
||||||
String broadcastIpString = broadcastAddress.toString();
|
String broadcastIpString = broadcastAddress.toString();
|
||||||
@ -39,7 +41,7 @@ void Participant::GetBroadcastAddress() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Participant::Receive() {
|
void Participant::Receive() {
|
||||||
#if ARDUINO
|
#if defined(ARDUINO)
|
||||||
int packetSize = udp.parsePacket();
|
int packetSize = udp.parsePacket();
|
||||||
while (packetSize > 0) {
|
while (packetSize > 0) {
|
||||||
udp.read(buffer, packetSize);
|
udp.read(buffer, packetSize);
|
||||||
@ -66,9 +68,9 @@ void Participant::Receive() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Participant::Send(RemoteParticipant* remoteParticipant, int bufferSize) {
|
bool Participant::Send(RemoteParticipant* remoteParticipant, int bufferSize) {
|
||||||
#if ARDUINO
|
#if defined(ARDUINO)
|
||||||
udp.beginPacket(remoteParticipant->ipAddress, remoteParticipant->port);
|
udp.beginPacket(remoteParticipant->ipAddress, remoteParticipant->port);
|
||||||
udp.write(buffer, bufferSize);
|
udp.write((unsigned char*)buffer, bufferSize);
|
||||||
udp.endPacket();
|
udp.endPacket();
|
||||||
|
|
||||||
// std::cout << "Sent to " << this->remoteIpAddress << ":"
|
// std::cout << "Sent to " << this->remoteIpAddress << ":"
|
||||||
@ -84,7 +86,7 @@ bool Participant::Publish(IMessage* msg) {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
udp.beginPacket(this->broadcastIpAddress, this->remotePort);
|
udp.beginPacket(this->broadcastIpAddress, this->remotePort);
|
||||||
udp.write(buffer, bufferSize);
|
udp.write((unsigned char*)buffer, bufferSize);
|
||||||
udp.endPacket();
|
udp.endPacket();
|
||||||
|
|
||||||
// std::cout << "Publish to " << this->broadcastIpAddress << ":"
|
// std::cout << "Publish to " << this->broadcastIpAddress << ":"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "LowLevelMessages.h"
|
#include "LowLevelMessages.h"
|
||||||
|
|
||||||
#include "float16.h"
|
#include "LinearAlgebra/float16.h"
|
||||||
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "LinearAlgebra/Spherical.h"
|
#include "LinearAlgebra/Spherical.h"
|
||||||
#include "LinearAlgebra/SwingTwist.h"
|
#include "LinearAlgebra/SwingTwist.h"
|
||||||
#include "Thing.h"
|
#include "Thing.h"
|
||||||
#include "float16.h"
|
|
||||||
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
|
@ -253,7 +253,8 @@ void Participant::Process(RemoteParticipant* sender, NameMsg* msg) {
|
|||||||
int nameLength = msg->nameLength;
|
int nameLength = msg->nameLength;
|
||||||
int stringLen = nameLength + 1;
|
int stringLen = nameLength + 1;
|
||||||
char* thingName = new char[stringLen];
|
char* thingName = new char[stringLen];
|
||||||
strcpy_s(thingName, stringLen, msg->name);
|
// Use strncpy with bounds checking for other platforms (Arduino, POSIX, ESP-IDF)
|
||||||
|
strncpy(thingName, msg->name, stringLen - 1); // Leave space for null terminator
|
||||||
thingName[nameLength] = '\0';
|
thingName[nameLength] = '\0';
|
||||||
thing->name = thingName;
|
thing->name = thingName;
|
||||||
std::cout << "thing name = " << thing->name << " length = " << nameLength << "\n";
|
std::cout << "thing name = " << thing->name << " length = " << nameLength << "\n";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user