Closed nfvelado closed 1 year ago
OK to close this. Appears the issue is that on iOS, the code calling the library functions must execute it it's own task or thread space and not from the main application thread context. On a .NET standard 2.0 Xamarin app things work.
However, on a .NET MAUI application using .NET core 6 or 7, there seems to still be some issue with some underlying runtime dependency not being met. Will save that for another issue though.
Attempting to use 1.0.3 of DigiDotCom XBee Sharp library in a Xamarin iOS application on .NET core 2 to connect to the XBRR module. This application works using Android, however, on an IPhone 13, the connection fails.
The application is able to resolve advertising devices prior to the call below.
Modifying the following code to show debug statements:
public void Open() { Debug.WriteLine("----- Open");
Produces the following output:
2023-02-26 20:44:57.872 iOS[864:113846] 26 Feb 20:44:57 BLEAdvertised Device: NA-9602980
2023-02-26 20:44:57.872 iOS[864:113846] 26 Feb 20:44:57 BLEAdvertised Connecting to device: NA-9602980
Resolved pending breakpoint at 'BLE.cs:220,1' to void BLE.BLEObj.d33.MoveNext () [0x0001f].
Resolved pending breakpoint at 'BLE.cs:217,1' to void BLE.BLEObj.d 33.MoveNext () [0x00009].
Resolved pending breakpoint at 'BLE.cs:253,1' to void BLE.BLEObj.d__33.MoveNext () [0x00115].
2023-02-26 20:45:01.435 iOS[864:113956] 26 Feb 20:45:01 BLEPurge: stale entry removed NA-9602980
[0:] ----- Open Thread started: #5
Thread started: #6
Thread started: #7
Thread started: #8
2023-02-26 20:45:02.714 iOS[864:114029] BLEInterface: ConnectToDeviceAsync NA-9602980
[0:] ----- Close 2023-02-26 20:45:22.699 iOS[864:113846] 26 Feb 20:45:22 ConnectToDevice: General Exception XBeeLibrary.Core.Exceptions.XBeeException: Error opening the connection interface > Could not connect to the XBee BLE device > A task was canceled. at XBeeLibrary.Core.AbstractXBeeDevice.Open () [0x00045] in C:\xbee-csharp-master\XBeeLibrary.Core\AbstractXBeeDevice.cs:2399 at XBeeLibrary.Xamarin.XBeeBLEDevice.Open () [0x00001] in C:\xbee-csharp-master\XBeeLibrary.Xamarin\XBeeBLEDevice.cs:228 at BLE.BLEObj.ConnectToDevice () [0x00009] in C:\BLE\BLE.cs:217
From info.plist, have the following snippit:
Not sure if there's any other iOS setup needed, assuming this may be a bug in this or the dependency dotnet-bluetooth-le library.