LitDev Extension API
LDBlueTooth
BlueTooth control.
The Advanced features refer to non file transfer (effectively writing a device driver).
To communicate with a USB bluetooth stick you also need have an external bluetooth device, setting it to be dicoverable etc before running your SmallBasic program.
Connect | DataAvailable | Device |
Encode | GetDevices | GetEncodings |
GetServices | Initialise | InRange |
LastDevice | LastError | OutOfRange |
ReceiveData | ReceiveFile | SendData |
SendFile | Service |
Connect()
Advanced feature.
Connect an external device and service to the bluetooth USB stick.
You must first Initialise, then set the device, service and encoding.
returns "True" or "False" on success or failure.
DataAvailable
The number of bytes of data received and waiting to be read.
This could be used in a Timer to check for data received.
Device
The current bluetooth device.
Encode
Advanced feature.
The current bluetooth data encoding.
GetDevices()
Get a list of discovered bluetooth devices.
returns An array of devices or "" on failure.
GetEncodings()
Advanced feature.
Get a list of available encodings.
returns An array of encodings or "" on failure.
GetServices()
Advanced feature.
Get a list of available service protocols.
returns An array of services or "" on failure.
Initialise()
Initialise a bluetooth USB stick and detect discoverable external devices.
As devices come into or out of range the devices list is updated.
returns "True" or "False" for success or failure configuring a bluetooth interface.
InRange
Event when a bluetooth device comes in range.
Seems to keep firing unexpectedly.
LastDevice
The last device in or out of range.
LastError
Get the last error message.
Error messages may be set for various failures.
OutOfRange
Event when a bluetooth device goes out of range.
Doesn't seem to work as expected.
ReceiveData()
Advanced feature.
Receive (fetch) data from a bluetooth device.
The device must be Initialised and Connected.
The encoding should also be set.
returns String of received characters or "" on failure.
ReceiveFile(fileName)
Receive (fetch) a file from an attached external bluetooth device.
You must first Initialise, then set the device.
fileName The location to save the received file.
returns A result status message "True" or "False".
SendData(data)
Advanced feature.
Send data to a bluetooth device.
The device must be Initialised and Connected.
The encoding should also be set.
data A string of characters to send.
returns A result status message "True" or "False".
SendFile(fileName)
Send a file to an attached external bluetooth device.
You must first Initialise, then set the device.
fileName The file to send.
returns A result status message "True" or "False".
Service
Advanced feature.
The current bluetooth service.