guter zwischenstand
This commit is contained in:
@@ -8,6 +8,12 @@ menuconfig BLE_MGMT
|
||||
Library for initializing and managing Bluetooth functionality.
|
||||
|
||||
if BLE_MGMT
|
||||
config BLE_MGMT_TX_QUEUE_DEPTH
|
||||
int "BLE TX queue depth"
|
||||
default 32
|
||||
help
|
||||
Number of notification payloads that can be queued in the BLE transport.
|
||||
|
||||
config BLE_MGMT_DEFAULT_DEVICE_NAME
|
||||
string "Default Bluetooth Device Name"
|
||||
default "Edis Buzzer"
|
||||
@@ -22,7 +28,6 @@ if BLE_MGMT
|
||||
help
|
||||
Maximal advertising interval. 160 equals to 100ms.
|
||||
|
||||
# 1. MTU und Data Length (Maximale Paketgrößen)
|
||||
config BT_L2CAP_TX_MTU
|
||||
default 247
|
||||
config BT_BUF_ACL_RX_SIZE
|
||||
@@ -33,14 +38,12 @@ if BLE_MGMT
|
||||
default 251
|
||||
config BT_USER_DATA_LEN_UPDATE
|
||||
default y
|
||||
|
||||
# 2. Physical Layer (Erlaubt 2M PHY)
|
||||
config BT_USER_PHY_UPDATE
|
||||
default y
|
||||
|
||||
# 3. Flow-Control und Queues (High Throughput, Host + SDC Controller synchronisiert)
|
||||
config BT_HCI_ACL_FLOW_CONTROL
|
||||
default y
|
||||
config BT_BUF_CMD_TX_COUNT
|
||||
default 24
|
||||
config BT_BUF_EVT_RX_COUNT
|
||||
default 22
|
||||
config BT_BUF_ACL_TX_COUNT
|
||||
@@ -49,13 +52,13 @@ if BLE_MGMT
|
||||
default 20
|
||||
config BT_CONN_TX_MAX
|
||||
default 20
|
||||
|
||||
# 4. SDC Controller Buffering (an Host-Tiefen angeglichen)
|
||||
config BT_CTLR_SDC_TX_PACKET_COUNT
|
||||
default 20
|
||||
config BT_CTLR_SDC_RX_PACKET_COUNT
|
||||
default 20
|
||||
|
||||
config BT_MAX_CONN
|
||||
default 2
|
||||
|
||||
module = BLE_MGMT
|
||||
module-str = ble_mgmt
|
||||
source "subsys/logging/Kconfig.template.log_config"
|
||||
|
||||
@@ -74,7 +74,7 @@ void buzz_proto_buf_free(uint8_t **buf)
|
||||
{
|
||||
if (buf && *buf)
|
||||
{
|
||||
k_mem_slab_free(&buzz_proto_slabs, (void **)*buf);
|
||||
k_mem_slab_free(&buzz_proto_slabs, *buf);
|
||||
*buf = NULL;
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,8 @@ int buzz_proto_submit_frame(struct buzz_frame_msg *msg)
|
||||
return k_msgq_put(&buzz_proto_msgq, msg, K_NO_WAIT);
|
||||
}
|
||||
|
||||
static void send_stream_error(buzz_transport_reply_fn reply_cb, uint16_t error_code);
|
||||
|
||||
static void send_error_frame(struct buzz_frame_msg *msg, uint16_t error_code)
|
||||
{
|
||||
struct buzz_proto_header *hdr = (struct buzz_proto_header *)msg->data_ptr;
|
||||
@@ -99,6 +101,18 @@ static void send_error_frame(struct buzz_frame_msg *msg, uint16_t error_code)
|
||||
}
|
||||
}
|
||||
|
||||
static void send_stream_error(buzz_transport_reply_fn reply_cb, uint16_t error_code)
|
||||
{
|
||||
uint8_t *buf = NULL;
|
||||
if (reply_cb == NULL || buzz_proto_buf_alloc(&buf) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
struct buzz_frame_msg err_msg = {.data_ptr = buf, .reply_cb = reply_cb};
|
||||
send_error_frame(&err_msg, error_code);
|
||||
buzz_proto_buf_free(&buf);
|
||||
}
|
||||
|
||||
static void handle_proto_version_request(struct buzz_frame_msg *msg)
|
||||
{
|
||||
struct buzz_proto_header *hdr = (struct buzz_proto_header *)msg->data_ptr;
|
||||
@@ -284,6 +298,8 @@ static void handle_file_get_request(struct buzz_frame_msg *msg)
|
||||
fs_mgmt_pm_close(&get_file_state.file);
|
||||
get_file_state.active = false;
|
||||
current_stream = STREAM_IDLE;
|
||||
k_sleep(K_MSEC(10));
|
||||
send_error_frame(msg, EIO);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -363,16 +379,20 @@ static void process_file_get_stream(void)
|
||||
return;
|
||||
}
|
||||
|
||||
// Daten gelesen -> CRC aktualisieren und Chunk senden
|
||||
get_file_state.crc32 = crc32_ieee_update(get_file_state.crc32, payload_ptr, read_len);
|
||||
get_file_state.offset += read_len;
|
||||
|
||||
// Chunk senden; CRC/Offset erst nach erfolgreichem Enqueue aktualisieren
|
||||
hdr->frame_type = BUZZ_FRAME_FILE_CHUNK;
|
||||
hdr->payload_length = sys_cpu_to_le16(read_len);
|
||||
|
||||
if (get_file_state.reply_cb)
|
||||
{
|
||||
int send_rc = get_file_state.reply_cb(buf, sizeof(*hdr) + read_len);
|
||||
if (send_rc == -ENOMEM)
|
||||
{
|
||||
// BLE TX queue voll - Datei zurücksetzen, nächster Zyklus wiederholt den Chunk
|
||||
fs_seek(&get_file_state.file, -(off_t)read_len, FS_SEEK_CUR);
|
||||
buzz_proto_buf_free(&buf);
|
||||
return;
|
||||
}
|
||||
if (send_rc)
|
||||
{
|
||||
LOG_ERR("Failed to send FILE_CHUNK (err %d)", send_rc);
|
||||
@@ -380,10 +400,15 @@ static void process_file_get_stream(void)
|
||||
get_file_state.active = false;
|
||||
current_stream = STREAM_IDLE;
|
||||
buzz_proto_buf_free(&buf);
|
||||
k_sleep(K_MSEC(10));
|
||||
send_stream_error(get_file_state.reply_cb, EIO);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Erfolgreich eingereiht: State aktualisieren
|
||||
get_file_state.crc32 = crc32_ieee_update(get_file_state.crc32, payload_ptr, read_len);
|
||||
get_file_state.offset += read_len;
|
||||
get_file_state.credits--;
|
||||
get_file_state.retry_counter = 0;
|
||||
buzz_proto_buf_free(&buf);
|
||||
@@ -590,6 +615,7 @@ static void buzz_proto_thread_fn(void *p1, void *p2, void *p3)
|
||||
{
|
||||
LOG_WRN("LS timeout waiting for ACK");
|
||||
fs_mgmt_pm_closedir(&ls_state.dir);
|
||||
send_stream_error(ls_state.reply_cb, ETIMEDOUT);
|
||||
ls_state.active = false;
|
||||
current_stream = STREAM_IDLE;
|
||||
}
|
||||
@@ -608,6 +634,7 @@ static void buzz_proto_thread_fn(void *p1, void *p2, void *p3)
|
||||
{
|
||||
LOG_WRN("FILE_GET timeout waiting for ACK");
|
||||
fs_close(&get_file_state.file);
|
||||
send_stream_error(get_file_state.reply_cb, ETIMEDOUT);
|
||||
get_file_state.active = false;
|
||||
current_stream = STREAM_IDLE;
|
||||
}
|
||||
|
||||
@@ -3,22 +3,13 @@ CONFIG_LOG=y
|
||||
|
||||
### File System
|
||||
CONFIG_FS_MGMT=y
|
||||
CONFIG_FS_MGMT_LOG_LEVEL_DBG=y
|
||||
# CONFIG_FS_MGMT_LOG_LEVEL_DBG=y
|
||||
CONFIG_FS_LOG_LEVEL_WRN=y
|
||||
|
||||
### Bluetooth
|
||||
CONFIG_BLE_MGMT=y
|
||||
# CONFIG_BLE_MGMT_LOG_LEVEL_DBG=y
|
||||
|
||||
# Explicit throughput tuning in project config (wins over competing defaults)
|
||||
CONFIG_BT_HCI_ACL_FLOW_CONTROL=y
|
||||
CONFIG_BT_BUF_CMD_TX_COUNT=24
|
||||
CONFIG_BT_BUF_ACL_TX_COUNT=20
|
||||
CONFIG_BT_L2CAP_TX_BUF_COUNT=20
|
||||
CONFIG_BT_CONN_TX_MAX=20
|
||||
CONFIG_BT_CTLR_SDC_TX_PACKET_COUNT=20
|
||||
CONFIG_BT_CTLR_SDC_RX_PACKET_COUNT=20
|
||||
|
||||
# Advertising 500ms - 1s
|
||||
CONFIG_BLE_MGMT_ADV_INT_MIN=160
|
||||
CONFIG_BLE_MGMT_ADV_INT_MAX=320
|
||||
|
||||
Reference in New Issue
Block a user