1 /*
2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited
3 */
4 /**
5 * @file main.c
6 *
7 * This file includes the entry code of link sdk related demo
8 *
9 */
10
11 #include <string.h>
12 #include <stdio.h>
13 #include <aos/kernel.h>
14 #include "ulog/ulog.h"
15 #include "netmgr.h"
16 #include <uservice/uservice.h>
17 #include <uservice/eventid.h>
18
19 extern int demo_main(int argc, char *argv[]);
20
21 static int _ip_got_finished = 0;
22
entry_func(void * data)23 static void entry_func(void *data)
24 {
25 demo_main(0 , NULL);
26 }
wifi_event_cb(uint32_t event_id,const void * param,void * context)27 static void wifi_event_cb(uint32_t event_id, const void *param, void *context)
28 {
29 if (event_id != EVENT_NETMGR_DHCP_SUCCESS)
30 return;
31
32 if (_ip_got_finished != 0)
33 return;
34
35 _ip_got_finished = 1;
36 aos_task_new("rfid_demo", entry_func, NULL, 6 << 10);
37 }
38
application_start(int argc,char * argv[])39 int application_start(int argc, char *argv[])
40 {
41 aos_set_log_level(AOS_LL_DEBUG);
42 event_service_init(NULL);
43
44 netmgr_service_init(NULL);
45
46 /*enable network auto reconnect*/
47 netmgr_set_auto_reconnect(NULL, true);
48
49 /*enable auto save wifi config*/
50 netmgr_wifi_set_auto_save_ap(true);
51
52 rfid_uart_init();
53
54 event_subscribe(EVENT_NETMGR_DHCP_SUCCESS, wifi_event_cb, NULL);
55
56 while (1) {
57 aos_msleep(1000);
58 };
59
60 return 0;
61 }
62