Refactor Models for InfluxDB (#1)
Update to InfluxDB 2.0 and update all interfaces to work with it. MAC has been deprecated, since current `influxdb2` doesn't support non built-in types for read/write into the DB. Co-authored-by: Felipe Diniello <felipediniello@pm.me> Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
@@ -4,10 +4,7 @@ use std::{thread, time};
|
||||
mod error_report;
|
||||
|
||||
use kairo_common::helper::for_sync::{get_mqtt_cli, mqtt_pub};
|
||||
use kairo_common::{
|
||||
influxdb_models::{BeaconMeasure, KnownPosition},
|
||||
Antenna, DeviceReport, Point,
|
||||
};
|
||||
use kairo_common::{Antenna, BeaconMeasure, DeviceReport, Point};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Config {
|
||||
@@ -25,12 +22,12 @@ async fn main() {
|
||||
let period = time::Duration::from_millis(config.period_ms);
|
||||
let noise_gen = Normal::new(0.0, config.noise_level).unwrap();
|
||||
|
||||
if config.real {
|
||||
let config = config.clone();
|
||||
tokio::spawn(async move {
|
||||
error_report::thread(config).await;
|
||||
});
|
||||
}
|
||||
// if config.real {
|
||||
// let config = config.clone();
|
||||
// tokio::spawn(async move {
|
||||
// error_report::thread(config).await;
|
||||
// });
|
||||
// }
|
||||
|
||||
let client = get_mqtt_cli();
|
||||
|
||||
@@ -55,14 +52,16 @@ async fn main() {
|
||||
|
||||
let noise: f64 = noise_gen.sample(&mut rand::thread_rng());
|
||||
|
||||
report.data.push(BeaconMeasure::new(&ant.id, rssi + noise));
|
||||
report
|
||||
.data
|
||||
.push(BeaconMeasure::new(&config.id, &ant.id, rssi + noise));
|
||||
}
|
||||
let payload = serde_json::to_string(&report).unwrap_or_else(|_| "".to_string());
|
||||
mqtt_pub(&client, topic.as_str(), payload.as_str()).expect("Pub error");
|
||||
|
||||
if config.real {
|
||||
let _r = KnownPosition::new(position).write_for("real").await;
|
||||
}
|
||||
// if config.real {
|
||||
// let _r = KnownPosition::new(position).write_for("real").await;
|
||||
// }
|
||||
|
||||
position.rotate_by(f64::to_radians(config.angle_step));
|
||||
thread::sleep(period - start.elapsed());
|
||||
|
||||
Reference in New Issue
Block a user