From 67bf2ca80011f251cead90bb2c3a9acb6f1eb567 Mon Sep 17 00:00:00 2001 From: "isha.pardikar@espressif.com" Date: Fri, 17 Mar 2023 14:22:16 +0530 Subject: [PATCH] NimBLE: Added support for writing data more than BLE_ATT_ATTR_MAX_LEN --- nimble/host/src/ble_att_clt.c | 7 +++++++ nimble/host/src/ble_att_svr.c | 3 ++- nimble/syscfg.yml | 4 ++++ porting/examples/linux/include/syscfg/syscfg.h | 4 ++++ porting/examples/linux_blemesh/include/syscfg/syscfg.h | 4 ++++ porting/examples/nuttx/include/syscfg/syscfg.h | 4 ++++ porting/nimble/include/syscfg/syscfg.h | 4 ++++ porting/npl/riot/include/syscfg/syscfg.h | 8 ++++++++ 8 files changed, 37 insertions(+), 1 deletion(-) diff --git a/nimble/host/src/ble_att_clt.c b/nimble/host/src/ble_att_clt.c index b500f416c..db847db66 100644 --- a/nimble/host/src/ble_att_clt.c +++ b/nimble/host/src/ble_att_clt.c @@ -769,10 +769,17 @@ ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t handle, goto err; } +#if MYNEWT_VAL(BLE_GATT_BLOB_TRANSFER) + if (OS_MBUF_PKTLEN(txom) > BLE_ATT_ATTR_MAX_LEN) { + rc = BLE_HS_EINVAL; + goto err; + } +#else if (offset + OS_MBUF_PKTLEN(txom) > BLE_ATT_ATTR_MAX_LEN) { rc = BLE_HS_EINVAL; goto err; } +#endif if (OS_MBUF_PKTLEN(txom) > ble_att_mtu(conn_handle) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ) { diff --git a/nimble/host/src/ble_att_svr.c b/nimble/host/src/ble_att_svr.c index f00b2cb00..c4dd51dae 100644 --- a/nimble/host/src/ble_att_svr.c +++ b/nimble/host/src/ble_att_svr.c @@ -2169,12 +2169,13 @@ ble_att_svr_prep_validate(struct ble_att_prep_entry_list *prep_list, } } +#if !MYNEWT_VAL(BLE_GATT_BLOB_TRANSFER) cur_len = entry->bape_offset + OS_MBUF_PKTLEN(entry->bape_value); if (cur_len > BLE_ATT_ATTR_MAX_LEN) { *err_handle = entry->bape_handle; return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; } - +#endif prev = entry; } diff --git a/nimble/syscfg.yml b/nimble/syscfg.yml index ce43a00b1..040171d35 100644 --- a/nimble/syscfg.yml +++ b/nimble/syscfg.yml @@ -124,6 +124,10 @@ syscfg.defs: description: > This enables LE Connection Subrating feature value: 0 + BLE_GATT_BLOB_TRANSFER: + description: > + This enables write blob feature + value: 1 # Allow periodic sync transfer only if 5.1 or higher syscfg.restrictions: diff --git a/porting/examples/linux/include/syscfg/syscfg.h b/porting/examples/linux/include/syscfg/syscfg.h index f60846de7..2549b4d44 100644 --- a/porting/examples/linux/include/syscfg/syscfg.h +++ b/porting/examples/linux/include/syscfg/syscfg.h @@ -659,6 +659,10 @@ #define MYNEWT_VAL_BLE_GATT_WRITE_RELIABLE (MYNEWT_VAL_BLE_ROLE_CENTRAL) #endif +#ifndef MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER +#define MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER (0) +#endif + #ifndef MYNEWT_VAL_BLE_HOST #define MYNEWT_VAL_BLE_HOST (1) #endif diff --git a/porting/examples/linux_blemesh/include/syscfg/syscfg.h b/porting/examples/linux_blemesh/include/syscfg/syscfg.h index 3af3ecc09..57615d4b6 100644 --- a/porting/examples/linux_blemesh/include/syscfg/syscfg.h +++ b/porting/examples/linux_blemesh/include/syscfg/syscfg.h @@ -660,6 +660,10 @@ #define MYNEWT_VAL_BLE_GATT_WRITE_RELIABLE (MYNEWT_VAL_BLE_ROLE_CENTRAL) #endif +#ifndef MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER +#define MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER (0) +#endif + #ifndef MYNEWT_VAL_BLE_HOST #define MYNEWT_VAL_BLE_HOST (1) #endif diff --git a/porting/examples/nuttx/include/syscfg/syscfg.h b/porting/examples/nuttx/include/syscfg/syscfg.h index 6035f7966..1506b735b 100644 --- a/porting/examples/nuttx/include/syscfg/syscfg.h +++ b/porting/examples/nuttx/include/syscfg/syscfg.h @@ -659,6 +659,10 @@ #define MYNEWT_VAL_BLE_GATT_WRITE_RELIABLE (MYNEWT_VAL_BLE_ROLE_CENTRAL) #endif +#ifndef MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER +#define MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER (0) +#endif + #ifndef MYNEWT_VAL_BLE_HOST #define MYNEWT_VAL_BLE_HOST (1) #endif diff --git a/porting/nimble/include/syscfg/syscfg.h b/porting/nimble/include/syscfg/syscfg.h index 54506184d..880a244f1 100644 --- a/porting/nimble/include/syscfg/syscfg.h +++ b/porting/nimble/include/syscfg/syscfg.h @@ -662,6 +662,10 @@ #define MYNEWT_VAL_BLE_GATT_WRITE_RELIABLE (MYNEWT_VAL_BLE_ROLE_CENTRAL) #endif +#ifndef MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER +#define MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER (0) +#endif + #ifndef MYNEWT_VAL_BLE_HOST #define MYNEWT_VAL_BLE_HOST (1) #endif diff --git a/porting/npl/riot/include/syscfg/syscfg.h b/porting/npl/riot/include/syscfg/syscfg.h index 75752c027..7877f801c 100644 --- a/porting/npl/riot/include/syscfg/syscfg.h +++ b/porting/npl/riot/include/syscfg/syscfg.h @@ -883,6 +883,14 @@ #define MYNEWT_VAL_BLE_WHITELIST (1) #endif +#ifndef MYNEWT_VAL_BLE_POWER_CONTROL +#define MYNEWT_VAL_BLE_POWER_CONTROL (0) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER +#define MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER (0) +#endif + /*** @apache-mynewt-nimble/nimble/controller */ #ifndef MYNEWT_VAL_BLE_CONTROLLER #define MYNEWT_VAL_BLE_CONTROLLER (1)