mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
WeDo2 Extension: First Pass (#1441)
* Adding WeDo2 connection/disconnection over Scratch Link BLE. * Testing motor and LED output. * Reading sensor attachment and registering for sensor notifications. * Motor indexing. * Some refactoring notes. Moving some functions around. * Refactoring and enums. * Removing some comments * Fixing linting error. * Fixing tilt reporter values and added stopAll bound to stop button to stop piezo, LED and motors.
This commit is contained in:
parent
30892dfd43
commit
f01733f019
2 changed files with 378 additions and 117 deletions
|
@ -1,5 +1,5 @@
|
|||
const JSONRPCWebSocket = require('../util/jsonrpc-web-socket');
|
||||
// const log = require('../util/log');
|
||||
const log = require('../util/log');
|
||||
const ScratchLinkWebSocket = 'wss://device-manager.scratch.mit.edu:20110/scratch/ble';
|
||||
|
||||
class BLESession extends JSONRPCWebSocket {
|
||||
|
@ -121,7 +121,9 @@ class BLESession extends JSONRPCWebSocket {
|
|||
this._characteristicDidChangeCallback = onCharacteristicChanged;
|
||||
return this.sendRemoteRequest('read', params)
|
||||
.catch(e => {
|
||||
this._sendError(e);
|
||||
if (e.data !== 'Reading is not permitted.') { // TODO: workaround til notify-only supported
|
||||
this._sendError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -144,9 +146,9 @@ class BLESession extends JSONRPCWebSocket {
|
|||
});
|
||||
}
|
||||
|
||||
_sendError (/* e */) {
|
||||
_sendError (e) {
|
||||
this._connected = false;
|
||||
// log.error(`BLESession error: ${JSON.stringify(e)}`);
|
||||
log.error(`BLESession error: ${JSON.stringify(e)}`);
|
||||
this._runtime.emit(this._runtime.constructor.PERIPHERAL_ERROR);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue