btOpen (Function) |
Top Previous Next |
This opens the Bluetooth module and enables the library functions. This function must be called and returned successfully before any other Bluetooth function is called. If the Bluetooth module is disconnected or power is removed, it is necessary to re-initialize the module by closing the module with btClose and reopen with btOpen.
Power will be applied directly from the serial port connector through the DC-Out output. Because of this, boardDCOUT should not be used in the program as the firmware will control this output when the Bluetooth module is opened and closed. There should also not be connected anything else to the DC-Out output when the Bluetooth module is connected. When the Bluetooth module is open, the normal programming port is disabled, and btClose must be called to re-enable it.
After the Bluetooth library has been opened, connections to other devices can be made. Use btConnect to initiate an outgoing connection where the program decides which device to connect to either by using a specific address or by doing a network search with btSearch. Alternatively use btListen to open for incoming connections where other Bluetooth devices may search for the module and connect to it.
The Bluetooth module is invisible for other Bluetooth devices until a btListen command is issued to allow incoming connections. Until then, however, the Bluetooth module will not be found during network searches.
Input: port : SINT The serial port where the Bluetooth module is located (only port 0, the default port, is supported).
name : STRING The name of the Bluetooth module. Other devices in the area will see this name. Maximum length is 40 characters.
Returns: INT
Declaration: FUNCTION btOpen : INT;
Example: INCLUDE rtcu.inc |