public boolean test(){
  if (!isConnected()) {
    onError(OneSheeldError.DEVICE_NOT_CONNECTED);
    return false;
  }
 else   if (isUpdatingFirmware()) {
    onError(OneSheeldError.FIRMWARE_UPDATE_IN_PROGRESS);
    return false;
  }
 else   if (hasFirmwareTestStarted || hasLibraryTestStarted) {
    Log.i("Device " + this.name + ": device is in the middle of another test.");
    return false;
  }
  Log.i("Device " + this.name + ": Testing the device, both firmware and library.");
  String currentMillis=String.valueOf(System.currentTimeMillis());
  byte[] bytes=currentMillis.getBytes(Charset.forName("US-ASCII"));
  int correctAnswer=0;
  for (  byte byteValue : bytes) {
    correctAnswer+=(byteValue & 0xFF);
  }
  correctTestingChallengeAnswer=(byte)(correctAnswer % 256);
  hasFirmwareTestStarted=true;
  hasLibraryTestStarted=true;
  ShieldFrame testingFrame=new ShieldFrame(CONFIGURATION_SHIELD_ID,LIBRARY_TESTING_CHALLENGE_REQUEST);
  testingFrame.addArgument("Are you ok?");
  testingFrame.addArgument(bytes);
synchronized (sendingDataLock) {
    sysex(BOARD_TESTING,bytes);
    sendShieldFrame(testingFrame);
  }
  initFirmwareTestingTimeOut();
  initLibraryTestingTimeOut();
  return true;
}

public boolean test ( ) { if ( ! isConnected ( ) ) { onError ( OneSheeldError . DEVICE_NOT_CONNECTED ) ; return false ; } else if ( isUpdatingFirmware ( ) ) { onError ( OneSheeldError . FIRMWARE_UPDATE_IN_PROGRESS ) ; return false ; } else if ( hasFirmwareTestStarted || hasLibraryTestStarted ) { Log . i ( "Device " + this . name + ": device is in the middle of another test." ) ; return false ; } Log . i ( "Device " + this . name + ": Testing the device, both firmware and library." ) ; String currentMillis = String . valueOf ( System . currentTimeMillis ( ) ) ; byte [ ] bytes = currentMillis . getBytes ( Charset . forName ( "US-ASCII" ) ) ; int correctAnswer = 0 ; for ( byte byteValue : bytes ) { correctAnswer += ( byteValue & 0xFF ) ; } correctTestingChallengeAnswer = ( byte ) ( correctAnswer % 256 ) ; hasFirmwareTestStarted = true ; hasLibraryTestStarted = true ; ShieldFrame testingFrame = new ShieldFrame ( CONFIGURATION_SHIELD_ID , LIBRARY_TESTING_CHALLENGE_REQUEST ) ; testingFrame . addArgument ( "Are you ok?" ) ; testingFrame . addArgument ( bytes ) ; synchronized ( sendingDataLock ) { sysex ( BOARD_TESTING , bytes ) ; sendShieldFrame ( testingFrame ) ; } initFirmwareTestingTimeOut ( ) ; initLibraryTestingTimeOut ( ) ; return true ; }
test the board , and make sure the firmware and library are working correctly .
