douglasjunior / AndroidBluetoothLibrary

A Library for easy implementation of Serial Bluetooth Classic and Low Energy on Android. 💙
MIT License
224 stars 68 forks source link

OnReadyRead only when bufferSize is reached #45

Closed Shunt22 closed 1 year ago

Shunt22 commented 2 years ago

As mentioned in #41 OnDataRead will be called when a characterDelimiter is received, or when the total data received exceeds the character limit of bufferSize.

Originally posted by @douglasjunior in https://github.com/douglasjunior/AndroidBluetoothLibrary/issues/41#issuecomment-787958999

Is there anyway to set OnDataRead to be called ONLY when config.bufferSize is reached? I don't care about character delimiter. Just want to read fixed-size portions of data.

douglasjunior commented 2 years ago

You can pass a characterDelimiter that never will be received by your device.

Shunt22 commented 2 years ago

You can pass a characterDelimiter that never will be received by your device.

In my case I transfer pretty much random data bytes (audio data), so I can't for sure say which character will never appear. I tried '\n', '\0',0x00, etc as characterDelimiter, but these characters sometimes occur in data stream and OnDataRead is called.