generated from thinkode/modelRepository
implement devices
This commit is contained in:
@@ -146,6 +146,18 @@ function onEndpointEvent(sn, event) {
|
||||
}, 200);
|
||||
}
|
||||
|
||||
// When a new device is added
|
||||
function onDeviceArrival(deviceInfo) {
|
||||
console.log("New device arrival")
|
||||
console.log(deviceInfo)
|
||||
}
|
||||
|
||||
// When a new device is removed
|
||||
function onDeviceRemoval(sn){
|
||||
console.log("New device removal")
|
||||
console.log(sn)
|
||||
}
|
||||
|
||||
let initialized = false
|
||||
|
||||
export function initRuntimeEvents(){
|
||||
@@ -172,6 +184,12 @@ export function initRuntimeEvents(){
|
||||
|
||||
// Handle a endpoint event
|
||||
EventsOn('PERIPHERAL_EVENT_EMITTED', onEndpointEvent)
|
||||
|
||||
// Handle a device arrival
|
||||
EventsOn('DEVICE_ARRIVAL', onDeviceArrival)
|
||||
|
||||
// Handle a device removal
|
||||
EventsOn('DEVICE_REMOVAL', onDeviceRemoval)
|
||||
}
|
||||
|
||||
export function destroyRuntimeEvents(){
|
||||
@@ -198,4 +216,10 @@ export function destroyRuntimeEvents(){
|
||||
|
||||
// Handle a endpoint event
|
||||
EventsOff('PERIPHERAL_EVENT_EMITTED')
|
||||
|
||||
// Handle a device arrival
|
||||
EventsOff('DEVICE_ARRIVAL')
|
||||
|
||||
// Handle a device removal
|
||||
EventsOff('DEVICE_REMOVAL')
|
||||
}
|
||||
Reference in New Issue
Block a user