Skip to content

Add toggle option for Bluetooth command - #2

Open
jeregon1 wants to merge 1 commit into
rafarrw:mainfrom
jeregon1:main
Open

Add toggle option for Bluetooth command#2
jeregon1 wants to merge 1 commit into
rafarrw:mainfrom
jeregon1:main

Conversation

@jeregon1

@jeregon1 jeregon1 commented Jan 5, 2026

Copy link
Copy Markdown

Adresses Issue #1

Copilot AI review requested due to automatic review settings January 5, 2026 12:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a "toggle" command option to the Bluetooth manager application, allowing users to switch Bluetooth state without specifying the target state explicitly.

  • Added "toggle" as a valid command-line argument alongside existing "on" and "off" options
  • Implemented toggle logic that switches Bluetooth state based on current state
  • Updated usage message and comments to reflect the new toggle command

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Program.cs
var newState = bluetoothRadio.State == RadioState.On ? RadioState.Off : RadioState.On;
await bluetoothRadio.SetStateAsync(newState);
Console.WriteLine($"Bluetooth was toggled to {(newState == RadioState.On ? "on" : "off")} successfully.");
}

Copilot AI Jan 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is trailing whitespace at the end of this line. This should be removed for consistency and to follow best practices.

Suggested change
}
}

Copilot uses AI. Check for mistakes.
Comment thread Program.cs
}
else if (command == "toggle")
{
var newState = bluetoothRadio.State == RadioState.On ? RadioState.Off : RadioState.On;

Copilot AI Jan 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The toggle logic doesn't handle intermediate states. The bluetooth radio could be in states other than On or Off (such as Unknown or Disabled). If bluetoothRadio.State is not RadioState.On, the code will attempt to turn it On, which may not be the intended behavior for all states. Consider checking if the current state is valid before toggling.

Suggested change
var newState = bluetoothRadio.State == RadioState.On ? RadioState.Off : RadioState.On;
var currentState = bluetoothRadio.State;
if (currentState != RadioState.On && currentState != RadioState.Off)
{
Console.WriteLine($"Bluetooth cannot be toggled from the current state: {currentState}.");
return;
}
var newState = currentState == RadioState.On ? RadioState.Off : RadioState.On;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants