/* begin(name)
   This function performs all tasks required to initialize the RN-42 HID module
   for use with the MaKey MaKey.
   We set up authentication, sleep, special config settings. As well as
   seting the auto-connect mode. The name can also be configured with the 
   *name* parameter. */
uint8_t makeyMateClass::begin(char * name)
{
  bluetooth.begin(9600);  // Initialize the software serial port at 9600
  freshStart();  // Get the module into a known mode, non-command mode, not connected

  while (!enterCommandMode())  // Enter command mode
      delay(100);    
  delay(BLUETOOTH_RESPONSE_DELAY);

  setAuthentication(1);  // enable authentication
  setName(name);  // Set the module name
  setMode(0);  // slave mode, worth trying mode 4 (auto dtr) as well 
  
  /* I'm torn on setting sleep mode. If you care about a low latency connection
   keep sleep mode set to 0000. You can save about 15mA of current consumption
   with the "80A0" setting, but I experience quite a bit more latency. */ 
  //setSleepMode("80A0");  // Deep sleep mode, 100ms sleeps - saves about 15mA when idling
  setSleepMode("0000");  // Low latency, high current usage ~ 40mA
  setSpecialConfig(16);  // optimize for low latency, short burst data
  
  /* These I wouldn't recommend changing. These settings are required for HID
     use and sending Keyboard and Mouse commands */
  setKeyboardMouseMode();  // bluetooth.println("SH,0030");
    
  // We must reboot if we're changing the mode to HID mode.
  // If you've already have the module in HID mode, this can be commented out
  if (!getHIDMode())
  {
    setHIDMode();  // Set RN-42 to HID profile mode
    reboot();
  }
  else
  {
    Serial.println("Already in HID mode!");
  }
}
void OnlineDataManager::clearAuthentication(OnlineDataManager::Provider provider)
{
    setAuthentication(provider, "", "");

    emit authenticationCleared((int)provider);
}