Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Enumerations | Functions
Power Supply

Enumerations

enum  sol_power_supply_capacity_level {
  SOL_POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN, SOL_POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL, SOL_POWER_SUPPLY_CAPACITY_LEVEL_LOW, SOL_POWER_SUPPLY_CAPACITY_LEVEL_NORMAL,
  SOL_POWER_SUPPLY_CAPACITY_LEVEL_HIGH, SOL_POWER_SUPPLY_CAPACITY_LEVEL_FULL
}
 Power supply capacity level. More...
 
enum  sol_power_supply_status {
  SOL_POWER_SUPPLY_STATUS_UNKNOWN, SOL_POWER_SUPPLY_STATUS_CHARGING, SOL_POWER_SUPPLY_STATUS_DISCHARGING, SOL_POWER_SUPPLY_STATUS_NOT_CHARGING,
  SOL_POWER_SUPPLY_STATUS_FULL
}
 Power supply charging status. More...
 
enum  sol_power_supply_type {
  SOL_POWER_SUPPLY_TYPE_UNKNOWN, SOL_POWER_SUPPLY_TYPE_BATTERY, SOL_POWER_SUPPLY_TYPE_UPS, SOL_POWER_SUPPLY_TYPE_MAINS,
  SOL_POWER_SUPPLY_TYPE_USB, SOL_POWER_SUPPLY_TYPE_USB_DCP, SOL_POWER_SUPPLY_TYPE_USB_CDP, SOL_POWER_SUPPLY_TYPE_USB_ACA
}
 Type of power supply. More...
 

Functions

int sol_power_supply_exists (const char *name, bool *exist)
 Check if a given power supply can be found. More...
 
int sol_power_supply_free_list (struct sol_ptr_vector *list)
 Free a list of power supply names. More...
 
int sol_power_supply_get_capacity (const char *name, int *capacity)
 Get power supply capacity percentage. More...
 
int sol_power_supply_get_capacity_level (const char *name, enum sol_power_supply_capacity_level *capacity_level)
 Get capacity level, as provided by driver (critical, low, normal, high, full). More...
 
int sol_power_supply_get_list (struct sol_ptr_vector *list)
 Retrieves a list of names of all power supplies found. More...
 
int sol_power_supply_get_list_by_type (struct sol_ptr_vector *list, enum sol_power_supply_type type)
 Retrieves a list of names of all power supplies found that match a specified type. More...
 
int sol_power_supply_get_manufacturer (const char *name, struct sol_buffer *manufacturer_buf)
 Get manufacturer of a given power supply. More...
 
int sol_power_supply_get_max_voltage (const char *name, int *voltage)
 Get maximum voltage measured by hardware. More...
 
int sol_power_supply_get_max_voltage_design (const char *name, int *voltage)
 Get value of voltage when supply is full as defined by design. More...
 
int sol_power_supply_get_min_voltage (const char *name, int *voltage)
 Get minimum voltage measured by hardware. More...
 
int sol_power_supply_get_min_voltage_design (const char *name, int *voltage)
 Get value of voltage when supply is empty as defined by design. More...
 
int sol_power_supply_get_model_name (const char *name, struct sol_buffer *model_name_buf)
 Get model name of a given power supply. More...
 
int sol_power_supply_get_serial_number (const char *name, struct sol_buffer *serial_number_buf)
 Get serial number of a given power supply. More...
 
int sol_power_supply_get_status (const char *name, enum sol_power_supply_status *status)
 Get power supply status (charging, discharging, not charging, full). More...
 
int sol_power_supply_get_type (const char *name, enum sol_power_supply_type *type)
 Get type of power supply (battery, USB, ...) More...
 
int sol_power_supply_get_voltage (const char *name, int *voltage)
 Get current voltage. More...
 
int sol_power_supply_is_online (const char *name, bool *online)
 Check if a power supply is online. More...
 
int sol_power_supply_is_present (const char *name, bool *present)
 Check if a power supply is present. More...
 

Detailed Description

Enumeration Type Documentation

Power supply capacity level.

It represents capacity as provided by sol_power_supply_get_capacity() in well defined ranges.

It doesn't apply to some types of power supplies. Batteries usually provide capacity level.

Enumerator
SOL_POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN 
SOL_POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL 
SOL_POWER_SUPPLY_CAPACITY_LEVEL_LOW 
SOL_POWER_SUPPLY_CAPACITY_LEVEL_NORMAL 
SOL_POWER_SUPPLY_CAPACITY_LEVEL_HIGH 
SOL_POWER_SUPPLY_CAPACITY_LEVEL_FULL 

Power supply charging status.

It doesn't apply to some types of power supplies. Batteries usually provide status.

Enumerator
SOL_POWER_SUPPLY_STATUS_UNKNOWN 
SOL_POWER_SUPPLY_STATUS_CHARGING 
SOL_POWER_SUPPLY_STATUS_DISCHARGING 
SOL_POWER_SUPPLY_STATUS_NOT_CHARGING 
SOL_POWER_SUPPLY_STATUS_FULL 

Type of power supply.

It may be unknown, battery, mains (like ac), and usb variants.

Enumerator
SOL_POWER_SUPPLY_TYPE_UNKNOWN 
SOL_POWER_SUPPLY_TYPE_BATTERY 
SOL_POWER_SUPPLY_TYPE_UPS 
SOL_POWER_SUPPLY_TYPE_MAINS 
SOL_POWER_SUPPLY_TYPE_USB 
SOL_POWER_SUPPLY_TYPE_USB_DCP 
SOL_POWER_SUPPLY_TYPE_USB_CDP 
SOL_POWER_SUPPLY_TYPE_USB_ACA 

