# Call back functions

This is a callback function that describes the application. Callback means called by the system (library). The user defines several callback functions to describe the behavior of the system.

The following callback functions are mandatory definitions.

* `setup()`
* `loop()`

If no other functions are defined, an empty function that does nothing is linked instead.

### Normal callback call sequence

```
init_coldboot()
  ↓ (TWENET internal processing: Initialization 1)
setup()
  ↓（TWENET internal processing: Initialization 2)
begin() --- First time only
  ↓
loop() <--+
  ↓       |Event processing, behavior processing
CPU DOZE -+
```

{% hint style="warning" %}
Please refer to the source code `mwx_appcore.cpp` if you want to see the exact behavior.
{% endhint %}

### Order of callback invocation on return to sleep

```
the_twelite.sleep()
  ↓ sleeping...
 
 
init_warmboot()
  ↓ (TWENET internal processing: Initialization 3)
wakeup()
  ↓（TWENET internal processing: Initialization 4)
loop() <--+
  ↓       |Event processing, behavior processing
CPU DOZE -+
```

{% hint style="warning" %}
Please refer to the source code `mwx_appcore.cpp` if you want to see the exact behavior.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mwx.twelite.info/latest_en/api-reference/sys_callbacks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
