Difference between revisions of "Component: Bluetooth (HC05 HC06) (Wireless)"

From Flowcode Help
Jump to navigationJump to search
(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
| 1.0 (Release)
+
| 2.0 (Release)
 
|-
 
|-
 
| width="20%" style="color: gray;" | Category
 
| width="20%" style="color: gray;" | Category
Line 21: Line 21:
  
 
==Examples==
 
==Examples==
''<span style="color:red;">No additional examples</span>''
+
Example Program that configures a HC05 / HC06 Bluetooth module and then allows a data connection to be established and utilised.
  
 +
Incoming data will be displayed on an LCD.
 +
 +
Outgoing data is assigned and sent using a keypad component.
 +
{{Fcfile|HC05_Example.fcfx|HC05 Example}}
  
 
==Downloadable macro reference==
 
==Downloadable macro reference==
Line 63: Line 67:
 
'''Parameters'''
 
'''Parameters'''
  
:[[Variable Types|BYTE]] ''Baud''
+
:[[Variable Types|BOOL]] ''Baud''
::1=1200, 2=2400, 3=4800, 4=9600, 5=19200, 6=38400, 7=57600, 8=115200
+
::1=1200, 2=2400, 3=4800, 4=9600, 5=19200, 6=NA, 7=38400, 8=57600, 9=115200
 +
 
 +
 
 +
'''Return value'''
 +
 
 +
:''This call does not return a value''
 +
 
 +
 
 +
===<span style="font-weight: normal;"><u><tt>SendCommand</tt></u></span>===
 +
Sends a command string to the HC05/HC06 module.
 +
 
 +
'''Parameters'''
 +
 
 +
:[[Variable Types|<- STRING]] ''Command''
 +
::''This parameter may be returned back to the caller''
  
  
Line 160: Line 178:
 
==Simulation macro reference==
 
==Simulation macro reference==
  
===<span style="font-weight: normal;"><u><tt>GetConsoleHandle</tt></u></span>===
+
''This component does not contain any simulation macros''
Gets the handle to the console allowing data displaying on the panel etc.
 
  
'''Parameters'''
 
  
:''This macro has no parameters''
+
==Property reference==
 +
<span style="font-weight: normal;"><u>Data Bits</u></span>
 +
 
 +
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::DBITS''.
 +
 
 +
Number of data bits
 +
 
 +
<span style="font-weight: normal;"><u>Return</u></span>
  
 +
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::RETURN''.
  
'''Return value'''
+
Return data width from Receive macro.
  
:[[Variable Types|HANDLE]]
+
8-bit data mode always returns a byte ranging from 0-255, 255 could mean a timeout or could be a valid data.
  
 +
16-bit data mode rereturns 0-255 for valid data, 256 for a timeout, return data must be stored into an INT or UINT variable.
  
 +
<span style="font-weight: normal;"><u>Echo</u></span>
  
 +
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::ECHO''.
  
==Property reference==
+
Echo selection
<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 ''CHANNEL''.
+
<span style="font-weight: normal;"><u>Baud Options</u></span>
  
Onboard UART peripheral to use to perform serial commands.
+
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::BAUD_LIST''.
  
Software mode available but not recommended for receive applications unless combined with a pin interrupt.
+
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 ''Fixed list of ints'' and can be referenced with the variable name ''BAUD_LIST''.
+
This property is of type ''Signed integer'' and can be referenced with the variable name ''cal_uart::BAUD''.
  
Theoretical number of digital bits that can be send or received a second.
+
''<span style="color:red;">No additional information</span>''
  
Theoretical because it is unlikely you will be constantly sending or receiving data 100% of the time.
 
  
<span style="font-weight: normal;"><u>Data Bits</u></span>
 
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''DBITS''.
+
<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.
  
Number of data bits in each send/receive packet
+
Hardware channels use the selected peripheral on-board the target microcontroller.
  
<span style="font-weight: normal;"><u>Return Type</u></span>
+
<span style="font-weight: normal;"><u>Use TX</u></span>
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''RETURN''.
+
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::UseTX''.
  
Specifies the way the receive function indicates a timeout.
+
Selects if the Transmit pin is used by the component.  
  
8 Bit mode - Timeout is represented by the value 255.
+
Yes: The TX pin is active and used to transmit data for the UART.
  
16 Bit mode - Timeout is represented by the value 512 allowing the value 255 to represent valid data
+
No: The TX pin is disabled and free to be used as general I/O.
  
<span style="font-weight: normal;"><u>Timeout Value</u></span>
+
<span style="font-weight: normal;"><u>TX</u></span>
  
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''ToutVal''.
+
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_uart::TX''.
  
Value used by the receive macros to indicate a timeout.
+
Pin to be used for Transmit data
  
<span style="font-weight: normal;"><u>Flow Control</u></span>
+
<span style="font-weight: normal;"><u>Use RX</u></span>
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''FLOWEN''.
+
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::UseRX''.
  
When enabled adds two extra pins to help control the flow of data between the device and the remote device.
+
Selects if the Receive pin is used by the component.  
  
<span style="font-weight: normal;"><u>Echo</u></span>
+
Yes: The RX pin is active and used to receive data for the UART.
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''ECHO''.
+
No: The RX pin is disabled and free to be used as general I/O.
  
When enabled automatically resends out any received data to help the remote device know that the data is getting through ok.
+
<span style="font-weight: normal;"><u>RX</u></span>
  
Most AT type modems (e.g. Bluetooth modules) will automatically echo back incoming data.
+
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_uart::RX''.
  
<span style="font-weight: normal;"><u>TX</u></span>
+
Pin to be used for Receive data
  
This property is of type ''Single digital pin'' and can be referenced with the variable name ''TX''.
+
<span style="font-weight: normal;"><u>Use Flow Control</u></span>
  
UART Transmit Pin
+
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::FLOWEN''.
  
<span style="font-weight: normal;"><u>RX</u></span>
+
Flow Control (Handshake) enable or disable.
  
This property is of type ''Single digital pin'' and can be referenced with the variable name ''RX''.
+
    On: Two I/O pins are used to control the flow of data in and out of the device.
  
UART Receive Pin
+
    Off: Flow control is disabled.
  
 
<span style="font-weight: normal;"><u>Label</u></span>
 
<span style="font-weight: normal;"><u>Label</u></span>
Line 248: Line 278:
 
<span style="font-weight: normal;"><u>Scope Traces</u></span>
 
<span style="font-weight: normal;"><u>Scope Traces</u></span>
  
This property is of type ''True or false'' and can be referenced with the variable name ''ScopeTraces''.
+
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.
  
Selects if the scope traces are automatically generated or not
+
    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>
 
<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 ''ConsoleData''.
+
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
 
Selects if the console data is automatically generated or not
Line 260: Line 294:
 
<span style="font-weight: normal;"><u>Console Columns</u></span>
 
<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 ''ConsoleColumns''.
+
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.
 
Number of characters that can be displayed on a single line of the console.
Line 266: Line 300:
 
<span style="font-weight: normal;"><u>Data Source</u></span>
 
<span style="font-weight: normal;"><u>Data Source</u></span>
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''DataSource''.
+
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 COM port hardware or the the data injector components.
+
Simulation data source used to allow the component to connect to various remote devices
  
<span style="font-weight: normal;"><u>Injector</u></span>
+
    Nothing - Simulation data is ignored
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''Injector''.
+
    COM port - Routes the communication data to and from a physical or virtual COM port
  
Lists all the current injector components available on the user's panel
+
    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


Image Bluetooth (HC05 HC06) component

Low level routines for controlling or interacting with a HC05 or HC06 Bluetooth module. Contains functions to allow the baud rate, bluetooth name and bluetooth key to be defined.


Examples

Example Program that configures a HC05 / HC06 Bluetooth module and then allows a data connection to be established and utilised.

Incoming data will be displayed on an LCD.

Outgoing data is assigned and sent using a keypad component. FC6 Icon.png HC05 Example

Downloadable macro reference

SetPairKey

Sets the Bluetooth pair key stored in the Bluetooth module's ROM.

Commands must be sent before Bluetooth communications are estabished e.g. right after power on and initialisation.

Parameters

STRING Key
Four digit pair key e.g. "0000" or "1234"


Return value

This call does not return a value


SendString

Sends out a string of bytes from the UART interface.

Parameters

<- STRING Data
This parameter may be returned back to the caller


Return value

This call does not return a value


SetBaud

Sets the Bluetooth baud rate stored in the Bluetooth module's ROM.

Commands must be sent before Bluetooth communications are estabished e.g. right after power on and initialisation.

Parameters

BOOL Baud
1=1200, 2=2400, 3=4800, 4=9600, 5=19200, 6=NA, 7=38400, 8=57600, 9=115200


Return value

This call does not return a value


SendCommand

Sends a command string to the HC05/HC06 module.

Parameters

<- STRING Command
This parameter may be returned back to the caller


Return value

This call does not return a value


SendNumber

Sends out a number as an ASCII String from the UART interface.

Parameters

<- LONG Number
This parameter may be returned back to the caller


Return value

This call does not return a value


SendChar

Sends out a single packet from the UART interface.

Parameters

INT Char


Return value

This call does not return a value


SetName

Sets the Bluetooth Friendly name stored in the Bluetooth module's ROM.

Commands must be sent before Bluetooth communications are estabished e.g. right after power on and initialisation.

Parameters

STRING Name
Name you wish to provide to the module


Return value

This call does not return a value


ReceiveString

Attempts to receive a string of bytes from the UART interface.

Parameters

BYTE Timeout
BYTE NumBytes


Return value

STRING


Initialise

Sets up the RS232 peripheral, must be called at the start of your program or at least before you start calling any other RS232 macros.

Parameters

This macro has no parameters


Return value

This call does not return a value


ReceiveChar

Attempts to receive a single packet from the UART interface.

Parameters

INT Timeout
Time to wait for valid data before returning, 0=Dont wait, 255=Wait forever.


Return value

INT


Simulation macro reference

This component does not contain any simulation macros


Property reference

Data Bits

This property is of type Fixed list of ints and can be referenced with the variable name cal_uart::DBITS.

Number of data bits

Return

This property is of type Fixed list of ints and can be referenced with the variable name cal_uart::RETURN.

Return data width from Receive macro.

8-bit data mode always returns a byte ranging from 0-255, 255 could mean a timeout or could be a valid data.

16-bit data mode rereturns 0-255 for valid data, 256 for a timeout, return data must be stored into an INT or UINT variable.

Echo

This property is of type Fixed list of ints and can be referenced with the variable name cal_uart::ECHO.

Echo selection

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


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.

Use TX

This property is of type True or false and can be referenced with the variable name cal_uart::UseTX.

Selects if the Transmit pin is used by the component.

Yes: The TX pin is active and used to transmit data for the UART.

No: The TX pin is disabled and free to be used as general I/O.

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

Use RX

This property is of type True or false and can be referenced with the variable name cal_uart::UseRX.

Selects if the Receive pin is used by the component.

Yes: The RX pin is active and used to receive data for the UART.

No: The RX pin is disabled and free to be used as general I/O.

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.

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.