Component: Bluetooth (HC05 HC06) (Wireless)

From Flowcode Help
Jump to navigationJump to search


Author Matrix Ltd
Version 1.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

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


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

GetConsoleHandle

Gets the handle to the console allowing data displaying on the panel etc.

Parameters

This macro has no parameters


Return value

HANDLE



Property reference

Channel

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

Onboard UART peripheral to use to perform serial commands.

Software mode available but not recommended for receive applications unless combined with a pin interrupt.

Baud Rate

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

Theoretical number of digital bits that can be send or received a second.

Theoretical because it is unlikely you will be constantly sending or receiving data 100% of the time.

Data Bits

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

Number of data bits in each send/receive packet

Return Type

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

Specifies the way the receive function indicates a timeout.

8 Bit mode - Timeout is represented by the value 255.

16 Bit mode - Timeout is represented by the value 512 allowing the value 255 to represent valid data

Timeout Value

This property is of type Unsigned integer and can be referenced with the variable name ToutVal.

Value used by the receive macros to indicate a timeout.

Flow Control

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

When enabled adds two extra pins to help control the flow of data between the device and the remote device.

Echo

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

When enabled automatically resends out any received data to help the remote device know that the data is getting through ok.

Most AT type modems (e.g. Bluetooth modules) will automatically echo back incoming data.

TX

This property is of type Single digital pin and can be referenced with the variable name TX.

UART Transmit Pin

RX

This property is of type Single digital pin and can be referenced with the variable name RX.

UART Receive Pin

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 ScopeTraces.

Selects if the scope traces are automatically generated or not

Console Data

This property is of type True or false and can be referenced with the variable name 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 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 DataSource.

Simulation data source used to allow the component to connect to COM port hardware or the the data injector components.

Injector

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

Lists all the current injector components available on the user's panel