Skip to content

Move SERVER_SEARCHING LED status indication to the LEDManager #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/LEDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,28 @@ void LEDManager::update() {
length = SERVER_CONNECTING_INTERVAL;
break;
}
} else {
} else if (statusManager.hasStatus(Status::SERVER_SEARCHING)) {
count = SERVER_SEARCHING_COUNT;
switch (m_CurrentStage)
{
case ON:
case OFF:
length = SERVER_SEARCHING_LENGTH;
break;
case GAP:
length = DEFAULT_GAP;
break;
case INTERVAL:
length = SERVER_SEARCHING_INTERVAL;
break;
}
} else {
#if defined(LED_INTERVAL_STANDBY) && LED_INTERVAL_STANDBY > 0
count = 1;
switch (m_CurrentStage) {
case ON:
case OFF:
length = STANDBUY_LENGTH;
length = STANDBY_LENGTH;
break;
case GAP:
length = DEFAULT_GAP;
Expand Down
5 changes: 4 additions & 1 deletion src/LEDManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define DEFAULT_GAP 500
#define DEFAULT_INTERVAL 3000

#define STANDBUY_LENGTH DEFAULT_LENGTH
#define STANDBY_LENGTH DEFAULT_LENGTH
#define IMU_ERROR_LENGTH DEFAULT_LENGTH
#define IMU_ERROR_INTERVAL 1000
#define IMU_ERROR_COUNT 5
Expand All @@ -42,6 +42,9 @@
#define WIFI_CONNECTING_LENGTH DEFAULT_LENGTH
#define WIFI_CONNECTING_INTERVAL 3000
#define WIFI_CONNECTING_COUNT 3
#define SERVER_SEARCHING_LENGTH 20
#define SERVER_SEARCHING_INTERVAL 1000
#define SERVER_SEARCHING_COUNT 1
#define SERVER_CONNECTING_LENGTH DEFAULT_LENGTH
#define SERVER_CONNECTING_INTERVAL 3000
#define SERVER_CONNECTING_COUNT 2
Expand Down
8 changes: 4 additions & 4 deletions src/network/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,10 @@ void Connection::searchForServer() {

auto now = millis();

// This makes the LED blink for 20ms every second
if (m_LastConnectionAttemptTimestamp + 1000 < now) {
m_LastConnectionAttemptTimestamp = now;
m_Logger.info("Searching for the server on the local network...");
Connection::sendTrackerDiscovery();
ledManager.on();
} else if (m_LastConnectionAttemptTimestamp + 20 < now) {
ledManager.off();
}
}

Expand Down Expand Up @@ -609,8 +605,12 @@ void Connection::reset() {

void Connection::update() {
if (!m_Connected) {
statusManager.setStatus(SlimeVR::Status::SERVER_SEARCHING, true);
searchForServer();
return;
} else
{
statusManager.setStatus(SlimeVR::Status::SERVER_SEARCHING, false);
}

auto& sensors = sensorManager.getSensors();
Expand Down
2 changes: 2 additions & 0 deletions src/status/Status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const char* statusToString(Status status) {
return "IMU_ERROR";
case WIFI_CONNECTING:
return "WIFI_CONNECTING";
case SERVER_SEARCHING:
return "SERVER_SEARCHING";
case SERVER_CONNECTING:
return "SERVER_CONNECTING";
default:
Expand Down
3 changes: 2 additions & 1 deletion src/status/Status.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ enum Status {
LOW_BATTERY = 1 << 1,
IMU_ERROR = 1 << 2,
WIFI_CONNECTING = 1 << 3,
SERVER_CONNECTING = 1 << 4
SERVER_CONNECTING = 1 << 4,
SERVER_SEARCHING = 1 << 5,
};

const char* statusToString(Status status);
Expand Down
Loading