4 posts / 0 new
Last post
libra_13179
Offline
Last seen:4 years 8 months ago
加入:2015-06-16 04:43
about Exchange MTU for sdk5

hi dialog,
1、 I can see it.The Attribute Protocol has a default maximum transmission unit (MTU) of 23 octets on a Bluetooth low energy link. If a device wants to send larger packets, it must negotiate a higher MTU size. Only the client can initiate this request. However, given that many devices have both client and server func tionality, this should not be a critical issue. The client request includes the client receiver’s MTU size; the server request includes the server receiver’s MTU size. These two values cannot not be the same value. The MTU size that a link uses can be calculated by taking the minimum of both the client Rx MTU and the server Rx MTU.
2、
@file app_sps_proj.c
@brief SPS project source code.

/**
****************************************************************************************
* @brief Sends a exchange MTU command
*
* @return void
****************************************************************************************
*/

void gattc_exc_mtu_cmd(void)
{
struct gattc_exc_mtu_cmd *cmd = KE_MSG_ALLOC(GATTC_EXC_MTU_CMD,
KE_BUILD_ID(TASK_GATTC,app_env.conidx ), TASK_APP,
gattc_exc_mtu_cmd);

cmd->req_type = GATTC_MTU_EXCH;

ke_msg_send(cmd);
}

#define APP_CFG_MAX_MTU 160
void app_configuration_func(ke_task_id_t const task_id, struct gapm_set_dev_config_cmd *cmd)
{
...
//Defined maximum transmission unit
cmd->max_mtu = APP_CFG_MAX_MTU;
}
3、How to realize the same function in sdk5。
I see.
1step
[add]
void gattc_exc_mtu_cmd(uint8_t connection_idx)
{
struct gattc_exc_mtu_cmd *cmd = KE_MSG_ALLOC(GATTC_EXC_MTU_CMD,
KE_BUILD_ID(TASK_GATTC, connection_idx), TASK_APP,
gattc_exc_mtu_cmd);

cmd->req_type = GATTC_MTU_EXCH;

ke_msg_send(cmd);
}
void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param)
{
default_app_on_connection(connection_idx, param);
gattc_exc_mtu_cmd(connection_idx);
}
2步
@file user_config.h
static const struct gapm_configuration user_gapm_conf={
.role = GAP_PERIPHERAL_SLV,
.irk={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
/// Device Appearance (0x0000 - Unknown appearance)
//Fill in according tohttps://developer.bluetooth.org/gatt/characteristics/Pages/Characteristi...
.appearance=0,
.appearance_write_perm = GAPM_WRITE_DISABLE,
.name_write_perm=GAPM_WRITE_DISABLE,
/// Maximal MTU
.max_mtu= 160,///////////////////////////////////////////modified
/// Peripheral only: *****************************************************************
/// Slave preferred Minimum of connection interval measured in ble double slots (1.25ms)
/// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
.con_intv_min = MS_TO_DOUBLESLOTS(10),
/// Slave preferred Maximum of connection interval measured in ble double slots (1.25ms)
/// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
.con_intv_max = MS_TO_DOUBLESLOTS(20),
/// Slave preferred Connection latency. It is measured in connection events skipped
.con_latency = 0,
/// Slave preferred Link supervision timeout measured in timer units (10 ms)
/// use the macro MS_TO_TIMERUNITS to convert from milliseconds (ms) to timer units
.superv_to = MS_TO_TIMERUNITS(1000),
/// Privacy settings bit field (0b1 = enabled, 0b0 = disabled)
/// - [bit 0]: Privacy Support
/// - [bit 1]: Multiple Bond Support (Peripheral only); If enabled, privacy flag is
/// read only.
/// - [bit 2]: Reconnection address visible.
.flags=0
};

Keywords:
Device:
MT_dialog
Offline
Last seen:2 months 4 weeks ago
工作人员
加入:2015-06-08 11:34
Hi libra_13179,

Hi libra_13179,

You can still use the gattc_exc_mtu_cmd function as is and change the .max_mtu member in the user_gapm_conf struct to the MTU size you want to use in the user_config.h file. Call thegattc_exc_mtu_cmd()function in user_app_connection and you should be ready to go.

Thanks MT_dialog

libra_13179
Offline
Last seen:4 years 8 months ago
加入:2015-06-16 04:43
hi MT_dialog

hi MT_dialog
Thanks for your reply.I try to modify .max_mtu=160 in the user_gapm_conf struct ,and Call the gattc_exc_mtu_cmd() function in user_app_connection and you should be ready to go.
i found the pack max size is 128 byte (MTU),If more than 128, send for several packages.I use a mobile phone app to DSPS.Why not a predetermined max_mtu ?
BY libra

MT_dialog
Offline
Last seen:2 months 4 weeks ago
工作人员
加入:2015-06-08 11:34
Hi libra_13179,

Hi libra_13179,

Sorry but i am not sure i undestand your question, you cant set your MTU over 128 bytes ?

Thanks MT_dialog