Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uuid as parameter for scanning #129

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ plugins {
id("signing")
}

group = "com.github.vishwaprojects"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you doing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Reedyuk i am completely new to github and contributing can you please add uuid in scan function ,immediately need for my project ,BTW i was trying to use mine forked library sorry for that

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. I will help you, when I get a moment.
For yourself for now, you can publish using mavenlocal to use it in your project locally, you can do this without your namespace. Just bump the version.

A tip for rookies, your commit message should be descriptive, not random words, it should represent a short summary so that others understand the reason for your change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @Reedyuk I tried using maven local as well as jetpack.io but was not successfully eagerly waiting for you to accept my pull request so that it will reflect changes in it and could able to use it

version = "1.0.0-SNAPSHOT"

repositories {
google()
mavenCentral()
Expand Down Expand Up @@ -56,6 +59,7 @@ android {
val frameworkName = "BlueFalcon"

kotlin {
task("testClasses")
androidTarget {
publishAllLibraryVariants()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ actual class BlueFalcon actual constructor(
bluetoothManager.adapter?.bluetoothLeScanner?.stopScan(mBluetoothScanCallBack)
}

actual fun scan() {
actual fun scan(uuid :String?) {
if (context.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
throw BluetoothPermissionException()
log("BT Scan started")
Expand Down
2 changes: 1 addition & 1 deletion library/src/commonMain/kotlin/dev/bluefalcon/BlueFalcon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ expect class BlueFalcon(context: ApplicationContext, serviceUUID: String?) {
BluetoothPermissionException::class,
BluetoothNotEnabledException::class
)
fun scan()
fun scan(uuid :String?)

fun stopScanning()

Expand Down
6 changes: 3 additions & 3 deletions library/src/iosMain/kotlin/dev/bluefalcon/BlueFalcon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ actual class BlueFalcon actual constructor(
BluetoothPermissionException::class,
BluetoothNotEnabledException::class
)
actual fun scan() {
actual fun scan(uuid : String?) {
isScanning = true
when (centralManager.state) {
CBManagerStateUnknown -> throw BluetoothUnknownException()
Expand All @@ -53,8 +53,8 @@ actual class BlueFalcon actual constructor(
CBManagerStateUnauthorized -> throw BluetoothPermissionException()
CBManagerStatePoweredOff -> throw BluetoothNotEnabledException()
CBManagerStatePoweredOn -> {
if (serviceUUID != null) {
val serviceCBUUID = CBUUID.UUIDWithString(serviceUUID)
if (uuid != null) {
val serviceCBUUID = CBUUID.UUIDWithString(uuid)
centralManager.scanForPeripheralsWithServices(listOf(serviceCBUUID), mapOf(CBCentralManagerScanOptionAllowDuplicatesKey to true) )
} else {
centralManager.scanForPeripheralsWithServices(null, mapOf(CBCentralManagerScanOptionAllowDuplicatesKey to true) )
Expand Down
4 changes: 2 additions & 2 deletions library/src/jsMain/kotlin/dev/bluefalcon/BlueFalcon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ actual class BlueFalcon actual constructor(context: ApplicationContext, serviceU
@JsName("scan")
fun scan(optionalServices: Array<String>) {
this.optionalServices = optionalServices
scan()
//scan()
}

@JsName("rescan")
actual fun scan() {
actual fun scan(uuid : String?) {
window.navigator.bluetooth.requestDevice(
BluetoothOptions(
false,
Expand Down
2 changes: 1 addition & 1 deletion library/src/macosMain/kotlin/dev/bluefalcon/BlueFalcon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ actual class BlueFalcon actual constructor(
BluetoothPermissionException::class,
BluetoothNotEnabledException::class
)
actual fun scan() {
actual fun scan(uuid : String?) {
isScanning = true
when (centralManager.state) {
CBManagerStateUnknown -> throw BluetoothUnknownException()
Expand Down
2 changes: 1 addition & 1 deletion library/src/rpiMain/kotlin/dev/bluefalcon/BlueFalcon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ actual class BlueFalcon actual constructor(context: ApplicationContext, private
BluetoothPermissionException::class,
BluetoothNotEnabledException::class
)
actual fun scan() {
actual fun scan(uuid : String?) {
isScanning = true
if(serviceUUID != null) {
bluetoothManager.scanForPeripheralsWithServices(arrayOf(UUID.fromString(serviceUUID)))
Expand Down