ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
Loading...
Searching...
No Matches
User Configuration

Soil Power Sensor userConfig library. More...

Macros

#define RX_BUFFER_SIZE   UserConfiguration_size
 
#define USER_CONFIG_START_ADDRESS   1794
 
#define USER_CONFIG_LEN_ADDR   1792
 

Enumerations

enum  UserConfigStatus {
  USERCONFIG_OK = 0 , USERCONFIG_FRAM_ERROR = -1 , USERCONFIG_DECODE_ERROR = -2 , USERCONFIG_NO_RESPONSE = -3 ,
  USERCONFIG_COMM_ERROR = -4 , USERCONFIG_INVALID_RESPONSE = -5 , USERCONFIG_NOT_LOADED = -6 , USERCONFIG_EMPTY_CONFIG = -7 ,
  USERCONFIG_ENCODE_ERROR = -8 , USERCONFIG_NULL_CONFIG = -9
}
 

Functions

UserConfigStatus UserConfigLoad (void)
 Loads user configuration data from FRAM to RAM.
 
UserConfigStatus UserConfigSave (const UserConfiguration *config)
 Saves the configuration to FRAM.
 
const UserConfiguration * UserConfigGet (void)
 Gets a reference to the loaded user configuration data in RAM.
 
void UserConfigPrintAny (const UserConfiguration *config)
 Prints arbitrary user config over serial.
 
void UserConfigPrint (void)
 Prints the current user configuration over serial.
 
UserConfigStatus UserConfigClear (void)
 Clears the user configuration stored in FRAM.
 
UserConfigStatus UserConfigBytes (uint8_t *buffer, uint16_t *length)
 Gets encoded bytes from userconfig.
 
UserConfigStatus UserConfigLoadBytes (uint8_t *buffer, uint16_t length)
 Load user config from bytes.
 

Detailed Description

Soil Power Sensor userConfig library.

This library provies functions for saving and loading user configurations from onboard non-volatile memory in the form of FRAM. The user configuration is assigned a block of memory where the encoded data is stored. The memory is structure in the form of [length, encoded data].

There is an optional #define TEST_USER_CONFIG that is used to guarentee a certain configuration is returned by functions for testing purposes.

Macro Definition Documentation

◆ RX_BUFFER_SIZE

#define RX_BUFFER_SIZE   UserConfiguration_size

Definition at line 45 of file user_config.h.

◆ USER_CONFIG_LEN_ADDR

#define USER_CONFIG_LEN_ADDR   1792

Definition at line 49 of file user_config.h.

◆ USER_CONFIG_START_ADDRESS

#define USER_CONFIG_START_ADDRESS   1794

Definition at line 47 of file user_config.h.

Enumeration Type Documentation

◆ UserConfigStatus

Enumerator
USERCONFIG_OK 
USERCONFIG_FRAM_ERROR 
USERCONFIG_DECODE_ERROR 
USERCONFIG_NO_RESPONSE 
USERCONFIG_COMM_ERROR 
USERCONFIG_INVALID_RESPONSE 
USERCONFIG_NOT_LOADED 
USERCONFIG_EMPTY_CONFIG 
USERCONFIG_ENCODE_ERROR 
USERCONFIG_NULL_CONFIG 

Definition at line 51 of file user_config.h.

Function Documentation

◆ UserConfigBytes()

UserConfigStatus UserConfigBytes ( uint8_t *  buffer,
uint16_t *  length 
)

Gets encoded bytes from userconfig.

Parameters
bufferOutput buffer.
lengthLength of user config.
Returns
USERCONFIG_OK if successful, error code otherwise.

Definition at line 79 of file user_config.c.

References buffer, USER_CONFIG_LEN_ADDR, USER_CONFIG_START_ADDRESS, USERCONFIG_EMPTY_CONFIG, USERCONFIG_FRAM_ERROR, USERCONFIG_OK, and UserConfig_ReadFromFRAM().

Referenced by main(), and UserConfigLoad().

◆ UserConfigClear()

UserConfigStatus UserConfigClear ( void  )

Clears the user configuration stored in FRAM.

This function sets the userconfig to all zeros in FRAM.

Returns
USERCONFIG_OK if successful, error code otherwise.

Definition at line 269 of file user_config.c.

References FRAM_OK, fram_write(), USER_CONFIG_LEN_ADDR, USER_CONFIG_START_ADDRESS, USERCONFIG_FRAM_ERROR, and USERCONFIG_OK.

◆ UserConfigGet()

const UserConfiguration * UserConfigGet ( void  )

Gets a reference to the loaded user configuration data in RAM.

This function returns a pointer to the UserConfig structure in RAM, allowing access to the loaded configuration without reading from FRAM.

Returns
Pointer to the loaded UserConfig structure.

Definition at line 151 of file user_config.c.

Referenced by Check(), Connect(), ControllerUserConfigSend(), main(), measure_sensor(), StartUploads(), UserConfigPrint(), and UserConfigStopCallback().

◆ UserConfigLoad()

UserConfigStatus UserConfigLoad ( void  )

Loads user configuration data from FRAM to RAM.

This function reads the stored user configuration data from FRAM, decodes it, and loads it into RAM. The data will be stored in a static UserConfig structure.

Returns
UserConfigStatus - USERCONFIG_OK if successful, error code otherwise.

get bytes

Definition at line 124 of file user_config.c.

References buffer, USERCONFIG_OK, UserConfigBytes(), and UserConfigLoadBytes().

Referenced by main(), UserConfigStart(), and UserConfigUpdateFromServer().

◆ UserConfigLoadBytes()

UserConfigStatus UserConfigLoadBytes ( uint8_t *  buffer,
uint16_t  length 
)

Load user config from bytes.

Parameters
bufferUser config bytes.
lengthLength of buffer.
Returns
USERCONFIG_OK if successful, error code otherwise.

Definition at line 113 of file user_config.c.

References buffer, DecodeUserConfiguration(), USERCONFIG_DECODE_ERROR, and USERCONFIG_OK.

Referenced by load_userconfig(), and UserConfigLoad().

◆ UserConfigPrint()

void UserConfigPrint ( void  )

Prints the current user configuration over serial.

See also
UserConfigPrintAny

Definition at line 263 of file user_config.c.

References UserConfigGet(), and UserConfigPrintAny().

Referenced by main(), UserConfigStart(), and UserConfigUpdateFromServer().

◆ UserConfigPrintAny()

void UserConfigPrintAny ( const UserConfiguration *  config)

Prints arbitrary user config over serial.

The printing/formatting is done with APP_LOG functions requiring SystemApp_Init() to be called before this function can be used.

Definition at line 188 of file user_config.c.

References i.

Referenced by UserConfigPrint().

◆ UserConfigSave()

UserConfigStatus UserConfigSave ( const UserConfiguration *  config)

Saves the configuration to FRAM.

Parameters
configPointer to the UserConfiguration structure to save.
Returns
USERCONFIG_OK if successful, error code otherwise.

Definition at line 159 of file user_config.c.

References EncodeUserConfiguration(), USER_CONFIG_LEN_ADDR, USER_CONFIG_START_ADDRESS, USERCONFIG_ENCODE_ERROR, USERCONFIG_NULL_CONFIG, USERCONFIG_OK, and UserConfig_WriteToFRAM().

Referenced by ControllerUserConfigRequest(), and main().