Main Content

flush

Clear Bluetooth device buffers

Since R2020b

Description

flush(device) flushes all data from both the input and output buffers of the specified Bluetooth® device.

example

flush(device,"input") flushes only the input buffer.

flush(device,"output") flushes only the output buffer.

Examples

collapse all

Create a connection to a nearby Bluetooth device.

device = bluetooth("TestDevice")
device = 
  bluetooth with properties:

                 Name: "TestDevice"
              Address: "BC275C50533C"
              Channel: 1
    NumBytesAvailable: 0
      NumBytesWritten: 0

  Show all properties

Write some data to the device and view the number of bytes available to be read in the input buffer.

write(device,1:5,"uint8")
device.NumBytesAvailable
ans =

     5

Flush both the input and output buffers.

flush(device);

View the number of bytes available to be read.

device.NumBytesAvailable
ans =

     0

The input buffer has no data.

Input Arguments

collapse all

Bluetooth device connection, specified as a bluetooth object.

Example: flush(device) flushes data from the Bluetooth connection device.

Version History

Introduced in R2020b

See Also

Functions