Compare commits
57
Commits
2185c6e6fb
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
743fc021f6 | ||
|
|
24c5d3e1f2 | ||
|
|
de72fa5e3e | ||
|
|
a8ff604873 | ||
|
|
00aa5a8526 | ||
|
|
d497b68bb7 | ||
|
|
432a34540d | ||
|
|
09ac478ae3 | ||
|
|
923540934e | ||
|
|
30120dacb2 | ||
|
|
f0b237d2a2 | ||
|
|
c72613bd76 | ||
|
|
cd139ab7c7 | ||
|
|
6f9ac2f9e3 | ||
|
|
0bf140dff2 | ||
|
|
9787d1619e | ||
|
|
c5904331d3 | ||
|
|
6553e7ead7 | ||
|
|
beb7264180 | ||
|
|
84d630dd38 | ||
|
|
d41a34ab1d | ||
|
|
55a36875c8 | ||
|
|
32562daf27 | ||
|
|
98ae6c5e28 | ||
|
|
6cd1a44b19 | ||
|
|
a4cb3a1ede | ||
|
|
1754b6a812 | ||
|
|
13d99a25c2 | ||
|
|
028cb90bff | ||
|
|
14215a615e | ||
|
|
3354416f6b | ||
|
|
6fe02acd86 | ||
|
|
a1efac9fd1 | ||
|
|
0617c1eb83 | ||
|
|
0359652b9c | ||
|
|
05d845521f | ||
|
|
8c9bc8b53c | ||
|
|
9acba79ec4 | ||
|
|
eab4ea5567 | ||
|
|
f2dcab4ca4 | ||
|
|
2777aaea84 | ||
|
|
f881c09475 | ||
|
|
c195d2bc99 | ||
|
|
f98cd2169a | ||
|
|
d0843a9518 | ||
|
|
f40b309886 | ||
|
|
830a2e908a | ||
|
|
e77cb835eb | ||
|
|
bb116775c4 | ||
|
|
424c0f7049 | ||
|
|
8bdb1fcd27 | ||
|
|
6e1eb9b9a5 | ||
|
|
bc3ac09f0c | ||
|
|
df87a5e811 | ||
|
|
62e1a286a7 | ||
|
|
43ad1645b2 | ||
|
|
da50a0f466 |
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
[registry]
|
||||||
|
default = "gitea"
|
||||||
|
|
||||||
|
[registries.gitea]
|
||||||
|
index = "sparse+https://git.segubi.com/api/packages/segubi/cargo/"
|
||||||
@@ -1,15 +1,12 @@
|
|||||||
name: Penerbitan Plugin
|
name: Penerbitan Plugin
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches: ["main"]
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: ["main"]
|
branches: ["main"]
|
||||||
types: ["opened", "synchronize"]
|
types: ["opened", "synchronize"]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
persiapan:
|
persiapan:
|
||||||
if: "!contains(gitea.event.head_commit.message, 'Merge pull request')"
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
organisasi: ${{ steps.var.outputs.organisasi }}
|
organisasi: ${{ steps.var.outputs.organisasi }}
|
||||||
@@ -24,19 +21,47 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: persiapan
|
needs: persiapan
|
||||||
steps:
|
steps:
|
||||||
|
- name: Unduh paket untuk membangun citra
|
||||||
|
run: |
|
||||||
|
apt update -y
|
||||||
|
sudo apt install -y libwebkit2gtk-4.1-dev \
|
||||||
|
build-essential \
|
||||||
|
curl \
|
||||||
|
wget \
|
||||||
|
file \
|
||||||
|
libxdo-dev \
|
||||||
|
libssl-dev \
|
||||||
|
libayatana-appindicator3-dev \
|
||||||
|
librsvg2-dev \
|
||||||
|
libudev-dev
|
||||||
|
apt clean -y
|
||||||
|
|
||||||
- name: Unduh program
|
- name: Unduh program
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Unduh pnpm
|
- name: Unduh Rust
|
||||||
uses: pnpm/action-setup@v6
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
version: 10
|
toolchain: stable
|
||||||
|
rustflags: "-A warnings"
|
||||||
|
|
||||||
- name: Unggah program
|
- name: Penerbitan peti Cargo
|
||||||
|
run: |
|
||||||
|
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: |
|
run: |
|
||||||
pnpm i
|
pnpm i
|
||||||
npm config set @${{ needs.persiapan.outputs.organisasi }}:registry=https://${{ vars.ALAMAT_GITEA }}/api/packages/${{ needs.persiapan.outputs.organisasi }}/npm/
|
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 config set -- '//${{ vars.ALAMAT_GITEA }}/api/packages/${{ needs.persiapan.outputs.organisasi }}/npm/:_authToken' "${{ secrets.KUNCI_PENERBITAN }}"
|
||||||
npm publish
|
npm publish
|
||||||
|
rm -rf pnpm-lock.yaml .pnpm-store/
|
||||||
+11
-3
@@ -1,10 +1,10 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tauri-plugin-bluclas"
|
name = "tauri-plugin-bluclas"
|
||||||
version = "0.1.0"
|
version = "0.1.23"
|
||||||
authors = [ "Rizky Denianto" ]
|
authors = [ "Rizky Denianto" ]
|
||||||
description = ""
|
description = "Program sederhana untuk interaksi dengan bluetooth classic"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.94.1"
|
rust-version = "1.98.0"
|
||||||
exclude = ["/examples", "/dist-js", "/guest-js", "/node_modules"]
|
exclude = ["/examples", "/dist-js", "/guest-js", "/node_modules"]
|
||||||
links = "tauri-plugin-bluclas"
|
links = "tauri-plugin-bluclas"
|
||||||
|
|
||||||
@@ -17,10 +17,18 @@ incremental = false
|
|||||||
strip = "symbols"
|
strip = "symbols"
|
||||||
debug = false
|
debug = false
|
||||||
|
|
||||||
|
[package.metadata.platforms.support]
|
||||||
|
windows = { level = "full" }
|
||||||
|
linux = { level = "full" }
|
||||||
|
macos = { level = "none" }
|
||||||
|
android = { level = "full" }
|
||||||
|
ios = { level = "none" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri = { version = "2.11.5" }
|
tauri = { version = "2.11.5" }
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
thiserror = "2"
|
thiserror = "2"
|
||||||
|
serialport = "4.10.1"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-plugin = { version = "2.6.3", features = ["build"] }
|
tauri-plugin = { version = "2.6.3", features = ["build"] }
|
||||||
@@ -1 +1,3 @@
|
|||||||
# Tauri Plugin bluclas
|
# Tauri Plugin bluclas
|
||||||
|
|
||||||
|
Program sederhana untuk interaksi dengan bluetooth classic
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
|
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ class KirimArgs {
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
class BluclasPlugin(private val activity: Activity) : Plugin(activity) {
|
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 val bluetoothAdapter: BluetoothAdapter? = this.activity.getSystemService(BluetoothManager::class.java).getAdapter()
|
||||||
private var soket: BluetoothSocket? = null
|
private var bluetoothSocket: BluetoothSocket? = null
|
||||||
private var keluaran: OutputStream? = null
|
private var outputStream: OutputStream? = null
|
||||||
|
|
||||||
@Command
|
@Command
|
||||||
override fun checkPermissions(invoke: Invoke) {
|
override fun checkPermissions(invoke: Invoke) {
|
||||||
@@ -55,13 +55,13 @@ class BluclasPlugin(private val activity: Activity) : Plugin(activity) {
|
|||||||
|
|
||||||
@Command
|
@Command
|
||||||
fun daftarPerangkat(invoke: Invoke) {
|
fun daftarPerangkat(invoke: Invoke) {
|
||||||
if (adapter == null) {
|
if (bluetoothAdapter == null) {
|
||||||
invoke.reject("Bluetooth tidak didukung")
|
invoke.reject("Bluetooth tidak didukung")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val daftarRes = JSArray()
|
val daftarRes = JSArray()
|
||||||
adapter.bondedDevices.map { i ->
|
bluetoothAdapter.bondedDevices.map { i ->
|
||||||
val res = JSObject()
|
val res = JSObject()
|
||||||
res.put("nama", i.name ?: "Unknown")
|
res.put("nama", i.name ?: "Unknown")
|
||||||
res.put("alamat", i.address)
|
res.put("alamat", i.address)
|
||||||
@@ -74,32 +74,37 @@ class BluclasPlugin(private val activity: Activity) : Plugin(activity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun menghubungkanKoneksi(alamat: String) {
|
fun menghubungkanKoneksi(alamat: String) {
|
||||||
val perangkat: BluetoothDevice = adapter!!.getRemoteDevice(alamat)
|
val bluetoothDevice: BluetoothDevice = bluetoothAdapter!!.getRemoteDevice(alamat)
|
||||||
soket = perangkat.createInsecureRfcommSocketToServiceRecord(uuidSpp)
|
bluetoothSocket = bluetoothDevice.createInsecureRfcommSocketToServiceRecord(uuid)
|
||||||
soket!!.connect()
|
bluetoothSocket!!.connect()
|
||||||
keluaran = soket!!.outputStream
|
outputStream = bluetoothSocket!!.outputStream
|
||||||
}
|
}
|
||||||
|
|
||||||
fun memutusKoneksi() {
|
fun memutusKoneksi() {
|
||||||
keluaran?.close()
|
outputStream?.close()
|
||||||
keluaran = null
|
outputStream = null
|
||||||
soket?.close()
|
bluetoothSocket?.close()
|
||||||
soket = null
|
bluetoothSocket = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command
|
@Command
|
||||||
fun kirim(invoke: Invoke) {
|
fun kirim(invoke: Invoke) {
|
||||||
val args = invoke.parseArgs(KirimArgs::class.java)
|
val args = invoke.parseArgs(KirimArgs::class.java)
|
||||||
|
val alamat = args.alamat
|
||||||
|
if (alamat.isNullOrEmpty()) {
|
||||||
|
invoke.resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
menghubungkanKoneksi(args.alamat ?: "")
|
menghubungkanKoneksi(alamat)
|
||||||
|
|
||||||
if (keluaran == null) {
|
if (outputStream == null) {
|
||||||
throw Exception("Tidak ada perangkat yang terhubung")
|
throw Exception("Tidak ada perangkat yang terhubung")
|
||||||
}
|
}
|
||||||
|
|
||||||
keluaran!!.write(args.data)
|
outputStream!!.write(args.data)
|
||||||
keluaran!!.flush()
|
outputStream!!.flush()
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
memutusKoneksi()
|
memutusKoneksi()
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
const COMMANDS: &[&str] = &["cek_izin", "minta_izin", "daftar_perangkat", "kirim"];
|
const COMMANDS: &[&str] = &[
|
||||||
|
"check_permissions",
|
||||||
|
"request_permissions",
|
||||||
|
"daftar_perangkat",
|
||||||
|
"kirim",
|
||||||
|
];
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri_plugin::Builder::new(COMMANDS)
|
tauri_plugin::Builder::new(COMMANDS)
|
||||||
|
|||||||
+33
-17
@@ -1,26 +1,42 @@
|
|||||||
import { invoke } from "@tauri-apps/api/core";
|
import {
|
||||||
import { SBlueclasMuatanKirim, SBlueclasResponDaftarPerangkat } from "./models";
|
checkPermissions as checkPermissions_,
|
||||||
|
invoke,
|
||||||
|
PermissionState,
|
||||||
|
requestPermissions as requestPermissions_,
|
||||||
|
} from "@tauri-apps/api/core";
|
||||||
|
|
||||||
export async function cekIzin(): Promise<string> {
|
export async function checkPermissions(): Promise<PermissionState> {
|
||||||
return await invoke<string>("plugin:bluclas|cek_izin").then((res: string) => res);
|
return await checkPermissions_<{ bluetooth: PermissionState }>(
|
||||||
|
"bluclas",
|
||||||
|
).then((e) => e.bluetooth);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mintaIzin(): Promise<null> {
|
export async function requestPermissions(): Promise<PermissionState> {
|
||||||
return await invoke<null>("plugin:bluclas|minta_izin");
|
return await requestPermissions_<{ bluetooth: PermissionState }>(
|
||||||
|
"bluclas",
|
||||||
|
).then((e) => e.bluetooth);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function daftarPerangkat(): Promise<
|
export type SDaftarPerangkatBlueclasResponDaftarPerangkat = {
|
||||||
SBlueclasResponDaftarPerangkat[]
|
nama: string;
|
||||||
> {
|
alamat: string;
|
||||||
return await invoke<SBlueclasResponDaftarPerangkat[]>(
|
};
|
||||||
|
|
||||||
|
export type SBlueclasResponDaftarPerangkat = {
|
||||||
|
data: SDaftarPerangkatBlueclasResponDaftarPerangkat[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function daftarPerangkat(): Promise<SBlueclasResponDaftarPerangkat> {
|
||||||
|
return await invoke<SBlueclasResponDaftarPerangkat>(
|
||||||
"plugin:bluclas|daftar_perangkat",
|
"plugin:bluclas|daftar_perangkat",
|
||||||
).then((res: SBlueclasResponDaftarPerangkat[]) => res);
|
).then((res: SBlueclasResponDaftarPerangkat) => res);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function kirim(value: SBlueclasMuatanKirim): Promise<null> {
|
export type SBlueclasMuatanKirim = {
|
||||||
return await invoke<null>("plugin:bluclas|kirim", {
|
alamat: string;
|
||||||
payload: {
|
data: number[];
|
||||||
value,
|
};
|
||||||
},
|
|
||||||
});
|
export async function kirim(muatan: SBlueclasMuatanKirim): Promise<null> {
|
||||||
|
return await invoke<null>("plugin:bluclas|kirim", { muatan: muatan });
|
||||||
}
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
type SDaftarPerangkatBlueclasResponDaftarPerangkat = {
|
|
||||||
nama: string,
|
|
||||||
alamat: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type SBlueclasResponDaftarPerangkat = {
|
|
||||||
data: SDaftarPerangkatBlueclasResponDaftarPerangkat[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export type SBlueclasMuatanKirim = {
|
|
||||||
alamat: string,
|
|
||||||
data: number[],
|
|
||||||
};
|
|
||||||
+4
-4
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@segubi/tauri-plugin-bluclas-api",
|
"name": "@segubi/tauri-plugin-bluclas-api",
|
||||||
"version": "0.1.1",
|
"version": "0.1.23",
|
||||||
"author": "Rizky Denianto",
|
"author": "Rizky Denianto",
|
||||||
"description": "",
|
"description": "Program sederhana untuk interaksi dengan bluetooth classic",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"types": "./dist-js/index.d.ts",
|
"types": "./dist-js/index.d.ts",
|
||||||
"main": "./dist-js/index.cjs",
|
"main": "./dist-js/index.cjs",
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-typescript": "^12.3.0",
|
"@rollup/plugin-typescript": "^12.3.0",
|
||||||
"rollup": "^4.62.2",
|
"rollup": "^4.63.2",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^6.0.3",
|
||||||
"tslib": "^2.8.1"
|
"tslib": "^2.8.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# Automatically generated - DO NOT EDIT!
|
|
||||||
|
|
||||||
"$schema" = "../../schemas/schema.json"
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "allow-cek-izin"
|
|
||||||
description = "Enables the cek_izin command without any pre-configured scope."
|
|
||||||
commands.allow = ["cek_izin"]
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "deny-cek-izin"
|
|
||||||
description = "Denies the cek_izin command without any pre-configured scope."
|
|
||||||
commands.deny = ["cek_izin"]
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Automatically generated - DO NOT EDIT!
|
||||||
|
|
||||||
|
"$schema" = "../../schemas/schema.json"
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-check-permissions"
|
||||||
|
description = "Enables the check_permissions command without any pre-configured scope."
|
||||||
|
commands.allow = ["check_permissions"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "deny-check-permissions"
|
||||||
|
description = "Denies the check_permissions command without any pre-configured scope."
|
||||||
|
commands.deny = ["check_permissions"]
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# Automatically generated - DO NOT EDIT!
|
|
||||||
|
|
||||||
"$schema" = "../../schemas/schema.json"
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "allow-minta-izin"
|
|
||||||
description = "Enables the minta_izin command without any pre-configured scope."
|
|
||||||
commands.allow = ["minta_izin"]
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "deny-minta-izin"
|
|
||||||
description = "Denies the minta_izin command without any pre-configured scope."
|
|
||||||
commands.deny = ["minta_izin"]
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Automatically generated - DO NOT EDIT!
|
||||||
|
|
||||||
|
"$schema" = "../../schemas/schema.json"
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-request-permissions"
|
||||||
|
description = "Enables the request_permissions command without any pre-configured scope."
|
||||||
|
commands.allow = ["request_permissions"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "deny-request-permissions"
|
||||||
|
description = "Denies the request_permissions command without any pre-configured scope."
|
||||||
|
commands.deny = ["request_permissions"]
|
||||||
@@ -4,8 +4,8 @@ Default permissions for the plugin
|
|||||||
|
|
||||||
#### This default permission set includes the following:
|
#### This default permission set includes the following:
|
||||||
|
|
||||||
- `allow-cek-izin`
|
- `allow-check-permissions`
|
||||||
- `allow-minta-izin`
|
- `allow-request-permissions`
|
||||||
- `allow-daftar-perangkat`
|
- `allow-daftar-perangkat`
|
||||||
- `allow-kirim`
|
- `allow-kirim`
|
||||||
|
|
||||||
@@ -21,12 +21,12 @@ Default permissions for the plugin
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
`bluclas:allow-cek-izin`
|
`bluclas:allow-check-permissions`
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
Enables the cek_izin command without any pre-configured scope.
|
Enables the check_permissions command without any pre-configured scope.
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -34,12 +34,12 @@ Enables the cek_izin command without any pre-configured scope.
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
`bluclas:deny-cek-izin`
|
`bluclas:deny-check-permissions`
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
Denies the cek_izin command without any pre-configured scope.
|
Denies the check_permissions command without any pre-configured scope.
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -99,12 +99,12 @@ Denies the kirim command without any pre-configured scope.
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
`bluclas:allow-minta-izin`
|
`bluclas:allow-request-permissions`
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
Enables the minta_izin command without any pre-configured scope.
|
Enables the request_permissions command without any pre-configured scope.
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -112,12 +112,12 @@ Enables the minta_izin command without any pre-configured scope.
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
`bluclas:deny-minta-izin`
|
`bluclas:deny-request-permissions`
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
Denies the minta_izin command without any pre-configured scope.
|
Denies the request_permissions command without any pre-configured scope.
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
[default]
|
[default]
|
||||||
description = "Default permissions for the plugin"
|
description = "Default permissions for the plugin"
|
||||||
permissions = [
|
permissions = [
|
||||||
"allow-cek-izin",
|
"allow-check-permissions",
|
||||||
"allow-minta-izin",
|
"allow-request-permissions",
|
||||||
"allow-daftar-perangkat",
|
"allow-daftar-perangkat",
|
||||||
"allow-kirim"
|
"allow-kirim"
|
||||||
]
|
]
|
||||||
@@ -295,16 +295,16 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"description": "Enables the cek_izin command without any pre-configured scope.",
|
"description": "Enables the check_permissions command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "allow-cek-izin",
|
"const": "allow-check-permissions",
|
||||||
"markdownDescription": "Enables the cek_izin command without any pre-configured scope."
|
"markdownDescription": "Enables the check_permissions command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Denies the cek_izin command without any pre-configured scope.",
|
"description": "Denies the check_permissions command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "deny-cek-izin",
|
"const": "deny-check-permissions",
|
||||||
"markdownDescription": "Denies the cek_izin command without any pre-configured scope."
|
"markdownDescription": "Denies the check_permissions command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Enables the daftar_perangkat command without any pre-configured scope.",
|
"description": "Enables the daftar_perangkat command without any pre-configured scope.",
|
||||||
@@ -331,22 +331,22 @@
|
|||||||
"markdownDescription": "Denies the kirim command without any pre-configured scope."
|
"markdownDescription": "Denies the kirim command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Enables the minta_izin command without any pre-configured scope.",
|
"description": "Enables the request_permissions command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "allow-minta-izin",
|
"const": "allow-request-permissions",
|
||||||
"markdownDescription": "Enables the minta_izin command without any pre-configured scope."
|
"markdownDescription": "Enables the request_permissions command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Denies the minta_izin command without any pre-configured scope.",
|
"description": "Denies the request_permissions command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "deny-minta-izin",
|
"const": "deny-request-permissions",
|
||||||
"markdownDescription": "Denies the minta_izin command without any pre-configured scope."
|
"markdownDescription": "Denies the request_permissions command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-cek-izin`\n- `allow-minta-izin`\n- `allow-daftar-perangkat`\n- `allow-kirim`",
|
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-check-permissions`\n- `allow-request-permissions`\n- `allow-daftar-perangkat`\n- `allow-kirim`",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "default",
|
"const": "default",
|
||||||
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-cek-izin`\n- `allow-minta-izin`\n- `allow-daftar-perangkat`\n- `allow-kirim`"
|
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-check-permissions`\n- `allow-request-permissions`\n- `allow-daftar-perangkat`\n- `allow-kirim`"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -20,7 +20,8 @@ export default {
|
|||||||
plugins: [
|
plugins: [
|
||||||
typescript({
|
typescript({
|
||||||
declaration: true,
|
declaration: true,
|
||||||
declarationDir: dirname(pkg.exports.import)
|
declarationDir: dirname(pkg.exports.import),
|
||||||
|
rootDir: 'guest-js'
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
external: [
|
external: [
|
||||||
|
|||||||
+2
-12
@@ -4,16 +4,6 @@ use crate::BluclasExt;
|
|||||||
use crate::Result;
|
use crate::Result;
|
||||||
use crate::models::*;
|
use crate::models::*;
|
||||||
|
|
||||||
#[command]
|
|
||||||
pub(crate) async fn cek_izin<R: Runtime>(app: AppHandle<R>) -> Result<String> {
|
|
||||||
return app.bluclas().cek_izin();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[command]
|
|
||||||
pub(crate) async fn minta_izin<R: Runtime>(app: AppHandle<R>) -> Result<()> {
|
|
||||||
return app.bluclas().minta_izin();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
pub(crate) async fn daftar_perangkat<R: Runtime>(
|
pub(crate) async fn daftar_perangkat<R: Runtime>(
|
||||||
app: AppHandle<R>,
|
app: AppHandle<R>,
|
||||||
@@ -24,7 +14,7 @@ pub(crate) async fn daftar_perangkat<R: Runtime>(
|
|||||||
#[command]
|
#[command]
|
||||||
pub(crate) async fn kirim<R: Runtime>(
|
pub(crate) async fn kirim<R: Runtime>(
|
||||||
app: AppHandle<R>,
|
app: AppHandle<R>,
|
||||||
payload: SBlueclasMuatanKirim,
|
muatan: SBlueclasMuatanKirim,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
return app.bluclas().kirim(payload);
|
return app.bluclas().kirim(muatan);
|
||||||
}
|
}
|
||||||
+22
-10
@@ -1,3 +1,5 @@
|
|||||||
|
use std::{mem, time::Duration};
|
||||||
|
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use tauri::{AppHandle, Runtime, plugin::PluginApi};
|
use tauri::{AppHandle, Runtime, plugin::PluginApi};
|
||||||
|
|
||||||
@@ -14,19 +16,29 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
|
|||||||
pub struct Bluclas<R: Runtime>(AppHandle<R>);
|
pub struct Bluclas<R: Runtime>(AppHandle<R>);
|
||||||
|
|
||||||
impl<R: Runtime> Bluclas<R> {
|
impl<R: Runtime> Bluclas<R> {
|
||||||
pub fn cek_izin(&self) -> crate::Result<String> {
|
|
||||||
return Ok(String::new());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn minta_izin(&self) -> crate::Result<()> {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasResponDaftarPerangkat> {
|
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasResponDaftarPerangkat> {
|
||||||
return Ok(SBlueclasResponDaftarPerangkat { data: vec![] });
|
let port = serialport::available_ports().unwrap_or(Vec::new());
|
||||||
|
let mut daftar_res: Vec<SDaftarPerangkatBlueclasResponDaftarPerangkat> = Vec::new();
|
||||||
|
for i in port {
|
||||||
|
let res = SDaftarPerangkatBlueclasResponDaftarPerangkat {
|
||||||
|
nama: i.port_name.clone(),
|
||||||
|
alamat: i.port_name,
|
||||||
|
};
|
||||||
|
daftar_res.push(res);
|
||||||
|
}
|
||||||
|
return Ok(SBlueclasResponDaftarPerangkat { data: daftar_res });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kirim(&self, _: SBlueclasMuatanKirim) -> crate::Result<()> {
|
pub fn kirim(&self, muatan: SBlueclasMuatanKirim) -> crate::Result<()> {
|
||||||
|
let mut pencetak = match serialport::new(&muatan.alamat, 9600)
|
||||||
|
.timeout(Duration::from_secs(4))
|
||||||
|
.open()
|
||||||
|
{
|
||||||
|
Ok(it) => it,
|
||||||
|
Err(_) => return Ok(()),
|
||||||
|
};
|
||||||
|
pencetak.write(&muatan.data).unwrap();
|
||||||
|
mem::drop(pencetak);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-9
@@ -1,11 +1,8 @@
|
|||||||
use crate::commands::{cek_izin, daftar_perangkat, kirim, minta_izin};
|
|
||||||
use tauri::{
|
use tauri::{
|
||||||
Manager, Runtime,
|
Manager, Runtime,
|
||||||
plugin::{Builder, TauriPlugin},
|
plugin::{Builder, TauriPlugin},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use models::*;
|
|
||||||
|
|
||||||
#[cfg(desktop)]
|
#[cfg(desktop)]
|
||||||
mod desktop;
|
mod desktop;
|
||||||
#[cfg(mobile)]
|
#[cfg(mobile)]
|
||||||
@@ -22,6 +19,8 @@ use desktop::Bluclas;
|
|||||||
#[cfg(mobile)]
|
#[cfg(mobile)]
|
||||||
use mobile::Bluclas;
|
use mobile::Bluclas;
|
||||||
|
|
||||||
|
use crate::commands::{daftar_perangkat, kirim};
|
||||||
|
|
||||||
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the bluclas APIs.
|
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the bluclas APIs.
|
||||||
pub trait BluclasExt<R: Runtime> {
|
pub trait BluclasExt<R: Runtime> {
|
||||||
fn bluclas(&self) -> &Bluclas<R>;
|
fn bluclas(&self) -> &Bluclas<R>;
|
||||||
@@ -36,12 +35,7 @@ impl<R: Runtime, T: Manager<R>> crate::BluclasExt<R> for T {
|
|||||||
/// Initializes the plugin.
|
/// Initializes the plugin.
|
||||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||||
Builder::new("bluclas")
|
Builder::new("bluclas")
|
||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![daftar_perangkat, kirim])
|
||||||
cek_izin,
|
|
||||||
minta_izin,
|
|
||||||
daftar_perangkat,
|
|
||||||
kirim
|
|
||||||
])
|
|
||||||
.setup(|app, api| {
|
.setup(|app, api| {
|
||||||
#[cfg(mobile)]
|
#[cfg(mobile)]
|
||||||
let bluclas = mobile::init(app, api)?;
|
let bluclas = mobile::init(app, api)?;
|
||||||
|
|||||||
+2
-16
@@ -25,20 +25,6 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
|
|||||||
pub struct Bluclas<R: Runtime>(PluginHandle<R>);
|
pub struct Bluclas<R: Runtime>(PluginHandle<R>);
|
||||||
|
|
||||||
impl<R: Runtime> Bluclas<R> {
|
impl<R: Runtime> Bluclas<R> {
|
||||||
pub fn cek_izin(&self) -> crate::Result<String> {
|
|
||||||
return self
|
|
||||||
.0
|
|
||||||
.run_mobile_plugin("checkPermissions", ())
|
|
||||||
.map_err(Into::into);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn minta_izin(&self) -> crate::Result<()> {
|
|
||||||
return self
|
|
||||||
.0
|
|
||||||
.run_mobile_plugin("requestPermissions", ())
|
|
||||||
.map_err(Into::into);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasResponDaftarPerangkat> {
|
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasResponDaftarPerangkat> {
|
||||||
return self
|
return self
|
||||||
.0
|
.0
|
||||||
@@ -46,10 +32,10 @@ impl<R: Runtime> Bluclas<R> {
|
|||||||
.map_err(Into::into);
|
.map_err(Into::into);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kirim(&self, payload: SBlueclasMuatanKirim) -> crate::Result<()> {
|
pub fn kirim(&self, muatan: SBlueclasMuatanKirim) -> crate::Result<()> {
|
||||||
return self
|
return self
|
||||||
.0
|
.0
|
||||||
.run_mobile_plugin("kirim", payload)
|
.run_mobile_plugin("kirim", muatan)
|
||||||
.map_err(Into::into);
|
.map_err(Into::into);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-3
@@ -1,19 +1,19 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct SDaftarPerangkatBlueclasResponDaftarPerangkat {
|
pub struct SDaftarPerangkatBlueclasResponDaftarPerangkat {
|
||||||
pub nama: String,
|
pub nama: String,
|
||||||
pub alamat: String,
|
pub alamat: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct SBlueclasResponDaftarPerangkat {
|
pub struct SBlueclasResponDaftarPerangkat {
|
||||||
pub data: Vec<SDaftarPerangkatBlueclasResponDaftarPerangkat>,
|
pub data: Vec<SDaftarPerangkatBlueclasResponDaftarPerangkat>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct SBlueclasMuatanKirim {
|
pub struct SBlueclasMuatanKirim {
|
||||||
pub alamat: String,
|
pub alamat: String,
|
||||||
|
|||||||
Reference in new issue
Block a user