112 lines
2.8 KiB
C
112 lines
2.8 KiB
C
![]() |
#include <components/log.h>
|
||
|
#include <components/system.h>
|
||
|
#include <os/os.h>
|
||
|
#include <components/shell_task.h>
|
||
|
#include <common/bk_include.h>
|
||
|
#include "gpio_map.h"
|
||
|
#include "gpio_driver.h"
|
||
|
#include <driver/gpio.h>
|
||
|
#include <common/bk_kernel_err.h>
|
||
|
|
||
|
//#include "bk_wifi_netif.h"
|
||
|
#include "bk_wifi.h"
|
||
|
|
||
|
#include <os/str.h>
|
||
|
#include "bk_uart.h"
|
||
|
#include <os/mem.h>
|
||
|
|
||
|
#include <os/os.h>
|
||
|
#include <common/bk_kernel_err.h>
|
||
|
#include <string.h>
|
||
|
//#include "wlan_ui_pub.h"
|
||
|
|
||
|
//#include <lwip/inet.h>
|
||
|
|
||
|
#include <driver/uart.h>
|
||
|
|
||
|
#include "net_client.h"
|
||
|
#define TAG "NET_CK"
|
||
|
|
||
|
//dtim
|
||
|
#include "modules/pm.h"
|
||
|
#include "bk_ps.h"
|
||
|
|
||
|
|
||
|
#define LOGI(...) BK_LOGI(TAG, ##__VA_ARGS__)
|
||
|
#define LOGE(...) BK_LOGE(TAG, ##__VA_ARGS__)
|
||
|
#define LOGW(...) BK_LOGW(TAG, ##__VA_ARGS__)
|
||
|
#define LOGD(...) BK_LOGD(TAG, ##__VA_ARGS__)
|
||
|
|
||
|
static beken_thread_t net_thread_hdl = NULL;
|
||
|
static int is_start = 0;
|
||
|
|
||
|
|
||
|
static void memory_free_show(void)
|
||
|
{
|
||
|
uint32_t total_size,free_size,mini_size;
|
||
|
|
||
|
LOGE("%-5s %-5s %-5s %-5s %-5s\r\n",
|
||
|
"name", "total", "free", "minimum", "peak");
|
||
|
|
||
|
total_size = rtos_get_total_heap_size();
|
||
|
free_size = rtos_get_free_heap_size();
|
||
|
mini_size = rtos_get_minimum_free_heap_size();
|
||
|
LOGE("heap:\t%d\t%d\t%d\t%d\r\n", total_size, free_size, mini_size, total_size - mini_size);
|
||
|
|
||
|
#if CONFIG_PSRAM_AS_SYS_MEMORY
|
||
|
total_size = rtos_get_psram_total_heap_size();
|
||
|
free_size = rtos_get_psram_free_heap_size();
|
||
|
mini_size = rtos_get_psram_minimum_free_heap_size();
|
||
|
LOGI("psram:\t%d\t%d\t%d\t%d\r\n", total_size, free_size, mini_size, total_size - mini_size);
|
||
|
#endif
|
||
|
|
||
|
}
|
||
|
|
||
|
static void net_check_task(void *arg)
|
||
|
{
|
||
|
while (is_start) {
|
||
|
rtos_delay_milliseconds(30000);
|
||
|
int err = kNoErr;
|
||
|
wifi_link_status_t link_status = {0};
|
||
|
os_memset(&link_status, 0x0, sizeof(link_status));
|
||
|
err = bk_wifi_sta_get_link_status(&link_status);
|
||
|
if (err != kNoErr)
|
||
|
{
|
||
|
os_printf("get sta link status fail!\n");
|
||
|
}
|
||
|
|
||
|
LOGE("RSSI:%d\n", link_status.rssi);
|
||
|
|
||
|
netif_ip4_config_t sta_ip4_info = {0};
|
||
|
err = bk_netif_get_ip4_config(NETIF_IF_STA, &sta_ip4_info);
|
||
|
if (err != kNoErr)
|
||
|
{
|
||
|
os_printf("get ip fail!\n");
|
||
|
bk_reboot();
|
||
|
}
|
||
|
memory_free_show();
|
||
|
LOGE("IP=%s,GATE=%s,MASK=%s,DNS=%s\r\n%s", sta_ip4_info.ip, sta_ip4_info.gateway, sta_ip4_info.mask, sta_ip4_info.dns);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
void net_check_start(){
|
||
|
bk_err_t ret = BK_OK;
|
||
|
is_start = 1;
|
||
|
ret = rtos_create_thread(&net_thread_hdl,
|
||
|
3,
|
||
|
"net_check",
|
||
|
(beken_thread_function_t)net_check_task,
|
||
|
2*1024,
|
||
|
NULL);
|
||
|
if (ret != kNoErr) {
|
||
|
warning_prf("create net_check_task fail \r\n");
|
||
|
net_thread_hdl = NULL;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void net_check_stop(){
|
||
|
is_start = 0;
|
||
|
}
|