Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to get serial from state message or from state message params #88

Merged
merged 1 commit into from
Oct 2, 2024
Merged
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
33 changes: 23 additions & 10 deletions src/cgw_ucentral_ap_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,17 @@ fn parse_state_event_data(
}
};

let serial = MacAddress::from_str(
state_map["serial"]
.as_str()
.ok_or_else(|| Error::UCentralParser("Failed to parse mac address"))?,
)?;
let serial = {
if let Value::String(mac) = &params["serial"] {
MacAddress::from_str(mac)?
} else if let Value::String(mac) = &state_map["serial"] {
MacAddress::from_str(mac)?
} else {
return Err(Error::UCentralParser(
"Failed to parse state: mac address is missing",
));
}
};

if let Value::Object(state_map) = &state_map["state"] {
let mut lldp_links: HashMap<
Expand Down Expand Up @@ -448,11 +454,18 @@ fn parse_state_event_data(
"Parsed, decompressed state message but failed to find state object",
));
} else if let Value::Object(state_map) = &params["state"] {
let serial = MacAddress::from_str(
params["serial"]
.as_str()
.ok_or_else(|| Error::UCentralParser("Failed to parse mac address"))?,
)?;
let serial = {
if let Value::String(mac) = &params["serial"] {
MacAddress::from_str(mac)?
} else if let Value::String(mac) = &state_map["serial"] {
MacAddress::from_str(mac)?
} else {
return Err(Error::UCentralParser(
"Failed to parse state: mac address is missing",
));
}
};

let mut lldp_links: HashMap<CGWUCentralEventStatePort, Vec<CGWUCentralEventStateLinks>> =
HashMap::new();
let mut clients_links: HashMap<
Expand Down