Services¶
A service is a software implementation of specific product functions, such as input keys, network configuration management, and battery check. Each service is also an abstraction of hardware. For example, the input key service supports ADC keys and GPIO keys. Services can be reused on different products, and high-level APIs and events allow easy and convenient product development.
For details please refer to descriptions listed below.
Header File¶
Functions¶
-
periph_service_handle_t
periph_service_create
(periph_service_config_t *config)¶ brief Create peripheral service instance
- Return
NULL, Fail
Others, Success
- Parameters
[in] config
: Configuration of the peripheral service instance
-
esp_err_t
periph_service_destroy
(periph_service_handle_t handle)¶ brief Destroy peripheral service instance
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The peripheral service instance
-
esp_err_t
periph_service_start
(periph_service_handle_t handle)¶ brief Start the specific peripheral service
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The peripheral service instance
-
esp_err_t
periph_service_stop
(periph_service_handle_t handle)¶ brief Stop the specific peripheral service
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The peripheral service instance
-
esp_err_t
periph_service_set_callback
(periph_service_handle_t handle, periph_service_cb cb, void *ctx)¶ brief Set the specific peripheral service callback function
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The peripheral service instance[in] cb
: A pointer to service_callback[in] ctx
: A pointer to user context
-
esp_err_t
periph_service_callback
(periph_service_handle_t handle, periph_service_event_t *evt)¶ brief Called peripheral service by configurations
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The peripheral service instance[in] evt
: A pointer to periph_service_event_t
-
esp_err_t
periph_service_set_data
(periph_service_handle_t handle, void *data)¶ brief Set user data to specific peripheral service instance
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The peripheral service instance[in] data
: A pointer to user data
-
void *
periph_service_get_data
(periph_service_handle_t handle)¶ brief Get user data by specific peripheral service instance
- Return
A pointer to user data
- Parameters
[in] handle
: The peripheral service instance
-
esp_err_t
periph_service_ioctl
(periph_service_handle_t handle, void *ioctl_handle, int cmd, int value)¶ brief In/out control by peripheral service instance
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The peripheral service instance[in] ioctl_handle
: Sub-instance handle[in] cmd
: Command of value[in] value
: Data of the command
Structures¶
-
struct
periph_service_event_t
¶ Peripheral service event informations.
-
struct
periph_service_config_t
¶ Peripheral service configurations.
Public Members
-
int
task_stack
¶ >0 Service task stack; =0 with out task created
-
int
task_prio
¶ Service task priority (based on freeRTOS priority)
-
int
task_core
¶ Service task running in core (0 or 1)
-
TaskFunction_t
task_func
¶ Service task function
-
bool
extern_stack
¶ Task stack allocate on the extern ram
-
periph_service_ctrl
service_start
¶ Start function
-
periph_service_ctrl
service_stop
¶ Stop function
-
periph_service_ctrl
service_destroy
¶ Destroy function
-
periph_service_io
service_ioctl
¶ In out control function
-
char *
service_name
¶ Name of peripheral service
-
void *
user_data
¶ User data
-
int
Type Definitions¶
-
typedef struct periph_service_impl *
periph_service_handle_t
¶
-
typedef esp_err_t (*
periph_service_ctrl
)(periph_service_handle_t handle)¶
-
typedef esp_err_t (*
periph_service_io
)(void *ioctl_handle, int cmd, int value)¶
-
typedef esp_err_t (*
periph_service_cb
)(periph_service_handle_t handle, periph_service_event_t *evt, void *ctx)¶
Enumerations¶
Header File¶
Functions¶
-
audio_service_handle_t
audio_service_create
(audio_service_config_t *config)¶ brief Create audio service instance
- Return
NULL, Fail
Others, Success
- Parameters
[in] config
: Configuration of the audio service instance
-
esp_err_t
audio_service_destroy
(audio_service_handle_t handle)¶ brief Destroy audio service instance
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The audio service instance
-
esp_err_t
audio_service_start
(audio_service_handle_t handle)¶ brief Start the specific audio service
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The audio service instance
-
esp_err_t
audio_service_stop
(audio_service_handle_t handle)¶ brief Stop the specific audio service
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The audio service instance
-
esp_err_t
audio_service_set_callback
(audio_service_handle_t handle, service_callback cb, void *ctx)¶ brief Set the specific audio service callback function.
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The audio service instance[in] cb
: A pointer to service_callback[in] ctx
: A pointer to user context
-
esp_err_t
audio_service_callback
(audio_service_handle_t handle, service_event_t *evt)¶ brief Called audio service by configurations
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The audio service instance[in] evt
: A pointer to service_event_t
-
esp_err_t
audio_service_connect
(audio_service_handle_t handle)¶ brief Connect the specific audio service
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The audio service instance
-
esp_err_t
audio_service_disconnect
(audio_service_handle_t handle)¶ brief Disconnect the specific audio service
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The audio service instance
-
esp_err_t
audio_service_set_data
(audio_service_handle_t handle, void *data)¶ brief Set user data to specific audio service instance
- Return
ESP_OK
ESP_FAIL
ESP_ERR_INVALID_ARG
- Parameters
[in] handle
: The audio service instance[in] data
: A pointer to user data
-
void *
audio_service_get_data
(audio_service_handle_t handle)¶ brief Get user data by specific audio service instance
- Return
A pointer to user data
- Parameters
[in] handle
: The audio service instance
Structures¶
-
struct
service_event_t
¶ Audio service event informations.
-
struct
audio_service_config_t
¶ Audio service configurations.
Public Members
-
int
task_stack
¶ >0 Service task stack; =0 with out task created
-
int
task_prio
¶ Service task priority (based on freeRTOS priority)
-
int
task_core
¶ Service task running in core (0 or 1)
-
TaskFunction_t
task_func
¶ A pointer to TaskFunction_t for service task function
-
service_ctrl
service_start
¶ Start function
-
service_ctrl
service_stop
¶ Stop function
-
service_ctrl
service_connect
¶ Connect function
-
service_ctrl
service_disconnect
¶ Disconnect function
-
service_ctrl
service_destroy
¶ Destroy function
-
const char *
service_name
¶ Name of audio service
-
void *
user_data
¶ User context
-
int
Type Definitions¶
-
typedef struct audio_service_impl *
audio_service_handle_t
¶
-
typedef esp_err_t (*
service_ctrl
)(audio_service_handle_t handle)¶
-
typedef esp_err_t (*
service_callback
)(audio_service_handle_t handle, service_event_t *evt, void *ctx)¶