I am using the cordova-plugin-ble-central to connect to a v.bttn device via Bluetooth BLE.
I am able to scan it, and connect to it. But I need send a verification code within 30 seconds. So using the information on the Github plugin site I used the write command.
This is what the command looks like:
var data = new Uint8Array(1);
data[0] = '80:BE:F5:AC:FF';
ble.write(bttnid, 'fffffff0-00f7-4000-b000-000000000000', '0xFFFFFFF5-00F7-4000-B000-000000000000', data.buffer, deviceVerifiedSuccess, deviceVerifiedFailed);
From the plugin docs, this is how the query should look:
ble.write(device_id, service_uuid, characteristic_uuid, value, success, failure);
I get the device id, and make that into a global variable. Below is the documentation from the manufacture v.bttn.
V.BTTN Verification (UUID: 0xFFFFFFF5-00F7-4000-B000-000000000000) The V.BTTN Verification Characteristic enables apps to communicate with V.BTTN. Verification key value is 80:BE:F5:AC:FF. Refer to section 5, Connecting to V.BTTN for details requirements for connecting to V.BTTN
What is i am missing ?
The table says the length of the verification code is 5 bytes, so try sending 80:BE:F5:AC:FF as bytes.
var verificationKey = new Uint8Array([0x80, 0xbe, 0xf5, 0xac, 0xff]);
ble.write(bttnid,
'fffffff0-00f7-4000-b000-000000000000', // v.bttn service
'fffffff5-00f7-4000-b000-000000000000', // verification characteristic
verificationKey.buffer,
function() { console.log('wrote verification key'); },
function(reason) { console.log('Error sending verification key ' + reason);
}