🌐 AI搜索 & 代理 主页
Skip to content

Circuitpython doesn't compile when disabling BLE (including working quick fix) #10750

@meatdryer

Description

@meatdryer

CircuitPython version and board name

Adafruit CircuitPython 10.0.1 on 2025-10-09; Adafruit Feather ESP32S3 4MB Flash 2MB PSRAM with ESP32S3

Code/REPL

mpconfigboard.mk:

CIRCUITPY_BLE_FILE_SERVICE = 0
CIRCUITPY_SERIAL_BLE = 0

Behavior

Circuitpython won't build when disabling BLE_FILE_SERVICE and SERIAL_BLE.

PacketBuffer.c seems to be missing a compilation guard when the build flags are set. It seems like the prototype is removed from the header file but the implementation still exists in the C-file.

There also seems to be a parameter mis-match between the header-file and the C-file:
max_packet_size vs. outgoing_buffer_size

-- Compilation error:
GEN build-adafruit_feather_esp32s3_4mbflash_2mbpsram/genhdr/root_pointers.h
common-hal/_bleio/PacketBuffer.c:162:6: error: no previous prototype for '_common_hal_bleio_packet_buffer_construct' [-Werror=missing-prototypes]
162 | void _common_hal_bleio_packet_buffer_construct(

-- Quick fix that works:

shared-bindings/_bleio/PacketBuffer.h:

uint32_t *outgoing_buffer1, uint32_t *outgoing_buffer2, size_t outgoing_buffer_size,
--->
uint32_t *outgoing_buffer1, uint32_t *outgoing_buffer2, size_t max_packet_size,

ports/espressif/common-hal/_bleio/PacketBuffer.c

(Line 162)
#if CIRCUITPY_SERIAL_BLE || CIRCUITPY_BLE_FILE_SERVICE void _common_hal_bleio_packet_buffer_construct( ... #endif

(Line 258)
`
#if CIRCUITPY_SERIAL_BLE || CIRCUITPY_BLE_FILE_SERVICE
_common_hal_bleio_packet_buffer_construct(self, characteristic,
incoming_buffer, incoming_buffer_size,
outgoing1, outgoing2, max_packet_size,
NULL);
#else
// When BLE services are disabled, inline the implementation
self->characteristic = characteristic;
self->client = self->characteristic->service->is_remote;
self->max_packet_size = max_packet_size;

if (self->client) {
    self->conn_handle = bleio_connection_get_conn_handle(MP_OBJ_TO_PTR(self->characteristic->service->connection));
} else {
    self->conn_handle = BLEIO_HANDLE_INVALID;
}

if (incoming) {
    ringbuf_init(&self->ringbuf, (uint8_t *)incoming_buffer, incoming_buffer_size);
}

self->packet_queued = false;
self->pending_index = 0;
self->pending_size = 0;
self->outgoing[0] = outgoing1;
self->outgoing[1] = outgoing2;

ble_event_add_handler(packet_buffer_on_ble_client_evt, self);
bleio_characteristic_set_observer(self->characteristic, self);

if (self->client) {
    if (incoming) {
        // Prefer notify if both are available.
        if (incoming & CHAR_PROP_NOTIFY) {
            common_hal_bleio_characteristic_set_cccd(self->characteristic, true, false);
        } else {
            common_hal_bleio_characteristic_set_cccd(self->characteristic, false, true);
        }
    }
    if (outgoing) {
        self->write_type = CHAR_PROP_WRITE;
        if (outgoing & CHAR_PROP_WRITE_NO_RESPONSE) {
            self->write_type = CHAR_PROP_WRITE_NO_RESPONSE;
        }
    }
} else {
    if (outgoing) {
        self->write_type = CHAR_PROP_NOTIFY;
        if (outgoing & CHAR_PROP_INDICATE) {
            self->write_type = CHAR_PROP_INDICATE;
        }
    }
}

#endif
}
`

Description

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions