0

I'm trying to adapt the SocketScan SDK (10.2.1.0) sample code code, SingleEntryApplication for android to create an Apache Cordova plugin. The SingleEntryApplication class is an Android application (android.app.Application). I'm trying to strip it down to the bear minimum that is necessary to receive a scan from a Socket Mobile CHS 8Qi in SPP connection mode (not as a keyboard wedge).

The obvious question is does a Cordova plugin for Android already exist? I've scoured the net and have not found one. If it doesn't exist, does anyone have the recipe for stripping down the code in the Android SingleEntry example to the essentials for receiving a scan.

I implemented a ScanApiHelper.ScanApiHelperNotification (the interface for callbacks) and got a callback of onScanApiInitializeComplete, without an error, indicating successful initialization of the scan API. However, I am not getting callback for onDeviceArrival, onDecodedData, etc. I suspect that all I've done is successfully initialize the SDK, but that the SDK is not connected to scanner device.

I have verified that the hosting app for the plugin has

  • android.permission.BLUETOOTH
  • android.permission.BLUETOOTH_ADMIN
  • android.permission.WRITE_EXTERNAL_STORAGE
  • android.permission.READ_EXTERNAL_STORAGE

There are no obvious errors in logs. I am at a loss as to how to proceed further. Does anyone have a solution?

REF: https://github.com/SocketMobile/samples-android

Rajeev Sreedharan
  • 1,753
  • 4
  • 20
  • 30
jasonw
  • 1
  • Is your scanner configured and paired? The scanner needs to be configured in SPP Initiator mode and paired with your phone before you will receive a device arrival event – Enrico May 19 '17 at 16:40
  • I think the scanner is paired, since it says that in the android bluetooth UI. But it sounds like there something more subtle I need to do to configure it properly. Can you walk me through the steps of ensuring the scanner is correctly paired in SPP Initiator mode. Here's what I'm currently doing to connect the device. (1) restore to factory default BC (2) scan Application SPP BC (#FNB00F40000#, 3 tones) (3) reset pairing (4) choose Socket CHS [745825] in Android bluetooth UI (5) Android now shows paired. – jasonw May 19 '17 at 20:15
  • In reading further, I see I'm supposed to scan a magic BC #FNIaabbccddeeff# to enable initiator mode. The aa...ff being the bluetooth mac address of android device's bluetooth adaptor. Since Marshmallow, Google removed the ability to programmatically obtain the bluetooth address. So I don't have a way to create such a barcode. Is there SocketMobile end-user friendly tool that will put the device into SPP initiator mode? – jasonw May 19 '17 at 21:06
  • Between Android M and O you can [get the Bluetooth address](https://github.com/SocketMobile/samples-android/commit/6e1c4727d7a47d8f2003d1d7d40a8203150c59a4) using `Settings.Secure.bluetooth_address`. In O, that api returns null. The EZPairActivity in the `samples-android` project shows how to put a paired scanner that is in SPP Acceptor mode into SPP Initiator mode – Enrico May 19 '17 at 21:14
  • Where is the EZPairActivity sample? Why is is necessary to put the device into SPP Initiator mode on Android? This seems less intuitive for end users. Thanks. – jasonw May 20 '17 at 05:53
  • [EZPairActivity](https://github.com/SocketMobile/samples-android/blob/6e1c4727d7a47d8f2003d1d7d40a8203150c59a4/singleEntry/src/main/java/com/example/socketmobile/singleentry/EzPairActivity.java) is in the samples-android project. Initiator mode allows the scanner to automatically reconnect if it disconnects - for example if the scanner goes out of range and comes back – Enrico May 20 '17 at 06:43

0 Answers0