Skip to content

Commit

Permalink
improve bluetooth device handeling
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevie-Ray committed Sep 8, 2024
1 parent fe2b172 commit bc39e65
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 122 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

237 changes: 121 additions & 116 deletions src/components/atoms/WorkoutBluetooth/WorkoutBluetooth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,25 @@ import {
mySmartBoard,
Progressor,
active,
battery,
connect,
disconnect,
info,
notify
} from '@hangtime/grip-connect'
import type { massObject } from '@hangtime/grip-connect/src/types/notify'
import { useBluetoothStore } from '@/stores/bluetooth'
const { device } = storeToRefs(useBluetoothStore())
const workout = defineModel<Workout>()
const { showDialog = false, size = 'default' } = defineProps<{
showDialog?: boolean
const { size = 'default' } = defineProps<{
size?: string
}>()
const emit = defineEmits(['notify', 'active', 'start', 'show-dialog'])
const emit = defineEmits(['notify', 'active', 'start'])
const { device } = storeToRefs(useBluetoothStore())
const dialog = ref(false)
const devices = [
{
Expand Down Expand Up @@ -84,121 +83,127 @@ const reset = () => {
device.value = null
}
const onSuccess = async () => {
try {
// set the device
device.value = dropdown.value
// Listen for notifications
notify((data: massObject) => {
emit('notify', data)
output.value = JSON.stringify(data)
})
active((value: boolean) => {
emit('active', value)
})
if (device.value?.name === Motherboard.filters.some((filter) => filter.name)) {
await battery(device.value)
await info(device.value)
const setup = () => {
connect(
dropdown.value,
async () => {
device.value = dropdown.value
// Listen for notifications
notify((data: massObject) => {
emit('notify', data)
// output.value = JSON.stringify(data)
})
active((value: boolean) => {
emit('active', value)
})
// Close Dialog
dialog.value = false
// Start workout
emit('start')
},
(error: Error) => {
errorElm.value = error
}
} catch (error) {
console.error(error)
} finally {
emit('show-dialog', false)
emit('start')
}
}
const onError = (error: Error) => {
errorElm.value = error
)
}
</script>

<template>
<v-dialog
:model-value="showDialog"
:scrim="false"
fullscreen
transition="dialog-bottom-transition"
>
<template v-slot:activator="{ props }">
<v-btn
v-if="isBluetoothSupported()"
:disabled="!isBluetoothAvailable"
:size="size"
color="text"
:icon="!device ? '$bluetooth' : '$bluetoothOff'"
v-bind="props"
variant="text"
></v-btn>
</template>
<v-card>
<v-toolbar>
<v-btn color="text" icon="$close" @click="emit('show-dialog', false)"></v-btn>
<v-toolbar-title>Force-Sensing Climbing Training</v-toolbar-title>
</v-toolbar>
<v-container>
<v-row>
<v-col cols="12">
<v-card class="mb-4">
<v-card-title>Test, Train, Measure and More</v-card-title>
<v-card-subtitle>Realtime data over Bluetooth.</v-card-subtitle>
<v-card-text>
<p class="mb-4">
Smart Bluetooth hangboards or plates revolutionize climbing training by
integrating sensors and connectivity. Devices like the
<a href="https://griptonite.io/motherboard/" target="_blank">
Griptonite Motherboard </a
>, <a href="https://climbro.com/" target="_blank">Climbro</a>,
<a href="https://www.smartboard-climbing.com/" target="_blank">SmartBoard</a>,
<a href="https://entralpi.com/" target="_blank">Entralpi</a>, and
<a href="https://tindeq.com/" target="_blank">Tindeq Progressor</a> offer
personalized workouts, performance tracking, and real-time feedback through mobile
apps, enhancing climbers' strength and technique with data-driven insights.
</p>
<p class="mb-4">
Excitingly, HangTime is now integrating bluetooth support, enhancing climbers'
training experiences. With the real-time feedback, HangTime users can seamlessly
sync and analyze their performance metrics, revolutionizing climbing training for
greater efficiency and progress.
</p>
<v-select v-model="dropdown" :items="devices" :item-props="true"></v-select>
<v-alert v-if="errorElm" closable type="error" :text="errorElm.message"></v-alert>
</v-card-text>
<v-card-actions>
<v-btn
:disabled="!isBluetoothAvailable"
:prepend-icon="!device ? '$bluetooth' : '$bluetoothOff'"
color="text"
variant="text"
@click="!device ? connect(dropdown, async () => onSuccess(), onError) : reset()"
>
{{ !device ? 'Connect' : 'Disconnect' }}
</v-btn>
<v-btn
href="https://github.com/Stevie-Ray/hangtime-grip-connect"
prepend-icon="$github"
color="text"
variant="text"
append-icon="$openInNew"
target="_blank"
>
Help development
</v-btn>
</v-card-actions>
</v-card>
<v-card v-if="output">
<v-card-text>
{{ output }}
</v-card-text>
</v-card>
</v-col>
</v-row>
</v-container>
</v-card>
</v-dialog>
<div>
<v-btn
v-if="isBluetoothSupported()"
:disabled="!isBluetoothAvailable"
:size="size"
color="text"
:icon="!device ? '$bluetooth' : '$bluetoothOff'"
variant="text"
@click="dialog = true"
></v-btn>
<v-dialog v-model="dialog" :scrim="false" fullscreen transition="dialog-bottom-transition">
<v-card>
<v-toolbar>
<v-btn color="text" icon="$close" @click="dialog = false"></v-btn>
<v-toolbar-title>Force-Sensing Climbing Training</v-toolbar-title>
</v-toolbar>
<v-container>
<v-row>
<v-col cols="12">
<v-card class="mb-4">
<v-card-title>Test, Train, Measure and More</v-card-title>
<v-card-subtitle>Realtime data over Bluetooth.</v-card-subtitle>
<v-card-text>
<p class="mb-4">
Smart Bluetooth hangboards or plates revolutionize climbing training by
integrating sensors and connectivity. Devices like the
<a
href="https://griptonite.io/shop/motherboard/"
target="_blank"
rel="nofollow"
>
Griptonite Motherboard </a
>, <a href="https://climbro.com/" target="_blank" rel="nofollow">Climbro</a>,
<a href="https://www.smartboard-climbing.com/" target="_blank" rel="nofollow">
mySmartBoard </a
>, <a href="https://entralpi.com/" target="_blank" rel="nofollow">Entralpi</a>,
<a href="https://tindeq.com/" target="_blank" rel="nofollow">
Tindeq Progressor
</a>
or
<a
href="https://weihengmanufacturer.com/products/wh-c06-bluetooth-300kg-hanging-scale/"
target="_blank"
rel="nofollow"
>
Weiheng WH-C06
</a>
offer performance tracking, and real-time feedback enhancing climbers' strength
and technique with data-driven insights.
</p>
<p class="mb-4">
Excitingly, HangTime is now integrating bluetooth support, enhancing climbers'
training experiences. With the real-time feedback, HangTime users can seamlessly
sync and analyze their performance metrics, revolutionizing climbing training
for greater efficiency and progress.
</p>
<v-select v-model="dropdown" :items="devices" :item-props="true"></v-select>
<v-alert v-if="errorElm" closable type="error" :text="errorElm.message"></v-alert>
</v-card-text>
<v-card-actions>
<v-btn
:disabled="!isBluetoothAvailable"
:prepend-icon="!device ? '$bluetooth' : '$bluetoothOff'"
color="text"
variant="text"
@click="!device ? setup() : reset()"
>
{{ !device ? 'Connect' : 'Disconnect' }}
</v-btn>
<v-btn
href="https://github.com/Stevie-Ray/hangtime-grip-connect"
prepend-icon="$github"
color="text"
variant="text"
append-icon="$openInNew"
target="_blank"
>
Help development
</v-btn>
</v-card-actions>
</v-card>
<v-card v-if="output">
<v-card-text>
{{ output }}
</v-card-text>
</v-card>
</v-col>
</v-row>
</v-container>
</v-card>
</v-dialog>
</div>
</template>

<style lang="scss" scoped>
Expand Down
3 changes: 0 additions & 3 deletions src/components/organisms/WorkoutTimer/WorkoutTimer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const workoutCompleteTimeTotal: Ref<number> = ref(0)
const workoutCompleteTimeHanging: Ref<number> = ref(0)
// bluetooth
const workoutBluetoothDialog = ref(false)
const bluetoothOutput = ref<massObject | null>(null)
const deviceInUse = ref(false)
Expand Down Expand Up @@ -794,11 +793,9 @@ onMounted(() => {
<workout-bluetooth
v-model="workout"
size="small"
:show-dialog="workoutBluetoothDialog"
@start="timerPaused === null ? startTimer() : null"
@notify="notify"
@active="active"
@show-dialog="workoutBluetoothDialog = !workoutBluetoothDialog"
/>
<workout-share v-model="workout" size="small" />
</div>
Expand Down

0 comments on commit bc39e65

Please sign in to comment.