Add callback for CPX app messages #1279
Merged
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.
Dear Bitcraze:
In the PR #1273, my collaborator @RavenLite commit a PR about fixing the CPX_F_APP in CPX protocol. Now this work will be carried forward by me.
In this PR, we fix three main problems:
We add a case about putting CPX_F_APP message into mixedQueue in cpx_internal_router.c to make sure that the CF can receive message with type CPX_F_APP.
We add a handle in main code cpx.c. As @krichardsson said last time:"You need to add a function pointer and a function where an app can register a handler function for the pointer."But we believe that, as the name of this message category(CPX_F_APP) suggests, processing this message should be done in a user-defined app. So we added only an alert for the received message.
We add a deepcopy function to carry the CPXpacket from cpxRx to user-defined cpx packet. We do this because we can't directly use the function named cpxInternalRouterReceiveOthers() in the app-layer due to the repeat reception. So we believe that a deep copy function is needed. Users can copy the packets received by the system to their own app without causing conflicts.
Thank you for your reviewing.