mirror of
https://github.com/jam422470459/EPD-nRF52-hema213.git
synced 2025-12-06 08:32:54 +08:00
send mtu on init
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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()}`);
|
||||
|
||||
Reference in New Issue
Block a user