mirror of
https://github.com/SlimeVR/SlimeVR-Tracker-ESP.git
synced 2026-04-06 02:01:57 +02:00
Remove m_Acked... fields from connection
This commit is contained in:
@@ -493,7 +493,7 @@ void Connection::updateSensorState(std::vector<std::unique_ptr<Sensor>>& sensors
|
||||
m_LastSensorInfoPacketTimestamp = millis();
|
||||
|
||||
for (int i = 0; i < (int)sensors.size(); i++) {
|
||||
if (isSensorStateUpdated(i, sensors[i])) {
|
||||
if (sensors[i]->isStateUpdated()) {
|
||||
sendSensorInfo(*sensors[i]);
|
||||
}
|
||||
}
|
||||
@@ -513,14 +513,6 @@ void Connection::maybeRequestFeatureFlags() {
|
||||
m_FeatureFlagsRequestAttempts++;
|
||||
}
|
||||
|
||||
bool Connection::isSensorStateUpdated(int i, std::unique_ptr<Sensor>& sensor) {
|
||||
return sensor->isStateUpdated(
|
||||
m_AckedSensorState[i],
|
||||
m_AckedSensorCalibration[i],
|
||||
m_AckedSensorConfigData[i]
|
||||
);
|
||||
}
|
||||
|
||||
void Connection::searchForServer() {
|
||||
while (true) {
|
||||
int packetSize = m_UDP.parsePacket();
|
||||
@@ -586,21 +578,10 @@ void Connection::searchForServer() {
|
||||
|
||||
void Connection::reset() {
|
||||
m_Connected = false;
|
||||
std::fill(
|
||||
m_AckedSensorState,
|
||||
m_AckedSensorState + MAX_SENSORS_COUNT,
|
||||
SensorStatus::SENSOR_OFFLINE
|
||||
);
|
||||
std::fill(
|
||||
m_AckedSensorCalibration,
|
||||
m_AckedSensorCalibration + MAX_SENSORS_COUNT,
|
||||
false
|
||||
);
|
||||
std::fill(
|
||||
m_AckedSensorConfigData,
|
||||
m_AckedSensorConfigData + MAX_SENSORS_COUNT,
|
||||
SlimeVR::Configuration::SensorConfigBits{}
|
||||
);
|
||||
|
||||
for (auto& sensor : sensorManager.getSensors()) {
|
||||
sensor->resetAckedState();
|
||||
}
|
||||
|
||||
m_UDP.begin(m_ServerPort);
|
||||
|
||||
@@ -622,16 +603,9 @@ void Connection::update() {
|
||||
statusManager.setStatus(SlimeVR::Status::SERVER_CONNECTING, true);
|
||||
|
||||
m_Connected = false;
|
||||
std::fill(
|
||||
m_AckedSensorState,
|
||||
m_AckedSensorState + MAX_SENSORS_COUNT,
|
||||
SensorStatus::SENSOR_OFFLINE
|
||||
);
|
||||
std::fill(
|
||||
m_AckedSensorCalibration,
|
||||
m_AckedSensorCalibration + MAX_SENSORS_COUNT,
|
||||
false
|
||||
);
|
||||
for (auto& sensor : sensorManager.getSensors()) {
|
||||
sensor->resetAckedState();
|
||||
}
|
||||
m_Logger.warn("Connection to server timed out");
|
||||
|
||||
return;
|
||||
@@ -691,15 +665,19 @@ void Connection::update() {
|
||||
|
||||
for (int i = 0; i < (int)sensors.size(); i++) {
|
||||
if (sensorInfoPacket.sensorId == sensors[i]->getSensorId()) {
|
||||
m_AckedSensorState[i] = sensorInfoPacket.sensorState;
|
||||
if (len < 12) {
|
||||
m_AckedSensorCalibration[i]
|
||||
= sensors[i]->hasCompletedRestCalibration();
|
||||
m_AckedSensorConfigData[i] = sensors[i]->getSensorConfigData();
|
||||
sensors[i]->signalAckedStateUpdate(
|
||||
sensorInfoPacket.sensorState,
|
||||
sensors[i]->hasCompletedRestCalibration(),
|
||||
sensors[i]->getSensorConfigData()
|
||||
);
|
||||
break;
|
||||
}
|
||||
m_AckedSensorCalibration[i]
|
||||
= sensorInfoPacket.hasCompletedRestCalibration;
|
||||
sensors[i]->signalAckedStateUpdate(
|
||||
sensorInfoPacket.sensorState,
|
||||
sensorInfoPacket.hasCompletedRestCalibration,
|
||||
sensorInfoPacket.sensorConfigData
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,6 @@ public:
|
||||
private:
|
||||
void updateSensorState(std::vector<std::unique_ptr<::Sensor>>& sensors);
|
||||
void maybeRequestFeatureFlags();
|
||||
bool isSensorStateUpdated(int i, std::unique_ptr<::Sensor>& sensor);
|
||||
|
||||
bool beginPacket();
|
||||
bool endPacket();
|
||||
|
||||
@@ -48,13 +48,7 @@ public:
|
||||
return SensorStatus::SENSOR_OFFLINE;
|
||||
};
|
||||
|
||||
bool isStateUpdated(
|
||||
SensorStatus ackedState,
|
||||
bool ackedCalibration,
|
||||
SlimeVR::Configuration::SensorConfigBits ackedConfig
|
||||
) final {
|
||||
return false;
|
||||
}
|
||||
bool isStateUpdated() final { return false; }
|
||||
};
|
||||
} // namespace SlimeVR::Sensors
|
||||
|
||||
|
||||
@@ -167,11 +167,7 @@ void Sensor::setFlag(SensorToggles toggle, bool state) {
|
||||
motionSetup();
|
||||
}
|
||||
|
||||
bool Sensor::isStateUpdated(
|
||||
SensorStatus ackedState,
|
||||
bool ackedCalibration,
|
||||
SlimeVR::Configuration::SensorConfigBits ackedConfig
|
||||
) {
|
||||
bool Sensor::isStateUpdated() {
|
||||
if (sensorType == SensorTypeID::Unknown) {
|
||||
// Shouldn't be possible, but better safe than sorry
|
||||
return false;
|
||||
@@ -181,3 +177,19 @@ bool Sensor::isStateUpdated(
|
||||
|| ackedCalibration != hasCompletedRestCalibration()
|
||||
|| ackedConfig != getSensorConfigData();
|
||||
}
|
||||
|
||||
void Sensor::signalAckedStateUpdate(
|
||||
SensorStatus ackedState,
|
||||
bool ackedCalibration,
|
||||
SlimeVR::Configuration::SensorConfigBits ackedConfig
|
||||
) {
|
||||
this->ackedState = ackedState;
|
||||
this->ackedCalibration = ackedCalibration;
|
||||
this->ackedConfig = ackedConfig;
|
||||
}
|
||||
|
||||
void Sensor::resetAckedState() {
|
||||
this->ackedState = SensorStatus::SENSOR_OFFLINE;
|
||||
this->ackedCalibration = false;
|
||||
this->ackedConfig = {};
|
||||
}
|
||||
|
||||
@@ -104,11 +104,13 @@ public:
|
||||
return SensorDataType::SENSOR_DATATYPE_ROTATION;
|
||||
};
|
||||
|
||||
virtual bool isStateUpdated(
|
||||
virtual bool isStateUpdated();
|
||||
void signalAckedStateUpdate(
|
||||
SensorStatus ackedState,
|
||||
bool ackedCalibration,
|
||||
SlimeVR::Configuration::SensorConfigBits ackedConfig
|
||||
);
|
||||
void resetAckedState();
|
||||
|
||||
SensorPosition getSensorPosition() { return m_SensorPosition; };
|
||||
|
||||
@@ -145,6 +147,10 @@ protected:
|
||||
|
||||
mutable SlimeVR::Logging::Logger m_Logger;
|
||||
|
||||
SensorStatus ackedState = SensorStatus::SENSOR_OFFLINE;
|
||||
bool ackedCalibration = false;
|
||||
SlimeVR::Configuration::SensorConfigBits ackedConfig = {};
|
||||
|
||||
private:
|
||||
void printTemperatureCalibrationUnsupported();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user