2018-06-20 13:59:23 -04:00
|
|
|
const JSONRPCWebSocket = require('../util/jsonrpc-web-socket');
|
2018-07-17 15:40:47 -04:00
|
|
|
const ScratchLinkWebSocket = 'wss://device-manager.scratch.mit.edu:20110/scratch/ble';
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
// const log = require('../util/log');
|
2018-06-20 13:59:23 -04:00
|
|
|
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
class BLE extends JSONRPCWebSocket {
|
2018-06-20 13:59:23 -04:00
|
|
|
|
|
|
|
/**
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
* A BLE peripheral socket object. It handles connecting, over web sockets, to
|
|
|
|
* BLE peripherals, and reading and writing data to them.
|
2018-06-20 13:59:23 -04:00
|
|
|
* @param {Runtime} runtime - the Runtime for sending/receiving GUI update events.
|
2018-09-21 09:44:48 -04:00
|
|
|
* @param {string} extensionId - the id of the extension using this socket.
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
* @param {object} peripheralOptions - the list of options for peripheral discovery.
|
2018-06-20 13:59:23 -04:00
|
|
|
* @param {object} connectCallback - a callback for connection.
|
|
|
|
*/
|
2018-09-21 09:44:48 -04:00
|
|
|
constructor (runtime, extensionId, peripheralOptions, connectCallback) {
|
2018-06-20 13:59:23 -04:00
|
|
|
const ws = new WebSocket(ScratchLinkWebSocket);
|
|
|
|
super(ws);
|
|
|
|
|
2018-06-24 22:00:23 -04:00
|
|
|
this._ws = ws;
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
this._ws.onopen = this.requestPeripheral.bind(this); // only call request peripheral after socket opens
|
2018-10-17 15:48:07 -04:00
|
|
|
this._ws.onerror = this._sendRequestError.bind(this, 'ws onerror');
|
|
|
|
this._ws.onclose = this._sendDisconnectError.bind(this, 'ws onclose');
|
2018-06-20 13:59:23 -04:00
|
|
|
|
|
|
|
this._availablePeripherals = {};
|
|
|
|
this._connectCallback = connectCallback;
|
2018-07-17 16:03:06 -04:00
|
|
|
this._connected = false;
|
2018-06-20 13:59:23 -04:00
|
|
|
this._characteristicDidChangeCallback = null;
|
2018-09-21 09:44:48 -04:00
|
|
|
this._extensionId = extensionId;
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
this._peripheralOptions = peripheralOptions;
|
2018-07-17 16:03:06 -04:00
|
|
|
this._discoverTimeoutID = null;
|
2018-06-20 13:59:23 -04:00
|
|
|
this._runtime = runtime;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
* Request connection to the peripheral.
|
2018-06-20 13:59:23 -04:00
|
|
|
* If the web socket is not yet open, request when the socket promise resolves.
|
|
|
|
*/
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
requestPeripheral () {
|
2018-06-24 22:00:23 -04:00
|
|
|
if (this._ws.readyState === 1) { // is this needed since it's only called on ws.onopen?
|
2018-07-17 16:03:06 -04:00
|
|
|
this._availablePeripherals = {};
|
2018-11-08 15:31:15 -05:00
|
|
|
if (this._discoverTimeoutID) {
|
|
|
|
window.clearTimeout(this._discoverTimeoutID);
|
|
|
|
}
|
2018-07-17 16:03:06 -04:00
|
|
|
this._discoverTimeoutID = window.setTimeout(this._sendDiscoverTimeout.bind(this), 15000);
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
this.sendRemoteRequest('discover', this._peripheralOptions)
|
|
|
|
.catch(e => {
|
2018-10-17 15:48:07 -04:00
|
|
|
this._sendRequestError(e);
|
2018-11-08 15:21:28 -05:00
|
|
|
});
|
2018-06-20 13:59:23 -04:00
|
|
|
}
|
2018-06-24 22:00:23 -04:00
|
|
|
// TODO: else?
|
2018-06-20 13:59:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try connecting to the input peripheral id, and then call the connect
|
|
|
|
* callback if connection is successful.
|
|
|
|
* @param {number} id - the id of the peripheral to connect to
|
|
|
|
*/
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
connectPeripheral (id) {
|
2018-06-20 13:59:23 -04:00
|
|
|
this.sendRemoteRequest('connect', {peripheralId: id})
|
|
|
|
.then(() => {
|
2018-06-27 14:21:11 -04:00
|
|
|
this._connected = true;
|
2018-07-10 15:57:25 -04:00
|
|
|
this._runtime.emit(this._runtime.constructor.PERIPHERAL_CONNECTED);
|
2018-06-20 13:59:23 -04:00
|
|
|
this._connectCallback();
|
|
|
|
})
|
|
|
|
.catch(e => {
|
2018-10-17 15:48:07 -04:00
|
|
|
this._sendRequestError(e);
|
2018-06-20 13:59:23 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-06-27 14:21:11 -04:00
|
|
|
/**
|
|
|
|
* Close the websocket.
|
|
|
|
*/
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
disconnect () {
|
2018-06-27 14:21:11 -04:00
|
|
|
this._ws.close();
|
2018-11-08 15:31:15 -05:00
|
|
|
if (this._discoverTimeoutID) {
|
|
|
|
window.clearTimeout(this._discoverTimeoutID);
|
|
|
|
}
|
2018-06-27 14:21:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {bool} whether the peripheral is connected.
|
|
|
|
*/
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
isConnected () {
|
2018-06-27 14:21:11 -04:00
|
|
|
return this._connected;
|
|
|
|
}
|
|
|
|
|
2018-06-20 13:59:23 -04:00
|
|
|
/**
|
2018-08-19 22:09:57 -04:00
|
|
|
* Start receiving notifications from the specified ble service.
|
|
|
|
* @param {number} serviceId - the ble service to read.
|
|
|
|
* @param {number} characteristicId - the ble characteristic to get notifications from.
|
|
|
|
* @param {object} onCharacteristicChanged - callback for characteristic change notifications.
|
|
|
|
* @return {Promise} - a promise from the remote startNotifications request.
|
|
|
|
*/
|
|
|
|
startNotifications (serviceId, characteristicId, onCharacteristicChanged = null) {
|
|
|
|
const params = {
|
|
|
|
serviceId,
|
|
|
|
characteristicId
|
|
|
|
};
|
|
|
|
this._characteristicDidChangeCallback = onCharacteristicChanged;
|
2018-08-22 17:45:26 -04:00
|
|
|
return this.sendRemoteRequest('startNotifications', params)
|
|
|
|
.catch(e => {
|
2018-10-17 15:48:07 -04:00
|
|
|
this._sendDisconnectError(e);
|
2018-08-22 17:45:26 -04:00
|
|
|
});
|
2018-08-19 22:09:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read from the specified ble service.
|
2018-06-20 13:59:23 -04:00
|
|
|
* @param {number} serviceId - the ble service to read.
|
|
|
|
* @param {number} characteristicId - the ble characteristic to read.
|
|
|
|
* @param {boolean} optStartNotifications - whether to start receiving characteristic change notifications.
|
|
|
|
* @param {object} onCharacteristicChanged - callback for characteristic change notifications.
|
|
|
|
* @return {Promise} - a promise from the remote read request.
|
|
|
|
*/
|
2018-08-19 22:09:57 -04:00
|
|
|
read (serviceId, characteristicId, optStartNotifications = false, onCharacteristicChanged = null) {
|
2018-06-20 13:59:23 -04:00
|
|
|
const params = {
|
|
|
|
serviceId,
|
|
|
|
characteristicId
|
|
|
|
};
|
|
|
|
if (optStartNotifications) {
|
|
|
|
params.startNotifications = true;
|
|
|
|
}
|
|
|
|
this._characteristicDidChangeCallback = onCharacteristicChanged;
|
2018-07-17 16:03:06 -04:00
|
|
|
return this.sendRemoteRequest('read', params)
|
|
|
|
.catch(e => {
|
2018-10-17 15:48:07 -04:00
|
|
|
this._sendDisconnectError(e);
|
2018-07-17 16:03:06 -04:00
|
|
|
});
|
2018-06-20 13:59:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write data to the specified ble service.
|
|
|
|
* @param {number} serviceId - the ble service to write.
|
|
|
|
* @param {number} characteristicId - the ble characteristic to write.
|
|
|
|
* @param {string} message - the message to send.
|
|
|
|
* @param {string} encoding - the message encoding type.
|
2018-08-16 15:38:03 -04:00
|
|
|
* @param {boolean} withResponse - if true, resolve after peripheral's response.
|
2018-06-20 13:59:23 -04:00
|
|
|
* @return {Promise} - a promise from the remote send request.
|
|
|
|
*/
|
2018-08-16 15:38:03 -04:00
|
|
|
write (serviceId, characteristicId, message, encoding = null, withResponse = null) {
|
2018-06-20 13:59:23 -04:00
|
|
|
const params = {serviceId, characteristicId, message};
|
|
|
|
if (encoding) {
|
|
|
|
params.encoding = encoding;
|
|
|
|
}
|
2018-08-16 15:38:03 -04:00
|
|
|
if (withResponse) {
|
|
|
|
params.withResponse = withResponse;
|
|
|
|
}
|
2018-07-17 16:03:06 -04:00
|
|
|
return this.sendRemoteRequest('write', params)
|
|
|
|
.catch(e => {
|
2018-10-17 15:48:07 -04:00
|
|
|
this._sendDisconnectError(e);
|
2018-07-17 16:03:06 -04:00
|
|
|
});
|
2018-06-20 13:59:23 -04:00
|
|
|
}
|
|
|
|
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
/**
|
|
|
|
* Handle a received call from the socket.
|
|
|
|
* @param {string} method - a received method label.
|
|
|
|
* @param {object} params - a received list of parameters.
|
|
|
|
* @return {object} - optional return value.
|
|
|
|
*/
|
|
|
|
didReceiveCall (method, params) {
|
|
|
|
switch (method) {
|
|
|
|
case 'didDiscoverPeripheral':
|
|
|
|
this._availablePeripherals[params.peripheralId] = params;
|
|
|
|
this._runtime.emit(
|
|
|
|
this._runtime.constructor.PERIPHERAL_LIST_UPDATE,
|
|
|
|
this._availablePeripherals
|
|
|
|
);
|
|
|
|
if (this._discoverTimeoutID) {
|
|
|
|
window.clearTimeout(this._discoverTimeoutID);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'characteristicDidChange':
|
|
|
|
this._characteristicDidChangeCallback(params.message);
|
|
|
|
break;
|
|
|
|
case 'ping':
|
|
|
|
return 42;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-17 15:48:07 -04:00
|
|
|
_sendRequestError (/* e */) {
|
|
|
|
// log.error(`BLE error: ${JSON.stringify(e)}`);
|
|
|
|
|
|
|
|
this._runtime.emit(this._runtime.constructor.PERIPHERAL_REQUEST_ERROR, {
|
|
|
|
message: `Scratch lost connection to`,
|
|
|
|
extensionId: this._extensionId
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_sendDisconnectError (/* e */) {
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
// log.error(`BLE error: ${JSON.stringify(e)}`);
|
2018-10-17 15:48:07 -04:00
|
|
|
|
|
|
|
if (!this._connected) return;
|
|
|
|
|
|
|
|
this._connected = false;
|
|
|
|
|
|
|
|
this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECT_ERROR, {
|
2018-09-22 14:48:41 -04:00
|
|
|
message: `Scratch lost connection to`,
|
2018-09-21 09:44:48 -04:00
|
|
|
extensionId: this._extensionId
|
2018-09-14 16:26:08 -04:00
|
|
|
});
|
2018-06-20 13:59:23 -04:00
|
|
|
}
|
2018-07-17 16:03:06 -04:00
|
|
|
|
|
|
|
_sendDiscoverTimeout () {
|
2018-11-08 15:31:15 -05:00
|
|
|
if (this._discoverTimeoutID) {
|
|
|
|
window.clearTimeout(this._discoverTimeoutID);
|
|
|
|
}
|
2018-07-17 16:03:06 -04:00
|
|
|
this._runtime.emit(this._runtime.constructor.PERIPHERAL_SCAN_TIMEOUT);
|
|
|
|
}
|
2018-06-20 13:59:23 -04:00
|
|
|
}
|
|
|
|
|
Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
|
|
|
module.exports = BLE;
|