增加收到USB设置的定时配置之后通过BLE发送一次出去
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
* - V1.1.1, 2026.07.30, cyWu, 修复设置后立即发送导致栈溢出复位
|
||||
* - V1.2.0, 2026.07.30, cyWu, USB 连接时暂停定时发送
|
||||
* - V1.2.1, 2026.07.30, cyWu, 改为 COM(DTR) 开闭控制暂停/恢复
|
||||
* - V1.2.2, 2026.08.01, cyWu, 设置后立即验发不受 COM 暂停限制
|
||||
*
|
||||
* USB 设置帧 payload(CMD=0x70)格式:
|
||||
* [0] slot 槽位 0~9
|
||||
@@ -362,14 +363,26 @@ static void dengle_send_bytes(const DengleSlot_t *slot)
|
||||
}
|
||||
}
|
||||
|
||||
static void dengle_send_slot(const DengleSlot_t *slot)
|
||||
/**
|
||||
* @brief 发送指定槽位
|
||||
* @param slot 槽位
|
||||
* @param ignore_pause 1=配置验发,忽略 COM 暂停;0=周期发送,COM 开则跳过
|
||||
*/
|
||||
static void dengle_send_slot(const DengleSlot_t *slot, uint8_t ignore_pause)
|
||||
{
|
||||
if (!slot || !slot->enable || slot->data_n == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* USB 连着电脑时不发,避免配置阶段干扰 */
|
||||
if (dengle_is_usb_pause()) {
|
||||
/* 周期发送:COM 打开时暂停;设置后验发不受此限制 */
|
||||
if (!ignore_pause && dengle_is_usb_pause()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (usr_get_conn_service() == 0) {
|
||||
if (ignore_pause) {
|
||||
printf("dengle verify skip: BLE not connected\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -381,7 +394,8 @@ static void dengle_send_slot(const DengleSlot_t *slot)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 延时立即发送:与 USB 解析/ACK 错开,降低栈峰值
|
||||
* @brief 延时立即验发:与 USB 解析/ACK 错开,降低栈峰值
|
||||
* @note 即使 COM 打开也发一次,方便设置时确认 BLE 是否收到
|
||||
*/
|
||||
static void dengle_imm_send_timeout(void *priv)
|
||||
{
|
||||
@@ -389,7 +403,8 @@ static void dengle_imm_send_timeout(void *priv)
|
||||
|
||||
s_imm_send_timer = 0;
|
||||
if (slot_id < DENGLE_SLOT_MAX) {
|
||||
dengle_send_slot(&s_slots[slot_id]);
|
||||
printf("dengle imm verify send slot=%u\n", slot_id);
|
||||
dengle_send_slot(&s_slots[slot_id], 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +456,7 @@ static void dengle_tick(void *priv)
|
||||
slot->elapsed_ms += DENGLE_TICK_MS;
|
||||
if (slot->elapsed_ms >= slot->period_ms) {
|
||||
slot->elapsed_ms = 0;
|
||||
dengle_send_slot(slot);
|
||||
dengle_send_slot(slot, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user