phyphox Forums

Full Version: Bluetooth ouput node not clearing buffer at input
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was playing with the BLE feature to integrate a laser distometer. The device can receive commands (laser on/off, continuous mode, single measurement, etc) that i managed to control with the BLE output node which is connected to a button output buffer of length 1. The issue is, that once the button has been pressed, its output buffer is filled and never cleared again. The output node will therefore repeat sending the command at each analysis cycle. Manually adding  clear="true" (and for the sake of testing, also clear="false") to the input line of the BLE output node doesn't have any effect. Also for other types of outputs that might be sent to an external device via BLE, i think "clear at input" might be a useful behavior?
Makes sense, indeed.

The current solution is to handle erasing in the analysis block. Sending BLE data is always (and only) done when the analysis cycle has finished, so you can control the data before each send. Usually, you would react to the button push by preparing the data to be sent. So, for example, your button would write the value 1 to a buffer "buttonTriggered" and in the analysis block you would copy some data to "dataToBeSent" if "buttonTriggered" equals 1 and just clear "dataToBeSent" otherwise (clear="true" at the output a type="empty" input for the else case). You can then simply unconditionally append a zero afterwards to clear the "buttonTriggered" buffer.

In your case this seems a bit awkward as you want to send the same value as set by the button. So you would do something like this, which appears unnecessarily overcomplicated as you do not need to fetch special data:

<if equal="true">
  <input clear="true">buttonTriggered</input>
  <input type="value">1</input>
  <input type="value">1</input>
  <input type="empty" />
  <output clear="true">dataToBeSend</output>

  <input type="value">0</input>