Loading files
8c13e4b54This file is pinned to the selected release. Download the original to open it in your design tool.
Files from this revision, including CAD and LFS contents. Git history is not included.
Or in GitHub Desktop, choose File → Clone repository → URL and paste this address.
Public repositories can be cloned without signing in. For pushing, use your ThingAtlas username and a Git access token as the password.
git lfs install git clone https://thingatlas.com/git/-unclaimed/stack-chan-374381865.git
Includes Git history, branches, and Git LFS files. Clones the repository’s default branch, regardless of the version shown here.
import BLEServer from 'bleserver'
import { uuid } from 'btutils'
const DEVICE_NAME = 'stk'
const SERVICE_UUID = '450f932b-bb09-4fe3-9856-6f66ddcc43ec'
// const CHARACTERISTIC_UUID = 'a2abc192-26aa-45d9-aa17-42db27585c57'
class StkServer extends BLEServer {
#handleReceive
#handleConnected
#handleDisconnected
constructor(options) {
super(options)
this.#handleReceive = options.onReceive
this.#handleConnected = options.onConnected
this.#handleDisconnected = options.onDisconnected
}
onReady() {
this.qr = ''
this.deviceName = DEVICE_NAME
this.onDisconnected()
}
onConnected(connection) {
this.stopAdvertising()
this.#handleConnected?.()
}
onDisconnected(connection) {
this.startAdvertising({
advertisingData: {
flags: 6,
completeName: DEVICE_NAME,
completeUUID128List: [uuid([SERVICE_UUID])],
},
})
this.#handleDisconnected?.()
}
onCharacteristicWritten(params, value) {
if (params.name === 'stk') {
const pose = JSON.parse(String.fromArrayBuffer(value))
this.#handleReceive?.(pose)
}
}
}
export default StkServer
8c13e4b54This file is pinned to the selected release. Download the original to open it in your design tool.