Skip to content

Commit

Permalink
feat(example): allow changing connection options
Browse files Browse the repository at this point in the history
  • Loading branch information
r3pwn committed Sep 4, 2023
1 parent b01bbcf commit 9c5bc50
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
36 changes: 34 additions & 2 deletions example/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
const devicePit = ref(undefined as libpit.PitData | undefined);
const connectedDevice = ref({} as OdinDevice);
const verboseLogging = ref(true);
const defaultTimeout = ref(15000);
const resetOnInit = ref(false);
async function setupDevice (device: OdinDevice) {
console.log(device.usbDevice);
await device.initialize();
connectedDevice.value = device;
Expand All @@ -24,7 +30,11 @@
}
function requestDeviceAccess () {
libmjolnir.requestDevice({ logging: true, timeout: 15000 })
libmjolnir.requestDevice({
logging: verboseLogging.value,
timeout: defaultTimeout.value,
resetOnInit: resetOnInit.value
})
.then(setupDevice);
}
Expand All @@ -38,10 +48,25 @@
</script>

<template>
<fieldset class="connection-options">
<legend>Connection options</legend>
<div>
<label>Verbose logging: </label>
<input type="checkbox" v-model="verboseLogging" />
</div>
<div>
<label>Packet timeout: </label>
<input type="number" v-model="defaultTimeout" />
</div>
<div>
<label>Reset on initialize: </label>
<input type="checkbox" v-model="resetOnInit" />
</div>
</fieldset>
<button @click="requestDeviceAccess">Request device access</button>
<p v-if="hasDevice">
<p v-if="devicePit?.entries?.length">
<div>board type: {{ devicePit.pitName }}</div>
<div>board type: {{ devicePit.boardType }}</div>
<button @click="rebootDevice">Reboot device</button>
<template v-for="(entry, index) in devicePit.entries">
<partition-entry
Expand All @@ -60,4 +85,11 @@
color-scheme: dark;
}
}
.connection-options {
display: flex;
flex-direction: column;
width: fit-content;
margin-bottom: 1rem;
}
</style>
4 changes: 2 additions & 2 deletions example/src/components/PartitionEntry.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { ref } from 'vue';
import { PropType, ref } from 'vue';
import { libpit } from 'libmjolnir';
defineProps({
entry: {
type: libpit.PitEntry,
type: Object as PropType<libpit.PitEntry>,
required: true
}
});
Expand Down
12 changes: 6 additions & 6 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


"@babel/parser@^7.20.15", "@babel/parser@^7.21.3":
version "7.22.14"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.22.14.tgz#c7de58e8de106e88efca42ce17f0033209dfd245"
integrity sha512-1KucTHgOvaw/LzCVrEOAyXkr9rQlp0A1HiHRYnSUE9dmb8PvPW7o5sscg+5169r54n3vGlbx6GevTE/Iw/P3AQ==
version "7.22.15"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.22.15.tgz#d34592bfe288a32e741aa0663dbc4829fcd55160"
integrity sha512-RWmQ/sklUN9BvGGpCDgSubhHWfAx24XDTDObup4ffvxaYsptOg2P3KG0j+1eWKLxpkX0j0uHxmpq2Z1SP/VhxA==

"@esbuild/android-arm64@0.18.20":
version "0.18.20"
Expand Down Expand Up @@ -326,9 +326,9 @@ he@^1.2.0:
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==

libmjolnir@latest:
version "0.5.1"
resolved "https://registry.yarnpkg.com/libmjolnir/-/libmjolnir-0.5.1.tgz#54d93e66af4876f2c53510a377623121a0efa3fe"
integrity sha512-1s4K+IVR+i2OFSzN7AQYw94VWjxYl8QVww6cf9zs0qlSxvRvWtuKIC7m5mfb3IndaLyFIGuE9b0bmI51JtLhYw==
version "0.5.2"
resolved "https://registry.yarnpkg.com/libmjolnir/-/libmjolnir-0.5.2.tgz#b20c840135d15b88a3bcd17b0db6d0085825d5b0"
integrity sha512-aC5IuXTRbJAJeanQAdVeOEQqrmG3cmD4a27jmYpOsUx1CVR4C7qWhsJCJF6rMZbnAwK+B87oDhEmQngXaP12iw==

lru-cache@^6.0.0:
version "6.0.0"
Expand Down

0 comments on commit 9c5bc50

Please sign in to comment.