Hello,
I am trying to make a Bluetooth enabled keyboard. So far the keyboard works but I'm having trouble properly sending the key press values to the Bluetooth module. I'm using the Arduino Keyboard library as well as the Adafruit BLE library for the nRF51 module.
Inside the Keybaord.h there is a struct called KeyReport as shown below:
typedef struct
{
uint8_t modifiers;
uint8_t reserved;
uint8_t keys[6];
} KeyReport;
The above struct holds the key press values and is updated in my main program. In my main program, I have to send these values using a ble.print() command to the bluetooth module. The ble.print() command is from the aforementioned ble library from adafruit but appears to behave like regular Serial.print().
Below is code that currently works with the BLE module - all is well but the BLE module is SLOW when responding to keypresses. I believe it is due to performing all of these ble.print() commands separately instead of one ble.print() command.
ble.print("AT+BLEKEYBOARDCODE=");
ble.print(Keyboard._keyReport.modifiers,HEX);
ble.print("-");
ble.print(Keyboard._keyReport.reserved,HEX);
ble.print("-");
ble.print((Keyboard._keyReport.keys[0]), HEX);
ble.print("-");
ble.print((Keyboard._keyReport.keys[1]), HEX);
ble.print("-");
ble.print((Keyboard._keyReport.keys[2]), HEX);
ble.print("-");
ble.print((Keyboard._keyReport.keys[3]), HEX);
ble.print("-");
ble.print((Keyboard._keyReport.keys[4]), HEX);
ble.print("-");
ble.print((Keyboard._keyReport.keys[5]), HEX);
ble.println();
How can I do the above but with ONE ble.println() statement? I have tried a ton of things... making a char buffer, using strcat, etc... with no luck. I don't think I understand the types I'm working with well enough. Any guidance would be great!
Thanks!