Original Author Paul Laughton, 2011
Page 127
De Re BASIC!
Ftp.mkdir <directory_sexp>
Creates a new directory of the specified name.
Bluetooth
BASIC! implements Bluetooth in a manner which allows the transfer of data bytes between an Android
device and some other device (which may or may not be another Android device).
Before attempting to execute any BASIC! Bluetooth commands, you should use the Android "Settings"
Application to enable Bluetooth and pair with any device(s) with which you plan to communicate.
When Bluetooth is opened using the Bt.open command, the device goes into the Listen Mode. While in
this mode it waits for a device to attempt to connect.
For an active attempt to make a Bluetooth connection, you can use the Connect Mode by successfully
executing the Bt.connect command. Upon executing the Bt.connect command the person running the
program is given a list of paired Bluetooth devices and asked. When the user selects a device, BASIC!
attempts to connect to it.
You should monitor the state of the Bluetooth using the Bt.status command. This command will report
states of Listening, Connecting and Connected. Once you receive a "Connected" report, you can proceed
to read bytes and write bytes to the connected device.
You can write bytes to a connected device using the Bt.write command.
Data is read from the connected device using the Bt.read.bytes command; however, before executing
Bt.read.bytes, you need to find out if there is data to be read. You do this using the Bt.read.ready
command.
Once connected, you should continue to monitor the status (using Bt.status) to ensure that the
connected device remains connected.
When you are done with a particular connection or with Bluetooth in general, execute Bt.close.
The sample program, f35_bluetooth, is a working example of Bluetooth using two Android devices in a
"chat" type application.
Bt.open {0|1}
Opens Bluetooth in Listen Mode. If you do not have Bluetooth enabled (using the Android Settings
Application) then the person running the program will be asked whether Bluetooth should be enabled.
After Bt.open is successfully executed, the code will listen for a device that wants to connect.
The optional parameter determines if BT will listen for a secure or insecure connection. If no parameter
is given or if the parameter is 1, then a secure connection request will be listened for. Otherwise, an
insecure connection will be listened for. It is not possible to listen for either a secure or insecure