Resources | Resources |



C/C++ application setup

The Brew MP SDK includes plugins that integrate with the Visual Studio and Eclipse development environments to simplify many of the tasks performed when creating Brew MP applications. The plugins include a wizard to generate a MOD/DLL or MOD1/DLL1 application framework for a Brew MP C/C++ application or extension that provides a baseline project complete with comments. Required source files are included in the project. The wizard also adds the header files into the #includes section. Additional header files are added as the application is built upon.

MOD project setup

Along with the application source .c file, two other helper files are included:

  • AEEAppGen.c - Defines a Brew MP application and provides general application functionality such as event handling.
  • AEEModGen.c - Defines a Brew MP module, loads it in memory, and provides access to the module.

Without these helper files, you would have to define your module and applet on your own. Look through these files for insight into how the module and application are created.

For code in a MOD file:

  • The IShell object is the first object provided to each class upon creation.
  • The IShell object is always available, and can be used to create and discover other objects available in the system.
  • Both MALLOC() (from AEEStdLib) and IEnv_ErrMalloc() can be used to allocate heap memory.
  • MOD applications inherit IApplet, which provides a mechanism to the shell to pass events to an applet.

The following is an example of a MOD entry point.

int AEEMod_Load(IShell *piShell, void *ph, IModule **ppMod) 

MOD entry points must be compiled in ARM mode. HandleEvent needs to be implemented when the class supports IApplet, which can be the case for both MOD and MOD1.

MOD1 project setup

The setup for MOD1 applications varies from that of MOD applications. The entry point for MOD1 applications is IMod_New(), rather than AEEMod_Load(). CIFC generates the module IMod stub, as well as code to call the individual classes' New() functions, eliminating the need to write your own module entry point.

For code in a MOD1 file:

  • The IEnv object is the first object provided to each class upon creation.
  • Rather than using AEEModGen.c, the CIF compiler (cifc.exe) generates code to provide the module entry point.
  • Only classes running inside the BREW Shell have access to the IShell object, and use it to discover and create other objects available in the system.
  • Heap memory is allocated via IEnv_ErrMalloc().

    Avoid using AEEStdLib.h functions, including MALLOC, GETUPTIMEMS, and STRNCPY. Some AEEStdLib.h functions can be replaced with functions from AEEStd.h. Malloc can be replaced with IEnv_ErrMalloc(). Uptime functionality can be replaced with ISysClock functions. Timer functionality is provided by ISysTimer.

The following is an example of the MOD1 entry point, which takes an IEnv* parameter rather than an IShell* parameter. This piEnv is passed to the New() function for the class via IMod_CreateInstance(). The class structure can be changed to hold this Env pointer instead.

int IMod_New(IEnv *piEnv, AEEIID iid, void** ppiModOut)

For more information on MOD vs. MOD1, see the MOD vs. MOD1 in Brew MP Technology Guide on the Brew MP website.