NuMaker Pelion Device Management example

Fork of mbed-os-example-pelion by cc li

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_main.cpp Source File

mbed_main.cpp

00001 /* 
00002  * Copyright (c) 2019 Nuvoton Technology Corporation
00003  *
00004  * SPDX-License-Identifier: Apache-2.0
00005  *
00006  * Licensed under the Apache License, Version 2.0 (the "License");
00007  * you may not use this file except in compliance with the License.
00008  * You may obtain a copy of the License at
00009  *
00010  *     http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  */
00018 
00019 #include "mbed.h"
00020 
00021 /* Run pre-main tasks via mbed_main()
00022  *
00023  * In Mbed OS boot sequence, mbed_main(), designed for user application override, is run
00024  * before main(). We use it to run the following tasks:
00025  *
00026  * 1. Simulate provision process for development
00027  * 2. Set up event queue for dispatching host command
00028  *
00029  * WARNING: For mass production, remove this file.
00030  */
00031 
00032 /* Check weak reference/definition at the link:
00033  * http://www.keil.com/support/man/docs/ARMLINK/armlink_pge1362065917715.htm */
00034 
00035 extern "C" {
00036     MBED_USED void mbed_main(void);
00037     MBED_WEAK void provision(void);
00038     MBED_WEAK void pump_host_command(void);
00039 }
00040 
00041 void mbed_main(void)
00042 {
00043     provision();
00044     /* Spare memory if event queue is unnecessary */
00045     if (pump_host_command) {
00046         mbed_event_queue()->call_every(2000, pump_host_command);
00047     }
00048 }