Component: Bluetooth v2 (EB024, Generic AT) (Wireless)

From Flowcode Help
Jump to navigationJump to search
Author Matrix Ltd.
Version 2.1
Category Wireless


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 to download the component source project: FC_Comp_Source_Bluetooth_V2.fcfx

Please click here to view the component source code (Beta): 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. FC6 Icon.png Bluetooth Discover Script 1 contains the AT commands to setup the Bluetooth device to be discoverable with pair key "1234".

DiscoverableScript.jpg


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. FC6 Icon.png Bluetooth Inquiry

Connecting to a device

Example program to connect to a specific Bluetooth device address and send data to the device. FC6 Icon.png Bluetooth Connect The device MAC address is specified using the "CreateCommandString" and "SendCommand" macros.

ConnectToMAC.jpg






Macro reference

Initialise

Fc9-comp-macro.png Initialise
Sets up the Bluetooth module. Returns 0 for OK, 255 for no reply and 254 for command fail. 
Fc9-u8-icon.png - BYTE Return


ReadString

Fc9-comp-macro.png ReadString
Copies the incoming data from the data string array to a local string variable.  
Fc9-u8-icon.png - BYTE NumBytes
 
Fc9-string-icon.png - STRING Return


ReceiveByte

Fc9-comp-macro.png ReceiveByte
Receives a single data byte from the Bluetooth module. 0xFF signifies no data available. 
Fc9-u8-icon.png - BYTE Timeout
Amount of time to wait in milliseconds 0=Wait forever 
Fc9-u8-icon.png - BYTE Return


RestoreFactorySettings

Fc9-comp-macro.png RestoreFactorySettings
Restores the factory settings to firmware using the AT&F* command. Returns 0 to indicate success 
Fc9-u8-icon.png - BYTE Return


SaveSettings

Fc9-comp-macro.png SaveSettings
Saves the current settings to firmware using the AT&W command followed by the ATZ command. Returns 0 to indicate success 
Fc9-u8-icon.png - BYTE Return


SendByte

Fc9-comp-macro.png SendByte
Sends a single data byte out to the Bluetooth module. 
Fc9-u8-icon.png - BYTE Data
 
Fc9-void-icon.png - VOID Return


SendCommand

Fc9-comp-macro.png SendCommand
Sends a command string to the Bluetooth module. 0 = Command sent ok, 255 = No Reply 
Fc9-string-icon.png - STRING Command
 
Fc9-u8-icon.png - BYTE SendCR
 
Fc9-u8-icon.png - BYTE DiscardReply
0=Do not touch the reply, 1=Wait for reply and remove from buffer 
Fc9-u8-icon.png - BYTE Return


SendScript

Fc9-comp-macro.png SendScript
Send an AT command script. Returns 0 for fail, 1 for success and 255 for unrecognised script idx. 
Fc9-u8-icon.png - BYTE idx
 
Fc9-u8-icon.png - BYTE Return


SendString

Fc9-comp-macro.png SendString
Sends a string to the Bluetooth module. 
Fc9-string-icon.png - STRING Command
 
Fc9-u8-icon.png - BYTE SendCR
 
Fc9-void-icon.png - VOID Return


SetMode

Fc9-comp-macro.png SetMode
Sets the bluetooth mode to be discoverable and or connectable. Returns 0 for success. 
Fc9-u8-icon.png - BYTE Discoverable
0 = Not Discoverable, 1 = Discoverable 
Fc9-u8-icon.png - BYTE Connectable
0 = Not Connectable, 1 = Connectable 
Fc9-u8-icon.png - BYTE Return


SetPairKey

Fc9-comp-macro.png SetPairKey
Sets the 4 digit Bluetooth pair key based on a string of numbers. e.g. "1234" Returns 0 to indicate success 
Fc9-string-icon.png - STRING PairKey
Key to use as the Pair key, e.g. "1234" or "0000" 
Fc9-u8-icon.png - BYTE Return


Property reference

Fc9-prop-icon.png Properties
Fc9-conn-icon.png Bluetooth Settings
Fc9-type-14-icon.png String Array Size
Amount of RAM memory to dedicate to receiving responses from the BT module. Default 40 
Fc9-type-7-icon.png Expect Echo
Sets if we expect an echo of any data we send out to the GSM modem. Most AT type modems (e.g. GSM modules) will automatically echo back incoming data. 
Fc9-type-10-icon.png Device Name
Sets the friendly name of the Bluetooth device. 
Fc9-type-10-icon.png Pair Key
 
Fc9-type-7-icon.png Restore Defaults
Is the Bluetooth module reset to factory settings at startup? 
Fc9-type-7-icon.png Discoverable
Is the Bluetooth module discoverable by default? 
Fc9-type-7-icon.png Connectable
Is the Bluetooth module connectable by default? 
Fc9-type-16-icon.png Script Count
Maximum number of scripts to store in the device's ROM 
Fc9-type-11-icon.png Script1
ASCII based AT command data stored in ROM and used when sending script 1 
Fc9-conn-icon.png Connections
Fc9-type-16-icon.png Channel
UART Channel selector Software channels are bit banged using generic I/O pins but are not as reliable as hardware channels. Hardware channels use the selected peripheral on-board the target microcontroller. 
Fc9-type-16-icon.png Baud Options
Baud rate option selector 
Fc9-type-14-icon.png Baud Rate
 
Fc9-type-5-icon.png TX
Pin to be used for Transmit data 
Fc9-type-5-icon.png RX
Pin to be used for Receive data 
Fc9-type-16-icon.png Use Flow Control
Flow Control (Handshake) enable or disable. On: Two I/O pins are used to control the flow of data in and out of the device. Off: Flow control is disabled. 
Fc9-type-5-icon.png Reset Pin
 
Fc9-conn-icon.png Simulation
Fc9-type-10-icon.png Label
Textual label shown on the component I/O flasher 
Fc9-type-7-icon.png Scope Traces
Selects if the scope traces are automatically added to the data recorder window or not. Simulation - draws an approximation of the UART data onto the scope trace. ICT - sets up the scope trace for incoming data and adds UART packet decoding at the correct BAUD. 
Fc9-type-7-icon.png Console Data
Selects if the console data is automatically generated or not 
Fc9-type-21-icon.png Console Columns
Number of characters that can be displayed on a single line of the console. 
Fc9-type-16-icon.png Data Source
Simulation data source used to allow the component to connect to various remote devices Nothing - Simulation data is ignored COM port - Routes the communication data to and from a physical or virtual COM port Injector - Routes the communication data via a data injector component on the Panel.