nRF5 IoT SDK
v0.9.0
|
Our file abstract library provides a unified definition of calls for accessing any object, which can be treated as a file.
Applications can use this library as a common API for read and write operations. Currently there are two file ports defined:
The generic API is shown below:
API | Description |
---|---|
iot_file_fopen | Open the file instance with given size. |
iot_file_fread | Read given number of bytes from the file |
iot_file_fwrite | Write given number of bytes to the file. |
iot_file_fseek | Move file's cursor to given position. |
iot_file_ftell | Read actual cursor position. |
iot_file_frewind | Set file cursor position to the beginning of the file. |
iot_file_fclose | Close file, reset cursor. |
Creating a new file port consists of a few steps:
In order to use the IoT File Static port, you need to include two files. One which includes the instance definition and API (file abstract) and another which defines the selected file type.
The second step is to define and initialize the file instance and components needed by that file type (like static buffer).
The file API can now be used for accessing the assigned buffer.
The flash memory access file port shows how to use the file abstract for memory that requires an asynchronous API. In order to support that, the file abstract defines the event structure (iot_file_evt_t) where the file port assigns a user callback that is passed during initialization of the specified file instance. Currently the IoT SDK supports the PStorage RAW port of file abstraction, presented below.
Initialization:
The callback can be defined to create a chain of operations (like fopen-fread-fclose), to notify the application when data is ready, or to unlock another procedure. In the following example the static variable m_lock is used to wait for completion.
The following configuration parameters should be defined in sdk_config.h
.
Disables debug tracing in the module. To enable tracing, this flag must be set to 0 and ENABLE_DEBUG_LOG_SUPPORT must be set to 1.
Description | Value |
---|---|
Enable debug trace | 0 |
Disable debug trace | 1 |
Dependencies | ENABLE_DEBUG_LOG_SUPPORT |
Disables API parameter checks in the module. Set this define to 1 to disable checks on API parameters in the module.
API parameter checks are added to ensure that the correct parameters are passed to the module. These checks are useful during development phase, but they might be redundant when the application is finalized. Disabling these checks might improve performance.
Description | Value |
---|---|
Enable API parameters check | 0 |
Disable API parameters check | 1 |
Dependencies | None |
The following sections describe the specifics and limitations of the current implementation.