Implemented connect/disconnect call on BluetoothService component.

This commit is contained in:
Fabio Manganiello 2023-03-20 01:27:47 +01:00
parent 714f853751
commit 0a4b22c12e
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -14,7 +14,7 @@
<div class="col-2 connector pull-right"> <div class="col-2 connector pull-right">
<ToggleSwitch <ToggleSwitch
:value="parent.connected" :value="value.connected"
:disabled="loading" :disabled="loading"
@input="connect" @input="connect"
@click.stop /> @click.stop />
@ -37,9 +37,13 @@ export default {
async connect(event) { async connect(event) {
event.stopPropagation() event.stopPropagation()
this.$emit('loading', true) this.$emit('loading', true)
const method = (
'bluetooth.' +
(this.value.connected ? 'disconnect' : 'connect')
)
try { try {
await this.request('bluetooth.connect', { await this.request(method, {
device: this.parent.address, device: this.parent.address,
service_uuid: this.uuid, service_uuid: this.uuid,
}) })