-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feat/topo map enhancements #77
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -71,6 +71,7 @@ pub struct CGWConnectionProcessor { | |
pub idx: i64, | ||
pub group_id: i32, | ||
pub feature_topomap_enabled: bool, | ||
pub device_type: CGWDeviceType, | ||
} | ||
|
||
impl CGWConnectionProcessor { | ||
|
@@ -82,6 +83,8 @@ impl CGWConnectionProcessor { | |
idx: conn_idx, | ||
group_id: 0, | ||
feature_topomap_enabled: server.feature_topomap_enabled, | ||
// Default to AP, it's safe, as later-on it will be changed | ||
device_type: CGWDeviceType::CGWDeviceAP, | ||
}; | ||
|
||
conn_processor | ||
|
@@ -187,7 +190,8 @@ impl CGWConnectionProcessor { | |
} | ||
|
||
self.serial = evt.serial; | ||
let device_type = CGWDeviceType::from_str(caps.platform.as_str())?; | ||
|
||
self.device_type = CGWDeviceType::from_str(caps.platform.as_str())?; | ||
|
||
// TODO: we accepted tls stream and split the WS into RX TX part, | ||
// now we have to ASK cgw_connection_server's permission whether | ||
|
@@ -253,16 +257,14 @@ impl CGWConnectionProcessor { | |
} | ||
} | ||
|
||
self.process_connection(stream, sink, mbox_rx, device_type) | ||
.await; | ||
self.process_connection(stream, sink, mbox_rx).await; | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn process_wss_rx_msg( | ||
&self, | ||
msg: std::result::Result<Message, tungstenite::error::Error>, | ||
device_type: CGWDeviceType, | ||
fsm_state: &mut CGWUCentralMessageProcessorState, | ||
pending_req_id: u64, | ||
) -> Result<CGWConnectionState> { | ||
|
@@ -278,20 +280,31 @@ impl CGWConnectionProcessor { | |
} | ||
Text(payload) => { | ||
if let Ok(evt) = cgw_ucentral_event_parse( | ||
&device_type, | ||
&self.device_type, | ||
self.feature_topomap_enabled, | ||
&payload, | ||
timestamp.timestamp(), | ||
) { | ||
kafaka_msg = payload.clone(); | ||
kafaka_msg.clone_from(&payload); | ||
if let CGWUCentralEventType::State(_) = evt.evt_type { | ||
if let Some(decompressed) = evt.decompressed.clone() { | ||
kafaka_msg = decompressed; | ||
} | ||
if self.feature_topomap_enabled { | ||
let topo_map = CGWUCentralTopologyMap::get_ref(); | ||
topo_map.process_state_message(&device_type, evt).await; | ||
topo_map.debug_dump_map().await; | ||
|
||
// TODO: remove this Arc clone: | ||
// Dirty hack for now: pass Arc ref of srv to topo map; | ||
// Future rework and refactoring would require to separate | ||
// NB api from being an internal obj of conn_server to be a | ||
// standalone (singleton?) object. | ||
topo_map.enqueue_event( | ||
evt, | ||
self.device_type, | ||
self.serial, | ||
self.group_id, | ||
self.cgw_server.clone(), | ||
); | ||
} | ||
} else if let CGWUCentralEventType::Reply(content) = evt.evt_type { | ||
if *fsm_state != CGWUCentralMessageProcessorState::ResultPending { | ||
|
@@ -313,10 +326,18 @@ impl CGWConnectionProcessor { | |
} else if let CGWUCentralEventType::RealtimeEvent(_) = evt.evt_type { | ||
if self.feature_topomap_enabled { | ||
let topo_map = CGWUCentralTopologyMap::get_ref(); | ||
topo_map | ||
.process_device_topology_event(&device_type, evt) | ||
.await; | ||
topo_map.debug_dump_map().await; | ||
// TODO: remove this Arc clone: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
// Dirty hack for now: pass Arc ref of srv to topo map; | ||
// Future rework and refactoring would require to separate | ||
// NB api from being an internal obj of conn_server to be a | ||
// standalone (singleton?) object. | ||
topo_map.enqueue_event( | ||
evt, | ||
self.device_type, | ||
self.serial, | ||
self.group_id, | ||
self.cgw_server.clone(), | ||
); | ||
} | ||
} | ||
} | ||
|
@@ -403,7 +424,6 @@ impl CGWConnectionProcessor { | |
mut stream: SStream, | ||
mut sink: SSink, | ||
mut mbox_rx: UnboundedReceiver<CGWConnectionProcessorReqMsg>, | ||
device_type: CGWDeviceType, | ||
) { | ||
#[derive(Debug)] | ||
enum WakeupReason { | ||
|
@@ -554,7 +574,7 @@ impl CGWConnectionProcessor { | |
let rc = match wakeup_reason { | ||
WakeupReason::WSSRxMsg(res) => { | ||
last_contact = Instant::now(); | ||
self.process_wss_rx_msg(res, device_type, &mut fsm_state, pending_req_id) | ||
self.process_wss_rx_msg(res, &mut fsm_state, pending_req_id) | ||
.await | ||
} | ||
WakeupReason::MboxRx(mbox_message) => { | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still relevant or should be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. it states that #306 should be removed, and some other way of accessing NB API should be made further on;
Currently, a copy of Arc is being passed around and copied, and we potentially have to come up with a new approach;