# Events

## Built-on events

| Name                   | Remark                                                                                                                                                                                                                                                                                                                                    |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| E\_EVENT\_START\_UP    | This event occurs when the system is woken up (or wakes up from sleep). The event argument is given as `EVARG_START_UP_WAKEUP_MASK` or `(EVARG_START_UP_WAKEUP_MASK \| EVARG_START_UP_WAKEUP_ RAMHOLD_MASK)`, the former means return from DEEP sleep, the latter means return from normal RAM hold sleep.                                |
| E\_EVENT\_NEW\_STATE   | This is the first event called when a state transition occurs. It is not called when the system starts (START\_UP event occurs). The event argument is undefined.                                                                                                                                                                         |
| E\_EVENT\_TICK\_TIMER  | Called every system timer (4ms, as default). The event argument is undefined. It is called after the module processing in the system is finished. Because of the variability of the calls, processes which require priority in timing should be described in `E_AHI_DEVICE_TICK_TIMER` in the interrupt handler in `cbToCoNet_u8HwInt()`. |
| E\_EVENT\_TICK\_SECOND | Called every second. The event argument is undefined.                                                                                                                                                                                                                                                                                     |
| E\_ORDER\_INITIALIZE   | Use this as a message to encourage initialization.                                                                                                                                                                                                                                                                                        |
| E\_ORDER\_KICK         | Use this as a message to encourage people to start.                                                                                                                                                                                                                                                                                       |

## User-defined events

If you prepare user-defined event names, assign values after `ToCoNet_EVENT_APP_BASE`.

```c
typedef enum
{
	E_EVENT_APP_BASE = ToCoNet_EVENT_APP_BASE,
    E_EVENT_TICK_A,
    E_EVENT_SCAN_FINISH,
    E_EVENT_SLAVE_CONF_FAIL,
    E_EVENT_SLEEP_REQUEST
} teEventApp;
```

{% hint style="warning" %}
Do not apply the compile option to reduce the enum to 16 or 8 bits.
{% 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://sdk.twelite.info/en/twelite-net-api-ref/yzaibento/ibento.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.
