1 /*
2 * Copyright (c) 2014-2016 Alibaba Group. All rights reserved.
3 * License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <stdarg.h>
24
25 #include "aos/kernel.h"
26 #include "netmgr.h"
27 #include "ulog/ulog.h"
28 #include "aiconfig.h"
29 #include <uservice/uservice.h>
30 #include <uservice/eventid.h>
31 #include "aiagent_common.h"
32 #include "ugraphics.h"
33 #ifdef AOS_USE_BEEPER
34 #include "beeper.h"
35 #endif
36
37 static char linkkit_started = 0;
38
39 extern void ucloud_ai_demo_main(void *p);
40 extern int linkkit_main(void *paras);
41 extern void set_iotx_info(void);
42
43 extern void do_comparing_facebody_async(void);
44 extern void do_recognize_expression_async(void);
45
wifi_service_event(uint32_t event_id,const void * param,void * context)46 static void wifi_service_event(uint32_t event_id, const void *param, void *context)
47 {
48 int ai_model = AI_MODEL;
49
50 if (event_id != EVENT_NETMGR_SNTP_SUCCESS) {
51 return;
52 }
53
54 if (!linkkit_started) {
55 printf("start to do ucloud_ai_demo\n");
56 aos_task_new("ucloud_ai_demo_main", ucloud_ai_demo_main, NULL, 1024 * 20);
57 if (ai_model == AI_MODEL_COMPARING_FACEBODY)
58 aos_task_new("linkkit", (void (*)(void *))linkkit_main, NULL, 1024 * 10);
59 linkkit_started = 1;
60 }
61 }
62
application_start(int argc,char ** argv)63 int application_start(int argc, char **argv)
64 {
65 aos_set_log_level(AOS_LL_DEBUG);
66
67 /*Init ugraphics component*/
68 ugraphics_init(SCREEN_W, SCREEN_H);
69
70 /*Set screen default color*/
71 ugraphics_set_color(COLOR_RED);
72
73 /*Load default font*/
74 ugraphics_load_font("/data/font/Alibaba-PuHuiTi-Heavy.ttf", 18);
75
76 /*Set default font style*/
77 ugraphics_set_font_style(UGRAPHICS_FONT_STYLE);
78
79 #ifdef AOS_OLED_SH1106
80 sh1106_init();
81 #endif
82
83 /*init event service*/
84 event_service_init(NULL);
85
86 /*init network service*/
87 netmgr_service_init(NULL);
88
89 /*enable network auto reconnect*/
90 netmgr_set_auto_reconnect(NULL, true);
91
92 /*enable auto save wifi config*/
93 netmgr_wifi_set_auto_save_ap(true);
94
95 /*Subscribe wifi service event*/
96 event_subscribe(EVENT_NETMGR_SNTP_SUCCESS, wifi_service_event, NULL);
97
98 while (1) {
99 aos_msleep(1000);
100 };
101
102 return 0;
103 }
104