Skip to content
Snippets Groups Projects
Commit cb5cf7d9 authored by Paul-Winpenny's avatar Paul-Winpenny
Browse files

Working on the uni wifi

parent 0bcc1120
No related branches found
No related tags found
1 merge request!1App now has a basic structure and BLE support
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
<Capabilities> <Capabilities>
<rescap:Capability Name="runFullTrust" /> <rescap:Capability Name="runFullTrust" />
<DeviceCapability Name="bluetooth" />
</Capabilities> </Capabilities>
</Package> </Package>
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PropertyGroup> <TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks> <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks> <OutputType>Exe</OutputType>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET --> <RootNamespace>MauiApp1</RootNamespace>
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> --> <UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<!-- Note for MacCatalyst: <ImplicitUsings>enable</ImplicitUsings>
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64. <Nullable>enable</Nullable>
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>. <ApplicationTitle>MauiApp1</ApplicationTitle>
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated; <ApplicationId>com.companyname.mauiapp1</ApplicationId>
either BOTH runtimes must be indicated or ONLY macatalyst-x64. --> <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> --> <ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<OutputType>Exe</OutputType> <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<RootNamespace>RobobinApp</RootNamespace> <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<UseMaui>true</UseMaui> <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<SingleProject>true</SingleProject> <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<ImplicitUsings>enable</ImplicitUsings> <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<Nullable>enable</Nullable> </PropertyGroup>
<!-- Display name --> <ItemGroup>
<ApplicationTitle>RobobinApp</ApplicationTitle> <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!-- App Identifier --> <MauiImage Include="Resources\Images\*" />
<ApplicationId>com.companyname.robobinapp</ApplicationId> <MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
<MauiFont Include="Resources\Fonts\*" />
<!-- Versions --> <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> </ItemGroup>
<ApplicationVersion>1</ApplicationVersion>
<ItemGroup>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion> <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion> <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.91" />
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion> <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.91" />
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion> <PackageReference Include="Microsoft.Maui.Essentials" Version="8.0.91" />
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion> <PackageReference Include="Microsoft.Maui.Resizetizer" Version="8.0.91" />
</PropertyGroup> <PackageReference Include="Plugin.BLE" Version="3.1.0" />
<PackageReference Include="Shiny" Version="2.7.3" />
<ItemGroup> <PackageReference Include="Shiny.BluetoothLE" Version="3.3.3" />
<!-- App Icon --> <PackageReference Include="Shiny.Hosting.Maui" Version="3.3.3" />
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" /> </ItemGroup>
<!-- Splash Screen --> <ItemGroup>
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" /> <Compile Update="LeftBox.xaml.cs">
<DependentUpon>LeftBox.xaml</DependentUpon>
<!-- Images --> </Compile>
<MauiImage Include="Resources\Images\*" /> <Compile Update="Views\ConnectionPage.xaml.cs">
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" /> <DependentUpon>ConnectionPage.xaml</DependentUpon>
</Compile>
<!-- Custom Fonts --> </ItemGroup>
<MauiFont Include="Resources\Fonts\*" />
<ItemGroup>
<!-- Raw Assets (also remove the "Resources\Raw" prefix) --> <MauiXaml Update="LeftBox.xaml">
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" /> <Generator>MSBuild:Compile</Generator>
</ItemGroup> </MauiXaml>
<MauiXaml Update="Views\ConnectionPage.xaml">
<ItemGroup> <Generator>MSBuild:Compile</Generator>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" /> </MauiXaml>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.91" /> </ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.91" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
<PackageReference Include="Microsoft.Maui.Essentials" Version="8.0.91" />
<PackageReference Include="Plugin.BLE" Version="3.1.0" />
<PackageReference Include="Shiny" Version="2.7.3" />
<PackageReference Include="Shiny.BluetoothLE" Version="3.3.3" />
<PackageReference Include="Shiny.Hosting.Maui" Version="3.3.3" />
</ItemGroup>
<ItemGroup>
<Compile Update="LeftBox.xaml.cs">
<DependentUpon>LeftBox.xaml</DependentUpon>
</Compile>
<Compile Update="Views\ConnectionPage.xaml.cs">
<DependentUpon>ConnectionPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<MauiXaml Update="LeftBox.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\ConnectionPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
</Project> </Project>
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen> <IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
<ActiveDebugFramework>net8.0-android</ActiveDebugFramework> <ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework>
<ActiveDebugProfile>Pixel 5 - API 34 (Android 14.0 - API 34)</ActiveDebugProfile> <ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
<SelectedPlatformGroup>Emulator</SelectedPlatformGroup> <SelectedPlatformGroup>Emulator</SelectedPlatformGroup>
<DefaultDevice>pixel_5_-_api_34</DefaultDevice> <DefaultDevice>pixel_5_-_api_34</DefaultDevice>
</PropertyGroup> </PropertyGroup>
......
...@@ -118,18 +118,17 @@ namespace RobobinApp.ViewModels ...@@ -118,18 +118,17 @@ namespace RobobinApp.ViewModels
// New method to handle discovered devices // New method to handle discovered devices
private void OnDeviceDiscovered(object sender, DeviceEventArgs e) private void OnDeviceDiscovered(object sender, DeviceEventArgs e)
{ {
Debug.WriteLine($"Discovered device: {e.Device.Name} ({e.Device.Id})"); Debug.WriteLine($"Discovered device: ID={e.Device.Id}, Name={e.Device.Name}, State={e.Device.State}, RSSI={e.Device.Rssi}");
var bluetoothDevice = new BluetoothDevice var bluetoothDevice = new BluetoothDevice
{ {
Name = e.Device.Name, Name = string.IsNullOrWhiteSpace(e.Device.Name) ? e.Device.Id.ToString() : e.Device.Name,
MacAddress = e.Device.Id.ToString() // Ensure this aligns with how you handle MAC addresses MacAddress = e.Device.Id.ToString()
}; };
// Check if the device is already in the list to avoid duplicates
if (!BluetoothDevices.Any(d => d.MacAddress == bluetoothDevice.MacAddress)) if (!BluetoothDevices.Any(d => d.MacAddress == bluetoothDevice.MacAddress))
{ {
// Use the Device.BeginInvokeOnMainThread to add the device on the UI thread
Device.BeginInvokeOnMainThread(() => Device.BeginInvokeOnMainThread(() =>
{ {
BluetoothDevices.Add(bluetoothDevice); BluetoothDevices.Add(bluetoothDevice);
...@@ -140,6 +139,7 @@ namespace RobobinApp.ViewModels ...@@ -140,6 +139,7 @@ namespace RobobinApp.ViewModels
private async void OnConnect() private async void OnConnect()
{ {
if (SelectedDevice == null) if (SelectedDevice == null)
...@@ -184,4 +184,4 @@ namespace RobobinApp.ViewModels ...@@ -184,4 +184,4 @@ namespace RobobinApp.ViewModels
public string Name { get; set; } public string Name { get; set; }
public string MacAddress { get; set; } public string MacAddress { get; set; }
} }
} }
\ No newline at end of file
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
HorizontalOptions="Center" HorizontalOptions="Center"
VerticalOptions="Start" /> VerticalOptions="Start" />
<!-- ListView to display available Bluetooth devices -->
<ListView x:Name="DeviceListView" <ListView x:Name="DeviceListView"
ItemsSource="{Binding BluetoothDevices}" ItemsSource="{Binding BluetoothDevices}"
SelectedItem="{Binding SelectedDevice}" SelectedItem="{Binding SelectedDevice}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment