Bluetooth: OTS: Unify object name size for client and server
Use Kconfig value for object name size also for client. Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit is contained in:
parent
7fabcb3124
commit
68745d87d5
3 changed files with 11 additions and 10 deletions
|
@ -45,8 +45,6 @@ struct bt_date_time {
|
|||
uint8_t seconds;
|
||||
};
|
||||
|
||||
#define BT_OTS_NAME_MAX_SIZE 120
|
||||
|
||||
#define BT_OTC_METADATA_REQ_NAME BIT(0)
|
||||
#define BT_OTC_METADATA_REQ_TYPE BIT(1)
|
||||
#define BT_OTC_METADATA_REQ_SIZE BIT(2)
|
||||
|
@ -91,7 +89,7 @@ struct bt_date_time {
|
|||
|
||||
/**@brief Metadata of an OTS Object */
|
||||
struct bt_otc_obj_metadata {
|
||||
char name[BT_OTS_NAME_MAX_SIZE + 1];
|
||||
char name[CONFIG_BT_OTS_OBJ_MAX_NAME_LEN + 1];
|
||||
struct bt_ots_obj_type type_uuid;
|
||||
uint32_t current_size;
|
||||
uint32_t alloc_size;
|
||||
|
|
|
@ -59,11 +59,6 @@ config BT_OTS_OLCP_GO_TO_SUPPORT
|
|||
bool "Support OLCP Go To Operation"
|
||||
default y
|
||||
|
||||
config BT_OTS_OBJ_MAX_NAME_LEN
|
||||
int "Maximum object name length"
|
||||
default 120
|
||||
range 1 120
|
||||
|
||||
config BT_OTS_OBJ_NAME_WRITE_SUPPORT
|
||||
bool "Support object name write"
|
||||
|
||||
|
@ -114,6 +109,14 @@ config BT_OTS_L2CAP_CHAN_RX_MTU
|
|||
default BT_BUF_ACL_RX_SIZE
|
||||
range 21 BT_BUF_ACL_RX_SIZE
|
||||
|
||||
config BT_OTS_OBJ_MAX_NAME_LEN
|
||||
int "Maximum object name length"
|
||||
# Max name length allowed by OTS spec is 120 octets
|
||||
# TODO: Set separate max name length for client, as other
|
||||
# servers may use the full 120 octets.
|
||||
default 120
|
||||
range 1 120
|
||||
|
||||
module = BT_OTS
|
||||
module-str = BT_OTS
|
||||
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"
|
||||
|
|
|
@ -852,12 +852,12 @@ static uint8_t read_obj_name_cb(struct bt_conn *conn, uint8_t err,
|
|||
}
|
||||
|
||||
if (data) {
|
||||
if (length <= BT_OTS_NAME_MAX_SIZE) {
|
||||
if (length <= CONFIG_BT_OTS_OBJ_MAX_NAME_LEN) {
|
||||
memcpy(inst->otc_inst->cur_object.name, data, length);
|
||||
inst->otc_inst->cur_object.name[length] = '\0';
|
||||
} else {
|
||||
BT_WARN("Invalid length %u (expected max %u)",
|
||||
length, BT_OTS_NAME_MAX_SIZE);
|
||||
length, CONFIG_BT_OTS_OBJ_MAX_NAME_LEN);
|
||||
err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue