Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/examples/csifw_sample/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# For a description of the syntax of this configuration file,
# see kconfig-language at https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt
#

config EXAMPLES_CSIFW_SAMPLE
bool "CSIFW SAMPLE Application"
default n
depends on CSIFW
---help---
CSIFW SAMPLE Application
3 changes: 3 additions & 0 deletions apps/examples/csifw_sample/Kconfig_ENTRY
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config ENTRY_CSIFW_SAMPLE
bool "CSI Framework example"
depends on EXAMPLES_CSIFW_SAMPLE
4 changes: 4 additions & 0 deletions apps/examples/csifw_sample/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ifeq ($(CONFIG_EXAMPLES_CSIFW_SAMPLE),y)
CONFIGURED_APPS += examples/csifw_sample
endif

164 changes: 164 additions & 0 deletions apps/examples/csifw_sample/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
###########################################################################
#
# Copyright 2024 Samsung Electronics All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
#
###########################################################################
############################################################################
# apps/examples/csifw_sample/Makefile
#
# Copyright (C) 2009-2012 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <[email protected]>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs

CXXEXT ?= .cpp
# C++ Test Example

APPNAME = csifw_sample
FUNCNAME = $(APPNAME)_main
THREADEXEC = TASH_EXECMD_ASYNC

# C++ Test Example
MAINSRC = csifw_sample.c

AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))

SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
OBJS = $(AOBJS) $(COBJS)

ifneq ($(CONFIG_BUILD_KERNEL),y)
OBJS += $(MAINOBJ)
endif

ifeq ($(CONFIG_WINDOWS_NATIVE),y)
BIN = $(APPDIR)\libapps$(LIBEXT)
else
ifeq ($(WINTOOL),y)
BIN = $(APPDIR)\\libapps$(LIBEXT)
else
BIN = $(APPDIR)/libapps$(LIBEXT)
endif
endif

CONFIG_EXAMPLES_CSIFW_SAMPLE_PROGNAME ?= csifw_sample$(EXEEXT)
PROGNAME = $(CONFIG_EXAMPLES_CSIFW_SAMPLE_PROGNAME)

ROOTDEPPATH = --dep-path .

# Common build

VPATH =

all: .built
.PHONY: clean depend distclean

$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)

$(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)

$(CXXOBJS): %$(OBJEXT): %$(CXXEXT)
$(call COMPILEXX, $<, $@)

ifeq ($(suffix $(MAINSRC)),$(CXXEXT))
$(MAINOBJ): %$(OBJEXT): %$(CXXEXT)
$(call COMPILEXX, $<, $@)
else
$(MAINOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
endif

.built: $(OBJS)
$(call ARCHIVE, $(BIN), $(OBJS))
@touch .built

ifeq ($(CONFIG_BUILD_KERNEL),y)
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ)
@echo "LD: $(PROGNAME)"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS)
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME)

install: $(BIN_DIR)$(DELIM)$(PROGNAME)

else
install:

endif

ifeq ($(CONFIG_BUILTIN_APPS)$(CONFIG_EXAMPLES_CSIFW_SAMPLE),yy)
$(BUILTIN_REGISTRY)$(DELIM)$(FUNCNAME).bdat: $(DEPCONFIG) Makefile
$(Q) $(call REGISTER,$(APPNAME),$(FUNCNAME),$(THREADEXEC),$(PRIORITY),$(STACKSIZE))

context: $(BUILTIN_REGISTRY)$(DELIM)$(FUNCNAME).bdat

else
context:

endif

.depend: Makefile $(SRCS)
ifeq ($(filter %$(CXXEXT),$(SRCS)),)
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
else
@$(MKDEP) $(ROOTDEPPATH) "$(CXX)" -- $(CXXFLAGS) -- $(SRCS) >Make.dep
endif
@touch $@

depend: .depend

clean:
$(call DELFILE, .built)
$(call CLEAN)

distclean: clean
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)

-include Make.dep
.PHONY: preconfig
preconfig:
113 changes: 113 additions & 0 deletions apps/examples/csifw_sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# CSI Framework Sample Application

## Overview

The CSI (Channel State Information) Framework Sample Application demonstrates how to use the CSI framework to collect and process wireless channel state information. This application provides a simple interface to register callbacks for raw and/or parsed CSI data, configure collection parameters, and run the collection for a specified duration.

## Features

- Support for different CSI data callback types:
- Raw data only
- Parsed data only (To be implemented)
- Both raw and parsed data
- Configurable CSI collection parameters
- Simple command-line interface
- Error handling and validation
- Clean resource management

## Usage

### Command Syntax

```bash
csifw_sample <Configuration> <Interval> <App_run_duration> <Callback_type>
```

### Parameters

| Parameter | Description | Valid Range |
|-----------|-------------|-------------|
| Configuration | CSI configuration type | 0-5 (framework dependent) |
| Interval | Data collection interval in milliseconds | ≥30 ms |
| App_run_duration | Application run time in seconds | >0 |
| Callback_type | Type of data callbacks to register | 0=Raw only, 1=Parsed only, 2=Both |

### Examples

```bash
# Run with raw data callback only
csifw_sample 0 64 100 0

# Run with parsed data callback only
csifw_sample 1 100 60 1

# Run with both raw and parsed data callbacks
csifw_sample 2 50 120 2
```

## Application Flow

1. **Initialization**: Register service with specified callbacks
2. **Start**: Begin CSI data collection
3. **Run**: Collect data for specified duration
4. **Stop**: Stop CSI data collection
5. **Deinitialization**: Unregister service and clean up resources

## Code Structure

### Main Components

- `csifw_sample_app_main()`: Entry point and main control flow
- `initialize_csi_service()`: Service initialization with callback configuration
- `start_csi_collection()`: Start CSI data collection
- `stop_csi_collection()`: Stop CSI data collection
- `deinitialize_csi_service()`: Service deinitialization
- Callback functions:
- `raw_data_callback()`: Handles raw CSI data
- `parsed_data_callback()`: Handles parsed CSI data

### Key Improvements

1. **Reduced Code Duplication**: Single initialization function handles all callback types
2. **Enhanced Error Handling**: Comprehensive input validation and error checking
3. **Improved Readability**: Enumerations and descriptive variable names
4. **Better Documentation**: Doxygen-style comments for all functions
5. **Robust Resource Management**: Proper cleanup even in error cases

## API Reference

### Data Structures

```c
typedef enum {
CB_TYPE_RAW_ONLY = 0,
CB_TYPE_PARSED_ONLY = 1,
CB_TYPE_BOTH = 2
} callback_type_t;
```

### Functions

#### `csifw_sample_app_main()`

Main initialization function that orchestrates the entire application flow.

#### `initialize_csi_service()`

Initializes the CSI service with the specified callback configuration.

#### `start_csi_collection()`, `stop_csi_collection()`, `deinitialize_csi_service()`

Control functions for managing the CSI service lifecycle.

#### Callback Functions

- `raw_data_callback()`: Processes raw CSI data
- `parsed_data_callback()`: Processes parsed CSI data

## Configuration Notes

- Minimum supported interval is 30ms
- Run time must be positive
- Callback type must be 0, 1, or 2
- Configuration values depend on the underlying CSI framework implementation
Loading