fix: Switch all advanced commands to binary protocol v2
Combo, Leader, KO create/delete all use send_binary() now: - COMBO_SET (0x60), COMBO_DELETE (0x62) - LEADER_SET (0x70), LEADER_DELETE (0x72) - KO_SET (0x91), KO_DELETE (0x93) Text protocol commands (COMBOSET, COMBODEL, etc.) were not working with the v2 firmware. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
362b0c729c
commit
d3ee9ef16f
1 changed files with 12 additions and 13 deletions
25
src/main.rs
25
src/main.rs
|
|
@ -910,10 +910,10 @@ fn main() {
|
||||||
window.global::<AdvancedBridge>().on_delete_combo(move |idx| {
|
window.global::<AdvancedBridge>().on_delete_combo(move |idx| {
|
||||||
let serial = serial.clone();
|
let serial = serial.clone();
|
||||||
let tx = tx.clone();
|
let tx = tx.clone();
|
||||||
let cmd = logic::protocol::cmd_combodel(idx as u8);
|
let payload = vec![idx as u8];
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
let _ = ser.send_command(&cmd);
|
let _ = ser.send_binary(logic::binary_protocol::cmd::COMBO_DELETE, &payload);
|
||||||
let lines = ser.query_command("COMBO?").unwrap_or_default();
|
let lines = ser.query_command("COMBO?").unwrap_or_default();
|
||||||
let _ = tx.send(BgMsg::TextLines("combo".into(), lines));
|
let _ = tx.send(BgMsg::TextLines("combo".into(), lines));
|
||||||
});
|
});
|
||||||
|
|
@ -928,10 +928,10 @@ fn main() {
|
||||||
window.global::<AdvancedBridge>().on_delete_leader(move |idx| {
|
window.global::<AdvancedBridge>().on_delete_leader(move |idx| {
|
||||||
let serial = serial.clone();
|
let serial = serial.clone();
|
||||||
let tx = tx.clone();
|
let tx = tx.clone();
|
||||||
let cmd = logic::protocol::cmd_leaderdel(idx as u8);
|
let payload = vec![idx as u8];
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
let _ = ser.send_command(&cmd);
|
let _ = ser.send_binary(logic::binary_protocol::cmd::LEADER_DELETE, &payload);
|
||||||
let lines = ser.query_command("LEADER?").unwrap_or_default();
|
let lines = ser.query_command("LEADER?").unwrap_or_default();
|
||||||
let _ = tx.send(BgMsg::TextLines("leader".into(), lines));
|
let _ = tx.send(BgMsg::TextLines("leader".into(), lines));
|
||||||
});
|
});
|
||||||
|
|
@ -946,10 +946,10 @@ fn main() {
|
||||||
window.global::<AdvancedBridge>().on_delete_ko(move |idx| {
|
window.global::<AdvancedBridge>().on_delete_ko(move |idx| {
|
||||||
let serial = serial.clone();
|
let serial = serial.clone();
|
||||||
let tx = tx.clone();
|
let tx = tx.clone();
|
||||||
let cmd = logic::protocol::cmd_kodel(idx as u8);
|
let payload = vec![idx as u8];
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
let _ = ser.send_command(&cmd);
|
let _ = ser.send_binary(logic::binary_protocol::cmd::KO_DELETE, &payload);
|
||||||
let lines = ser.query_command("KO?").unwrap_or_default();
|
let lines = ser.query_command("KO?").unwrap_or_default();
|
||||||
let _ = tx.send(BgMsg::TextLines("ko".into(), lines));
|
let _ = tx.send(BgMsg::TextLines("ko".into(), lines));
|
||||||
});
|
});
|
||||||
|
|
@ -1056,13 +1056,12 @@ fn main() {
|
||||||
w.global::<AppState>().set_status_text("Pick both keys first".into());
|
w.global::<AppState>().set_status_text("Pick both keys first".into());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let cmd = logic::protocol::cmd_comboset(255, r1, c1, r2, c2, result);
|
let payload = logic::binary_protocol::combo_set_payload(255, r1, c1, r2, c2, result);
|
||||||
eprintln!("COMBOSET: {}", cmd);
|
|
||||||
let serial = serial.clone();
|
let serial = serial.clone();
|
||||||
let tx = tx.clone();
|
let tx = tx.clone();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
let _ = ser.send_command(&cmd);
|
let _ = ser.send_binary(logic::binary_protocol::cmd::COMBO_SET, &payload);
|
||||||
let lines = ser.query_command("COMBO?").unwrap_or_default();
|
let lines = ser.query_command("COMBO?").unwrap_or_default();
|
||||||
let _ = tx.send(BgMsg::TextLines("combo".into(), lines));
|
let _ = tx.send(BgMsg::TextLines("combo".into(), lines));
|
||||||
});
|
});
|
||||||
|
|
@ -1081,12 +1080,12 @@ fn main() {
|
||||||
let trig_mod = mod_idx_to_byte(trig_mod_idx);
|
let trig_mod = mod_idx_to_byte(trig_mod_idx);
|
||||||
let result = result_code as u8;
|
let result = result_code as u8;
|
||||||
let res_mod = mod_idx_to_byte(res_mod_idx);
|
let res_mod = mod_idx_to_byte(res_mod_idx);
|
||||||
let cmd = logic::protocol::cmd_koset(255, trig, trig_mod, result, res_mod);
|
let payload = logic::binary_protocol::ko_set_payload(255, trig, trig_mod, result, res_mod);
|
||||||
let serial = serial.clone();
|
let serial = serial.clone();
|
||||||
let tx = tx.clone();
|
let tx = tx.clone();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
let _ = ser.send_command(&cmd);
|
let _ = ser.send_binary(logic::binary_protocol::cmd::KO_SET, &payload);
|
||||||
let lines = ser.query_command("KO?").unwrap_or_default();
|
let lines = ser.query_command("KO?").unwrap_or_default();
|
||||||
let _ = tx.send(BgMsg::TextLines("ko".into(), lines));
|
let _ = tx.send(BgMsg::TextLines("ko".into(), lines));
|
||||||
});
|
});
|
||||||
|
|
@ -1113,12 +1112,12 @@ fn main() {
|
||||||
if count > 3 { sequence.push(adv.get_new_leader_seq3_code() as u8); }
|
if count > 3 { sequence.push(adv.get_new_leader_seq3_code() as u8); }
|
||||||
let result = result_code as u8;
|
let result = result_code as u8;
|
||||||
let result_mod = mod_idx_to_byte(mod_idx);
|
let result_mod = mod_idx_to_byte(mod_idx);
|
||||||
let cmd = logic::protocol::cmd_leaderset(255, &sequence, result, result_mod);
|
let payload = logic::binary_protocol::leader_set_payload(255, &sequence, result, result_mod);
|
||||||
let serial = serial.clone();
|
let serial = serial.clone();
|
||||||
let tx = tx.clone();
|
let tx = tx.clone();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
let mut ser = serial.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
let _ = ser.send_command(&cmd);
|
let _ = ser.send_binary(logic::binary_protocol::cmd::LEADER_SET, &payload);
|
||||||
let lines = ser.query_command("LEADER?").unwrap_or_default();
|
let lines = ser.query_command("LEADER?").unwrap_or_default();
|
||||||
let _ = tx.send(BgMsg::TextLines("leader".into(), lines));
|
let _ = tx.send(BgMsg::TextLines("leader".into(), lines));
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue