Compare commits

...
2 Commits
Author SHA1 Message Date
rizky_denianto d497b68bb7 Merge pull request 'Menggunakan nama variabel sesuai dengan nama kelas' (#24) from pengembangan into main
Reviewed-on: #24
2026-09-05 16:37:07 +07:00
rizky_denianto 432a34540d Menggunakan nama variabel sesuai dengan nama kelas
Penerbitan Plugin / persiapan (pull_request) Successful in 5s
Penerbitan Plugin / penerbitan (pull_request) Successful in 3m47s
2026-09-05 16:00:59 +07:00
3 changed files with 19 additions and 19 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "tauri-plugin-bluclas"
version = "0.1.19"
version = "0.1.20"
authors = [ "Rizky Denianto" ]
description = "Program sederhana untuk interaksi dengan bluetooth classic"
edition = "2024"
+17 -17
View File
@@ -37,11 +37,11 @@ class KirimArgs {
]
)
class BluclasPlugin(private val activity: Activity) : Plugin(activity) {
private val uuidSpp: UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB")
private val uuid: UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB")
private val adapter: BluetoothAdapter? = this.activity.getSystemService(BluetoothManager::class.java).getAdapter()
private var soket: BluetoothSocket? = null
private var keluaran: OutputStream? = null
private val bluetoothAdapter: BluetoothAdapter? = this.activity.getSystemService(BluetoothManager::class.java).getAdapter()
private var bluetoothSocket: BluetoothSocket? = null
private var outputStream: OutputStream? = null
@Command
override fun checkPermissions(invoke: Invoke) {
@@ -55,13 +55,13 @@ class BluclasPlugin(private val activity: Activity) : Plugin(activity) {
@Command
fun daftarPerangkat(invoke: Invoke) {
if (adapter == null) {
if (bluetoothAdapter == null) {
invoke.reject("Bluetooth tidak didukung")
return
}
val daftarRes = JSArray()
adapter.bondedDevices.map { i ->
bluetoothAdapter.bondedDevices.map { i ->
val res = JSObject()
res.put("nama", i.name ?: "Unknown")
res.put("alamat", i.address)
@@ -74,17 +74,17 @@ class BluclasPlugin(private val activity: Activity) : Plugin(activity) {
}
fun menghubungkanKoneksi(alamat: String) {
val perangkat: BluetoothDevice = adapter!!.getRemoteDevice(alamat)
soket = perangkat.createInsecureRfcommSocketToServiceRecord(uuidSpp)
soket!!.connect()
keluaran = soket!!.outputStream
val bluetoothDevice: BluetoothDevice = bluetoothAdapter!!.getRemoteDevice(alamat)
bluetoothSocket = bluetoothDevice.createInsecureRfcommSocketToServiceRecord(uuid)
bluetoothSocket!!.connect()
outputStream = bluetoothSocket!!.outputStream
}
fun memutusKoneksi() {
keluaran?.close()
keluaran = null
soket?.close()
soket = null
outputStream?.close()
outputStream = null
bluetoothSocket?.close()
bluetoothSocket = null
}
@Command
@@ -99,12 +99,12 @@ class BluclasPlugin(private val activity: Activity) : Plugin(activity) {
try {
menghubungkanKoneksi(alamat)
if (keluaran == null) {
if (outputStream == null) {
throw Exception("Tidak ada perangkat yang terhubung")
}
keluaran!!.write(args.data)
keluaran!!.flush()
outputStream!!.write(args.data)
outputStream!!.flush()
} catch (e: Exception) {
memutusKoneksi()
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@segubi/tauri-plugin-bluclas-api",
"version": "0.1.19",
"version": "0.1.20",
"author": "Rizky Denianto",
"description": "Program sederhana untuk interaksi dengan bluetooth classic",
"type": "module",