#include #include #include #include #include #include #include "bk_private/bk_init.h" #include #include #include #include "cli.h" #include "media_service.h" #define TAG "AGORA" //#define AUTOCONNECT_WIFI #define CONFIG_WIFI_SSID "aclsemi"//"BEKEN-CES"//"test123"//"biubiu"//"MEGSCREEN_TEST"//"cs-ruowang-2.4G"//"Carl"//"NXIOT" #define CONFIG_WIFI_PASSWORD "ACL8semi"//"1233211234567"//"1234567890"//"87654321"//"987654321"//"wohenruo"//"12345678"//"88888888" #if (CONFIG_SYS_CPU0) #define AGORA_RTC_CMD_CNT (sizeof(s_agora_rtc_commands) / sizeof(struct cli_command)) extern void cli_agora_rtc_test_cmd(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv); static const struct cli_command s_agora_rtc_commands[] = { {"agora_test", "agora_test {audio start|stop appid audio_type sample_rate aec_en}", cli_agora_rtc_test_cmd}, {"agora_test", "agora_test {video start|stop appid video_type}", cli_agora_rtc_test_cmd}, {"agora_test", "agora_test {both start|stop appid audio_type sample_rate video_type aec_en}", cli_agora_rtc_test_cmd}, }; static int agora_rtc_cli_init(void) { return cli_register_commands(s_agora_rtc_commands, AGORA_RTC_CMD_CNT); } /* connect wifi by cli */ #ifdef AUTOCONNECT_WIFI static int netif_event_cb(void *arg, event_module_t event_module, int event_id, void *event_data) { netif_event_got_ip4_t *got_ip; switch (event_id) { case EVENT_NETIF_GOT_IP4: got_ip = (netif_event_got_ip4_t *)event_data; BK_LOGI(TAG, "%s got ip %s.\n", got_ip->netif_if == NETIF_IF_STA ? "STA" : "unknown netif", got_ip->ip); extern void temp_agora_run(void); temp_agora_run(); break; default: BK_LOGI(TAG, "rx event <%d %d>\n", event_module, event_id); break; } return BK_OK; } int wifi_event_cb(void *arg, event_module_t event_module, int event_id, void *event_data) { wifi_event_sta_disconnected_t *sta_disconnected; wifi_event_sta_connected_t *sta_connected; switch (event_id) { case EVENT_WIFI_STA_CONNECTED: sta_connected = (wifi_event_sta_connected_t *)event_data; BK_LOGI(TAG, "STA connected to %s\n", sta_connected->ssid); break; case EVENT_WIFI_STA_DISCONNECTED: sta_disconnected = (wifi_event_sta_disconnected_t *)event_data; BK_LOGI(TAG, "STA disconnected, reason(%d)\n", sta_disconnected->disconnect_reason); break; default: BK_LOGI(TAG, "rx event <%d %d>\n", event_module, event_id); break; } return BK_OK; } static void event_handler_init(void) { BK_LOG_ON_ERR(bk_event_register_cb(EVENT_MOD_WIFI, EVENT_ID_ALL, wifi_event_cb, NULL)); BK_LOG_ON_ERR(bk_event_register_cb(EVENT_MOD_NETIF, EVENT_ID_ALL, netif_event_cb, NULL)); } static void sta_connect(void) { wifi_sta_config_t sta_config = WIFI_DEFAULT_STA_CONFIG(); strncpy(sta_config.ssid, CONFIG_WIFI_SSID, WIFI_SSID_STR_LEN); if (strlen(CONFIG_WIFI_PASSWORD)) { strncpy(sta_config.password, CONFIG_WIFI_PASSWORD, WIFI_PASSWORD_LEN); } BK_LOGI(TAG, "sta ssid:%s password:%s.\n", sta_config.ssid, sta_config.password); BK_LOG_ON_ERR(bk_wifi_sta_set_config(&sta_config)); BK_LOG_ON_ERR(bk_wifi_sta_start()); } #endif //AUTOCONNECT_WIFI #endif extern void user_app_main(void); extern void rtos_set_user_app_entry(beken_thread_function_t entry); extern int bk_cli_init(void); extern void bk_set_jtag_mode(uint32_t cpu_id, uint32_t group_id); void user_app_main(void){ #if (CONFIG_SYS_CPU0) #ifdef AUTOCONNECT_WIFI event_handler_init(); sta_connect(); #endif agora_rtc_cli_init(); #endif } int main(void) { #if (CONFIG_SYS_CPU0) rtos_set_user_app_entry((beken_thread_function_t)user_app_main); #endif bk_init(); media_service_init(); return 0; }