Component: Bluetooth (BL0170) (E-blocks 2): Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 17: | Line 17: | ||
==Component Source Code== | ==Component Source Code== | ||
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/ | Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_temp/EBlocks2_Bluetooth_RN4677_BL0170.fcfx FC_Comp_Source_temp/EBlocks2_Bluetooth_RN4677_BL0170.fcfx] | ||
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/ | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_temp/EBlocks2_Bluetooth_RN4677_BL0170.fcfx FC_Comp_Source_temp/EBlocks2_Bluetooth_RN4677_BL0170.fcfx] | ||
==Detailed description== | ==Detailed description== | ||
| Line 49: | Line 49: | ||
''<span style="color:red;">No additional examples</span>'' | ''<span style="color:red;">No additional examples</span>'' | ||
| Line 57: | Line 59: | ||
==Macro reference== | ==Macro reference== | ||
=== | ===ConnectToMAC=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ConnectToMAC''' | ||
|- | |||
| colspan="2" | Connects to a specific Bluetooth MAC address. Waits up to 5 seconds for connection to be established. Returns 1 if connection was successful. | |||
|- | |||
|- | |||
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | |||
| width="90%" | MACAddress | |||
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL | |||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | |||
|} | |||
===EnterCommandMode=== | |||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | |||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9- | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''EnterCommandMode''' | ||
|- | |||
| colspan="2" | Enters command mode allowing commands to be sent using the SendCommand macro. Returns: 0 = No Reply / 1 = Command Mode OK | |||
|- | |- | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
=== | ===GetMACAddress=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetMACAddress''' | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | Gets the local Bluetooth device MAC address. | ||
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING | ||
| width="90%" | | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |||
===Initialise=== | |||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | |||
|- | |- | ||
| | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise''' | |||
|- | |- | ||
| | | colspan="2" | Sets up the Bluetooth module including: - Enabling the UART - Configuring the module (Name / Key / etc) Returns 1 for OK and 0 for no reply. | ||
|- | |- | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
| Line 114: | Line 134: | ||
=== | ===ReadString=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadString''' | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | Copies the incoming data from the data string array to a local string variable. | ||
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9- | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
| width="90%" | | | width="90%" | NumBytes | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | Maximum number of bytes to try and read | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
=== | ===ReceiveByte=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveByte''' | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | Receives a single data byte from the Bluetooth module. 0-255 signifies valid data / 256 signifies no data available. | ||
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9- | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
| width="90%" | | | width="90%" | Timeout | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | Amount of time to wait in milliseconds 0=Wait forever | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | |||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | |||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
| Line 176: | Line 186: | ||
=== | ===SendByte=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendByte''' | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | Sends a single data byte out to the Bluetooth module. | ||
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
| width="90%" | | | width="90%" | Data | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
=== | ===SendCommand=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendCommand''' | ||
|- | |||
| colspan="2" | Sends a command string to the Bluetooth module. Returns: 0 = No Reply / 1 = Command sent ok | |||
|- | |||
|- | |- | ||
| | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
| width="90%" | Command | |||
|- | |- | ||
| colspan="2" | | |||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
| width="90%" | | | width="90%" | SendCR | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
| width="90%" | DiscardReply | |||
|- | |||
| colspan="2" | 0=Do not touch the reply, 1=Wait for reply and remove from buffer | |||
|- | |||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | |||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
=== | ===SendString=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendString''' | ||
|- | |||
| colspan="2" | Sends a string to the Bluetooth module. | |||
|- | |||
|- | |||
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | |||
| width="90%" | Command | |||
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | |||
| width="90%" | SendCR | |||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | | colspan="2" | | ||
|- | |||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | |||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
| Line 248: | Line 278: | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
Revision as of 12:00, 3 February 2023
| Author | Matrix Ltd. |
| Version | 1.3 |
| Category | E-blocks 2 |
Bluetooth component
Low level routines for controlling a Microchip RN4677 Bluetooth Module. Also available in the form of the BL0170 Bluetooth E-block. Uses an interrupt to receive characters from the UART and improve reliability, Must be used with a hardware UART channel.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_temp/EBlocks2_Bluetooth_RN4677_BL0170.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_temp/EBlocks2_Bluetooth_RN4677_BL0170.fcfx
Detailed description
No detailed description exists yet for this component
Examples
No additional examples
Macro reference
ConnectToMAC
| ConnectToMAC | |
| Connects to a specific Bluetooth MAC address. Waits up to 5 seconds for connection to be established. Returns 1 if connection was successful. | |
| MACAddress | |
| Return | |
EnterCommandMode
| EnterCommandMode | |
| Enters command mode allowing commands to be sent using the SendCommand macro. Returns: 0 = No Reply / 1 = Command Mode OK | |
| Return | |
GetMACAddress
| GetMACAddress | |
| Gets the local Bluetooth device MAC address. | |
| Return | |
Initialise
| Initialise | |
| Sets up the Bluetooth module including: - Enabling the UART - Configuring the module (Name / Key / etc) Returns 1 for OK and 0 for no reply. | |
| Return | |
LeaveCommandMode
| LeaveCommandMode | |
| Leaves command mode allowing data to be passed back and forth, | |
| Return | |
ReadString
| ReadString | |
| Copies the incoming data from the data string array to a local string variable. | |
| NumBytes | |
| Maximum number of bytes to try and read | |
| Return | |
ReceiveByte
ReceiveCount
| ReceiveCount | |
| Returns the number of bytes currently sat waiting in the receive buffer. | |
| Return | |
SendByte
| SendByte | |
| Sends a single data byte out to the Bluetooth module. | |
| Data | |
| Return | |
SendCommand
SendString
| SendString | |
| Sends a string to the Bluetooth module. | |
| Command | |
| SendCR | |
| Return | |
WaitForStringValue