Difference between revisions of "Component: Bluetooth v2 (EB024, Generic AT) (Wireless)"
(XML import) |
(XML import) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
|- | |- | ||
| width="20%" style="color: gray;" | Version | | width="20%" style="color: gray;" | Version | ||
− | | | + | | 2.0 (Release) |
|- | |- | ||
| width="20%" style="color: gray;" | Category | | width="20%" style="color: gray;" | Category | ||
Line 21: | Line 21: | ||
==Examples== | ==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. | ||
+ | {{Fcfile|BluetoothDiscover2.fcfx|Bluetooth Discover}} | ||
+ | Script 1 contains the AT commands to setup the Bluetooth device to be discoverable with pair key "1234". | ||
+ | |||
+ | [[File: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. | ||
+ | {{Fcfile|BluetoothInquire2.fcfx|Bluetooth Inquiry}} | ||
+ | ===Connecting to a device=== | ||
+ | |||
+ | Example program to connect to a specific Bluetooth device address and send data to the device. | ||
+ | {{Fcfile|BluetoothConnect2.fcfx|Bluetooth Connect}} | ||
+ | The device MAC address is specified using the "CreateCommandString" and "SendCommand" macros. | ||
+ | |||
+ | [[File:ConnectToMAC.jpg]] | ||
==Downloadable macro reference== | ==Downloadable macro reference== | ||
Line 210: | Line 228: | ||
==Property reference== | ==Property reference== | ||
+ | <span style="font-weight: normal;"><u>String Array Size</u></span> | ||
+ | |||
+ | This property is of type ''Signed integer'' and can be referenced with the variable name ''string_size''. | ||
+ | |||
+ | Amount of RAM memory to dedicate to receiving responses from the BT module. | ||
+ | |||
+ | Default 40 | ||
+ | |||
+ | <span style="font-weight: normal;"><u>Expect Echo</u></span> | ||
+ | |||
+ | This property is of type ''True or false'' and can be referenced with the variable name ''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. | ||
+ | |||
<span style="font-weight: normal;"><u>Device Name</u></span> | <span style="font-weight: normal;"><u>Device Name</u></span> | ||
Line 254: | Line 288: | ||
ASCII based AT command data stored in ROM and used when sending script 1 | ASCII based AT command data stored in ROM and used when sending script 1 | ||
− | <span style="font-weight: normal;"><u> | + | <span style="font-weight: normal;"><u>Channel</u></span> |
+ | |||
+ | This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::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. | ||
− | + | <span style="font-weight: normal;"><u>Baud Options</u></span> | |
− | + | This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::BAUD_LIST''. | |
− | + | Baud rate option selector | |
<span style="font-weight: normal;"><u>Baud Rate</u></span> | <span style="font-weight: normal;"><u>Baud Rate</u></span> | ||
− | This property is of type '' | + | This property is of type ''Signed integer'' and can be referenced with the variable name ''cal_uart::BAUD''. |
− | + | ''<span style="color:red;">No additional information</span>'' | |
− | |||
− | |||
− | + | <span style="font-weight: normal;"><u>TX</u></span> | |
− | + | This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_uart::TX''. | |
− | <span style="font-weight: normal;"><u> | + | Pin to be used for Transmit data |
+ | |||
+ | <span style="font-weight: normal;"><u>RX</u></span> | ||
+ | |||
+ | This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_uart::RX''. | ||
+ | |||
+ | Pin to be used for Receive data | ||
− | + | <span style="font-weight: normal;"><u>Use Flow Control</u></span> | |
− | + | This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::FLOWEN''. | |
− | + | 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. | |
− | + | <span style="font-weight: normal;"><u>Reset Pin</u></span> | |
− | + | This property is of type ''Single digital pin'' and can be referenced with the variable name ''Reset''. | |
− | <span style=" | + | ''<span style="color:red;">No additional information</span>'' |
− | |||
− | |||
− | <span style="font-weight: normal;"><u> | + | <span style="font-weight: normal;"><u>Label</u></span> |
− | This property is of type '' | + | This property is of type ''Line of text'' and can be referenced with the variable name ''label''. |
− | + | Textual label shown on the component I/O flasher | |
− | <span style="font-weight: normal;"><u> | + | <span style="font-weight: normal;"><u>Scope Traces</u></span> |
− | This property is of type '' | + | This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::ScopeTraces''. |
− | + | 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. | |
− | + | <span style="font-weight: normal;"><u>Console Data</u></span> | |
− | + | This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::ConsoleData''. | |
− | + | Selects if the console data is automatically generated or not | |
− | + | <span style="font-weight: normal;"><u>Console Columns</u></span> | |
+ | This property is of type ''Unsigned integer'' and can be referenced with the variable name ''cal_uart::ConsoleColumns''. | ||
+ | Number of characters that can be displayed on a single line of the console. | ||
− | <span style="font-weight: normal;"><u> | + | <span style="font-weight: normal;"><u>Data Source</u></span> |
− | This property is of type '' | + | This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::DataSource''. |
− | + | 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. |
Latest revision as of 10:26, 9 May 2018
Author | Matrix Ltd. |
Version | 2.0 (Release) |
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.
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.
Downloadable macro reference
SetPairKey
Sets the 4 digit Bluetooth pair key based on a string of numbers.
e.g. "1234"
Returns 0 to indicate success
Parameters
- <- STRING PairKey
- Key to use as the Pair key, e.g. "1234" or "0000"
- This parameter may be returned back to the caller
Return value
ReceiveByte
Receives a single data byte from the Bluetooth module.
0xFF signifies no data available.
Parameters
- BYTE Timeout
- Amount of time to wait in milliseconds 0=Wait forever
Return value
SendString
Sends a string to the GSM module.
Parameters
- <- STRING Command
- This parameter may be returned back to the caller
- BYTE SendCR
Return value
- This call does not return a value
SendScript
Send an AT command script.
Returns 0 for fail, 1 for success and 255 for unrecognised script idx.
Parameters
- BYTE idx
Return value
SendCommand
Sends a command string to the GSM module.
0 = Command sent ok, 255 = No Reply
Parameters
- <- STRING Command
- This parameter may be returned back to the caller
- BYTE SendCR
- BYTE DiscardReply
- 0=Do not touch the reply, 1=Wait for reply and remove from buffer
Return value
ReadString
Copies the incoming data from the data string array to a local string variable.
Parameters
- BYTE NumBytes
Return value
SaveSettings
Saves the current settings to firmware using the AT&W command followed by the ATZ command.
Returns 0 to indicate success
Parameters
- This macro has no parameters
Return value
SendByte
Sends a single data byte out to the Bluetooth module.
Parameters
- BYTE Data
Return value
- This call does not return a value
SetMode
Sets the bluetooth mode to be discoverable and or connectable.
Returns 0 for success.
Parameters
- BYTE Discoverable
- 0 = Not Discoverable, 1 = Discoverable
- BYTE Connectable
- 0 = Not Connectable, 1 = Connectable
Return value
RestoreFactorySettings
Restores the factory settings to firmware using the AT&F* command.
Returns 0 to indicate success
Parameters
- This macro has no parameters
Return value
Initialise
Sets up the GSM module.
Returns 0 for OK, 255 for no reply and 254 for command fail.
Parameters
- This macro has no parameters
Return value
Simulation macro reference
This component does not contain any simulation macros
Property reference
String Array Size
This property is of type Signed integer and can be referenced with the variable name string_size.
Amount of RAM memory to dedicate to receiving responses from the BT module.
Default 40
Expect Echo
This property is of type True or false and can be referenced with the variable name 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.
Device Name
This property is of type Line of text and can be referenced with the variable name DeviceName.
Sets the friendly name of the Bluetooth device.
Pair Key
This property is of type Line of text and can be referenced with the variable name PairKey.
No additional information
Restore Defaults
This property is of type True or false and can be referenced with the variable name InitDefs.
Is the Bluetooth module reset to factory settings at startup?
Discoverable
This property is of type True or false and can be referenced with the variable name InitDisc.
Is the Bluetooth module discoverable by default?
Connectable
This property is of type True or false and can be referenced with the variable name InitConn.
Is the Bluetooth module connectable by default?
Script Count
This property is of type Fixed list of ints and can be referenced with the variable name script_count.
Maximum number of scripts to store in the device's ROM
Script1
This property is of type Multiple lines of text and can be referenced with the variable name script1.
ASCII based AT command data stored in ROM and used when sending script 1
Channel
This property is of type Fixed list of ints and can be referenced with the variable name cal_uart::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.
Baud Options
This property is of type Fixed list of ints and can be referenced with the variable name cal_uart::BAUD_LIST.
Baud rate option selector
Baud Rate
This property is of type Signed integer and can be referenced with the variable name cal_uart::BAUD.
No additional information
TX
This property is of type Single digital pin and can be referenced with the variable name cal_uart::TX.
Pin to be used for Transmit data
RX
This property is of type Single digital pin and can be referenced with the variable name cal_uart::RX.
Pin to be used for Receive data
Use Flow Control
This property is of type Fixed list of ints and can be referenced with the variable name cal_uart::FLOWEN.
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.
Reset Pin
This property is of type Single digital pin and can be referenced with the variable name Reset.
No additional information
Label
This property is of type Line of text and can be referenced with the variable name label.
Textual label shown on the component I/O flasher
Scope Traces
This property is of type True or false and can be referenced with the variable name cal_uart::ScopeTraces.
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.
Console Data
This property is of type True or false and can be referenced with the variable name cal_uart::ConsoleData.
Selects if the console data is automatically generated or not
Console Columns
This property is of type Unsigned integer and can be referenced with the variable name cal_uart::ConsoleColumns.
Number of characters that can be displayed on a single line of the console.
Data Source
This property is of type Fixed list of ints and can be referenced with the variable name cal_uart::DataSource.
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.