Switch to MPU6050, finally getting good data
This commit is contained in:
parent
8901e6933a
commit
f20ebd7ad2
@ -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<int>(this->buffer[0]) & 0xff)
|
||||
// << " to " << this->ipAddress << std::endl;
|
||||
|
||||
// #if defined(_WIN32) || defined(_WIN64)
|
||||
// Windows::ParticipantUDP* thisWindows =
|
||||
// static_cast<Windows::ParticipantUDP*>(this);
|
||||
// return thisWindows->SendTo(this, bufferSize);
|
||||
// #elif defined(__unix__) || defined(__APPLE__)
|
||||
// Posix::ParticipantUDP* thisPosix =
|
||||
// static_cast<Posix::ParticipantUDP*>(this); return thisPosix->SendTo(this,
|
||||
// bufferSize);
|
||||
// #elif defined(ARDUINO)
|
||||
// Arduino::ParticipantUDP* thisArduino =
|
||||
// static_cast<Arduino::ParticipantUDP*>(this);
|
||||
// return thisArduino->SendTo(this, bufferSize);
|
||||
// #elif defined(IDF_VER)
|
||||
// EspIdf::ParticipantUDP* thisEspIdf =
|
||||
// static_cast<EspIdf::ParticipantUDP*>(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<Windows::ParticipantUDP*>(this);
|
||||
thisWindows->Setup(localPort, remoteIpAddress, remotePort);
|
||||
#elif defined(__unix__) || defined(__APPLE__)
|
||||
Posix::ParticipantUDP* thisPosix = static_cast<Posix::ParticipantUDP*>(this);
|
||||
thisPosix->Setup(localPort, remoteIpAddress, remotePort);
|
||||
#elif defined(ARDUINO)
|
||||
Arduino::ParticipantUDP* thisArduino =
|
||||
static_cast<Arduino::ParticipantUDP*>(this);
|
||||
thisArduino->Setup();
|
||||
#elif defined(IDF_VER)
|
||||
EspIdf::ParticipantUDP* thisEspIdf =
|
||||
static_cast<EspIdf::ParticipantUDP*>(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<ParticipantUDP*>(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,21 +196,18 @@ 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?
|
||||
// Because when a thing creates a thing in the update,
|
||||
// that new thing is not sent out (because of hierarchyChanged)
|
||||
@ -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<Windows::ParticipantUDP*>(this);
|
||||
return thisWindows->Publish(msg);
|
||||
#elif defined(__unix__) || defined(__APPLE__)
|
||||
Posix::ParticipantUDP* thisPosix = static_cast<Posix::ParticipantUDP*>(this);
|
||||
return thisPosix->Publish(msg);
|
||||
#elif defined(ARDUINO)
|
||||
Arduino::ParticipantUDP* thisArduino =
|
||||
static_cast<Arduino::ParticipantUDP*>(this);
|
||||
return thisArduino->Publish(msg);
|
||||
#elif defined(IDF_VER)
|
||||
EspIdf::ParticipantUDP* thisEspIdf =
|
||||
static_cast<EspIdf::ParticipantUDP*>(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<Windows::ParticipantUDP*>(this);
|
||||
thisWindows->Receive();
|
||||
#elif defined(__unix__) || defined(__APPLE__)
|
||||
Posix::ParticipantUDP* thisPosix = static_cast<Posix::ParticipantUDP*>(this);
|
||||
thisPosix->Receive();
|
||||
#elif defined(ARDUINO)
|
||||
Arduino::ParticipantUDP* thisArduino =
|
||||
static_cast<Arduino::ParticipantUDP*>(this);
|
||||
thisArduino->Receive();
|
||||
#elif defined(IDF_VER)
|
||||
EspIdf::ParticipantUDP* thisEspIdf =
|
||||
static_cast<EspIdf::ParticipantUDP*>(this);
|
||||
thisEspIdf->Receive();
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
||||
void ParticipantUDPGeneric::ReceiveData(unsigned char packetSize,
|
||||
char* senderIpAddress,
|
||||
unsigned int senderPort) {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user