@@ -78,6 +78,10 @@ impl RxRouterQueue {
78
78
///
79
79
/// It is expected, that frames like beacons and probe responses will be matched for this operation.
80
80
pub trait HasScanOperation : RxRouterOperation {
81
+ /// Does a scan like router operation exist.
82
+ ///
83
+ /// At the moment, the requirement for this is, that all beacon frames will be matched by
84
+ /// that operation.
81
85
const SCAN_OPERATION : Self ;
82
86
}
83
87
@@ -100,12 +104,15 @@ pub trait RxRouterOperation: Clone + Copy {
100
104
101
105
#[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
102
106
#[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
103
- /// Errors returned by the RX router.
104
- pub enum RxRouterError {
107
+ /// Errors related to router operations.
108
+ pub enum RxRouterOperationError {
109
+ /// Another router operation is already in progress for this queue.
110
+ ///
111
+ /// This does not mean, that the request operation is incompatible with that of the other
112
+ /// queue. [Self::IncompatibleOperations] indicates this instead.
105
113
OperationAlreadyInProgress ,
114
+ /// The requested operation is incompatible with the one on the other queue.
106
115
IncompatibleOperations ,
107
- QueueFull ,
108
- InvalidFrame ,
109
116
}
110
117
111
118
/// Used for dynamic dispatch.
@@ -114,7 +121,7 @@ trait Router<'foa, Operation: RxRouterOperation> {
114
121
fn receive ( & self , router_queue : RxRouterQueue )
115
122
-> DynamicReceiveFuture < ' _ , ReceivedFrame < ' foa > > ;
116
123
//// Route a frame to a specific queue.
117
- fn route_frame ( & self , frame : ReceivedFrame < ' foa > ) -> Result < ( ) , RxRouterError > ;
124
+ fn route_frame ( & self , frame : ReceivedFrame < ' foa > ) -> Result < ( ) , RxRouterRoutingError > ;
118
125
/// Get the operation state for the specified [RxRouterQueue].
119
126
fn operation_state ( & self , router_queue : RxRouterQueue ) -> & Cell < Option < Operation > > ;
120
127
/// Get the operation completion signal.
@@ -148,6 +155,15 @@ impl<const QUEUE_DEPTH: usize, O: RxRouterOperation> QueueState<'_, QUEUE_DEPTH,
148
155
self . operation_state . get ( ) . is_some ( )
149
156
}
150
157
}
158
+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
159
+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
160
+ /// An error related to the routing of a received frame.
161
+ pub enum RxRouterRoutingError {
162
+ /// The queue, that the frame was supposed to be routed to, is full.
163
+ QueueFull ,
164
+ /// The frame could not parsed.
165
+ InvalidFrame ,
166
+ }
151
167
152
168
/// The core of the RX router.
153
169
///
@@ -215,11 +231,11 @@ impl<'foa, const QUEUE_DEPTH: usize, Operation: RxRouterOperation> Router<'foa,
215
231
) -> DynamicReceiveFuture < ' _ , ReceivedFrame < ' foa > > {
216
232
self . queue_state ( router_queue) . queue . receive ( ) . into ( )
217
233
}
218
- fn route_frame ( & self , frame : ReceivedFrame < ' foa > ) -> Result < ( ) , RxRouterError > {
234
+ fn route_frame ( & self , frame : ReceivedFrame < ' foa > ) -> Result < ( ) , RxRouterRoutingError > {
219
235
// Usually the RX handler will have already created a GenericFrame, however we can't
220
236
// reasonably assume that, so we recreate it here and hope the compiler opimizes away.
221
237
let Ok ( generic_frame) = GenericFrame :: new ( frame. mpdu_buffer ( ) , false ) else {
222
- return Err ( RxRouterError :: InvalidFrame ) ;
238
+ return Err ( RxRouterRoutingError :: InvalidFrame ) ;
223
239
} ;
224
240
let router_queue = if self
225
241
. foreground_queue_state
@@ -239,7 +255,7 @@ impl<'foa, const QUEUE_DEPTH: usize, Operation: RxRouterOperation> Router<'foa,
239
255
if self . queue_state ( router_queue) . queue . try_send ( frame) . is_ok ( ) {
240
256
Ok ( ( ) )
241
257
} else {
242
- Err ( RxRouterError :: QueueFull )
258
+ Err ( RxRouterRoutingError :: QueueFull )
243
259
}
244
260
}
245
261
fn operation_state ( & self , router_queue : RxRouterQueue ) -> & Cell < Option < Operation > > {
@@ -264,14 +280,17 @@ pub struct RxRouterInput<'foa, 'router, Operation: RxRouterOperation> {
264
280
265
281
impl < ' foa , Operation : RxRouterOperation > RxRouterInput < ' foa , ' _ , Operation > {
266
282
/// Route the provided frame to the correct queue.
267
- pub fn route_frame ( & self , frame : ReceivedFrame < ' foa > ) -> Result < ( ) , RxRouterError > {
283
+ pub fn route_frame ( & self , frame : ReceivedFrame < ' foa > ) -> Result < ( ) , RxRouterRoutingError > {
268
284
self . rx_router . route_frame ( frame)
269
285
}
286
+ /// Get the currently active operation for the specified [RxRouterQueue].
270
287
pub fn operation ( & self , router_queue : RxRouterQueue ) -> Option < Operation > {
271
288
self . rx_router . operation_state ( router_queue) . get ( )
272
289
}
273
290
}
274
291
#[ derive( Clone , Copy , Debug , Default , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
292
+ /// The requested operation transition is not possible, due to it being incompatible with another
293
+ /// currently active operation.
275
294
pub struct TransitionNotPossibleError ;
276
295
/// A scoped router operation.
277
296
///
@@ -329,16 +348,16 @@ impl<'foa, 'router, Operation: RxRouterOperation> RxRouterEndpoint<'foa, 'router
329
348
self . rx_router . receive ( self . router_queue )
330
349
}
331
350
/// Check if the operation can be started.
332
- fn can_start_operation ( & self , operation : Operation ) -> Result < ( ) , RxRouterError > {
351
+ fn can_start_operation ( & self , operation : Operation ) -> Result < ( ) , RxRouterOperationError > {
333
352
if let Some ( opposing_operation) = self
334
353
. rx_router
335
354
. operation_state ( self . router_queue . opposite ( ) )
336
355
. get ( )
337
356
{
338
357
if !Operation :: CONCORRUENT_OPERATIONS_SUPPORTED {
339
- Err ( RxRouterError :: OperationAlreadyInProgress )
358
+ Err ( RxRouterOperationError :: OperationAlreadyInProgress )
340
359
} else if !opposing_operation. compatible_with ( & operation) {
341
- Err ( RxRouterError :: IncompatibleOperations )
360
+ Err ( RxRouterOperationError :: IncompatibleOperations )
342
361
} else {
343
362
Ok ( ( ) )
344
363
}
@@ -370,7 +389,7 @@ impl<'foa, 'router, Operation: RxRouterOperation> RxRouterEndpoint<'foa, 'router
370
389
pub fn try_start_operation < ' endpoint > (
371
390
& ' endpoint mut self ,
372
391
operation : Operation ,
373
- ) -> Result < RxRouterScopedOperation < ' foa , ' router , ' endpoint , Operation > , RxRouterError > {
392
+ ) -> Result < RxRouterScopedOperation < ' foa , ' router , ' endpoint , Operation > , RxRouterOperationError > {
374
393
self . can_start_operation ( operation) ?;
375
394
self . start_operation_internal ( operation) ;
376
395
Ok ( RxRouterScopedOperation { endpoint : self } )
0 commit comments