Open marron9999 opened 3 years ago
Can a user only experience this with a custom extension?
Yes. I made another extension. It is scratch-microbit extension with the UUID changed to UART. OK: this._ble.write(BLEUUID.service, BLEUUID.txChar, data, "base64", true) NG: this._ble.read(BLEUUID.service, BLEUUID.rxChar, true, this._onMessage) => this._onMessage is not called. I want you to be able to with "Notify" and "Indicate".
rxChar
and txChar
are different from the comments.
rxChar: '6e400002-b5a3-f393-e0a9-e50e24dcca9e', // TX_Characteristic
txChar: '6e400003-b5a3-f393-e0a9-e50e24dcca9e' // RX_Characteristic
Are these correct?
Yes, please see code of scratch extension
const BLEUUID = { service: '6e400001-b5a3-f393-e0a9-e50e24dcca9e', // UART_SERVICE rxChar: '6e400002-b5a3-f393-e0a9-e50e24dcca9e', // TX_Characteristic txChar: '6e400003-b5a3-f393-e0a9-e50e24dcca9e' // RX_Characteristic };
this._ble.read(BLEUUID.service, BLEUUID.rxChar, true, this._onMessage) this._ble.write(BLEUUID.service, BLEUUID.txChar, data, "base64", true)
scratch-vm/src/io/BLE.js
read (serviceId, characteristicId, optStartNotifications = false, onCharacteristicChanged = null) { const params = { serviceId, characteristicId }; if (optStartNotifications) { params.startNotifications = true; } if (onCharacteristicChanged) { this._characteristicDidChangeCallback = onCharacteristicChanged; } return this.sendRemoteRequest('read', params) .catch(e => { this.handleDisconnectError(e); }); }
write (serviceId, characteristicId, message, encoding = null, withResponse = null) { const params = {serviceId, characteristicId, message}; if (encoding) { params.encoding = encoding; } if (withResponse !== null) { params.withResponse = withResponse; } return this.sendRemoteRequest('write', params) .catch(e => { this.handleDisconnectError(e); }); }
Expected Behavior
Hope to be able to receive with _onMessage (base64)
Actual Behavior
_onMessage (base64) is not called
Steps to Reproduce
const BLEUUID = { service: '6e400001-b5a3-f393-e0a9-e50e24dcca9e', // UART_SERVICE rxChar: '6e400002-b5a3-f393-e0a9-e50e24dcca9e', // TX_Characteristic txChar: '6e400003-b5a3-f393-e0a9-e50e24dcca9e' // RX_Characteristic };
this._ble.read(BLEUUID.service, BLEUUID.rxChar, true, this._onMessage);
Operating System and Browser
Windows 10 Home 20H2 (19042.867) Google Chrome 89.0.4389.90(Official Build)(64 bit)
NOTE:
Bluetooth Developer Studio Level 3 Profile Report TX Characteristic Notify Excluded Indicate Mandatory
scratch-link/Windows/scratch-link/BLESession.cs private async Task StartNotifications(GattCharacteristic endpoint, string encoding)
Can be received by changing "Notify" to "Indicate"