monoZ docs
|
There are certain context variables provided by user to initialize all the context required by the monoZ_Lib.
i. Hardware related context[Mandatory]
ii. Modem related context[Optional]
i. Hardware related context
The definitions of all hardware context variables are present in “MZ_public.h” header file. The sample template for using is also provided in the same header file.
a. Main context variable
User must create this context variable for successful use of the library. In case the context variable is not created by user, The monoZ_Lib will not initialize and a linker error will occur.
Example App Sample code implementation
TODO
ii. Modem related context
User must create the modem context functions if wish to initialize modem with specific configuration. There are 2 function definitions present to provide flexibility. The names of the function are fixed. User need to define the function with this exact name. Prototype of the functions are as follows:
Note: User must define the desired AT commands need to be executed during these actions.
Example App Sample code implementation
void mz_reset_sequence(void * arg) { (void)arg; mz_power_config(); mz_apn_set(); mz_lwm2m_config(); mz_device_reboot(); mz_device_start(); mz_lwm2m_start(); } Void mz_reboot_sequence(void * arg) { (void)arg; mz_device_reboot(); mz_device_start(); mz_lwm2m_start(); }
User must initialize the monoZ_Lib before it can start using the library features. The monoZ Library can be initialized using the API MZ_init (). “MZ_main. h” header file provides a sample use of how to initialize the library.
Example App Sample code implementation
mz_version ver = { ._major = MZ_SW_VERSION_MAJOR, ._minor = MZ_SW_VERSION_MINOR, ._patch = MZ_SW_VERSION_PATCH }; if(MZ_OK != MZ_init(&ver)) { Error_Handler(); }
The Application initialization is done before the Main FreeRTOS kernel starts. User must create a user application using the monoZ Library API’s.
Example App Sample code implementation
mz_error_t mz_app1_init(void) { … // Create the Application thread if(!mz_thread_create( &app1_thread_id,"App1 Scheduler",app1_scheduler,NULL,osPriorityNormal,app1_stack,APP1_STACK_SIZE,&app1_cb_mem,sizeof(app1_cb_mem))) { _ret = MZ_THREAD_CREATE_FAIL; } … }
/* creation of user task */ if(MZ_OK != uv_app_init()) { Error_Handler(); }
User must design the application based on requirements.
Example App Sample code implementation
The logic of the Application should be written inside the app scheduler
static void app1_scheduler(void * arg) { (void)arg; /* Place code here That need to run once during application start */ /* * This is the infinite loop for this thread - the thread will execute this * loop forever and not come outside of this loop */ while(1) { /* Need to write the periodic executing logic in this loop block */ __NOP(); }//End of while(1) - Do not place any code after this. }
Click here to access the source code of this file.