Bluetooth: Classic: OBEX: Optimize MOPL configuration

Set the MOPL of RX and TX to `BT_OBEX_MIN_MTU` when registering OBEX
server.

Set the TX MOPL to `BT_OBEX_MIN_MTU` when sending OBEX connection
request.

Check if the MOPL of client exceeds MTU of transport when server
receives the connection request.

Check if the MOPL of server exceeds MTU of transport when client
receives the connection response.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
diff --git a/subsys/bluetooth/host/classic/obex.c b/subsys/bluetooth/host/classic/obex.c
index 4c63d0a..2f30cec 100644
--- a/subsys/bluetooth/host/classic/obex.c
+++ b/subsys/bluetooth/host/classic/obex.c
@@ -212,7 +212,13 @@
 	LOG_DBG("version %u, flags %u, mopl %u", version, flags, mopl);
 
 	if (mopl < BT_OBEX_MIN_MTU) {
-		LOG_WRN("Invalid MTU length (%d < %d)", mopl, BT_OBEX_MIN_MTU);
+		LOG_WRN("Invalid MOPL (%d < %d)", mopl, BT_OBEX_MIN_MTU);
+		rsp_code = BT_OBEX_RSP_CODE_PRECON_FAIL;
+		goto failed;
+	}
+
+	if (mopl > server->obex->tx.mtu) {
+		LOG_WRN("MOPL exceeds MTU (%d > %d)", mopl, server->obex->tx.mtu);
 		rsp_code = BT_OBEX_RSP_CODE_PRECON_FAIL;
 		goto failed;
 	}
@@ -949,9 +955,15 @@
 	}
 
 	if (mopl < BT_OBEX_MIN_MTU) {
-		LOG_WRN("Invalid MTU length (%d < %d)", mopl, BT_OBEX_MIN_MTU);
+		LOG_WRN("Invalid MOPL (%d < %d)", mopl, BT_OBEX_MIN_MTU);
 		goto failed;
 	}
+
+	if (mopl > client->obex->tx.mtu) {
+		LOG_WRN("MOPL exceeds MTU (%d > %d)", mopl, client->obex->tx.mtu);
+		goto failed;
+	}
+
 	client->tx.mopl = mopl;
 
 	atomic_set(&client->_state,
@@ -1374,9 +1386,9 @@
 		return -EINVAL;
 	}
 
-	server->rx.mopl = server->obex->rx.mtu;
+	server->rx.mopl = BT_OBEX_MIN_MTU;
 	/* Set MOPL of TX to MTU by default to avoid the OBEX connect rsp cannot be sent. */
-	server->tx.mopl = server->obex->tx.mtu;
+	server->tx.mopl = BT_OBEX_MIN_MTU;
 
 	server->uuid = uuid;
 
@@ -1485,7 +1497,7 @@
 
 	client->rx.mopl = mopl;
 	/* Set MOPL of TX to MTU by default to avoid the OBEX connect req cannot be sent. */
-	client->tx.mopl = client->obex->tx.mtu;
+	client->tx.mopl = BT_OBEX_MIN_MTU;
 	atomic_set(&client->_state, BT_OBEX_CONNECTING);
 
 	if (!sys_slist_find(&client->obex->_clients, &client->_node, NULL)) {