Compare commits
7
Commits
09ac478ae3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
743fc021f6 | ||
|
|
24c5d3e1f2 | ||
|
|
de72fa5e3e | ||
|
|
a8ff604873 | ||
|
|
00aa5a8526 | ||
|
|
d497b68bb7 | ||
|
|
432a34540d |
No files matched your search
@@ -41,20 +41,6 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Unduh pnpm
|
||||
uses: pnpm/setup@v2
|
||||
with:
|
||||
version: 11
|
||||
|
||||
- name: Penerbitan paket NPM
|
||||
run: |
|
||||
pnpm i
|
||||
npm config set @${{ needs.persiapan.outputs.organisasi }}:registry=https://${{ vars.ALAMAT_GITEA }}/api/packages/${{ needs.persiapan.outputs.organisasi }}/npm/
|
||||
npm config set -- '//${{ vars.ALAMAT_GITEA }}/api/packages/${{ needs.persiapan.outputs.organisasi }}/npm/:_authToken' "${{ secrets.KUNCI_PENERBITAN }}"
|
||||
npm run prepublishOnly
|
||||
npm publish
|
||||
rm -rf pnpm-lock.yaml .pnpm-store/
|
||||
|
||||
- name: Unduh Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
@@ -66,3 +52,16 @@ jobs:
|
||||
cargo publish
|
||||
env:
|
||||
CARGO_REGISTRIES_GITEA_TOKEN: Bearer ${{ secrets.KUNCI_PENERBITAN }}
|
||||
|
||||
- name: Unduh pnpm
|
||||
uses: pnpm/setup@v2
|
||||
with:
|
||||
version: 11
|
||||
|
||||
- name: Penerbitan paket NPM
|
||||
run: |
|
||||
pnpm i
|
||||
npm config set @${{ needs.persiapan.outputs.organisasi }}:registry=https://${{ vars.ALAMAT_GITEA }}/api/packages/${{ needs.persiapan.outputs.organisasi }}/npm/
|
||||
npm config set -- '//${{ vars.ALAMAT_GITEA }}/api/packages/${{ needs.persiapan.outputs.organisasi }}/npm/:_authToken' "${{ secrets.KUNCI_PENERBITAN }}"
|
||||
npm publish
|
||||
rm -rf pnpm-lock.yaml .pnpm-store/
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-plugin-bluclas"
|
||||
version = "0.1.19"
|
||||
version = "0.1.23"
|
||||
authors = [ "Rizky Denianto" ]
|
||||
description = "Program sederhana untuk interaksi dengan bluetooth classic"
|
||||
edition = "2024"
|
||||
@@ -28,7 +28,7 @@ ios = { level = "none" }
|
||||
tauri = { version = "2.11.5" }
|
||||
serde = "1.0"
|
||||
thiserror = "2"
|
||||
serialport = "4.10.0"
|
||||
serialport = "4.10.1"
|
||||
|
||||
[build-dependencies]
|
||||
tauri-plugin = { version = "2.6.3", features = ["build"] }
|
||||
@@ -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()
|
||||
|
||||
+18
-1
@@ -1,4 +1,21 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import {
|
||||
checkPermissions as checkPermissions_,
|
||||
invoke,
|
||||
PermissionState,
|
||||
requestPermissions as requestPermissions_,
|
||||
} from "@tauri-apps/api/core";
|
||||
|
||||
export async function checkPermissions(): Promise<PermissionState> {
|
||||
return await checkPermissions_<{ bluetooth: PermissionState }>(
|
||||
"bluclas",
|
||||
).then((e) => e.bluetooth);
|
||||
}
|
||||
|
||||
export async function requestPermissions(): Promise<PermissionState> {
|
||||
return await requestPermissions_<{ bluetooth: PermissionState }>(
|
||||
"bluclas",
|
||||
).then((e) => e.bluetooth);
|
||||
}
|
||||
|
||||
export type SDaftarPerangkatBlueclasResponDaftarPerangkat = {
|
||||
nama: string;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@segubi/tauri-plugin-bluclas-api",
|
||||
"version": "0.1.19",
|
||||
"version": "0.1.23",
|
||||
"author": "Rizky Denianto",
|
||||
"description": "Program sederhana untuk interaksi dengan bluetooth classic",
|
||||
"type": "module",
|
||||
@@ -26,7 +26,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-typescript": "^12.3.0",
|
||||
"rollup": "^4.63.1",
|
||||
"rollup": "^4.63.2",
|
||||
"typescript": "^6.0.3",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@ export default {
|
||||
plugins: [
|
||||
typescript({
|
||||
declaration: true,
|
||||
declarationDir: dirname(pkg.exports.import)
|
||||
declarationDir: dirname(pkg.exports.import),
|
||||
rootDir: 'guest-js'
|
||||
})
|
||||
],
|
||||
external: [
|
||||
|
||||
Reference in new issue
Block a user