-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
79 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![allow(dead_code)] | ||
#[macro_use] | ||
extern crate lazy_static; | ||
use crate::viewer::viewer; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
use ratatui::{ | ||
layout::Constraint, | ||
style::{Color, Modifier, Style}, | ||
style::{Modifier, Style}, | ||
widgets::{Block, Borders, Row, Table}, | ||
}; | ||
|
||
use crate::structs::DeviceInfo; | ||
use crate::structs::Characteristic; | ||
|
||
/// Provides an overlay with the selected device's service data. | ||
pub fn inspect_overlay(selected_device: &DeviceInfo) -> Table<'static> { | ||
// Iterate through the selected device's service_data to create rows | ||
let rows: Vec<Row> = selected_device | ||
.service_data | ||
pub fn inspect_overlay(characteristics: &Vec<Characteristic>) -> Table<'static> { | ||
// Iterate through the selected device's characteristics to create rows | ||
let rows: Vec<Row> = characteristics | ||
.iter() | ||
.map(|(uuid, data)| { | ||
let data_str = data | ||
.map(|characteristic| { | ||
let properties = format!("{:?}", characteristic.properties); | ||
let descriptors = characteristic | ||
.descriptors | ||
.iter() | ||
.map(|byte| format!("{:02x}", byte)) | ||
.map(|uuid| uuid.to_string()) | ||
.collect::<Vec<String>>() | ||
.join(" "); | ||
// Create a row for each UUID and its corresponding data | ||
Row::new(vec![uuid.to_string(), data_str]) | ||
.join(", "); | ||
Row::new(vec![ | ||
characteristic.uuid.to_string(), | ||
properties, | ||
descriptors, | ||
]) | ||
}) | ||
.collect(); | ||
|
||
let table = Table::new( | ||
rows, | ||
[Constraint::Percentage(50), Constraint::Percentage(50)], | ||
) | ||
.header(Row::new(vec!["UUID", "Data"]).style(Style::default().fg(Color::Yellow))) | ||
.block( | ||
Block::default() | ||
.borders(Borders::ALL) | ||
.title("Data Overview"), | ||
) | ||
.highlight_style(Style::default().add_modifier(Modifier::BOLD)); | ||
let table = Table::new(rows, [Constraint::Percentage(100)]) | ||
.block( | ||
Block::default() | ||
.borders(Borders::ALL) | ||
.title("Inspecting Device Characteristics"), | ||
) | ||
.highlight_style(Style::default().add_modifier(Modifier::BOLD)); | ||
|
||
table | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pub mod detail_table; | ||
pub mod device_table; | ||
pub mod info_table; | ||
pub mod inspect_overlay; | ||
pub mod inspect_overlay; |