Skip to content

Commit

Permalink
Fix Bluetooth LED during WiFi config
Browse files Browse the repository at this point in the history
  • Loading branch information
nseidle committed Apr 29, 2024
1 parent 1dc5ff7 commit 4ce2435
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
3 changes: 1 addition & 2 deletions Firmware/RTK_Everywhere/Begin.ino
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,7 @@ void tickerBegin()
ledcSetup(ledBtChannel, pwmFreq, pwmResolution);
ledcAttachPin(pin_bluetoothStatusLED, ledBtChannel);
ledcWrite(ledBtChannel, 255); // Turn on BT LED at startup
bluetoothLedTask.detach(); // Turn off any previous task
bluetoothLedTask.attach(bluetoothLedTaskPace2Hz, tickerBluetoothLedUpdate); // Rate in seconds, callback
//Attach happens in bluetoothStart()
}

if (pin_gnssStatusLED != PIN_UNDEFINED)
Expand Down
3 changes: 3 additions & 0 deletions Firmware/RTK_Everywhere/Bluetooth.ino
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ void bluetoothStart()

systemPrintln(deviceName);

bluetoothLedTask.detach(); // Reset BT LED blinker task rate to 2Hz
bluetoothLedTask.attach(bluetoothLedTaskPace2Hz, tickerBluetoothLedUpdate); // Rate in seconds, callback

bluetoothState = BT_NOTCONNECTED;
reportHeapNow(false);
online.bluetooth = true;
Expand Down
30 changes: 14 additions & 16 deletions Firmware/RTK_Everywhere/Tasks.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1115,22 +1115,8 @@ void handleGnssDataTask(void *e)
// This is only called if ticker task is started so no pin tests are done
void tickerBluetoothLedUpdate()
{
// Blink on/off while we wait for BT connection
if (bluetoothGetState() == BT_NOTCONNECTED)
{
if (btFadeLevel == 0)
btFadeLevel = 255;
else
btFadeLevel = 0;
ledcWrite(ledBtChannel, btFadeLevel);
}

// Solid LED if BT Connected
else if (bluetoothGetState() == BT_CONNECTED)
ledcWrite(ledBtChannel, 255);

// Pulse LED while no BT and we wait for WiFi connection
else if (wifiState == WIFI_STATE_CONNECTING || wifiState == WIFI_STATE_CONNECTED)
// If we are in WiFi config mode, fade LED
if (inWiFiConfigMode() == true)
{
// Fade in/out the BT LED during WiFi AP mode
btFadeLevel += pwmFadeAmount;
Expand All @@ -1144,6 +1130,18 @@ void tickerBluetoothLedUpdate()

ledcWrite(ledBtChannel, btFadeLevel);
}
// Blink on/off while we wait for BT connection
else if (bluetoothGetState() == BT_NOTCONNECTED)
{
if (btFadeLevel == 0)
btFadeLevel = 255;
else
btFadeLevel = 0;
ledcWrite(ledBtChannel, btFadeLevel);
}
// Solid LED if BT Connected
else if (bluetoothGetState() == BT_CONNECTED)
ledcWrite(ledBtChannel, 255);
else
ledcWrite(ledBtChannel, 0);
}
Expand Down

0 comments on commit 4ce2435

Please sign in to comment.