Logicrom Library APIs
Header File
Source: include/lib.h
#include <lib.h>
Functions
-
void logicrom_init(const char *stdio, urc_callback_f handler)
Initialize Logicrom OpenCPU SDK library
- Parameters:
stdio – [in] STDIO port (e.g. /dev/ttyUSB0), can be NULL if STDIO is not required
handler – [in] Function pointer for handling unsolicited responses urc_callback_f
-
const char *system_getserial(void)
Get device serial number
- Returns:
Serial number of device. Buffer is statically allocated, do not free
-
const char *get_logicrom_version(void)
Get SDK library version
- Returns:
Library version string.
-
void system_settz(const char *tz)
Set system time-zone in +/-HH:MM format (e.g. +5:30)
- Parameters:
tz – [in] Timezone value
-
void system_gettz(char *tz, int size)
Get current time-zone
- Parameters:
tz – [out] Buffer to store timezone
size – [in] Size of buffer
-
int system_set_reboot_callback(reboot_confirm_callback_f callback)
Set reboot confirm callback
- Parameters:
callback – [in] Callback function pointer
-
int debug(int level, const char *fmt, ...)
Debug printf with debug level.
Can be used to print messages at specific loglevel
e.g.
Message will print if loglevel is set to 1debug(DBG_INFO, "Hello\n");
- Parameters:
level – [in] Debug level
fmt – [in] String format
- Returns:
Number of bytes printed
-
int formatfs(const char *path)
Format Filesystem
- Parameters:
path – [in] Mount point of filesystem
- Returns:
0 on success, -ve for error
Type Definitions
-
typedef void (*urc_callback_f)(unsigned int urc_code, unsigned int urc_param)
Unsolicited response code handler callback
- Param urc_code:
URC code sysurc_e
- Param urc_param:
URC parameter
-
typedef int (*reboot_confirm_callback_f)(int reason)
Reboot callback function called when reboot is issued by the system. this callback can be used to confirm or deny reboot.
- Param reason:
[in] Reboot reason reboot_reason_e
- Return:
True if reboot is allowed, false otherwise
Enumerations
-
enum [anonymous]
Library URC events
Values:
-
enumerator URC_FILE_DOWNLOAD_STATUS
File download status event
See also
-
enumerator URC_FOTA_STARTED
FOTA start event
-
enumerator URC_FOTA_FINISHED
FOTA file download finished
-
enumerator URC_FOTA_FAILED
FOTA failed
-
enumerator URC_DEV_REBOOT_REQUEST
System reboot requested (generated if reboot command is executed)
-
enumerator URC_FILE_DOWNLOAD_STATUS
-
enum loglevel_e
Debug Log levels
Values:
-
enumerator DBG_OFF
Default loglevel, equivalent to printf
-
enumerator DBG_INFO
Log level info
-
enumerator DBG_VERBOSE
Log level verbose for more information
-
enumerator DBG_LIB_END
-
enumerator DBG_USER_START
Start of Application log levels
-
enumerator DBG_OFF
-
enum reboot_reason_e
Reboot reasons.
Values:
-
enumerator RESET_REASON_REBOOT
Reboot command or sys_reset()
-
enumerator RESET_REASON_NOSIM
Reboot due to No SIM card
-
enumerator RESET_REASON_NETWORKFAIL
Reboot due to network registration failure
-
enumerator RESET_REASON_DATAFAIL
Reboot due to data connection failure
-
enumerator RESET_REASON_FOTA
Reboot due to FOTA update
-
enumerator RESET_REASON_PARAMRESET
Reboot due to parameter reset
-
enumerator RESET_REASON_SYSFORMAT
Reboot due to system memory format
-
enumerator RESET_REASON_REBOOT
