cmd_handler: Add newline at the end of json sent

This commit is contained in:
linuswck 2024-03-25 12:27:35 +08:00
parent af68b0e90a
commit b1a1173075
1 changed files with 9 additions and 3 deletions

View File

@ -179,7 +179,9 @@ pub fn send_response(buffer: &mut [u8], msg_type: ResponseEnum, msg: MsgType, so
};
debug!("{:?}", response.json);
let num_bytes = response.get_json("/json", buffer).unwrap();
let mut num_bytes = response.get_json("/json", buffer).unwrap();
buffer[num_bytes] = b'\n';
num_bytes += 1;
net::eth_send(buffer, num_bytes, *socket);
}
@ -190,7 +192,9 @@ pub fn send_settings_summary(buffer: &mut [u8], laser: &mut LdDrive, thermostat:
thermostat: thermostat.get_settings_summary(),
}
};
let num_bytes = settings_summary.get_json("/json", buffer).unwrap();
let mut num_bytes = settings_summary.get_json("/json", buffer).unwrap();
buffer[num_bytes] = b'\n';
num_bytes += 1;
net::eth_send(buffer, num_bytes, *socket);
}
@ -203,7 +207,9 @@ pub fn send_status_report(buffer: &mut [u8], laser: &mut LdDrive, thermostat: &m
thermostat: thermostat.get_status_report(),
}
};
let num_bytes = status_report.get_json("/json", buffer).unwrap();
let mut num_bytes = status_report.get_json("/json", buffer).unwrap();
buffer[num_bytes] = b'\n';
num_bytes += 1;
net::eth_send(buffer, num_bytes, *socket);
}