├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── sirvar │ │ │ │ └── bluetoothkit │ │ │ │ └── MainActivity.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── sirvar │ │ │ └── bluetoothkit │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── sirvar │ │ └── bluetoothkit │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── .github └── logo.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── bluetoothkit ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── sirvar │ │ │ └── bluetoothkit │ │ │ ├── BluetoothKitSocketInterface.kt │ │ │ ├── BluetoothKitSocket.kt │ │ │ ├── BluetoothKitSecuredSocket.kt │ │ │ └── BluetoothKit.kt │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── sirvar │ │ │ └── bluetoothkit │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── sirvar │ │ └── bluetoothkit │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── docs ├── index.html ├── com.sirvar.bluetoothkit │ ├── -bluetooth-kit │ │ ├── -init-.html │ │ ├── enable.html │ │ ├── disable.html │ │ ├── disconnect.html │ │ ├── is-enabled.html │ │ ├── get-bluetooth-adapter.html │ │ ├── get-paired-devices.html │ │ ├── get-bluetooth-socket.html │ │ ├── get-device-by-name.html │ │ ├── get-device-by-address.html │ │ ├── connect.html │ │ └── index.html │ ├── -bluetooth-kit-socket-interface │ │ ├── socket.html │ │ ├── device-name.html │ │ ├── device-address.html │ │ ├── input-stream.html │ │ ├── close.html │ │ ├── output-stream.html │ │ ├── connect.html │ │ └── index.html │ ├── -bluetooth-kit-socket │ │ ├── socket.html │ │ ├── device-name.html │ │ ├── -init-.html │ │ ├── close.html │ │ ├── input-stream.html │ │ ├── device-address.html │ │ ├── connect.html │ │ ├── output-stream.html │ │ └── index.html │ ├── -bluetooth-kit-secured-socket │ │ ├── close.html │ │ ├── input-stream.html │ │ ├── output-stream.html │ │ ├── connect.html │ │ ├── -init-.html │ │ └── index.html │ └── index.html ├── alltypes │ └── index.html ├── style.css └── index-outline.html ├── gradle.properties ├── LICENSE ├── .gitignore ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':bluetoothkit' 2 | -------------------------------------------------------------------------------- /.github/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/HEAD/.github/logo.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirvar/bluetoothkit-android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BluetoothKit 3 | Enable 4 | Disable 5 | Status 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Dec 29 10:09:35 EST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-milestone-1-all.zip 7 | -------------------------------------------------------------------------------- /bluetoothkit/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
10 |

Packages

11 | 12 | 13 | 14 | 16 | 18 | 19 | 20 |
15 | com.sirvar.bluetoothkit 17 |
21 |

Index

22 | All Types 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/test/java/com/sirvar/bluetoothkit/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.sirvar.bluetoothkit 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /bluetoothkit/src/test/java/com/sirvar/bluetoothkit/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.sirvar.bluetoothkit; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit/-init-.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKit.<init> - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKit / <init>
9 |
10 |

<init>

11 | BluetoothKit() 12 |

BluetoothKit controller to interface with Android BluetoothAdapter and BluetoothSocket

13 |

Author
14 | Rikin Katyal

15 | 16 | 17 | -------------------------------------------------------------------------------- /bluetoothkit/src/main/java/com/sirvar/bluetoothkit/BluetoothKitSocketInterface.kt: -------------------------------------------------------------------------------- 1 | package com.sirvar.bluetoothkit 2 | 3 | import android.bluetooth.BluetoothSocket 4 | import java.io.IOException 5 | import java.io.InputStream 6 | import java.io.OutputStream 7 | 8 | /** 9 | * Bluetooth Socket interface for primary functions 10 | * @author Rikin Katyal 11 | */ 12 | interface BluetoothKitSocketInterface { 13 | 14 | val inputStream: InputStream 15 | val outputStream: OutputStream 16 | val deviceName: String 17 | val deviceAddress: String 18 | val socket: BluetoothSocket 19 | 20 | @Throws(IOException::class) 21 | fun connect() 22 | 23 | @Throws(IOException::class) 24 | fun close() 25 | } 26 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit/enable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKit.enable - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKit / enable
9 |
10 |

enable

11 | 12 | fun enable(): Boolean 13 |

Enables bluetooth on device

14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit/disable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKit.disable - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKit / disable
9 |
10 |

disable

11 | 12 | fun disable(): Boolean 13 |

Disable bluetooth on device

14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket-interface/socket.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocketInterface.socket - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocketInterface / socket
9 |
10 |

socket

11 | 12 | abstract val socket: <ERROR CLASS> 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/sirvar/bluetoothkit/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.sirvar.bluetoothkit 2 | 3 | import android.os.Bundle 4 | import android.support.v7.app.AppCompatActivity 5 | import kotlinx.android.synthetic.main.activity_main.* 6 | 7 | class MainActivity : AppCompatActivity() { 8 | 9 | companion object { 10 | private const val TAG = "MainActivity" 11 | } 12 | 13 | override fun onCreate(savedInstanceState: Bundle?) { 14 | super.onCreate(savedInstanceState) 15 | setContentView(R.layout.activity_main) 16 | 17 | val bluetoothKit = BluetoothKit() 18 | 19 | enable.setOnClickListener { bluetoothKit.enable() } 20 | disable.setOnClickListener { bluetoothKit.disable() } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket-interface/device-name.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocketInterface.deviceName - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocketInterface / deviceName
9 |
10 |

deviceName

11 | 12 | abstract val deviceName: String 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket-interface/device-address.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocketInterface.deviceAddress - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocketInterface / deviceAddress
9 |
10 |

deviceAddress

11 | 12 | abstract val deviceAddress: String 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket-interface/input-stream.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocketInterface.inputStream - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocketInterface / inputStream
9 |
10 |

inputStream

11 | 12 | abstract val inputStream: <ERROR CLASS> 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket-interface/close.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocketInterface.close - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocketInterface / close
9 |
10 |

close

11 | 12 | abstract fun close(): Unit 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket-interface/output-stream.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocketInterface.outputStream - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocketInterface / outputStream
9 |
10 |

outputStream

11 | 12 | abstract val outputStream: <ERROR CLASS> 13 | 14 | 15 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket-interface/connect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocketInterface.connect - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocketInterface / connect
9 |
10 |

connect

11 | 12 | abstract fun connect(): Unit 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit/disconnect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKit.disconnect - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKit / disconnect
9 |
10 |

disconnect

11 | 12 | fun disconnect(): Unit 13 |

Closes all IO streams and terminates the socket. 14 | NOTE: does not turn off bluetooth

15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/sirvar/bluetoothkit/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.sirvar.bluetoothkit 2 | 3 | import android.support.test.InstrumentationRegistry 4 | import android.support.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.sirvar.bluetoothkit", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket/socket.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocket.socket - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocket / socket
9 |
10 |

socket

11 | 12 | open val socket: <ERROR CLASS> 13 |

Overrides BluetoothKitSocketInterface.socket

14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit/is-enabled.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKit.isEnabled - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKit / isEnabled
9 |
10 |

isEnabled

11 | 12 | fun isEnabled(): Boolean 13 |

Checks if bluetooth is enabled

14 |

Return
15 | boolean enabled status

16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-secured-socket/close.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSecuredSocket.close - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSecuredSocket / close
9 |
10 |

close

11 | 12 | fun close(): Unit 13 |

Overrides BluetoothKitSocket.close

14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-secured-socket/input-stream.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSecuredSocket.inputStream - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSecuredSocket / inputStream
9 |
10 |

inputStream

11 | 12 | val inputStream: <ERROR CLASS> 13 |

Overrides BluetoothKitSocket.inputStream

14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket/device-name.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocket.deviceName - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocket / deviceName
9 |
10 |

deviceName

11 | 12 | open val deviceName: String 13 |

Overrides BluetoothKitSocketInterface.deviceName

14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-secured-socket/output-stream.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSecuredSocket.outputStream - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSecuredSocket / outputStream
9 |
10 |

outputStream

11 | 12 | val outputStream: <ERROR CLASS> 13 |

Overrides BluetoothKitSocket.outputStream

14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-secured-socket/connect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSecuredSocket.connect - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSecuredSocket / connect
9 |
10 |

connect

11 | 12 | fun connect(): Unit 13 |

Overrides BluetoothKitSocket.connect

14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket/-init-.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocket.<init> - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocket / <init>
9 |
10 |

<init>

11 | BluetoothKitSocket(socket: <ERROR CLASS>) 12 |

Bluetooth Socket wrapper

13 |

Author
14 | Rikin Katyal

15 | 16 | 17 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket/close.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocket.close - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocket / close
9 |
10 |

close

11 | 12 | open fun close(): Unit 13 |

Overrides BluetoothKitSocketInterface.close

14 | 15 | 16 | -------------------------------------------------------------------------------- /bluetoothkit/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket/input-stream.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocket.inputStream - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocket / inputStream
9 |
10 |

inputStream

11 | 12 | open val inputStream: <ERROR CLASS> 13 |

Overrides BluetoothKitSocketInterface.inputStream

14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket/device-address.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocket.deviceAddress - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocket / deviceAddress
9 |
10 |

deviceAddress

11 | 12 | open val deviceAddress: String 13 |

Overrides BluetoothKitSocketInterface.deviceAddress

14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket/connect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocket.connect - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocket / connect
9 |
10 |

connect

11 | 12 | open fun connect(): Unit 13 |

Overrides BluetoothKitSocketInterface.connect

14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-socket/output-stream.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSocket.outputStream - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSocket / outputStream
9 |
10 |

outputStream

11 | 12 | open val outputStream: <ERROR CLASS> 13 |

Overrides BluetoothKitSocketInterface.outputStream

14 | 15 | 16 | -------------------------------------------------------------------------------- /bluetoothkit/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | android { 6 | compileSdkVersion 28 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 27 | } 28 | -------------------------------------------------------------------------------- /bluetoothkit/src/main/java/com/sirvar/bluetoothkit/BluetoothKitSocket.kt: -------------------------------------------------------------------------------- 1 | package com.sirvar.bluetoothkit 2 | 3 | import android.bluetooth.BluetoothSocket 4 | import java.io.InputStream 5 | import java.io.OutputStream 6 | 7 | /** 8 | * Bluetooth Socket wrapper 9 | * @author Rikin Katyal 10 | */ 11 | open class BluetoothKitSocket(override val socket: BluetoothSocket) : BluetoothKitSocketInterface { 12 | 13 | override val inputStream: InputStream 14 | get() = socket.inputStream 15 | override val outputStream: OutputStream 16 | get() = socket.outputStream 17 | override val deviceName: String 18 | get() = socket.remoteDevice.name 19 | override val deviceAddress: String 20 | get() = socket.remoteDevice.address 21 | 22 | override fun connect() { 23 | socket.connect() 24 | } 25 | 26 | override fun close() { 27 | socket.close() 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /bluetoothkit/src/androidTest/java/com/sirvar/bluetoothkit/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.sirvar.bluetoothkit; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.sirvar.bluetoothkit.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit-secured-socket/-init-.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKitSecuredSocket.<init> - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKitSecuredSocket / <init>
9 |
10 |

<init>

11 | BluetoothKitSecuredSocket(bluetoothSocket: <ERROR CLASS>) 12 |

Secured Bluetooth Socket wrapper with low level method invocation

13 |

Author
14 | Rikin Katyal

15 | 16 | 17 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit/get-bluetooth-adapter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKit.getBluetoothAdapter - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKit / getBluetoothAdapter
9 |
10 |

getBluetoothAdapter

11 | 12 | fun getBluetoothAdapter(): <ERROR CLASS> 13 |

Get the BluetoothAdapter

14 |

Return
15 | BluetoothAdapter

16 |

See Also
17 |

android.bluetooth.BluetoothAdapter

18 |

19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit/get-paired-devices.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKit.getPairedDevices - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKit / getPairedDevices
9 |
10 |

getPairedDevices

11 | 12 | fun getPairedDevices(): Set<<ERROR CLASS>> 13 |

Gets Set of paired BluetoothDevice

14 |

See Also
15 |

android.bluetooth.BluetoothDevice

16 |

Set

17 |

18 | 19 | 20 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit/get-bluetooth-socket.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKit.getBluetoothSocket - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKit / getBluetoothSocket
9 |
10 |

getBluetoothSocket

11 | 12 | fun getBluetoothSocket(): BluetoothKitSocketInterface 13 |

Get the bluetooth socket implementing BluetoothKitSocketInterface

14 |

Return
15 | BluetoothKitSocketInterface

16 |

See Also
17 |

BluetoothKitSocketInterface

18 |

19 | 20 | 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Rikin Katyal 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /docs/alltypes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | alltypes - 5 | 6 | 7 | 8 |

All Types

9 | 10 | 11 | 12 | 14 | 17 | 18 | 19 | 21 | 24 | 25 | 26 | 28 | 31 | 32 | 33 | 35 | 38 | 39 | 40 |
13 | com.sirvar.bluetoothkit.BluetoothKit 15 |

BluetoothKit controller to interface with Android BluetoothAdapter and BluetoothSocket

16 |
20 | com.sirvar.bluetoothkit.BluetoothKitSecuredSocket 22 |

Secured Bluetooth Socket wrapper with low level method invocation

23 |
27 | com.sirvar.bluetoothkit.BluetoothKitSocket 29 |

Bluetooth Socket wrapper

30 |
34 | com.sirvar.bluetoothkit.BluetoothKitSocketInterface 36 |

Bluetooth Socket interface for primary functions

37 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # IntelliJ 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/assetWizardSettings.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | .idea/caches 44 | 45 | # Keystore files 46 | # Uncomment the following line if you do not want to check your keystore files in. 47 | #*.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | 60 | # fastlane 61 | fastlane/report.xml 62 | fastlane/Preview.html 63 | fastlane/screenshots 64 | fastlane/test_output 65 | fastlane/readme.md.idea 66 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit/get-device-by-name.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKit.getDeviceByName - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKit / getDeviceByName
9 |
10 |

getDeviceByName

11 | 12 | fun getDeviceByName(name: String): <ERROR CLASS>? 13 |

Get paired BluetoothDevice by name

14 |

Parameters

15 | 16 |

17 | name - paired device name to get 18 |

Return
19 | BluetoothDevice the device if it exists, else null

20 |

See Also
21 |

android.bluetooth.BluetoothDevice

22 |

23 | 24 | 25 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 28 9 | defaultConfig { 10 | applicationId "com.sirvar.bluetoothkit" 11 | minSdkVersion 15 12 | targetSdkVersion 28 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation project(":bluetoothkit") 27 | 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) 29 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 30 | implementation 'com.android.support:appcompat-v7:28.0.0' 31 | implementation 'com.android.support:recyclerview-v7:28.0.0' 32 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 33 | testImplementation 'junit:junit:4.12' 34 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 35 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 36 | } 37 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/-bluetooth-kit/get-device-by-address.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | BluetoothKit.getDeviceByAddress - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit / BluetoothKit / getDeviceByAddress
9 |
10 |

getDeviceByAddress

11 | 12 | fun getDeviceByAddress(address: String): <ERROR CLASS>? 13 |

Get paired BluetoothDevice by MAC address

14 |

Parameters

15 | 16 |

17 | address - MAC address of device to get 18 |

Return
19 | BluetoothDevice the device if it exists, else null

20 |

See Also
21 |

android.bluetooth.BluetoothDevice

22 |

23 | 24 | 25 | -------------------------------------------------------------------------------- /bluetoothkit/src/main/java/com/sirvar/bluetoothkit/BluetoothKitSecuredSocket.kt: -------------------------------------------------------------------------------- 1 | package com.sirvar.bluetoothkit 2 | 3 | import android.bluetooth.BluetoothSocket 4 | import java.io.InputStream 5 | import java.io.OutputStream 6 | import java.lang.reflect.Method 7 | 8 | /** 9 | * Secured Bluetooth Socket wrapper with low level method invocation 10 | * @author Rikin Katyal 11 | */ 12 | class BluetoothKitSecuredSocket(bluetoothSocket: BluetoothSocket) : BluetoothKitSocket(bluetoothSocket) { 13 | 14 | private val securedSocket: BluetoothSocket 15 | 16 | init { 17 | val bluetoothDeviceClass = bluetoothSocket.remoteDevice.javaClass 18 | // createRfcommSocket has 2 overloaded methods, we want channel type int 19 | val intParamType = arrayOf(Integer.TYPE) 20 | val method: Method? = bluetoothDeviceClass.getMethod("createRfcommSocket", *intParamType) 21 | val securedSocket = method?.invoke(socket.remoteDevice, 1) 22 | ?: throw IllegalStateException("Unable to create a secure socket using reflection.") 23 | this.securedSocket = securedSocket as BluetoothSocket 24 | } 25 | 26 | override val inputStream: InputStream 27 | get() = securedSocket.inputStream 28 | 29 | override val outputStream: OutputStream 30 | get() = securedSocket.outputStream 31 | 32 | override fun connect() { 33 | securedSocket.connect() 34 | } 35 | 36 | override fun close() { 37 | securedSocket.close() 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /docs/com.sirvar.bluetoothkit/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | com.sirvar.bluetoothkit - 5 | 6 | 7 | 8 | com.sirvar.bluetoothkit
9 |
10 |

Package com.sirvar.bluetoothkit

11 |

Types

12 | 13 | 14 | 15 | 17 | 21 | 22 | 23 | 25 | 29 | 30 | 31 | 33 | 37 | 38 | 39 | 41 | 45 | 46 | 47 |
16 | BluetoothKit 18 | class BluetoothKit : Any 19 |

BluetoothKit controller to interface with Android BluetoothAdapter and BluetoothSocket

20 |
24 | BluetoothKitSecuredSocket 26 | class BluetoothKitSecuredSocket : BluetoothKitSocket 27 |

Secured Bluetooth Socket wrapper with low level method invocation

28 |
32 | BluetoothKitSocket 34 | open class BluetoothKitSocket : BluetoothKitSocketInterface 35 |

Bluetooth Socket wrapper

36 |
40 | BluetoothKitSocketInterface 42 | interface BluetoothKitSocketInterface : Any 43 |

Bluetooth Socket interface for primary functions

44 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |