In a project for disabled persons, I am trying to read the values send by a bluetooth mouse.
(the aim of the project is to convert the electronic wheelchair integrated joystick - behaving like a mouse - to directional keys , for a specific app)
I connect to a bluetooth mouse and try to put in BOOT Mouse Input protocol mode and subscribe to BOOT_MOUSE_INPUT_REPORT
characteristic (uuid 2a33
) to get the 4 bytes packet describing the mouse movements.
In the mail loop:
if (peripheral.discoverAttributes()) {
Serial.println("Attributes discovered");
} else {
Serial.println("Attribute discovery failed!");
peripheral.disconnect();
return;
}
// readXXX writeXX subscribeXXX are functions that wrap the neccesary code
readCharacteristic(peripheral, SERVICE_UUID_BATTERY, CHARACTERISTIC_UUID_BATTERY_LEVEL);
writeCharacteristic(peripheral, SERVICE_UUID_HUMAN_INTERFACE_DEVICE, CHARACTERISTIC_UUID_PROTOCOL_MODE, (byte)0x00);
BLECharacteristic bootCharacteristic = subscribeCharacteristic(peripheral, SERVICE_UUID_HUMAN_INTERFACE_DEVICE, CHARACTERISTIC_UUID_BOOT_MOUSE_INPUT_REPORT);
bootCharacteristic.setEventHandler(BLEWritten, characteristicEventHandler);
and I have an event handler :
void characteristicEventHandler(BLEDevice central, BLECharacteristic characteristic) {
Serial.print("Characteristic event, written: ");
printData(characteristic.value(), characteristic.valueLength());
}
So far, nothing happens.
I must admit I am completely lost. I am lacking an example of such code, and the documentation is terse on that issue.