Skip to content

Commit

Permalink
Some build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Eirenliel authored and TheDevMinerTV committed Mar 26, 2024
1 parent b89ab7d commit 3bd4959
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
21 changes: 14 additions & 7 deletions src/network/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bool Connection::endPacket() {
MUST_TRANSFER_BOOL((innerPacketSize > 0));

m_IsBundle = false;

if (m_BundlePacketInnerCount == 0) {
sendPacketType(PACKET_BUNDLE);
sendPacketNumber();
Expand Down Expand Up @@ -128,7 +128,7 @@ bool Connection::endBundle() {
MUST_TRANSFER_BOOL(m_IsBundle);

m_IsBundle = false;

MUST_TRANSFER_BOOL((m_BundlePacketInnerCount > 0));

return endPacket();
Expand Down Expand Up @@ -540,7 +540,7 @@ void Connection::updateSensorState(std::vector<Sensor *> & sensors) {
}
}

void Connection::maybeRequestFeatureFlags() {
void Connection::maybeRequestFeatureFlags() {
if (m_ServerFeatures.isAvailable() || m_FeatureFlagsRequestAttempts >= 15) {
return;
}
Expand Down Expand Up @@ -572,6 +572,8 @@ void Connection::searchForServer() {
m_UDP.remotePort()
);
m_Logger.traceArray("UDP packet contents: ", m_Packet, len);
#else
(void)len;
#endif

// Handshake is different, it has 3 in the first byte, not the 4th, and data
Expand All @@ -586,7 +588,7 @@ void Connection::searchForServer() {
m_ServerPort = m_UDP.remotePort();
m_LastPacketTimestamp = millis();
m_Connected = true;

m_FeatureFlagsRequestAttempts = 0;
m_ServerFeatures = ServerFeatures { };

Expand Down Expand Up @@ -704,15 +706,15 @@ void Connection::update() {

break;

case PACKET_FEATURE_FLAGS:
case PACKET_FEATURE_FLAGS: {
// Packet type (4) + Packet number (8) + flags (len - 12)
if (len < 13) {
m_Logger.warn("Invalid feature flags packet: too short");
break;
}

bool hadFlags = m_ServerFeatures.isAvailable();

uint32_t flagsLength = len - 12;
m_ServerFeatures = ServerFeatures::from(&m_Packet[12], flagsLength);

Expand All @@ -725,7 +727,9 @@ void Connection::update() {
}

break;
case PACKET_SET_CONFIG_FLAG:
}

case PACKET_SET_CONFIG_FLAG: {
// Packet type (4) + Packet number (8) + sensor_id(1) + flag_id (2) + state (1)
if (len < 16) {
m_Logger.warn("Invalid sensor config flag packet: too short");
Expand All @@ -740,9 +744,12 @@ void Connection::update() {
std::vector<Sensor *> & sensors = sensorManager.getSensors();
if(sensorId < sensors.size()) {
Sensor * sensor = sensors[sensorId];
sensor->setFlag(flagId, newState);
}
}
sendAcknowledgeConfigChange(sensorId, flagId);
break;
}
}
}

Expand Down
18 changes: 11 additions & 7 deletions src/sensors/bno080sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void BNO080Sensor::motionSetup()
break;
default:
// Ignore lack of config for BNO, byt default use from FW build
break;
}

if(!m_magEnabled) {
Expand Down Expand Up @@ -132,7 +133,7 @@ void BNO080Sensor::motionLoop()

setFusedRotationReady();
// Leave new quaternion if context open, it's closed later

}
} else {

if (imu.hasNewQuat()) // New quaternion if context
Expand All @@ -142,6 +143,7 @@ void BNO080Sensor::motionLoop()

setFusedRotationReady();
// Leave new quaternion if context open, it's closed later
} // Closing new quaternion if context
}

// Continuation of the new quaternion if context, used for both 6 and 9 axis
Expand All @@ -152,9 +154,9 @@ void BNO080Sensor::motionLoop()
setAccelerationReady();
}
#endif // SEND_ACCELERATION
} // Closing new quaternion if context

if(BNO_USE_MAGNETOMETER_CORRECTION && !m_magEnabled) {

#if BNO_USE_MAGNETOMETER_CORRECTION
if(!m_magEnabled) {
if (imu.hasNewMagQuat())
{
imu.getMagQuat(magQuaternion.x, magQuaternion.y, magQuaternion.z, magQuaternion.w, magneticAccuracyEstimate, magCalibrationAccuracy);
Expand All @@ -169,6 +171,7 @@ void BNO080Sensor::motionLoop()
newMagData = true;
}
}
#endif

if (imu.getTapDetected())
{
Expand Down Expand Up @@ -203,7 +206,8 @@ void BNO080Sensor::motionLoop()
}
}

SensorStatus BNO080Sensor::getSensorState() {
SensorStatus BNO080Sensor::getSensorState()
{
return lastReset > 0 ? SensorStatus::SENSOR_ERROR : isWorking() ? SensorStatus::SENSOR_OK : SensorStatus::SENSOR_OFFLINE;
}

Expand Down Expand Up @@ -247,11 +251,11 @@ void BNO080Sensor::sendData()
}
}

void BNO080Sensor::setFlag(uint16_t flagId, bool state) {
void BNO080Sensor::setFlag(uint16_t flagId, bool state)
{
if(flagId == FLAG_SENSOR_BNO0XX_MAG_ENABLED) {
m_Calibration.magEnabled = state;
m_magEnabled = state;
configuration.setCalibration(sensorId, m_Calibration);
if(state) {
if ((sensorType == IMU_BNO085 || sensorType == IMU_BNO086) && BNO_USE_ARVR_STABILIZATION) {
imu.enableARVRStabilizedRotationVector(10);
Expand Down

0 comments on commit 3bd4959

Please sign in to comment.