nRF5 IoT SDK  v0.9.0
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
IoT file abstraction

Structures and public API definition. More...

Typedefs

typedef void(* iot_file_callback_t )(iot_file_t *p_file, iot_file_evt_t event, uint32_t result, void *p_data, uint32_t size)
 IoT File user callback type definition. More...
 

Enumerations

enum  iot_file_evt_t {
  IOT_FILE_OPENED,
  IOT_FILE_WRITE_COMPLETE,
  IOT_FILE_READ_COMPLETE,
  IOT_FILE_CLOSED,
  IOT_FILE_ERROR
}
 List of events returned in callback for file ports with asynchrounous operation like open, read, write and close. More...
 

Functions

uint32_t iot_file_fopen (iot_file_t *p_file, uint32_t requested_size)
 Function to open IoT file. Depending on port, it should allocate required buffer. More...
 
uint32_t iot_file_fwrite (iot_file_t *p_file, const void *p_data, uint32_t size)
 Function to write data buffer into a file. More...
 
uint32_t iot_file_fread (iot_file_t *p_file, void *p_data, uint32_t size)
 Function to read data buffer from file. More...
 
uint32_t iot_file_ftell (iot_file_t *p_file, uint32_t *p_cursor)
 Function to read current cursor position. More...
 
uint32_t iot_file_fseek (iot_file_t *p_file, uint32_t cursor)
 Function to set current cursor position. More...
 
uint32_t iot_file_frewind (iot_file_t *p_file)
 Function to rewind file cursor. More...
 
uint32_t iot_file_fclose (iot_file_t *p_file)
 Function to close IoT file. Depending on port, it should free used buffer. More...
 

Detailed Description

Structures and public API definition.

Typedef Documentation

typedef void(* iot_file_callback_t)(iot_file_t *p_file, iot_file_evt_t event, uint32_t result, void *p_data, uint32_t size)

IoT File user callback type definition.

Parameters
[in]p_fileReference to an IoT file instance.
[in]eventEvent structure describing what has happened.
[in]resultResult code (should be NRF_SUCCESS for all events except errors).
[in]p_dataPointer to memory buffer.
[in]sizeSize of data stored in memory buffer.
Return values
None.

Enumeration Type Documentation

List of events returned in callback for file ports with asynchrounous operation like open, read, write and close.

Enumerator
IOT_FILE_OPENED 

Event indicates that file has been opened.

IOT_FILE_WRITE_COMPLETE 

Event indicates that single write operation has been completed.

IOT_FILE_READ_COMPLETE 

Event indicates that single read operation has been completed.

IOT_FILE_CLOSED 

Event indicates that file has been closed.

IOT_FILE_ERROR 

Event indicates that file encountered a problem.

Function Documentation

uint32_t iot_file_fclose ( iot_file_t p_file)

Function to close IoT file. Depending on port, it should free used buffer.

Parameters
[in]p_filePointer to an IoT file instance.
Return values
NRF_SUCCESSon successful execution of procedure, else an error code indicating reason for failure.
uint32_t iot_file_fopen ( iot_file_t p_file,
uint32_t  requested_size 
)

Function to open IoT file. Depending on port, it should allocate required buffer.

Parameters
[in]p_filePointer to an IoT file instance.
[in]requested_sizeMaximum number of bytes to be read/written.
Return values
NRF_SUCCESSon successful execution of procedure, else an error code indicating reason for failure.
uint32_t iot_file_fread ( iot_file_t p_file,
void *  p_data,
uint32_t  size 
)

Function to read data buffer from file.

Parameters
[in]p_filePointer to an IoT file instance.
[in]p_dataPointer to data block to be filled with read data.
[in]sizeNumber of bytes to be read.
Return values
NRF_SUCCESSon successful execution of procedure, else an error code indicating reason for failure.
uint32_t iot_file_frewind ( iot_file_t p_file)

Function to rewind file cursor.

Parameters
[in]p_filePointer to an IoT file instance.
Return values
NRF_SUCCESSon successful execution of procedure, else an error code indicating reason for failure.
uint32_t iot_file_fseek ( iot_file_t p_file,
uint32_t  cursor 
)

Function to set current cursor position.

Parameters
[in]p_filePointer to an IoT file instance.
[in]cursorNew cursor value.
Return values
NRF_SUCCESSon successful execution of procedure, else an error code indicating reason for failure.
uint32_t iot_file_ftell ( iot_file_t p_file,
uint32_t *  p_cursor 
)

Function to read current cursor position.

Parameters
[in]p_filePointer to an IoT file instance.
[out]p_cursorCurrent value of a cursor.
Return values
NRF_SUCCESSon successful execution of procedure, else an error code indicating reason for failure.
uint32_t iot_file_fwrite ( iot_file_t p_file,
const void *  p_data,
uint32_t  size 
)

Function to write data buffer into a file.

Parameters
[in]p_filePointer to an IoT file instance.
[in]p_dataPointer to data block which will be written into the file.
[in]sizeNumber of bytes to be written.
Return values
NRF_SUCCESSon successful execution of procedure, else an error code indicating reason for failure.