Skip to main content

System Services Module

The system services module is one of the core components of ElenixOS, providing a series of system-level services and functions, including battery management, sensor management, etc. This module provides a unified service interface for applications and system components, simplifying access to hardware resources.

Directory Structure

├── src/core/system/services/
│ ├── eos_services.c # System services core implementation
│ ├── eos_services.h # System services interface definition
│ ├── eos_sensor.c # Sensor service implementation
│ └── eos_sensor.h # Sensor service interface definition

Core Features

Battery Service

The battery service provides functionality to get battery level and charging status, providing battery-related information for applications.

Sensor Service

The sensor service provides access and management functions for various sensors, including accelerometer, heart rate sensor, etc.

Service Startup and Management

The system services module is responsible for starting and managing various system services, ensuring their normal operation.

Key Interfaces

Battery Service Interfaces

uint8_t eos_battery_service_get_level(void);
bool eos_battery_service_get_charging(void);
  • eos_battery_service_get_level:Get battery level, range 0-100
  • eos_battery_service_get_charging:Get battery charging status, returns true if charging

Sensor Service Interfaces

The sensor service provides access and management functions for various sensors. For specific interfaces, please refer to the eos_sensor.h file.

Service Startup Interface

void eos_services_start(void);
  • Start system services, initialize various service components

Implementation Details

The core implementation of the system services module includes:

  1. Service initialization:Initialize various service components when the system starts
  2. Service management:Manage the lifecycle and status of services
  3. Hardware abstraction:Abstract hardware resources to provide a unified service interface
  4. Event notification:Notify relevant components when service status changes

This module works closely with the hardware layer to provide a unified service access interface for upper-level applications.

Usage Examples

Get Battery Level

uint8_t battery_level = eos_battery_service_get_level();
printf("Battery level: %d%%\n", battery_level);

Get Charging Status

bool is_charging = eos_battery_service_get_charging();
if (is_charging) {
printf("Battery is charging\n");
} else {
printf("Battery is not charging\n");
}

Start System Services

eos_services_start();

Service Architecture

The system services module adopts a layered architecture:

  1. Service interface layer:Provide a unified service access interface
  2. Service implementation layer:Implement specific service functions
  3. Hardware adaptation layer:Adapt to different hardware platform implementations

This architectural design allows system services to maintain a consistent interface across different hardware platforms while providing optimized implementations for specific platforms.