Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/esp-idf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: ESP-IDF

on:
push:
branches: ["master"]
branches: ["*"]
pull_request:
branches: ["master"]
branches: ["*"]

jobs:
build:
Expand All @@ -26,4 +26,4 @@ jobs:
with:
esp_idf_version: v5.2.2
target: ${{matrix.target}}
path: '.'
path: '.'
32 changes: 27 additions & 5 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
set(JAC_ESP32_VERSION "0.0.17")

# Base source files
set(COMPONENT_SRCS
"main.cpp"
"platform/espWifi.cpp"
"platform/espNvsKeyValue.cpp"
"espFeatures/gridui/gridUiFeature.cpp"
"espFeatures/gridui/widgets/_common.cpp"
)

# Base requirements
set(COMPONENT_REQUIRES
jac-dcore jac-machine jac-link
driver pthread spiffs vfs fatfs
SmartLeds esp_timer Esp32-RBGridUI
)

# Conditionally add BLE support
if(CONFIG_JAC_ESP32_ENABLE_BLE)
list(APPEND COMPONENT_SRCS "util/bleStream.cpp")
list(APPEND COMPONENT_REQUIRES "bt")
message(STATUS "BLE Stream support enabled")
else()
message(STATUS "BLE Stream support disabled")
endif()

idf_component_register(
SRCS "main.cpp" "platform/espWifi.cpp" "platform/espNvsKeyValue.cpp"
"espFeatures/gridui/gridUiFeature.cpp" "espFeatures/gridui/widgets/_common.cpp"
SRCS ${COMPONENT_SRCS}
INCLUDE_DIRS ""
REQUIRES jac-dcore jac-machine jac-link
driver pthread spiffs vfs fatfs
SmartLeds esp_timer Esp32-RBGridUI
REQUIRES ${COMPONENT_REQUIRES}
)

target_compile_definitions(${COMPONENT_LIB} PRIVATE JAC_ESP32_VERSION="${JAC_ESP32_VERSION}")
Expand Down
69 changes: 69 additions & 0 deletions main/Kconfig.projbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
menu "Jaculus ESP32 Configuration"

config JAC_ESP32_ENABLE_BLE
bool "Enable BLE Stream Support"
default y
help
Enable BLE (Bluetooth Low Energy) stream support for wireless communication.
This allows the ESP32 to act as a BLE GATT server that can be used
as a communication transport alongside UART, TCP, and JTAG streams.

When enabled:
- BLE stack will be initialized
- GATT server with custom service will be created
- Device will be discoverable as "ESP32_JAC_BLE_XXXX" (XXXX = MAC suffix)
- BLE stream will be available on mux channel 4

When disabled:
- BLE functionality is completely removed from build
- Reduces binary size and memory usage
- BT component dependency is optional

config JAC_ESP32_BLE_DEVICE_NAME
string "BLE Device Name Prefix"
depends on JAC_ESP32_ENABLE_BLE
default "ESP32_JAC_BLE"
help
The prefix for the BLE device name. The actual device name will be
this prefix followed by the last 2 bytes of the MAC address.
For example: "ESP32_JAC_BLE_A1B2"

config JAC_ESP32_BLE_SERVICE_UUID
hex "BLE GATT Service UUID (16-bit)"
depends on JAC_ESP32_ENABLE_BLE
default 0x00FF
range 0x0001 0xFFFE
help
The 16-bit UUID for the custom BLE GATT service.
Default is 0x00FF (255 in decimal).

config JAC_ESP32_BLE_CHARACTERISTIC_UUID
hex "BLE GATT Characteristic UUID (16-bit)"
depends on JAC_ESP32_ENABLE_BLE
default 0xFF01
range 0x0001 0xFFFE
help
The 16-bit UUID for the BLE GATT characteristic used for data transfer.
Default is 0xFF01 (65281 in decimal).

config JAC_ESP32_BLE_MTU_SIZE
int "BLE MTU Size"
depends on JAC_ESP32_ENABLE_BLE
default 500
range 23 512
help
Maximum Transmission Unit (MTU) size for BLE communication.
Larger values allow more data per packet but may not be supported
by all devices. Default is 500 bytes.

config JAC_ESP32_BLE_DEBUG_LOGS
bool "Enable BLE Debug Logging"
depends on JAC_ESP32_ENABLE_BLE
default n
help
Enable detailed debug logging for BLE operations.
This will show step-by-step initialization, connection events,
and data transfer details. Useful for debugging but increases
log output significantly.

endmenu
17 changes: 17 additions & 0 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

#include "util/uartStream.h"
#include "util/tcpStream.h"
#ifdef CONFIG_JAC_ESP32_ENABLE_BLE
#include "util/bleStream.h"
#endif

#include "resources/resources.h"

Expand Down Expand Up @@ -124,6 +127,9 @@ jac::Device<Machine> device(
using Mux_t = jac::Mux<jac::CobsEncoder>;
std::unique_ptr<Mux_t> muxUart;
std::unique_ptr<Mux_t> muxTcp;
#ifdef CONFIG_JAC_ESP32_ENABLE_BLE
std::unique_ptr<Mux_t> muxBle;
#endif

#if defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3)
std::unique_ptr<Mux_t> muxJtag;
Expand Down Expand Up @@ -214,6 +220,17 @@ int main() {
muxTcp->bindRx(std::make_unique<decltype(handleTcp)>(std::move(handleTcp)));
}

#ifdef CONFIG_JAC_ESP32_ENABLE_BLE
// initialize BLE stream
auto bleStream = std::make_unique<BleStream>("ESP32_JAC_BLE");
bleStream->start();

muxBle = std::make_unique<Mux_t>(std::move(bleStream));
muxBle->setErrorHandler(reportMuxError);
auto handleBle = device.router().subscribeTx(4, *muxBle);
muxBle->bindRx(std::make_unique<decltype(handleBle)>(std::move(handleBle)));
#endif


device.onConfigureMachine([&](Machine &machine) {
device.machineIO().in->clear();
Expand Down
2 changes: 1 addition & 1 deletion main/resources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.10)

set(ts_examples_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../ts-examples)
set(ts_examples_tgz ts_examples.tar.gz)
Expand Down
Loading