ConnectionBasedLink extends AbstractListenerLink { @Override public long sendTone(Tone tone) throws IOException { ToDeviceMessageTone msg; synchronized (connection) { msg = addMessageIdIfNeeded(new DefaultToDeviceMessageTone(tone)); send(this.protocol.toDevice(msg)); } return messageIdOf(msg); } ConnectionBasedLink(Connection connection, Protocol protocol); Connection getConnection(); Protocol getProtocol(); boolean waitForArduinoToBoot(int wait, TimeUnit timeUnit); boolean waitForArduinoToBoot(int wait, TimeUnit timeUnit, final Mode mode); @Override long startListening(Pin pin); @Override long stopListening(Pin pin); @Override long switchAnalogPin(AnalogPin analogPin, int value); @Override long switchDigitalPin(DigitalPin digitalPin, boolean value); @Override long sendKeyPressEvent(char keychar, int keycode, int keylocation, int keymodifiers, int keymodifiersex); @Override long sendTone(Tone tone); @Override long sendNoTone(AnalogPin analogPin); @Override long sendCustomMessage(String... messages); @Override void close();  }
@Test public void canSendToneWithDuration() throws IOException { this.link.sendTone(Tone.forPin(analogPin(2)).withHertz(3000) .withDuration(5, SECONDS)); assertThat(toArduinoWasSent(), is("alp: }
@Test public void canSendEndlessTone() throws IOException { this.link.sendTone(Tone.forPin(analogPin(2)).withHertz(3000).endless()); assertThat(toArduinoWasSent(), is("alp: }