Skip to content

Commit

Permalink
Fix plugin compilation errors and some minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
obasille committed Aug 5, 2024
1 parent daf4620 commit 8d3bb72
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Default Doxyfile build documentation to html directory.
# Change the directory if changes in Doxyfile
# Overrides the directory specified in Doxyfile
publish_dir: ./doc/html
6 changes: 3 additions & 3 deletions Assets/Systemic/Examples/Scripts/BleConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ IEnumerator Start()
yield return null;

Debug.Log("Waiting for Central to be ready...");
while (!Central.IsReady)
while (Central.Status != BluetoothStatus.Ready)
{
yield return null;
}
Expand All @@ -49,15 +49,15 @@ IEnumerator Start()
Debug.Log("Scanning for Pixels...");

// Filter peripherals with the Pixel service UUID
Central.ScanForPeripheralsWithServices(new[] { PixelBleUuids.Service });
Central.StartScanning(new[] { PixelBleUuids.Service });

// Wait until a Pixel is found
while (Central.ScannedPeripherals.Length == 0)
{
yield return null;
}

Central.StopScan();
Central.StopScanning();

Debug.Log($"Found {Central.ScannedPeripherals.Length} Pixels");

Expand Down
17 changes: 9 additions & 8 deletions Assets/Systemic/Examples/Scripts/BleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,18 @@ void OnDisable()
void Update()
{
// Update buttons intractability based on Bluetooth state
_startScanBtn.interactable = Central.IsReady && !Central.IsScanning;
_stopScanBtn.interactable = Central.IsReady && Central.IsScanning;
_connectBtn.interactable = Central.IsReady && (Central.ScannedPeripherals.Length > 0) && (!_peripheralIsConnected);
_shutdownBtn.interactable = Central.IsReady;
bool isReady = Central.Status == BluetoothStatus.Ready;
_startScanBtn.interactable = isReady && !Central.IsScanning;
_stopScanBtn.interactable = isReady && Central.IsScanning;
_connectBtn.interactable = isReady && (Central.ScannedPeripherals.Length > 0) && (!_peripheralIsConnected);
_shutdownBtn.interactable = isReady;
foreach (var btn in _operationsBtn)
{
btn.interactable = Central.IsReady && (_peripheral != null) && _peripheralIsConnected;
btn.interactable = isReady && (_peripheral != null) && _peripheralIsConnected;
}

// Update status text
_statusText.text = Central.IsReady ? (Central.IsScanning ? "Scanning" : "Ready") : "Unavailable";
_statusText.text = isReady ? (Central.IsScanning ? "Scanning" : "Ready") : "Unavailable";
if (Central.ScannedPeripherals.Length > 0)
{
_statusText.text += $"- Found {Central.ScannedPeripherals.Length} Pixel(s)";
Expand All @@ -115,15 +116,15 @@ void Update()
public void StartScan()
{
// Filter peripherals with the Pixel service UUID
Central.ScanForPeripheralsWithServices(new[] { PixelBleUuids.Service });
Central.StartScanning(new[] { PixelBleUuids.Service });
}

/// <summary>
/// Stops an on-going scan, if any.
/// </summary>
public void StopScan()
{
Central.StopScan();
Central.StopScanning();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Assets/Systemic/Examples/Scripts/UIPixelPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void AttachToPixel(Pixel pixel)
if (Pixel != pixel)
{
Pixel = pixel;
Pixel.ConnectionStateChanged += (pixel, oldState, newState) =>
Pixel.ConnectionStateChanged += (pixel, newState) =>
{
if (newState == PixelConnectionState.Ready)
{
Expand Down
8 changes: 4 additions & 4 deletions Assets/Systemic/Tests/CentralTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ IEnumerator WaitUntilWithTimeout(Func<bool> condition, float timeoutSec = 5)

IEnumerator WaitCentralReady()
{
yield return WaitUntilWithTimeout(() => Central.IsReady);
Assert.IsTrue(Central.IsReady, "Central not ready");
yield return WaitUntilWithTimeout(() => Central.Status == BluetoothStatus.Ready);
Assert.IsTrue(Central.Status == BluetoothStatus.Ready, "Central not ready");
}

IEnumerator SelectPeripheral()
{
Central.ScanForPeripheralsWithServices(new[] { PixelBleUuids.Service });
Central.StartScanning(new[] { PixelBleUuids.Service });
yield return WaitUntilWithTimeout(() =>
{
_peripheral = Central.ScannedPeripherals.FirstOrDefault(p => p.Services.Contains(PixelBleUuids.Service));
return _peripheral != null;
});
Central.StopScan();
Central.StopScanning();
Assert.NotNull(_peripheral, "No Pixel peripheral found");
}

Expand Down
3 changes: 1 addition & 2 deletions WinRTBle/src/LibWinRTBle/Systemic/BluetoothLE/Scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Systemic::BluetoothLE
using BluetoothLEAdvertisementWatcherStoppedEventArgs = winrt::Windows::Devices::Bluetooth::Advertisement::BluetoothLEAdvertisementWatcherStoppedEventArgs;

// Watcher and its event tokens
BluetoothLEAdvertisementWatcher _watcher{ nullptr };
BluetoothLEAdvertisementWatcher _watcher{};
winrt::event_token _receivedToken{};
winrt::event_token _stoppedToken{};

Expand Down Expand Up @@ -55,7 +55,6 @@ namespace Systemic::BluetoothLE
std::function<void(std::shared_ptr<ScannedPeripheral>)> peripheralDiscovered,
std::vector<winrt::guid> services = std::vector<winrt::guid>{})
:
_watcher{},
_requestedServices{ services },
_onPeripheralDiscovered{ peripheralDiscovered }
{
Expand Down

0 comments on commit 8d3bb72

Please sign in to comment.