This library simplifies using the RN-42 Bluetooth Module (or the $3 HC-05/6 flashed with RN-42 firmware).
The main advantage of the RN-42 module is it allows you to emulate HID devices, which allows your Arduino project to connect to your devices as a Bluetooth keyboard, mouse or gamepad.
This library is forked from this one here, the main differences between this one and the original is that hardcoded references to a serial interface have been removed so it can be used with basically any Arduino device.
Basic usage of the library is as shown, this sketch when connected to your device will send the key commands "H" and "i" every 5 seconds.
#include <BPLib.h>
BPLib *BPMod;
void setup(){
Serial.begin(115200); // 115200 is the default baud of the RN-42
BPMod = new BPLib(Serial);
BPMod->begin(BP_MODE_HID,BP_HID_KEYBOARD); //Begin HID Mode with HID KEYBOARD AS TYPE
}
void loop(){
delay(5000);
BPMod->sendString("Hi");
}
The library also supports connecting using software serial interfaces.
#include <SoftwareSerial.h>
SoftwareSerial swSer(1, 2, false, 128);
....
void setup(){
swSer.begin(115200);
BPMod = new BPLib(swSer);
BPMod->begin(BP_MODE_HID,BP_HID_KEYBOARD);
}
...
It is also worth noting that the BPMod->begin method is a once off configuration, if you do it for your module once it does not need to be run again, even after reboots, so it does not need to be part of your final sketch.
Check out the header file of the library for a full list of functions and parameters available. If you have suggests on how to present this better please feel free to submit a PR!