BTListen


BTListen channel {,timeout,UUID$}

This command opens a Bluetooth channel and begins to listen for devices that want to connect.

The channel number is chosen by the programmer. It is a lot like a file number and may be 1 to 10. So theoretically you could have up to 10 Bluetooth connections open at the same time, but you may find your Android device is limited to 5 or 6 connections before one of the existing connections is dropped. Some online references say up to 60 Bluetooth devices can be connected at once. If anyone succeeds in connecting 10 devices and wants to try more, post a topic on the forum and I will increase the limit.

The optional timeout parameter specifies the read timeout in milliseconds.

The UUID$ is an optional string which will override the default unique application identifier. This field should always be omitted unless you have a good reason for using a particular unique identifier. If used, the unique identifier will only be used for the specified channel.


Example:


' First make your device discoverable by other Bluetooth devices for say 200 seconds.

' Then start to listen.

BTDiscoverable 200
BTListen 1

'Now wait for a connection.

For i = 1 to 200
Print BTGetState(1);" - ";
Print BTGetError$(1)
If BTGetstate(1)=4 Then Exit For
Wait 1000
Next i

If BTGetState(1) = 4 Then
Print "Connected"
Else
Print "Connect Failed"
Endif



Screenshot from above code



Bluetooth On|Off


Bluetooth device pairing


BTClose


BTConnect


BTDiscoverable


BTGetAddress$()


BTGetError$()


BTGetName$()


BTGetPaired$()


BTGetSize()


BTGetState()


BTRead$()


BTRead


BTReadln


BTReadUTF


BTWrite


BTWriteln


BTWriteUTF







Become a Patron