how to get list of paired bluetooth devices that are power off or not is range in UWP - xamarin

I want to get the list of paired devices that are not in range or power off. I am doing in Xamarin forms UWP

I want to get the list of paired devices that are not in range or power off. I am doing in Xamarin forms UWP
If you want to get the paired Bluetooth data from Xamarin platform side, we suggest you use DependencyService to approach, make device watcher in uwp client and callback the paired list data to Xamarin side.
For getting paired Bluetooth device. please refer official code sample here. For callback data with DependencyService please refer here.

Related

Connect bluetooth scanner to Xamarin.Forms App

I want to listen to a bluetooth barcode scanner input events in my Xamarin.Forms app targetted for iOS, Android and UWP.
I found a few GitHub like bluetoothLE, on how to list BLE devices with Xamarin for iOS or Android (it also says it is compatible with UWP), and some hints as to how to register to input, but I couldn't get it to work...
So I was thinking if there was a way to register to ALREADY PAIRED items (which are paired at OS level, before launching the app) and hook up to input events? Does anyone have some suggestions?

Pairing issue when using SingleEntry (Android)

Socket Mobile SDK documentation states that the socket mobile scanner must be in "SPP" mode in order to work with the SingleEntry example. However, it seems that none of the Android phones i've tested recognize the device when in this mode for initial pairing. It does display in the paired devices list, connects to it fine, but does not fire any of the events (OnDeviceArrival, OnDecodedData, etc..) when a scan happens.
I can only get the SingleEntry example app to work with my Socket Mobile S800 by following the below steps (exactly):
Make sure scanner is in HID mode (default)
On my Android device, scan for pair-able devices. (the S800 displays with a keyboard icon)
Select the S800 device. (S800 does beep confirmation on connection)
Once the device is paired, un-pair it.
Change the S800 mode to "SPP" by scanning the appropriate code (recommended mode to work with Xamarin SingleEntry example)
Re-pair with the S800 device on my Android phone. (the S800 icon is now a desktop instead of a keyboard)
Open the "Socket EZ Pair" app, select pair using Bluetooth, select my S800 device from the list.
Now the OnDecodedData callback fires in the SingleEntry project.
What is the "Socket EZ Pair" app doing that i should be doing in my code to properly pair the device when in "SPP" mode?
Are there any better solutions for cross platform Bluetooth scanning? I'm particularly interested in just the OnScan (OnDecodedData) events...
UPDATE
The explanation is actually very simple. The SingleEntry Xamarin.Android app doesn't handle configuring the scanner for ScanAPI.
As you noted, after pairing the scanner you need to use EZ Pair before the scanner will be recognized by your app. This is because when you pair the scanner using Bluetooth settings, it creates an outgoing connection to the scanner, but ScanAPI listens for incoming connections. EZ Pair presents you with a list of paired Bluetooth devices, it connects to the one you select and configures that scanner to connect back before closing the connection.
The SingleEntry Android sample application includes the EZ Pair logic, but the Xamarin sample does not.
However, once you've used EZ Pair to configure your scanner to connect back, you should receive device arrival and decoded data notifications in the unmodified SingleEntry Xamarin.Android sample application.
Original answer
Not the solution, but good to check
Runtime permissions were introduced in Android 6.0 and SingleEntry has not been updated to check for the required permissions. Unfortunately, the file that sets the target framework is not checked in to git so fresh clones of the sample app now target newer versions than SingleEntry was designed for.
If you open Settings > Apps > Single Entry > Permissions and enable the storage permission, then it should start working.
The real fix is to check for WRITE_EXTERNAL_STORAGE and BLUETOOTH permissions before calling ScanApiHelper.Open() in your application.

Xamarin Forms - What is the current device/system type?

I was working by debug my app with a Microsoft Phone 10 when I realized "UWP is a cross windows logic", so now I'm working with my computer.
However, a question comes up in my mind :
How can you know/get information about what type of system your app is running on?
I mean by this question, by example, does my app is currently running on a phone or on a computer?
Thank for your help !
In PCL or SAP
The static Device class includes several properties and methods that allow your code to deal with device differences at run time in a very simple and straightforward manner:
The Device.OS property returns a member of the TargetPlatform
enumeration: iOS, Android, WinPhone, or Other. The WinPhone member
refers to all the Windows and Windows Phone platforms.
The Device.Idiom property returns a member of the TargetIdiom
enumeration: Phone, Tablet, Desktop, or Unsupported.
You can use these two properties in if and else statements, or a switch and case block, to execute code specific to a particular platform.
Device

Does Xamarin support to develop apps for Windows surface and how well?

I want to develop an app for Windows surface tablet and iOS mobile and iPad.
As I am a new user to Xamarin, when I created my first project,it shows 3 projects:-
hello.driod, hello.ios and hello.winPhone.
I have 3 questions based on this:-
How will I be able to write the same code and share for windows 8.1 and iOS?
and whenever I drag and drop the elements to the UI page, will the same elements be copied to both windows and iOS simultaneously or I got to add them seperately?
Currently I dont have a MAC to connect to my PC. Can I write the code and and there while testing it, connect it to a MAC or should it be connected during the whole process?
Please Help!
Using the same code depends on how your structure your app.
You can go the native route where you can share the bulk of your logic by containing it in a shared / PCL project (more on that here), but have platform specific code for your UI.
For example, if you have a cross platform app targeting iOS and Android you would still create the UI in a storyboard for iOS and AXML files for Android. Any code you want to "connect" to your UI would be specific to that platform as you would use the platform APIs. Any code that is not platform specific (i.e., not calling iOS or Android APIs) can go in your shared / PCL project.
Or you can choose Xamarin.Forms which adds a layer of abstraction by allowing you to write the UI in XAML once and have it work on all platforms. The advantage is increased code sharing as now your UI is also shared. The downside is to utilise platform specific features you'll need to implement DependencyService or custom renderers. Read more about Xamarin.Forms here.
As above, it depends. If you are going the native route, then no. If you are going with Xamarin.Forms, then you are using the same XAML code for the UI across platforms, but there is no drag and drop designer.
To build an iOS app you need to be connected to a Mac. You will also need to be connected to a Mac to use the iOS Designer.

Storing domain events with Xamarin

I'm looking for a way to store events using Xamarin on a mobile device.
On the server there are event stores I can use, but I don't know what is possible with Xamarin mobile.
(e.g. https://geteventstore.com/)
Event store says it can run on mono, but I'm not sure if that means xamarin mobile.
I suppose I could use sqlite database to store events, but I'm new to all this and I'm not sure how that would work.

Resources