Classic Bluetooth used.. Are you saying that the connection interval is invoked each time a write happens?
Bar one brief foray with Classic Bluetooth when I accidentally ordered a non-BLE wireless relay board, I have only dealt with BLE. I haven't studied Classic Bluetooth much. With BLE, once a connection is established, the two devices schedule regular communications, so that they don't need to keep their radios operating continuously (which helps with the low energy aspect), and that schedule is at intervals of 7.5 to 4000 ms. Low speed stuff like tyre pressure sensors would tend towards long periods, high speed stuff like accelerometers would tend towards shorter periods.
where would I find this information?
For BLE, Google:
ble connection interval
For Bluetooth Classic, this limit shouldn't apply, but nonetheless I tried Googling:
bluetooth connection interval -ble -"low energy" spp
and got
https://scholarworks.iupui.edu/bitstream/handle/1805/12496/LIBBY_ECET491_POSTER.pdf which mentions:
Sniff Mode – This is a power-saving mode, where the
device is less active. It’ll sleep and only listen for
transmissions at a set interval (e.g. every 100ms).
and also a paragraph about SPP.
Can you explain 'trick/trap of Sleep(55)" please
The trick (in the good sense of the word) is that Sleep is an efficient way to do a delay.
The trap is that, in B4X, Sleep(x) doesn't work the way you might be used to. Instead, it forks into
two program flows:
one returns immediately from the current Sub, before the delay takes effect, and thus the calling Sub does not see/experience the delay, and
the other continues in the current Sub after delaying for the specified period.
Thus, if you had something like:
Sub Main
Log("Open warehouse")
For I = 1 To 4
SendRoses(I)
Next I
Log("Close warehouse")
End Sub
Sub SendRoses(N As Int)
Log("Packing " & N & " roses")
Sleep(300)
Log("Sending " & N & " roses")
Sleep(700)
Log("Sent " & N & " roses")
End Sub
you would probably be surprised to find that your warehouse closed much sooner than you'd expected, per the log:
Waiting for debugger to connect...
Program started.
Open warehouse
Packing 1 roses
Packing 2 roses
Packing 3 roses
Packing 4 roses
Packing 5 roses
Close warehouse
Sending 1 roses
Sending 2 roses
Sending 3 roses
Sending 4 roses
Sending 5 roses
1 roses sent
2 roses sent
3 roses sent
4 roses sent
5 roses sent
The fix for this is to declare the Sub "As ResumableSub":
Sub SendRoses(N As Int) As ResumableSub
and then call the Sub using
Wait For() Complete:
For I = 1 To 5
Wait For (SendRoses(I)) Complete
Next
This example is for a Sub that nominally does not return a value (well, it does, but it's an unspecified Object and will default to Null, and B4X will be warning you about not returning a value). If your sub needs to return a value, read:
https://www.b4x.com/android/forum/threads/b4x-resumable-subs-that-return-values-resumablesub.82670/