Open kb1lqd opened 7 years ago
I'm going to start with Layer 4 <-> Layer 4 service first.
Line
rf_rx_service_broadcast_rule_get()
Broadcast rule is a method for Faraday to determine if the packet should be accepted if it is not addressed to the specific Faraday (i.e. broadcasted). Unit specific data is determined at layer 2 (datalink) and therefore needs to be filtered to avoid commands from affecting ALL units in an area but allow all units to receive broadcasted telemetry.
Broadcast function argument is determined if the destination
callsign is CQCQCQ
.
For some reason I keep rf_rx_service_broadcast_rule_get()
in services and this is an array where the indexes are the "ports" and if the value is 1 then that port is allowed to accept "broadcasted" data.
This really should be done completely in layer 2.
Decouple the layer stacks by using function pointers that allow interactions between the stacks by pointing to a function rather than full import of the header. This will follow the higher levels of RF and UART stack interactions with applications themselves while allowing easier debugging.
This is a push to both clean, optimize, and potentially fix bugs such as corrupted telemetry data possibly getting sent to proxy.
Correct Method Example - Command Application
The command application "opens" a port from the RF receive stack which just places a function pointer to the command application PUT() function using a standardized FIFO interface. The pointer is stored in an array where the index is the "port".
To assign the command application through a function pointer the initialization in main{} is performed:
When a data packet at the transport layer level is received the RF network stack uses the assigned port to call the correct standardized PUT() function in the Command application:
Command Application interacts with RF receive through this PUT() function the is used through a function pointer.
It is important to realize that:
Incorrect Implementation
Note below that the includes for
"rf_transport.h"
(layer 4) directly imported"rf.h"
(layer 2) and this is unwanted and causing both headers to be coupled. This breaks the modular desirement and creates blurred interfaces between layers.RF Layer 2 (rf.c)
Calls To Layer 4 (rf_transport.h)
Lines
rf_transport_parse()
rf_transport_parse()
These references are in
rf_housekeeping()
and simply checking the transport FIFO for new data from Layer 4 to Layer 2.Layer 4 (rf_transport.c)
rf_transport.c
includes both layer 2 and rf service headers:rf.h
Line
rf_tx_datalink_packet()
rf_service.h
Line
rf_rx_service_broadcast_rule_get()
rf_rx_stack_rx()
rf_rx_stack_rx()
Layer 4 Services (rf_services.h)
This layer doesn't seem to have any of its own import issues but it is also a weird header to have.