Function Documentation

int sol_power_supply_exists ( const char *  name,
bool *  exist 
)

Check if a given power supply can be found.

Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
existOn success, if power supply is found, exist will be set to True. Otherwise it'll be set to false.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_free_list ( struct sol_ptr_vector list)

Free a list of power supply names.

It will free strings and vector data.

Parameters
listA vector returned by sol_power_supply_get_list() or sol_power_supply_get_list_by_type().
Returns
On success, it returns 0. On error, a negative value is returned.
int sol_power_supply_get_capacity ( const char *  name,
int *  capacity 
)

Get power supply capacity percentage.

Value should vary from 0 to 100 (full).

Usually provided by batteries.

Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
capacityCapacity percentage will be set on this pointer on success.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_get_capacity_level ( const char *  name,
enum sol_power_supply_capacity_level capacity_level 
)

Get capacity level, as provided by driver (critical, low, normal, high, full).

Usually provided by batteries.

If interested on evaluate level using other ranges, or interested on make them consistent for the same percentage between different drivers, sol_power_supply_get_capacity() should be used.

Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
capacity_levelCapacity level of power supply will be set on this pointer on success.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_get_list ( struct sol_ptr_vector list)

Retrieves a list of names of all power supplies found.

Types may vary.

Parameters
listA vector that will be initialized and filled with all power supply names found. It's required to free it with sol_power_supply_free_list() after usage.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_get_list_by_type ( struct sol_ptr_vector list,
enum sol_power_supply_type  type 
)

Retrieves a list of names of all power supplies found that match a specified type.

Parameters
listA vector that will be initialized and filled with all power supply names found. It's required to free it with sol_power_supply_free_list() after usage.
typeType of power supply to be fetched.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_get_manufacturer ( const char *  name,
struct sol_buffer manufacturer_buf 
)

Get manufacturer of a given power supply.

Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
manufacturer_bufManufacturer of power supply will be appended to this buffer. The buffer must be already initialized.
Returns
On success, it returns 0. On error, a negative value is returned and the property value will not be appended to manufacturer_buf.
int sol_power_supply_get_max_voltage ( const char *  name,
int *  voltage 
)

Get maximum voltage measured by hardware.

See Also
sol_power_supply_get_voltage() for more details.
Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
voltageMaximum voltage measured by hardwared will be set on this pointer on success.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_get_max_voltage_design ( const char *  name,
int *  voltage 
)

Get value of voltage when supply is full as defined by design.

See Also
sol_power_supply_get_voltage() for more details.
Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
voltageMaximum voltage as defined by design will be set on this pointer on success.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_get_min_voltage ( const char *  name,
int *  voltage 
)

Get minimum voltage measured by hardware.

See Also
sol_power_supply_get_voltage() for more details.
Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
voltageMinimum voltage measured by hardwared will be set on this pointer on success.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_get_min_voltage_design ( const char *  name,
int *  voltage 
)

Get value of voltage when supply is empty as defined by design.

See Also
sol_power_supply_get_voltage() for more details.
Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
voltageMinimum voltage as defined by design will be set on this pointer on success.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_get_model_name ( const char *  name,
struct sol_buffer model_name_buf 
)

Get model name of a given power supply.

Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
model_name_bufModel name of power supply will be appended to this buffer. The buffer must be already initialized.
Returns
On success, it returns 0. On error, a negative value is returned and the property value will not be appended to model_name_buf
int sol_power_supply_get_serial_number ( const char *  name,
struct sol_buffer serial_number_buf 
)

Get serial number of a given power supply.

Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
serial_number_bufSerial number of power supply will be appended to this buffer. The buffer must be already initialized.
Returns
On success, it returns 0. On error, a negative value is returned and the property value will not be appended to serial_number_buf.
int sol_power_supply_get_status ( const char *  name,
enum sol_power_supply_status status 
)

Get power supply status (charging, discharging, not charging, full).

Usually provided by batteries.

Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
statusStatus of power supply will be set on this pointer on success.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_get_type ( const char *  name,
enum sol_power_supply_type type 
)

Get type of power supply (battery, USB, ...)

Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
typeType of power supply will be set on this pointer on success.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_get_voltage ( const char *  name,
int *  voltage 
)

Get current voltage.

There are two possible voltage ranges: defined by design and measured by hardware.

Minimal and maximal voltages defined by design means expected voltage at normal conditions for supply when it's empty and full. Such values are provided by sol_power_supply_get_min_voltage_design() and sol_power_supply_get_max_voltage_design().

If hardware is able to measure and retain voltage information, these thresholds may be provided by sol_power_supply_get_min_voltage() and sol_power_supply_get_max_voltage().

Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
voltageCurrent voltage will be set on this pointer on success.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_is_online ( const char *  name,
bool *  online 
)

Check if a power supply is online.

Usually provided by AC / USB power supplies.

For example, if a charger is connected to the wall it would be considered online.

Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
onlineOn success, if power supply is online this pointer will be set to True or to False otherwise.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).
int sol_power_supply_is_present ( const char *  name,
bool *  present 
)

Check if a power supply is present.

Usually provided by batteries.

Parameters
nameName of power supply. A list of all board supplies names may be fetched with sol_power_supply_get_list().
presentOn success, if power supply is present this pointer will be set to True or to False if not attached to the board at the moment.
Returns
On success, it returns 0. On error, a negative value is returned and properties won't be set (pointers won't be valid).