Difference between revisions of "Component: Bluetooth BLE (ESP32 SPP Server) (Wireless)"

From Flowcode Help
Jump to navigationJump to search
 
(One intermediate revision by the same user not shown)
Line 19: Line 19:
 
This component requires the Bluetooth and Bluedroid libraries from the ESP32 IPE.  
 
This component requires the Bluetooth and Bluedroid libraries from the ESP32 IPE.  
  
If you get this error when compiling: esp_bt.h: No such file or directory
+
If you get this error when compiling: <span style="color:#FF0000">esp_bt.h: No such file or directory</span>
  
 
Then you may not have Bluetooth enabled.
 
Then you may not have Bluetooth enabled.

Latest revision as of 16:14, 2 December 2025

Author Matrix TSL
Version 1.0
Category Wireless


Bluetooth BLE (ESP32 SPP Server) component

Bluetooth BLE server component designed to run on a ESP32 providing GATT SPP functionality. BT BLE functionality must be switched on via the sdkconfig file.

Detailed description

This component requires the Bluetooth and Bluedroid libraries from the ESP32 IPE.

If you get this error when compiling: esp_bt.h: No such file or directory

Then you may not have Bluetooth enabled.

To fix this navigate to C:\FC_ESP\mtx<chiptype>_sdkconfig\

Then run menuconfig.bat to open the configuration editor.

Goto Component Config -> Bluetooth

Check the item Bluetooth.

Then go into Bluedroid Options and ensure the Enable BLE 4.2 features near the bottom is ticked.

Save and exit and then re-compile 🙂

Examples

No additional examples

Macro reference

CheckConnectionStatus

Fc9-comp-macro.png CheckConnectionStatus
Checks to see if the Bluetooth device is connected. Returns 1 if connected. 
Fc9-bool-icon.png - BOOL Return


Initialise

Fc9-comp-macro.png Initialise
Starts up the Bluetooth communications SPP service. 
Fc9-void-icon.png - VOID Return


ReceiveArray

Fc9-comp-macro.png ReceiveArray
Attempts to receive an array of bytes from the bluetooth serial port. Returns the number of bytes received. 
Fc9-u8-icon.png - BYTE Data
Buffer to place received data into 
Fc9-u16-icon.png - UINT MaxBytes
Max number of bytes to try and read within the time 
Fc9-u16-icon.png - UINT Timeout
Number of ms to wait for incoming data 
Fc9-u16-icon.png - UINT Return


ReceiveByte

Fc9-comp-macro.png ReceiveByte
Attempts to receive a byte from the bluetooth serial port. 0-255 = a valid received value 256 = a timeout has occured 
Fc9-u16-icon.png - UINT Timeout
Number of ms to wait for incoming data 
Fc9-u16-icon.png - UINT Return


ReceiveCount

Fc9-comp-macro.png ReceiveCount
Collects the number of bytes currently stored in the receive buffer. 
Fc9-u16-icon.png - UINT Return


ReceiveINTArray

Fc9-comp-macro.png ReceiveINTArray
Receives an array of 16-bit INT/UINT values and returns the number of values received. 
Fc9-u16-icon.png - UINT Data
Array to store the incoming data 
Fc9-u8-icon.png - BYTE NumValues
Maximum number of values to try and receive 
Fc9-bool-icon.png - BOOL MSBfirst
0=Least significant byte first, 1=Most significant byte first 
Fc9-u8-icon.png - BYTE Timeout
Max amount of time in ms to wait between bytes 
Fc9-u8-icon.png - BYTE Return


ReceiveString

Fc9-comp-macro.png ReceiveString
 
Fc9-u16-icon.png - UINT MaxBytes
Max number of bytes to try and read within the time 
Fc9-u16-icon.png - UINT Timeout
Number of ms to wait for incoming data 
Fc9-string-icon.png - STRING Return


SendArray

Fc9-comp-macro.png SendArray
Sends a byte to the Bluetooth serial connection 
Fc9-u8-icon.png - BYTE Data
Data Array to send 
Fc9-u16-icon.png - UINT NumBytes
Number of bytes to send 
Fc9-void-icon.png - VOID Return


SendByte

Fc9-comp-macro.png SendByte
Sends a byte to the Bluetooth serial connection 
Fc9-u8-icon.png - BYTE Data
 
Fc9-void-icon.png - VOID Return


SendINTArray

Fc9-comp-macro.png SendINTArray
Transmits an array of 16-bit INT/UINT values via the Bluetooth peripheral 
Fc9-u16-icon.png - UINT Data
Data Array to send 
Fc9-u8-icon.png - BYTE NumValues
Number of 16-bit values to send from the array 
Fc9-bool-icon.png - BOOL MSBfirst
0=Least significant byte first, 1=Most significant byte first 
Fc9-void-icon.png - VOID Return


SendString

Fc9-comp-macro.png SendString
Sends a string to the Bluetooth serial connection 
Fc9-string-icon.png - STRING Data
Data Array to send 
Fc9-void-icon.png - VOID Return


SetBTName

Fc9-comp-macro.png SetBTName
Overrides the current friendly name 
Fc9-string-icon.png - STRING Name
Name you want to use 
Fc9-void-icon.png - VOID Return


Uninitialise

Fc9-comp-macro.png Uninitialise
Shots down the Bluetooth communications SPP service. 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-10-icon.png Device Name
Sets the Bluetooth device friendly name 
Fc9-type-21-icon.png Receive Buffer
Configures the size of the receive buffer in bytes to store incoming data until we are ready to receive it. 
Fc9-type-7-icon.png Data Receive Interrupt
 
Fc9-type-7-icon.png Heartbeat
 
Fc9-type-16-icon.png Verbose Debug
When enabled debug messages will be placed onto UART CH1 which is generally connected to via a Serial to USB IC to pipe messages back to the host PC. 
Fc9-conn-icon.png Simulation
Fc9-type-16-icon.png COM Port
Selects which port to communicate with, only lists ports which are currently available.  
Fc9-type-7-icon.png Refresh COM Ports
When set to yes the COM port list is rescanned for newly connected or available ports. Note that refreshing the ports list may take a few seconds depending on the number of connected ports. 
Fc9-type-14-icon.png Baud
Baud rate passed to the COM port to control the rate of data. 
Fc9-type-7-icon.png Console Data
 

Component Source Code

Please click here to download the component source project: FC_Comp_Source_Bluetooth_ESP32_BLE_GATT_SPP_Server.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_Bluetooth_ESP32_BLE_GATT_SPP_Server.fcfx