Application main framework

The Application Main module contains common code used by all the applications, such as:

  • The Main Task

  • Messaging framework between the Bluetooth LE Host Stack Task and the Application Task

Start task

The Start Task (start_task) is the first task created by the operating system and is also the one that initializes the rest of the system. It initializes framework components (Memory Manager, Timers Manager etc.) and it calls BluetoothLEHost_AppInit from app.c, which is used to initialize the Bluetooth LE Host Stack as well as peripheral drivers specific to the implemented application.

The function calls BluetoothLEHost_HandleMessages, which represents the Application Task and is used to process events and messages from the Host Stack.

The stack size and priority of the main task are defined in fsl_os_abstraction_config.h:

**\#ifndef** gMainThreadStackSize_c
**\#define** gMainThreadStackSize_c 1024
**\#endif**
**\#ifndef** gMainThreadPriority_c
**\#define** gMainThreadPriority_c 7
**\#endif**

Parent topic:Application main framework

Application messaging

The module contains a wrapper that is used to create messages for events generated by the Bluetooth LE Host Stack in the Host Task context. The wrapper also sends them to be processed by the application in the context of the Application Task.

For example, connection events generated by the Host are received by App_ConnectionCallback. The function creates a message, places it in the Host to Application queue and signals the Application with gAppEvtMsgFromHostStack_c. The Application Task de-queues the message and calls App_HandleHostMessageInput, which calls the corresponding callback implemented the application-specific code (app.c), in this example: BleApp_ConnectionCallback.

It is strongly recommended that the application developer uses the app.c module to add custom code on this type of callbacks.

Parent topic:Application main framework

Parent topic:Application Structure