RDKB-62699: Add CSI interval parameter to JSON in consumer sample app#867
RDKB-62699: Add CSI interval parameter to JSON in consumer sample app#867narendradandu wants to merge 2 commits intordkcentral:developfrom
Conversation
Reason for change: Added support for the CSI interval parameter by including
it in the JSON used in the consumer sample app.
Test Procedure:
1) Load the OneWifi build.
2) Start the consumer sample app with the CSI interval parameter.
3) Capture packets while the app is running.
4) Stop the consumer sample app.
5) Verify that a JSON file (csi_samples.json) is generated containing the captured CSI data.
Risks: Low
Priority: P1
Signed-off-by: apatel599@cable.comcast.com
There was a problem hiding this comment.
Pull request overview
This pull request adds support for including the CSI (Channel State Information) sampling interval parameter in the JSON output generated by the consumer sample app. The change enables the JSON file to capture the configured sampling interval alongside the CSI data samples.
Changes:
- Added
get_csi_data_interval()helper function to retrieve the CSI interval from global variable or default value - Added
add_or_update_number()utility function to add or update numeric fields in cJSON objects - Modified
csi_data_in_json_format()to include thecsi_sampling_interval_msfield in the JSON output
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (item == NULL) { | ||
| cJSON_AddNumberToObject(obj, key, value); | ||
| } else { | ||
| item->valuedouble = value; |
There was a problem hiding this comment.
The add_or_update_number function directly modifies the valuedouble field of a cJSON item. While this works, it's safer to use the standard cJSON API pattern. Consider using cJSON_ReplaceItemInObject to replace the existing item with a new number object, which is the pattern consistently used throughout the codebase (see source/dml/tr_181/sbapi/cosa_wifi_apis.c:1664 and source/platform/common/data_model/wifi_dml_api.c:1815). Alternatively, if using a modern version of cJSON, use cJSON_SetNumberValue. Also note that when directly modifying valuedouble, you should also update valueint for consistency.
| item->valuedouble = value; | |
| #ifdef cJSON_SetNumberValue | |
| cJSON_SetNumberValue(item, value); | |
| #else | |
| cJSON *new_item = cJSON_CreateNumber(value); | |
| if (new_item != NULL) | |
| { | |
| cJSON_ReplaceItemInObject(obj, key, new_item); | |
| } | |
| #endif |
Reason for change: Added support for the CSI interval parameter by including
it in the JSON used in the consumer sample app.
Test Procedure:
Risks: Low
Priority: P1
Signed-off-by: apatel599@cable.comcast.com