|
int dns_test(void)
{
int ret;
printf("\r\n===== DNS Client Example =====\r\n");
printf("> DNS 1st: %d.%d.%d.%d\r\n",net_info.dns[0],net_info.dns[1],net_info.dns[2],net_info.dns[3]);
printf("> DNS 2nd: %d.%d.%d.%d\r\n",DNS_2nd[0],DNS_2nd[1],DNS_2nd[2],DNS_2nd[3]);
printf("==============================\r\n");
printf("> Example Domain Name : %s\r\n",Domain_name);
if((ret = DNS_run(net_info.dns, Domain_name, destip)) > 0)
{
printf("> 1st DNS Reponsed\r\n");
}
else if((ret != -1) && ((ret = DNS_run(DNS_2nd, Domain_name, destip)) > 0))
{
printf("> 2nd DNS Responsed\r\n");
}
else if(ret == -1)
{
printf("> MAX_DOMAIN_NAME is too small. Should be redefined it. \r\n");
}
else
{
printf("> DNS Failed\r\n");
}
if(ret > 0)
{
printf("> Translated %s to %d.%d.%d.%d\r\n",Domain_name,destip[0],destip[1],destip[2],destip[3]);
return 1;
}
return 0;
}
stdio_init_all();
sleep_ms(2000);
printf("lcd init\n\r");
lcd_SharpMem_io_init(); //init spi cs
// SharpMem_clearDisplay();
u8g2_Setup_ls013b7dh05_144x168_f(&u8g2, U8G2_R0, sharpmem_byte_3wire_hw_spi, sharpmem_gpio_and_delay_cb);
u8g2_InitDisplay(&u8g2); // 根据所选的芯片进行初始化工作,初始化完成后,显示器处于关闭状态
u8g2_SetPowerSave(&u8g2, 0); // 打开显示器
u8g2_SetDrawColor(&u8g2, 0); //设置绘制颜色(反色)
u8g2_ClearDisplay(&u8g2); // 清除显示数据及屏幕
u8g2_ClearBuffer(&u8g2);//清空缓冲区的内容
u8g2_SetFont(&u8g2,u8g2_font_10x20_mr);//设置英文字体
u8g2_DrawStr(&u8g2,20,15,"PING TEST");//输出固定不变的字符串
u8g2_SetFont(&u8g2,u8g2_font_7x14_mr);//设置英文字体
u8g2_DrawStr(&u8g2,0,40,"DNS:218.203.59.116");//输出固定不变的字符串
u8g2_DrawStr(&u8g2,0,60,"Ping Domain Name:");//输出固定不变的字符串
u8g2_DrawStr(&u8g2,20,80,"www.baidu.com");//输出固定不变的字符串
u8g2_SendBuffer(&u8g2);//绘制缓冲区的内容
// SharpMem_clearDisplayBuffer();
// SharpMem_refresh() ;
network_init();
DNS_init(0,ethernet_buf);
add_repeating_timer_ms(1000, repeating_timer_callback, NULL, &timer);
dns_test();
do_ping();
u8g2_DrawStr(&u8g2,0,100,"DNS GetIP:");//输出固定不变的字符串
sprintf(cstr_buf,"%d.%d.%d.%d",destip[0],destip[1],destip[2],destip[3]);
u8g2_DrawStr(&u8g2,20,120,cstr_buf);//输出固定不变的字符串
u8g2_DrawStr(&u8g2,0,140,"PING SUCCESS!");//输出固定不变的字符串
u8g2_SendBuffer(&u8g2);//绘制缓冲区的内容