diff --git a/EPD/EPD_service.c b/EPD/EPD_service.c index 2d89c5e..63a8992 100644 --- a/EPD/EPD_service.c +++ b/EPD/EPD_service.c @@ -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; diff --git a/html/js/main.js b/html/js/main.js index 035ce1d..b75381d 100644 --- a/html/js/main.js +++ b/html/js/main.js @@ -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()}`);