Difference between revisions of "Component: Bluetooth BLE (ESP32 SPP Server) (Wireless)"
| (3 intermediate revisions by 2 users 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: <span style="color:# | + | 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. | ||
| Line 171: | Line 171: | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveString''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveString''' | ||
|- | |- | ||
| − | | colspan="2" | | + | | colspan="2" | Attempts to receive a string of characters from the Bluetooth SPP. Terminates on timeout, on receiving the MaxBytes or on receiving a '\n' character |
|- | |- | ||
|- | |- | ||
| Line 195: | Line 195: | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendArray''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendArray''' | ||
|- | |- | ||
| − | | colspan="2" | Sends | + | | colspan="2" | Sends an array of bytes to the Bluetooth serial connection |
|- | |- | ||
|- | |- | ||
| Line 238: | Line 238: | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendINTArray''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendINTArray''' | ||
|- | |- | ||
| − | | colspan="2" | | + | | colspan="2" | Sends an array of 16-bit integers to the Bluetooth serial connection |
|- | |- | ||
|- | |- | ||
| Line 246: | Line 246: | ||
| colspan="2" | Data Array to send | | colspan="2" | Data Array to send | ||
|- | |- | ||
| − | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
| width="90%" | NumValues | | width="90%" | NumValues | ||
|- | |- | ||
| − | | colspan="2" | Number of | + | | colspan="2" | Number of bytes to send |
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
| − | | width="90%" | | + | | width="90%" | MSBFirst |
|- | |- | ||
| colspan="2" | 0=Least significant byte first, 1=Most significant byte first | | colspan="2" | 0=Least significant byte first, 1=Most significant byte first | ||
| Line 274: | Line 274: | ||
|- | |- | ||
| colspan="2" | Data Array to send | | colspan="2" | Data Array to send | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
| Line 324: | Line 305: | ||
| width="90%" | Device Name | | width="90%" | Device Name | ||
|- | |- | ||
| − | | colspan="2" | Sets the Bluetooth device friendly name | + | | colspan="2" | Sets the Bluetooth device friendly name. Max 19 characters. |
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]] | | width="10%" align="center" | [[File:Fc9-type-21-icon.png]] | ||
| Line 331: | Line 312: | ||
| colspan="2" | Configures the size of the receive buffer in bytes to store incoming data until we are ready to receive it. | | colspan="2" | Configures the size of the receive buffer in bytes to store incoming data until we are ready to receive it. | ||
|- | |- | ||
| − | | width="10%" align="center" | [[File:Fc9-type- | + | | width="10%" align="center" | [[File:Fc9-type-21-icon.png]] |
| − | | width="90%" | | + | | width="90%" | Service UUID |
| + | |- | ||
| + | | colspan="2" | 16-bit value that identifies the custom “Simple SPP” service so scanners know the device supports that feature. | ||
| + | |- | ||
| + | | width="10%" align="center" | [[File:Fc9-type-21-icon.png]] | ||
| + | | width="90%" | Characteristic UUID | ||
|- | |- | ||
| − | | colspan="2" | | + | | colspan="2" | 16-bit value that describes the single characteristic that carries the serial-like data flow (reads, writes, notifications). |
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]] | | width="10%" align="center" | [[File:Fc9-type-7-icon.png]] | ||
| − | | width="90%" | | + | | width="90%" | Data Receive Interrupt |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
| Line 373: | Line 359: | ||
==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_Bluetooth_ESP32_BLE_GATT_SPP_Server_1.fcfx FC_Comp_Source_Bluetooth_ESP32_BLE_GATT_SPP_Server_1.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_Bluetooth_ESP32_BLE_GATT_SPP_Server_1.fcfx FC_Comp_Source_Bluetooth_ESP32_BLE_GATT_SPP_Server_1.fcfx] |
Latest revision as of 14:45, 7 January 2026
| Author | Matrix TSL |
| Version | 1.0 |
| Category | Wireless |
Contents
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
| CheckConnectionStatus | |
| Checks to see if the Bluetooth device is connected. Returns 1 if connected. | |
| Return | |
Initialise
| Initialise | |
| Starts up the Bluetooth communications SPP service. | |
| Return | |
ReceiveArray
ReceiveByte
| ReceiveByte | |
| Attempts to receive a byte from the bluetooth serial port. 0-255 = a valid received value 256 = a timeout has occured | |
| Timeout | |
| Number of ms to wait for incoming data | |
| Return | |
ReceiveCount
| ReceiveCount | |
| Collects the number of bytes currently stored in the receive buffer. | |
| Return | |
ReceiveINTArray
ReceiveString
SendArray
| SendArray | |
| Sends an array of bytes to the Bluetooth serial connection | |
| Data | |
| Data Array to send | |
| NumBytes | |
| Number of bytes to send | |
| Return | |
SendByte
| SendByte | |
| Sends a byte to the Bluetooth serial connection | |
| Data | |
| Return | |
SendINTArray
SendString
| SendString | |
| Sends a string to the Bluetooth serial connection | |
| Data | |
| Data Array to send | |
| Return | |
Uninitialise
| Uninitialise | |
| Shots down the Bluetooth communications SPP service. | |
| Return | |
Property reference
Component Source Code
Please click here to download the component source project: FC_Comp_Source_Bluetooth_ESP32_BLE_GATT_SPP_Server_1.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_Bluetooth_ESP32_BLE_GATT_SPP_Server_1.fcfx