cd27a101f88cd44fc4c2ccd501681602_edited.

Software Development Kits

3500f07bc4e37f8a4f2016ad04121ea5_edited.

Software Development Kits

The Generalscan SDK Development Kit is a SDK software package developed by Generalscan for third-party software developers using the Generalscan full range of Bluetooth scanners on Android smartphone platforms. This software package provides a variety of low-level functions, so that users do not need to understand complex Bluetooth protocols and communication mechanisms of various USB devices, so that the Generalscan Bluetooth scanner can be easily and directly embedded into your application.

The Generalscan SDK development kit provides a variety of software functions, including Bluetooth SPP communication, pairing, data transmission, Bluetooth device name modification, barcode function setting, hardware ID reading, DES encryption algorithm and decryption algorithm, standby sleep time setting. 
The source code of Generalscan SDK is maintained on GitHub, users can download it by themselves.

Import SDK to Android Studio project

1. Copy the SDK aar file to app/libs

2. Add the flatDir setting Gradle configuration to your Android project. In your root build.gradle file:

allprojects { 

repositories

{

jcenter()

flatDir { dirs 'libs' }  // add flatDir setting }

}

3. Open app level build.grdle file and add .aar file and kotlin runtime

dependencies 

{

implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.10'

implementation(name:'generalscan-sdk-1.0', ext:'aar')

}

4. Add the follow permissions into manifest.xml

<!-- Permission For Bluetooth -->

<uses-permission android:name="android.permission.BLUETOOTH" /> 

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> 

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 

<uses-permission android:name="android.permission.VIBRATE" /> <!-- Permissions for USB Host (Scan Buddy) -->

<uses-feature android:name="android.hardware.usb.host" android:required="true" />

<!-- Show Alert Dialog in Service -->

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

5. Add the follow service declarations into manifest.xml

<service android:name="com.generalscan.scannersdk.core.session.bluetooth.

service.BluetoothConnectService"

android:enabled="true"    

android:exported="true" />

<service android:name="com.generalscan.scannersdk.core.session.usbhost.

service.UsbHostService"

android:enabled="true" 

android:exported="true" />

<service android:name="com.generalscan.scannersdk.core.session.usbhost.

service.FloatingScanButtonService"    

android:enabled="true"    

android:exported="true" />

Interacting with a Bluetooth scanner

  1. Turn on Bluetooth

  2. Start Bluetooth session after activity created

BluetoothConnectSession mBluetoothConnectSession = new BluetoothConnectSession(this);

//Setup session listener

mBluetoothConnectSession.setSessionListener(

new SessionListener()

{

//When session is ready

@Override

public void onSessionReady(IConnectSession iConnectSession) {

//TODO:to connect the device here or later }

//When session service initialization timeout

@Override

public void onSessionStartTimeOut(IConnectSession iConnectSession) {

//TODO:show error message }

}

);

mBluetoothConnectSession.startSession();

Set the receiver to read the barcode

Setup listenter to ceceieve data

mBluetoothConnectSession.setConnectListener(

new CommunicateListener()

{  

//Bluetooth device disconnected

@Override

public void onDisconnected()

{ showMessage("Device has been disconnected");

}      

//Bluetooth device connect failed

@Override

public void onConnectFailure(String errorMessage) {  

showMessage(errorMessage);

}  

//Bluetooth device connect success

@Override

public void onConnected() {    

showMessage(R.string.scanner_connect_success);

}  

//Scanner data received

@Override

public void onDataReceived(String data) {

mTxtReceiveData.append(data); }  

//Bluetooth command callback

@Override

public void onCommandCallback(String name, String data) {

mTxtReceiveData.append("$name:$data");

}  

//Battery data receive

@Override

public void onBatteryDataReceived(String voltage, String percentage) { mTxtReceiveData.append(voltage + ":" + percentage); }  

//Scanner command timeout

@Override

public void onCommandNoResponse(String errorMessage) { }  

//Data receive error

@Override

public void onRawDataReceiveError(String errorMessage, String source) { }  

//Raw data receive

@Override

public void onRawDataReceived(byte data) {

}

}  

);

Bluetooth pairing, connection, stop session

Pair Bluetooth device

Connect Bluetooth device

BluetoothAdapter mBluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter()

BluetoothDevice device = BluetoothAdapter.getRemoteDevice(mSelectedDeviceAddress); mBluetoothConnectSession.setBluetoothDeviceToConnect(device); mBluetoothConnectSession.connect();

Stop Bluetooth session after activity is destroy

//Send current bluetooth session

mBluetoothConnectSession.endSession();

1c2f6a9e1831a438a761c8a8e06a7415_edited.

Download from Google Play

Generalscan Inc.

200 Buckelew Ave, Jamesburg,  NJ, 08831, USA

+1 1469583-7367
 

Generalscan Electronics GmbH

Heinrich-Koulen-Weg 3,52525 Heinsberg Germany

+49 15167161256 +49 24529892299

Generalscan Electronics Limited

Room A608,6 Floor, Building 3, Ya Di Science Park, He Tai Road , BaiYun District , Guangzhou , China.

+86 022 58171186 

  • LinkedIn - Beyaz Çember
  • Heyecan - Beyaz Çember
  • Facebook - Beyaz Çember
  • YouTube - Beyaz Çember

Copyright ©2020 All rights reserved

GENERALSCAN ELECTRONICS CO.,LIMITED