From f20ebd7ad2d869903d9ced2e733c10baf673c5d9 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Fri, 27 Jun 2025 17:12:42 +0200 Subject: [PATCH] Switch to MPU6050, finally getting good data --- Participants/ParticipantUDP.cpp | 114 ++------------------------------ Participants/ParticipantUDP.h | 2 +- 2 files changed, 8 insertions(+), 108 deletions(-) diff --git a/Participants/ParticipantUDP.cpp b/Participants/ParticipantUDP.cpp index 1fdb695..e806493 100644 --- a/Participants/ParticipantUDP.cpp +++ b/Participants/ParticipantUDP.cpp @@ -118,32 +118,9 @@ RemoteParticipantUDP::RemoteParticipantUDP(const char* ipAddress, int port) { } bool RemoteParticipantUDP::Send(IMessage* msg) { - int bufferSize = msg->Serialize(this->buffer); - if (bufferSize <= 0) - return true; - - // std::cout << "send msg " << (static_cast(this->buffer[0]) & 0xff) - // << " to " << this->ipAddress << std::endl; - - // #if defined(_WIN32) || defined(_WIN64) - // Windows::ParticipantUDP* thisWindows = - // static_cast(this); - // return thisWindows->SendTo(this, bufferSize); - // #elif defined(__unix__) || defined(__APPLE__) - // Posix::ParticipantUDP* thisPosix = - // static_cast(this); return thisPosix->SendTo(this, - // bufferSize); - // #elif defined(ARDUINO) - // Arduino::ParticipantUDP* thisArduino = - // static_cast(this); - // return thisArduino->SendTo(this, bufferSize); - // #elif defined(IDF_VER) - // EspIdf::ParticipantUDP* thisEspIdf = - // static_cast(this); - // return thisEspIdf->SendTo(this, bufferSize); - // #else + // No message is actually sent, because this class has no networking + // implementation return false; - // #endif } #pragma region Init @@ -192,30 +169,6 @@ void ParticipantUDPGeneric::begin() { SetupUDP(this->port, this->remoteSite->ipAddress, this->remoteSite->port); } -/* -void ParticipantUDPGeneric::SetupUDP(int localPort, - const char* remoteIpAddress, - int remotePort) { -#if defined(_WIN32) || defined(_WIN64) - Windows::ParticipantUDP* thisWindows = - static_cast(this); - thisWindows->Setup(localPort, remoteIpAddress, remotePort); -#elif defined(__unix__) || defined(__APPLE__) - Posix::ParticipantUDP* thisPosix = static_cast(this); - thisPosix->Setup(localPort, remoteIpAddress, remotePort); -#elif defined(ARDUINO) - Arduino::ParticipantUDP* thisArduino = - static_cast(this); - thisArduino->Setup(); -#elif defined(IDF_VER) - EspIdf::ParticipantUDP* thisEspIdf = - static_cast(this); - thisEspIdf->Setup(localPort, remoteIpAddress, remotePort); -#endif - this->connected = true; -} - */ - #pragma endregion Init #pragma region Update @@ -231,14 +184,9 @@ void ParticipantUDPGeneric::Update(bool recurse) { if (this->connected == false) begin(); - ParticipantUDP* thisEspIdf = - static_cast(this); - // thisEspIdf->SendTest(); - if (this->publishInterval > 0 && currentTimeMs > this->nextPublishMe) { ParticipantMsg* msg = new ParticipantMsg(this->networkId); - // thisEspIdf->SendTest(); if (this->remoteSite == nullptr) this->Publish(msg); else @@ -248,22 +196,19 @@ void ParticipantUDPGeneric::Update(bool recurse) { this->nextPublishMe = currentTimeMs + this->publishInterval; } - // this->ReceiveUDP(); + this->ReceiveUDP(); } - // UpdateMyThings(); - // UpdateOtherThings(); + UpdateMyThings(); + UpdateOtherThings(); } void ParticipantUDPGeneric::UpdateMyThings() { - std::cout << "# things = " << this->things.size() << std::endl; for (Thing* thing : this->things) { - std::cout << ".\n"; if (thing == nullptr) // || thing->GetParent() != nullptr) continue; - std::cout << (int)this->root << std::endl; - std::cout << thing->name << std::endl; - // Why don't we do recursive? + + // Why don't we do recursive? // Because when a thing creates a thing in the update, // that new thing is not sent out (because of hierarchyChanged) // before it is updated itself: it is immediatedly updated! @@ -356,56 +301,11 @@ void ParticipantUDPGeneric::PublishThingInfo(Thing* thing) { delete customMsg; } -/* -bool ParticipantUDPGeneric::Publish(IMessage* msg) { - // std::cout << "publish msg\n"; -#if defined(_WIN32) || defined(_WIN64) - Windows::ParticipantUDP* thisWindows = - static_cast(this); - return thisWindows->Publish(msg); -#elif defined(__unix__) || defined(__APPLE__) - Posix::ParticipantUDP* thisPosix = static_cast(this); - return thisPosix->Publish(msg); -#elif defined(ARDUINO) - Arduino::ParticipantUDP* thisArduino = - static_cast(this); - return thisArduino->Publish(msg); -#elif defined(IDF_VER) - EspIdf::ParticipantUDP* thisEspIdf = - static_cast(this); - return thisEspIdf->Publish(msg); -#else - return false; -#endif -} -*/ - // Send #pragma endregion #pragma region Receive -/* -void ParticipantUDPGeneric::ReceiveUDP() { -#if defined(_WIN32) || defined(_WIN64) - Windows::ParticipantUDP* thisWindows = - static_cast(this); - thisWindows->Receive(); -#elif defined(__unix__) || defined(__APPLE__) - Posix::ParticipantUDP* thisPosix = static_cast(this); - thisPosix->Receive(); -#elif defined(ARDUINO) - Arduino::ParticipantUDP* thisArduino = - static_cast(this); - thisArduino->Receive(); -#elif defined(IDF_VER) - EspIdf::ParticipantUDP* thisEspIdf = - static_cast(this); - thisEspIdf->Receive(); -#endif -} -*/ - void ParticipantUDPGeneric::ReceiveData(unsigned char packetSize, char* senderIpAddress, unsigned int senderPort) { diff --git a/Participants/ParticipantUDP.h b/Participants/ParticipantUDP.h index 3e60a01..159062e 100644 --- a/Participants/ParticipantUDP.h +++ b/Participants/ParticipantUDP.h @@ -181,7 +181,7 @@ class ParticipantUDPGeneric : public RemoteParticipantUDP { void SendThingInfo(Participant* remoteParticipant, Thing* thing); void PublishThingInfo(Thing* thing); - virtual bool Send(IMessage* msg); + virtual bool Send(IMessage* msg) override; virtual bool Publish(IMessage* msg) = 0; #pragma endregion Send