I am trying to connect to a Buwizz V2 hub (and start a motor) via BLE on a windows machine via WebBluetooth in Google Chrome Browser.
The API for the Buwizz is https://buwizz.com/BuWizz_2.0_API_1.3_web.pdf
The result of my code is
ble.html:21 discoverDevicesOrDisconnect
ble.html:31 discoverDevices
ble.html:40 > Name: BuWizz
ble.html:41 > Id: NtY+vKj4GR1vb/VowbQdJw==
ble.html:42 > Connected: false
ble.html:44 BluetoothDevice {id: ‘NtY+vKj4GR1vb/VowbQdJw==’, name: ‘BuWizz’, gatt: BluetoothRemoteGATTServer, ongattserverdisconnected: null, watchingAdvertisements: false, …}
ble.html:74 connecting
ble.html:77 Connected to NtY+vKj4GR1vb/VowbQdJw==
ble.html:78 connected=true
ble.html:96 discoverSvcsAndChars server=[object BluetoothRemoteGATTServer]
ble.html:102 Got 1 services
ble.html:109 Getting Characteristics for service 4e050000-74fb-4481-88b3-9919b1676e93
ble.html:111 > Service: 4e050000-74fb-4481-88b3-9919b1676e93
ble.html:117 >> Characteristic: 000092d1-0000-1000-8000-00805f9b34fb
ble.html:125 FINISHED DISCOVERY
ble.html:54 Try to startMotor
ble.html:55 Will send command to Characteristic:000092d1-0000-1000-8000-00805f9b34fb
ble.html:56 Characteristic has writeWithoutResponse ability:true
ble.html:60 Motor command ->16,127,127,127,127,0
So I can discover and connect to the device, find the Service 4e050000-74fb-4481-88b3-9919b1676e93
, find the characteristic 000092d1-0000-1000-8000-00805f9b34fb
and check that is has writeWithoutResponse
.
Since the motor is not running after sending the command, I have obviously made something wrong.
And I guess that it is somewhere around here:
console.log("Try to startMotor");
console.log("Will send command to Characteristic:" + motor_characteristic.uuid);
console.log("Characteristic has writeWithoutResponse ability:" + motor_characteristic.properties.writeWithoutResponse);
let full_ahead_command_data = new Uint8Array;
full_ahead_command_data = Uint8Array.of(0x10, 0x7F, 0x7F, 0x7F, 0x7F, 0x00);
console.log('Motor command ->' + full_ahead_command_data);
motor_characteristic.writeValueWithoutResponse(full_ahead_command_data.buffer)
.then(_ => { })
.catch(error => {
console.log('Error: ' + error);
alert('Error: ' + error);
return;
});
I checked the hub and motor with the official app. Both are working fine, so i would appreciate hints where I made something wrong or made a wrong assumption.