Pairing issue when using SingleEntry (Android) - xamarin

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.

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?

Can we detect ibeacons through android phones without explicitly turning on the bluetooth or location?

How can we detect ibeacons from a android phone without explicitly switching on the bluetooth or location...?
I want to design an app which detects for the beacon even when the bluetooth is off...please suggest the answer
Sorry, this is not possible. Bluetooth must be turned on to detect t beacons as it requires using the Bluetooth radio to do a scan.
With BLUETOOTH_ADMIN permission (required for scanning anyway), it is possible to detect if bluetooth is off, then turn it on long enough to do a scan, then turn it back off again. The user will see the Bluetooth icon when this happens, and the user will be told at install time that the app requires this permission.

TTimer not working while iOS app in background

I have an app that needs to perform some actions based on a TTimer.
When the app becomes inactive (in background), the timer stops working.
I could not find any relevant options for UIBackgroundModes.
How can I make a timer keeps running?
iOS pauses your app automatically shortly after it goes into the background. You need to let iOS know that you are going to continue operating in the background.
In Project > Options > Version Info you can add to the array key UIBackgroundModes the string values for the services that require to continue running in the background. This gets added to the info.plist for your project on iOS.
You can consult Apple's documentation on what these values do . . .
Value - Description
audio - The app plays audible content in the
background.
location - The app provides location-based information to
the user and requires the use of the standard location services (as
opposed to the significant change location service) to implement this
feature.
voip - The app provides Voice-over-IP services. Apps with this
key are automatically launched after system boot so that the app can
reestablish VoIP services. Apps with this key are also allowed to
play background audio.
fetch - The app requires new content from the
network on a regular basis. When it is convenient to do so, the
system launches or resumes the app in the background and gives it a
small amount of time to download any new content. This value is
supported in iOS 7.0 and later.
remote-notification - The app uses
remote notifications as a signal that there is new content available
for download. When a remote notification arrives, the system launches
or resumes the app in the background and gives it a small amount of
time to download the new content. This value is supported in iOS 7.0
and later.
newsstand-content - The app processes content that was
recently downloaded in the background using the Newsstand Kit
framework, so that the content is ready when the user wants it. This
value is supported in iOS 5.0 and later.
external-accessory - The app
communicates with an accessory that delivers data at regular
intervals. This value is supported in iOS 5.0 and later.
bluetooth-central - The app uses the CoreBluetooth framework to
communicate with a Bluetooth accessory while in the background. This
value is supported in iOS 5.0 and later.
bluetooth-peripheral - The app
uses the CoreBluetooth framework to communicate in peripheral mode
with a Bluetooth accessory. The system will alert the user to the
potential privacy implications of apps with this key set. See Best
Practices for Maintaining User Privacy for more information on
privacy. This value is supported in iOS 6.0 and later.
Notice you need to actually select the mode that matches what you are doing. You can't just select fetch when really all you are doing is background processing.

Android Wear can't connect my device via bluetooth

I enabled debugging over bluetooth on my Moto 360
and enabled Android Wear app on my Nexus4.
Status displays target : disconnected
Forwarding the port from my computer shows the status host will be changed to connected, but the target status remains disconnected.
I toggled debug via the bluetooth switch which had no effect.
My phone is a Nexus 4. Is there a problem with my phone or the Moto 360?
I eventually managed to get it working. The issue seems to be related to having paired your device with an emulator first. Take a look at this post to see how I fixed it: http://melix.github.io/blog/2014/10/android-moto360.html
open the applications settings, search for the Android Wear application, then force stop it
clear its data and cache
Search for Google Play Services
Click on Manage space. Delete all data.
reboot your phone
reset your Moto 360
Pair watch with phone
Following the instructions from android.com https://developer.android.com/training/wearables/apps/bt-debugging.html to setup debugging and it should work now.
Done.
I tried it on a Sony z1.
It succeeded without any problems.
So, maybe it's not supported perfectly in Nexus 4.
If you have the same problem, I suggest using another device.
I fixed without factory reset with these steps
-Force stop android wear application and clear cache
-Disconnect emulator on android wear app
-Forget emulator on android wear app
-Connect your real device via bluetooth
-Open debugging over bluetooth
Make sure that debugging options are also active in android wear device
Run this commands in command window:
adb forward tcp:4444 localabstract:/adb-hub
adb connect localhost:4444

How to programatically send data over bluetooth from windows 7 laptop?

I am working a project from my school. We are using a microcontroller to send integers over bluetooth (Sparkfun's bluesmirf) to an android device.
Because different people need the microcontroller I am wondering if it is possible to programmatically send send data over bluetooth to my android phone via my laptop's bluetooth?
I previously was testing we CoolTerm, but I am only able to send data manually by pressing the Enter key each time.
I want to create a loop that sends a random number (12 digit long) over and over (differnet int each time) from my HP Pavilion DV7 laptop? I am using Windows 7 Ultimate, and Coolterm 1.4.1.
My solution to this problem was using RealTerm.
I creared a *.txt file with the ints in each line (copy+paste from Excel table - made it easier). Then, after I connect to the Laptop's bluetooth port under the Port tab, I go to the Send tab and use the Dump File To Port option and add the *.txt file I created. Also, I used 999 as delay to send each line every 999miliseconds, and under repeats I changed from 1 to 0 in order to make it reapet until i press Stop.
Check out this Codeplex project - http://32feet.codeplex.com/ it allows you to open up Bluetooth sessions using C# through the native Windows stack. It will also allow a Bluetooth Serial Port (SPP) session which is what you'll want to use to connect to your device. The project is fairly longstanding and has a good amount of documentation on the site or on blogs if you Google.

Resources