-
Notifications
You must be signed in to change notification settings - Fork 164
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
update(): new implementation - frame type handling #15
Comments
Well, I guess it depends on exactly how far you are looking to extend the current functionality, and what ideas you have for additional frame types. One of the biggest challenges in extending the RF24Network library is ensuring compatibility with devices like Arduino and ATTiny85, since they can be used as routing nodes etc. so trying to keep memory usage and code size down in that regard is very important. I'm not entirely sure that completely breaking up the update() function would simplify things, since it is the starting point for almost every non-user initiated action, unless a large number of frame types is added etc. One thing that is bugging me about the current implementation, is that using fragmentation currently breaks the feature of user-defined header types, since it replaces that field with the fragmentation types. For example, if I define a header of type T, and add a large payload, my user defined type is replaced with the system fragmentation types. It doesn't really affect the RF24toTUN implementation, but is an important feature otherwise. I think this should be addressed prior to extending the current functionality, but haven't looked at a solution yet. |
I understand the problems with arduino, therefore my willing to start a discussion before taking action. In regard to the flags issue, you are right: that behavior is a bug in my eyes. It broke previous design without warning current users. A have two proposals:
I personally prefer the second option. If the user "above" the lib does not need to know much or change its code its a win situation. Although using this new schema means a maximal IP payload of 1500bytes. Anyways: jumbo frames should not be send across a NR24Network ^^ Does use someone the field header.next_id? The lib seems not to use this. |
Since a fragment_id and fragment type is sent, we can include and restore the user-defined header type with fragmented payloads by including it with the final fragment, since we know its expected fragment_id and that this should be the last expected fragment.
Haha, nice timing, I guess you were thinking about this issue too. After creating the error checking per your suggestions, I realized that the final payload can include the original header type, since we know we are expecting the final payload, we don't need the fragment_id, it can be inferred by the expected total_fragments count. *Also the next_id is not used, not sure about its origins. |
If we can restore the user type, we should do it. But we need to document this feature to not confuse other lib users/developers that it is not an error. |
Good call there, it would probably confuse me if I looked at it next week. I can see about adding some comments etc. to be pushed on the next commit. |
Notes: - May require updating the RF24 driver (radio.rxFifoFull()) - Continue buffering data if a Network Ack is received and there is data in the FIFO - Fragmented payload handling improvements - Repair and tested non-fragmented and fragmented data transfers with user-defined header types - Handling for data sent to self - Stop listening during fragmented data transfers, speeds up data rates (more to come) - Adjusted frag_delay. - Thanks to https://github.com/reixd and rRF24toTUN for making testing things a lot easier
Currently the update() function encapsulated the following activities:
I propose to split this function activities into functions to handle exclusively each action.
Additionally handling different frame types could be also splitted into different functions.
This measure could make the code easy to read and implementing different frame types would be easy: define new type, add type to switch-case, define new type handling function.
Would be this code changes a problem using arduino?
The text was updated successfully, but these errors were encountered: