send mtu on init

This commit is contained in:
Shuanglei Tao
2025-06-27 18:28:22 +08:00
parent 59a63de6ac
commit 3ddeaeba47
2 changed files with 13 additions and 1 deletions

View File

@@ -94,6 +94,13 @@ static void epd_send_time(ble_epd_t * p_epd)
ble_epd_string_send(p_epd, (uint8_t *)buf, strlen(buf));
}
static void epd_send_mtu(ble_epd_t * p_epd)
{
char buf[10] = {0};
snprintf(buf, sizeof(buf), "mtu=%d", p_epd->max_data_len);
ble_epd_string_send(p_epd, (uint8_t *)buf, strlen(buf));
}
static void epd_service_on_write(ble_epd_t * p_epd, uint8_t * p_data, uint16_t length)
{
NRF_LOG_DEBUG("[EPD]: on_write LEN=%d\n", length);
@@ -128,6 +135,7 @@ static void epd_service_on_write(ble_epd_t * p_epd, uint8_t * p_data, uint16_t l
epd_config_write(&p_epd->config);
}
p_epd->epd = epd_init((epd_model_id_t)id);
epd_send_mtu(p_epd);
epd_send_time(p_epd);
} break;

View File

@@ -314,7 +314,11 @@ function handleNotify(value, idx) {
if (textDecoder == null) textDecoder = new TextDecoder();
const msg = textDecoder.decode(data);
addLog(msg, '⇓');
if (msg.startsWith('t=') && msg.length > 2) {
if (msg.startsWith('mtu=') && msg.length > 4) {
const mtuSize = parseInt(msg.substring(4));
document.getElementById('mtusize').value = mtuSize;
addLog(`MTU 已更新为: ${mtuSize}`);
} else if (msg.startsWith('t=') && msg.length > 2) {
const t = parseInt(msg.substring(2)) + new Date().getTimezoneOffset() * 60;
addLog(`远端时间: ${new Date(t * 1000).toLocaleString()}`);
addLog(`本地时间: ${new Date().toLocaleString()}`);