Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions rust_osc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn print_toio_connected(toio_connected: i32){

fn return_toio_id(name: &str) -> &str{
//list of toio ids
const IDARR : [&str; 193] = [
const IDARR : [&str; 199] = [
"Individual ID", //TOIO Num
"0", // #1
"j1c", // #2
Expand Down Expand Up @@ -106,17 +106,17 @@ fn return_toio_id(name: &str) -> &str{
"0", // #59
"0", // #60
"0", // #61
"0", // #62
"0", // #63
"G42", // #62
"446", // #63
"0", // #64
"0", // #65
"0", // #66
"0", // #67
"0", // #68
"0", // #69
"0", // #70
"a8h", // #70
"0", // #71
"0", // #72
"", // #72
"0", // #73
"0", // #74
"0", // #75
Expand Down Expand Up @@ -156,7 +156,7 @@ fn return_toio_id(name: &str) -> &str{
"p50", // #109
"c9k", // #110
"N0N", // #111
"0", // #112
"79N", // #112
"B1m", // #113
"h7E", // #114
"c05", // #115
Expand Down Expand Up @@ -237,6 +237,12 @@ fn return_toio_id(name: &str) -> &str{
"p3E", // #190
"h6t", // #191
"n2L", // #192
"0", // #193
"0", // #194
"0", // #195
"0", // #196
"0", // #197
"0" // #198
];
match name.parse::<i32>() {
Ok(n) => {
Expand All @@ -249,6 +255,13 @@ fn return_toio_id(name: &str) -> &str{
}
}

fn toio_name_variants(id: &str) -> Vec<String> {
vec![
format!("toio Core Cube-{}", id), // old firmware
format!("toio-{}", id), // new firmware
]
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
env_logger::init();
Expand Down Expand Up @@ -310,7 +323,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
match matches.opt_str("a") {
Some(names) => {
for part in names.split(",") {
res.push(format!("toio Core Cube-{}", return_toio_id(part)));
//res.push(format!("toio Core Cube-{}", return_toio_id(part)));
res.extend(toio_name_variants(&return_toio_id(part)));
}
},
None => {}
Expand Down Expand Up @@ -504,9 +518,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
//we kave a toio cube!
let tx3 = tx.clone();
if !(peripheral.is_connected().await?) {
println!("Device Connected: {}", local_name);

toio_connected += 1;
print_toio_connected(toio_connected);
println!("Device Connected: {}", local_name);

// Connect if we aren't already connected.
if let Err(err) = peripheral.connect().await {
Expand Down