Component: Bluetooth v2 (EB024, Generic AT) (Wireless)
Author | Matrix Ltd. |
Version | 2.1 |
Category | Wireless |
Contents
Bluetooth v2 (EB024, Generic AT) component
Low level routines for controlling a standard AT Bluetooth interface. Also available in the form of the EB024 Bluetooth E-block. Uses an interrupt to receive characters from the UART and improve reliability, Must be used with a hardware channel.
Component Source Code
Please click here for the component source code: FC_Comp_Source_Bluetooth_V2.fcfx
Detailed description
No detailed description exists yet for this component
Examples
Making a device discoverable
Example program to set up the Bluetooth module to be discoverable with a pair key. Any data received is then output onto the LCD component. You can connect to the Bluetooth device using a PC with Bluetooth connection and using software such as Flowcode 6, RealTerm or HyperTerminal. Alternatively you can connect using a smart phone running a terminal emulator app or via another embedded Bluetooth board.
Bluetooth Discover
Script 1 contains the AT commands to setup the Bluetooth device to be discoverable with pair key "1234".
Searching for a device
Example program to scan for local discoverable Bluetooth devices. For each device found the MAC address is displayed on to the LCD.
Bluetooth Inquiry
Connecting to a device
Example program to connect to a specific Bluetooth device address and send data to the device.
Bluetooth Connect
The device MAC address is specified using the "CreateCommandString" and "SendCommand" macros.
Macro reference
![]() |
SetPairKey |
Sets the 4 digit Bluetooth pair key based on a string of numbers. e.g. "1234" Returns 0 to indicate success | |
![]() |
PairKey |
Key to use as the Pair key, e.g. "1234" or "0000" | |
![]() |
Return |
![]() |
ReceiveByte |
Receives a single data byte from the Bluetooth module. 0xFF signifies no data available. | |
![]() |
Timeout |
Amount of time to wait in milliseconds 0=Wait forever | |
![]() |
Return |
![]() |
SendString |
Sends a string to the Bluetooth module. | |
![]() |
Command |
![]() |
SendCR |
![]() |
Return |
![]() |
SendScript |
Send an AT command script. Returns 0 for fail, 1 for success and 255 for unrecognised script idx. | |
![]() |
idx |
![]() |
Return |
![]() |
ReadString |
Copies the incoming data from the data string array to a local string variable. | |
![]() |
NumBytes |
![]() |
Return |
![]() |
SaveSettings |
Saves the current settings to firmware using the AT&W command followed by the ATZ command. Returns 0 to indicate success | |
![]() |
Return |
![]() |
SendByte |
Sends a single data byte out to the Bluetooth module. | |
![]() |
Data |
![]() |
Return |
![]() |
RestoreFactorySettings |
Restores the factory settings to firmware using the AT&F* command. Returns 0 to indicate success | |
![]() |
Return |
![]() |
Initialise |
Sets up the Bluetooth module. Returns 0 for OK, 255 for no reply and 254 for command fail. | |
![]() |
Return |