Soletta™ Framework
|
The Platform API is about target states and services. More...
Files | |
file | sol-platform-linux-micro.h |
These routines are used for Soletta platform Linux micro interaction. | |
file | sol-platform-linux.h |
These routines are used for Soletta platform Linux interaction. | |
Macros | |
#define | SOL_PLATFORM_TARGET_DEFAULT "default" |
Default target string. More... | |
#define | SOL_PLATFORM_TARGET_EMERGENCY "emergency" |
Emergency target string. More... | |
#define | SOL_PLATFORM_TARGET_POWER_OFF "poweroff" |
Power-off target string. More... | |
#define | SOL_PLATFORM_TARGET_REBOOT "reboot" |
Reboot target string. More... | |
#define | SOL_PLATFORM_TARGET_RESCUE "rescue" |
Rescue target string. More... | |
#define | SOL_PLATFORM_TARGET_SUSPEND "suspend" |
Suspend target string. More... | |
Functions | |
int | sol_platform_add_hostname_monitor (void(*cb)(void *data, const char *hostname), const void *data) |
Adds a hostname monitor. More... | |
int | sol_platform_add_locale_monitor (void(*cb)(void *data, enum sol_platform_locale_category category, const char *locale), const void *data) |
Add a locale monitor. More... | |
int | sol_platform_add_service_monitor (void(*cb)(void *data, const char *service, enum sol_platform_service_state state), const char *service, const void *data) |
Adds a service monitor. More... | |
int | sol_platform_add_state_monitor (void(*cb)(void *data, enum sol_platform_state state), const void *data) |
Adds a state monitor. More... | |
int | sol_platform_add_system_clock_monitor (void(*cb)(void *data, int64_t timestamp), const void *data) |
Add a callback to monitor system clock changes. More... | |
int | sol_platform_add_timezone_monitor (void(*cb)(void *data, const char *timezone), const void *data) |
Add a timezone monitor. More... | |
int | sol_platform_apply_locale (enum sol_platform_locale_category category) |
Apply the locale category to the process. More... | |
int | sol_platform_del_hostname_monitor (void(*cb)(void *data, const char *hostname), const void *data) |
Remove a hostname monitor. More... | |
int | sol_platform_del_locale_monitor (void(*cb)(void *data, enum sol_platform_locale_category category, const char *locale), const void *data) |
Remove a locale monitor. More... | |
int | sol_platform_del_service_monitor (void(*cb)(void *data, const char *service, enum sol_platform_service_state state), const char *service, const void *data) |
Removes a service monitor. More... | |
int | sol_platform_del_state_monitor (void(*cb)(void *data, enum sol_platform_state state), const void *data) |
Removes a state monitor. More... | |
int | sol_platform_del_system_clock_monitor (void(*cb)(void *data, int64_t timestamp), const void *data) |
Delete a register system_clock monitor. More... | |
int | sol_platform_del_timezone_monitor (void(*cb)(void *data, const char *timezone), const void *data) |
Remove a timezone monitor. More... | |
struct sol_str_slice | sol_platform_get_appname (void) |
Get current app name. More... | |
const char * | sol_platform_get_board_name (void) |
Retrieves the name of the board on which Soletta is running. More... | |
const char * | sol_platform_get_hostname (void) |
Gets the hostname. More... | |
const char * | sol_platform_get_locale (enum sol_platform_locale_category category) |
Get the current locale of a given category. More... | |
const char * | sol_platform_get_machine_id (void) |
Retrieves the machine-id present in the file system as a string. More... | |
const uint8_t * | sol_platform_get_machine_id_as_bytes (void) |
Retrieves the machine-id present in the file system as a byte array. More... | |
int | sol_platform_get_mount_points (struct sol_ptr_vector *vector) |
List mount points mounted by us on hotplug events. More... | |
const char * | sol_platform_get_os_version (void) |
Retrieves the operating system's version that Soletta is running on top of. More... | |
const char * | sol_platform_get_serial_number (void) |
Retrieves, in number, the platform's main board serial number/identifier. More... | |
enum sol_platform_service_state | sol_platform_get_service_state (const char *service) |
Retrieves the state of a given service. More... | |
int | sol_platform_get_state (void) |
Retrieves the current platform state. More... | |
const char * | sol_platform_get_sw_version (void) |
Retrieves the version of Soletta that is running. More... | |
int64_t | sol_platform_get_system_clock (void) |
Get the current system time. More... | |
const char * | sol_platform_get_timezone (void) |
Get the current timezone. More... | |
int | sol_platform_restart_service (const char *service) |
Restarts a given service. More... | |
int | sol_platform_set_hostname (const char *name) |
Changes the hostname to name . More... | |
int | sol_platform_set_locale (enum sol_platform_locale_category category, const char *locale) |
Set locale for a category. More... | |
int | sol_platform_set_system_clock (int64_t timestamp) |
Set the system wide time. More... | |
int | sol_platform_set_target (const char *target) |
Set the platform target. More... | |
int | sol_platform_set_timezone (const char *tzone) |
Set the system timezone. More... | |
int | sol_platform_start_service (const char *service) |
Starts a given service. More... | |
int | sol_platform_stop_service (const char *service) |
Stops a given service. More... | |
int | sol_platform_unmount (const char *mpoint, void(*cb)(void *data, const char *mpoint, int error), const void *data) |
Umount a mpoint . More... | |
The Platform API is about target states and services.
It is specially useful when Soletta is used in a PID 1 process.
#define SOL_PLATFORM_TARGET_DEFAULT "default" |
Default target string.
#define SOL_PLATFORM_TARGET_EMERGENCY "emergency" |
Emergency target string.
#define SOL_PLATFORM_TARGET_POWER_OFF "poweroff" |
Power-off target string.
#define SOL_PLATFORM_TARGET_REBOOT "reboot" |
Reboot target string.
#define SOL_PLATFORM_TARGET_RESCUE "rescue" |
Rescue target string.
#define SOL_PLATFORM_TARGET_SUSPEND "suspend" |
Suspend target string.
A locale category.
List of service states.
enum sol_platform_state |
int sol_platform_add_hostname_monitor | ( | void(*)(void *data, const char *hostname) | cb, |
const void * | data | ||
) |
Adds a hostname monitor.
If the hostname changes cb
will be called.
cb | The callback that will inform the new hostname. |
data | The data to the callback. |
0
on success, negative errno otherwise.int sol_platform_add_locale_monitor | ( | void(*)(void *data, enum sol_platform_locale_category category, const char *locale) | cb, |
const void * | data | ||
) |
Add a locale monitor.
cb | A callback to be called when the locale changes |
data | The data to cb |
cb
will be called and category
will be set to SOL_PLATFORM_SERVICE_STATE_UNKNOWN and locale
to NULL
. int sol_platform_add_service_monitor | ( | void(*)(void *data, const char *service, enum sol_platform_service_state state) | cb, |
const char * | service, | ||
const void * | data | ||
) |
Adds a service monitor.
service
will be monitored and whenever it's state changes, cb
will be called receiving the new state and the provided data
.
cb | Callback |
service | Service name |
data | Callback data |
0
on success, error code (always negative) otherwise. Referenced by on_timeout_cmd(), and startup().
int sol_platform_add_state_monitor | ( | void(*)(void *data, enum sol_platform_state state) | cb, |
const void * | data | ||
) |
Adds a state monitor.
Whenever the platform state changes, cb
is called receiving the new state and data
.
cb | Callback |
data | Callback data |
0
on success, error code (always negative) otherwise. int sol_platform_add_system_clock_monitor | ( | void(*)(void *data, int64_t timestamp) | cb, |
const void * | data | ||
) |
Add a callback to monitor system clock changes.
cb | A callback to be called when the system clock changes |
data | The data to cb |
0
on success, negative errno otherwiseint sol_platform_add_timezone_monitor | ( | void(*)(void *data, const char *timezone) | cb, |
const void * | data | ||
) |
Add a timezone monitor.
cb | A callback to be called when the timezone changes |
data | The data to cb |
0
on success, negative errno otherwise int sol_platform_apply_locale | ( | enum sol_platform_locale_category | category | ) |
Apply the locale category to the process.
This function sets the current locale of the given category to the process, in order to set a new locale value to a category use sol_platform_set_locale().
category | The category to set the process locale |
int sol_platform_del_hostname_monitor | ( | void(*)(void *data, const char *hostname) | cb, |
const void * | data | ||
) |
Remove a hostname monitor.
cb | The registered callback. |
data | The data to the callback. |
0
on success, negative errno otherwise.int sol_platform_del_locale_monitor | ( | void(*)(void *data, enum sol_platform_locale_category category, const char *locale) | cb, |
const void * | data | ||
) |
Remove a locale monitor.
cb | The previous registered callback |
data | The data to cb |
int sol_platform_del_service_monitor | ( | void(*)(void *data, const char *service, enum sol_platform_service_state state) | cb, |
const char * | service, | ||
const void * | data | ||
) |
Removes a service monitor.
cb | Callback to be removed |
service | Service name from which cb should be removed |
data | Callback data |
0
on success, error code (always negative) otherwise. Referenced by on_timeout_cmd(), and shutdown().
int sol_platform_del_state_monitor | ( | void(*)(void *data, enum sol_platform_state state) | cb, |
const void * | data | ||
) |
Removes a state monitor.
cb | Callback to be removed |
data | Callback data |
0
on success, error code (always negative) otherwise. Referenced by main(), and shutdown().
int sol_platform_del_system_clock_monitor | ( | void(*)(void *data, int64_t timestamp) | cb, |
const void * | data | ||
) |
Delete a register system_clock monitor.
cb | The previous registered callback |
data | The data to cb |
0
on success, negative errno otherwiseint sol_platform_del_timezone_monitor | ( | void(*)(void *data, const char *timezone) | cb, |
const void * | data | ||
) |
Remove a timezone monitor.
cb | The previous registered callback |
data | The data to cb |
0
on success, negative errno otherwise struct sol_str_slice sol_platform_get_appname | ( | void | ) |
Get current app name.
Generate current app name from sol_argv[0]. If argv is not set, app name will be soletta.
const char* sol_platform_get_board_name | ( | void | ) |
Retrieves the name of the board on which Soletta is running.
NULL
otherwise.const char* sol_platform_get_hostname | ( | void | ) |
const char* sol_platform_get_locale | ( | enum sol_platform_locale_category | category | ) |
Get the current locale of a given category.
category | The category which one wants to know the locale |
NULL
otherwiseconst char* sol_platform_get_machine_id | ( | void | ) |
Retrieves the machine-id present in the file system as a string.
The returned string is assured to be a valid null terminated string with the 16 bytes-long (128 bits) UUID encoded as hexadecimal ASCII characters.
NULL
. const uint8_t* sol_platform_get_machine_id_as_bytes | ( | void | ) |
Retrieves the machine-id present in the file system as a byte array.
The returned byte array is assured to be a 16 bytes-long (128 bits) array with the machine UUID.
NULL
. int sol_platform_get_mount_points | ( | struct sol_ptr_vector * | vector | ) |
List mount points mounted by us on hotplug events.
vector | Initialized sol_vector used to store the resulting list |
const char* sol_platform_get_os_version | ( | void | ) |
Retrieves the operating system's version that Soletta is running on top of.
NULL
. const char* sol_platform_get_serial_number | ( | void | ) |
Retrieves, in number, the platform's main board serial number/identifier.
NULL
. enum sol_platform_service_state sol_platform_get_service_state | ( | const char * | service | ) |
Retrieves the state of a given service.
service | Service to be queried |
Referenced by startup().
int sol_platform_get_state | ( | void | ) |
const char* sol_platform_get_sw_version | ( | void | ) |
Retrieves the version of Soletta that is running.
NULL
. int64_t sol_platform_get_system_clock | ( | void | ) |
Get the current system time.
const char* sol_platform_get_timezone | ( | void | ) |
int sol_platform_restart_service | ( | const char * | service | ) |
Restarts a given service.
service | Service name |
0
on success, error code (always negative) otherwise. Referenced by on_timeout_cmd().
int sol_platform_set_hostname | ( | const char * | name | ) |
Changes the hostname to name
.
name | The new hostname. |
0
on success, negative errno otherwise.int sol_platform_set_locale | ( | enum sol_platform_locale_category | category, |
const char * | locale | ||
) |
Set locale for a category.
This function will change the system wide locale for a given category. The already running proceses might not be aware that the locale has changed.
category | The category to set the new locale |
locale | The locale string (Example: en_US.UTF-8) |
int sol_platform_set_system_clock | ( | int64_t | timestamp | ) |
Set the system wide time.
timestamp | The new system_clock |
0
on succes, negative errno otherwiseint sol_platform_set_target | ( | const char * | target | ) |
Set the platform target.
target | Target name |
0
on success, error code (always negative) otherwise. Referenced by on_timeout_cmd().
int sol_platform_set_timezone | ( | const char * | tzone | ) |
Set the system timezone.
tzone | The new timezone. (Example: America/Sao_Paulo) |
0
on success, negative errno on errorint sol_platform_start_service | ( | const char * | service | ) |
Starts a given service.
service | Service name |
0
on success, error code (always negative) otherwise. Referenced by on_timeout_cmd().
int sol_platform_stop_service | ( | const char * | service | ) |
Stops a given service.
service | Service name |
0
on success, error code (always negative) otherwise. Referenced by on_timeout_cmd().
int sol_platform_unmount | ( | const char * | mpoint, |
void(*)(void *data, const char *mpoint, int error) | cb, | ||
const void * | data | ||
) |
Umount a mpoint
.
mpoint | The mount point to be unmounted |
cb | Callback to be called when unmount operation finishes |
data | Context data to be provided to async_cb function |