void act_nset_q(int8 num) { wiz_NetInfo ni; if(num == 1) { GetNetInfo(&ni); if(ni.DHCP > NETINFO_STATIC) MAKE_TCMD_CHAR(atci.tcmd.arg1, 'D'); else MAKE_TCMD_CHAR(atci.tcmd.arg1, 'S'); CMD_RESP_RET(RET_OK, VAL_NONE); } else if(num > 1) { dhcp_get_storage(&ni); switch(num) { case 2: MAKE_TCMD_ADDR(atci.tcmd.arg1, ni.IP[0], ni.IP[1], ni.IP[2], ni.IP[3]); break; case 3: MAKE_TCMD_ADDR(atci.tcmd.arg1, ni.SN[0], ni.SN[1], ni.SN[2], ni.SN[3]); break; case 4: MAKE_TCMD_ADDR(atci.tcmd.arg1, ni.GW[0], ni.GW[1], ni.GW[2], ni.GW[3]); break; case 5: MAKE_TCMD_ADDR(atci.tcmd.arg1, ni.DNS[0], ni.DNS[1], ni.DNS[2], ni.DNS[3]); break; case 6: CMD_RESP_RET(RET_NOT_ALLOWED, VAL_NONE); } CMD_RESP_RET(RET_OK, VAL_NONE); } else { GetNetInfo(&ni); if(ni.DHCP > NETINFO_STATIC) MAKE_TCMD_CHAR(atci.tcmd.arg1, 'D'); else MAKE_TCMD_CHAR(atci.tcmd.arg1, 'S'); dhcp_get_storage(&ni); MAKE_TCMD_ADDR(atci.tcmd.arg2, ni.IP[0], ni.IP[1], ni.IP[2], ni.IP[3]); MAKE_TCMD_ADDR(atci.tcmd.arg3, ni.SN[0], ni.SN[1], ni.SN[2], ni.SN[3]); MAKE_TCMD_ADDR(atci.tcmd.arg4, ni.GW[0], ni.GW[1], ni.GW[2], ni.GW[3]); MAKE_TCMD_ADDR(atci.tcmd.arg5, ni.DNS[0], ni.DNS[1], ni.DNS[2], ni.DNS[3]); CMD_RESP_RET(RET_OK, VAL_NONE); } }
void act_nset_a(int8 mode, uint8 *ip, uint8 *sn, uint8 *gw, uint8 *dns1, uint8 *dns2) { wiz_NetInfo ni = {0,}; if(ip) memcpy(ni.IP, ip, 4); if(sn) memcpy(ni.SN, sn, 4); if(gw) memcpy(ni.GW, gw, 4); if(dns1) memcpy(ni.DNS, dns1, 4); if(dns2) { MAKE_TCMD_DIGIT(atci.tcmd.arg1, 6); CMD_RESP_RET(RET_NOT_ALLOWED, VAL_NONE); } if(mode == 'S') { if(dhcp_static_mode(&ni) != RET_OK) { dhcp_set_storage(&ni); SetNetInfo(&ni); } } else if(mode == 'D') { dhcp_set_storage(&ni); dhcp_alarm_start(NULL); } else { dhcp_set_storage(&ni); GetNetInfo(&ni); if(ni.DHCP == NETINFO_STATIC) SetNetInfo(&ni); } CMD_RESP_RET(RET_OK, VAL_NONE); }
void act_nmac_q(void) { wiz_NetInfo ni = {0,}; GetNetInfo(&ni); sprintf((char*)atci.tcmd.arg1, "%d:%d:%d:%d:%d:%d", ni.Mac[0], ni.Mac[1], ni.Mac[2], ni.Mac[3], ni.Mac[4], ni.Mac[5]); CMD_RESP_RET(RET_OK, VAL_NONE); }
int8 dhcp_alarm_start(uint8 *saved_ip) { GetNetInfo(&workinfo); if(workinfo.DHCP > NETINFO_STATIC) { DBGA("Already DHCP Mode(%d)", workinfo.DHCP); return RET_NOK; } else DBG("DHCP Start"); SET_STATE(DHCP_STATE_INIT); di.action = DHCP_ACT_START; memset(&workinfo, 0, sizeof(workinfo)); if(saved_ip) memcpy(workinfo.IP, saved_ip, 4); workinfo.DHCP = NETINFO_DHCP_BUSY; SetNetInfo(&workinfo); if(dhcp_alarm) alarm_set(10, dhcp_alarm_cb, 0); return RET_OK; }
void DisplayNetInfo(void) { GetNetInfo(&display_NetInfo); printf("============================================\r\n"); printf(" HTTP Client Net Config Information\r\n"); printf("============================================\r\n"); printf("MAC ADDRESS : \r\n"); //display MAC addr printf("%02x.%02x.%02x.%02x.%02x.%02x\r\n",display_NetInfo.Mac[0],display_NetInfo.Mac[1],display_NetInfo.Mac[2],display_NetInfo.Mac[3],display_NetInfo.Mac[4],display_NetInfo.Mac[5]); printf("SUBNET MASK : \r\n"); //display subnet printf("%d.%d.%d.%d\r\n",display_NetInfo.Subnet[0],display_NetInfo.Subnet[1],display_NetInfo.Subnet[2],display_NetInfo.Subnet[3]); printf("G/W IP ADDRESS : \r\n"); //display W5200's IP addr printf("%d.%d.%d.%d\r\n",display_NetInfo.IP[0],display_NetInfo.IP[1],display_NetInfo.IP[2],display_NetInfo.IP[3]); printf("LOCAL IP ADDRESS : \r\n"); //display W5200's G/W printf("%d.%d.%d.%d\r\n",display_NetInfo.Gateway[0],display_NetInfo.Gateway[1],display_NetInfo.Gateway[2],display_NetInfo.Gateway[3]); printf("============================================\r\n"); }
int8 dhcp_static_mode(wiz_NetInfo *net) { wiz_NetInfo cur; if(net == NULL) { DBG("NULL arg"); return RET_NOK; } GetNetInfo(&cur); if(cur.DHCP == NETINFO_STATIC) { DBG("Already Static Mode"); return RET_NOK; } di.action = DHCP_ACT_NONE; SET_STATE(DHCP_STATE_INIT); if(net->IP[0]!=0 || net->IP[1]!=0 || net->IP[2]!=0 || net->IP[3]!=0) memcpy(storage.IP, net->IP, 4); else memcpy(net->IP, storage.IP, 4); if(net->SN[0]!=0 || net->SN[1]!=0 || net->SN[2]!=0 || net->SN[3]!=0) memcpy(storage.SN, net->SN, 4); else memcpy(net->SN, storage.SN, 4); if(net->GW[0]!=0 || net->GW[1]!=0 || net->GW[2]!=0 || net->GW[3]!=0) memcpy(storage.GW, net->GW, 4); else memcpy(net->GW, storage.GW, 4); if(net->DNS[0]!=0 || net->DNS[1]!=0 || net->DNS[2]!=0 || net->DNS[3]!=0) memcpy(storage.DNS, net->DNS, 4); else memcpy(net->DNS, storage.DNS, 4); net->DHCP = NETINFO_STATIC; SetNetInfo(net); if(dhcp_alarm) alarm_del(dhcp_alarm_cb, -1); //send_checker_NB(); return RET_OK; }
void WIZ_Config(void) { uint8 i; wiz_NetInfo netinfo; Reset_W5200(); wizInit(); for(i=0; i<4; i++){ netinfo.Mac[i] = Mac[i]; printf("MAC[%d]: 0x%2x\r\n", i, Mac[i]); netinfo.IP[i] = IP[i]; netinfo.Subnet[i] = Subnet[i]; netinfo.Gateway[i] = Gateway[i]; netinfo.DNSServerIP[i] = DNSServerIP[i]; } netinfo.Mac[i] = Mac[i]; printf("MAC[%d]: 0x%2x\r\n", i, Mac[i]); i++; netinfo.Mac[i] = Mac[i]; printf("MAC[%d]: 0x%2x\r\n", i, Mac[i]); SetNetInfo(&netinfo); printf("\r\n--------------------------------------- \r\n"); printf("W5200E01-M3 \r\n"); printf("Network Configuration Information \r\n"); printf("--------------------------------------- "); GetNetInfo(&netinfo); printf("\r\nMAC : %.2X.%.2X.%.2X.%.2X.%.2X.%.2X", netinfo.Mac[0],netinfo.Mac[1],netinfo.Mac[2],netinfo.Mac[3],netinfo.Mac[4],netinfo.Mac[5]); printf("\r\nIP : %d.%d.%d.%d", netinfo.IP[0],netinfo.IP[1],netinfo.IP[2],netinfo.IP[3]); printf("\r\nSN : %d.%d.%d.%d", netinfo.Subnet[0],netinfo.Subnet[1],netinfo.Subnet[2],netinfo.Subnet[3]); printf("\r\nGW : %d.%d.%d.%d", netinfo.Gateway[0],netinfo.Gateway[1],netinfo.Gateway[2],netinfo.Gateway[3]); printf("\r\nDNS server : %d.%d.%d.%d", netinfo.DNSServerIP[0],netinfo.DNSServerIP[1],netinfo.DNSServerIP[2],netinfo.DNSServerIP[3]); }
/******************************************************************************* * Function Name : Main_Menu * Description : Display/Manage a Menu on HyperTerminal Window * Input : None * Output : None * Return : None *******************************************************************************/ void Main_Menu(void) { static char choice[3]; static char subject[32], msg[256], sender[32], passwd[32], recipient[32], encodedText[256]; static bool bTreat; static u8 Sip[4]; static char key = 0; static wiz_NetInfo netinfo; while (1) { /* Display Menu on HyperTerminal Window */ bTreat = (bool)RESET ; SerialPutString("\r\n====================== STM32-Discovery ===================\r\n"); SerialPutString("This Application is basic example of UART interface with\r\n"); SerialPutString("Windows Hyper Terminal. \r\n"); SerialPutString("\r\n==========================================================\r\n"); SerialPutString(" APPLICATION MENU :\r\n"); SerialPutString("\r\n==========================================================\r\n\n"); SerialPutString(" 1 - Set LD1 on \r\n"); SerialPutString(" 2 - Set LD1 off \r\n"); SerialPutString(" 3 - Show network setting\r\n"); SerialPutString(" 4 - Set network setting\r\n"); SerialPutString(" 5 - Run TCP Loopback\r\n"); SerialPutString(" 6 - Run UDP Loopback\r\n"); SerialPutString(" 7 - DNS test\r\n"); SerialPutString(" 8 - BASE64 test\r\n"); SerialPutString(" 9 - Send Mail\r\n"); SerialPutString("Enter your choice : "); GetInputString(choice); /* Set LD1 on */ if (strcmp(choice,"1")== 0) { bTreat = (bool)SET; LED3_onoff(ON); LED4_onoff(ON); } /* Set LD1 off */ if ((strcmp(choice,"2") == 0)) { bTreat = (bool)SET; LED3_onoff(OFF); LED4_onoff(OFF); } if (strcmp(choice,"3") == 0) { bTreat = (bool)SET; GetNetInfo(&netinfo); printf("\r\nIP : %d.%d.%d.%d", netinfo.IP[0],netinfo.IP[1],netinfo.IP[2],netinfo.IP[3]); printf("\r\nSN : %d.%d.%d.%d", netinfo.Subnet[0],netinfo.Subnet[1],netinfo.Subnet[2],netinfo.Subnet[3]); printf("\r\nGW : %d.%d.%d.%d", netinfo.Gateway[0],netinfo.Gateway[1],netinfo.Gateway[2],netinfo.Gateway[3]); printf("\r\nDNS server : %d.%d.%d.%d", netinfo.DNSServerIP[0],netinfo.DNSServerIP[1],netinfo.DNSServerIP[2],netinfo.DNSServerIP[3]); } if (strcmp(choice,"4") == 0) { bTreat = (bool)SET; // IP address SerialPutString("\r\nIP address : "); GetInputString(msg); if(!VerifyIPAddress(msg, netinfo.IP)) { SerialPutString("\aInvalid."); } // Subnet mask SerialPutString("\r\nSubnet mask : "); GetInputString(msg); if(!VerifyIPAddress(msg, netinfo.Subnet)) { SerialPutString("\aInvalid."); } // gateway address SerialPutString("\r\nGateway address : "); GetInputString(msg); if(!VerifyIPAddress(msg, netinfo.Gateway)) { SerialPutString("\aInvalid."); } // DNS address SerialPutString("\r\nDNS address : "); GetInputString(msg); if(!VerifyIPAddress(msg, netinfo.DNSServerIP)) { SerialPutString("\aInvalid."); } printf("\r\nIP : %d.%d.%d.%d", netinfo.IP[0],netinfo.IP[1],netinfo.IP[2],netinfo.IP[3]); printf("\r\nSN : %d.%d.%d.%d", netinfo.Subnet[0],netinfo.Subnet[1],netinfo.Subnet[2],netinfo.Subnet[3]); printf("\r\nGW : %d.%d.%d.%d", netinfo.Gateway[0],netinfo.Gateway[1],netinfo.Gateway[2],netinfo.Gateway[3]); printf("\r\nDNS server : %d.%d.%d.%d", netinfo.DNSServerIP[0],netinfo.DNSServerIP[1],netinfo.DNSServerIP[2],netinfo.DNSServerIP[3]); SetNetInfo(&netinfo); } if (strcmp(choice,"5") == 0) { bTreat = (bool)SET; SerialPutString("\r\nRun TCP loopback"); printf("\r\nRun TCP loopback, port number [%d] is listened", (u16)TCP_LISTEN_PORT); SerialPutString("\r\nTo Exit, press [Q]"); while(1) { if ((SerialKeyPressed((char*)&key) == 1) && (key == 'Q')) { SerialPutString("\r\n Stop "); break; } loopback_tcps(7, (u16)TCP_LISTEN_PORT); } } if (strcmp(choice,"6") == 0) { bTreat = (bool)SET; SerialPutString("\r\nRun UDP loopback"); printf("\r\nRun UDP loopback, port number [%d] is listened", (u16)UDP_LISTEN_PORT); SerialPutString("\r\nTo Exit, press [Q]"); while(1) { if ((SerialKeyPressed((char*)&key) == 1) && (key == 'Q')) { SerialPutString("\r\n Stop "); break; } loopback_udp(7, (u16)UDP_LISTEN_PORT); } } if (strcmp(choice,"7")== 0) { bTreat = (bool)SET; SerialPutString("\r\nServer address : "); GetInputString(msg); SerialPutString("URL = "); SerialPutString(msg); if (dns_query(SOCK_DNS, (void *)msg, Sip) == 1) { printf("\r\nSIP : %d.%d.%d.%d", (u16)Sip[0],(u16)Sip[1],(u16)Sip[2],(u16)Sip[3]); }else { SerialPutString("\n\r DNS fail"); } } if (strcmp(choice,"8")== 0) { bTreat = (bool)SET; memset(encodedText, '\0', 256); SerialPutString("\r\n"); SerialPutString(" 1 - BASE64 Encode \r\n"); SerialPutString(" 2 - BASE64 Decode \r\n"); SerialPutString("Enter your choice : "); GetInputString(choice); if (strcmp(choice,"1")== 0) { SerialPutString("Type Plain Text\r\n"); GetInputString(msg); base64_encode(msg, strlen(msg)+1, encodedText); SerialPutString("Encoded Text\r\n"); printf("%s\r\n", encodedText); }else if(strcmp(choice,"2")== 0){ SerialPutString("Type Encoded Text\r\n"); GetInputString(msg); base64_decode(msg, (void *)encodedText, strlen(msg)); SerialPutString("Decoded Text\r\n"); printf("%s\r\n", encodedText); } } if (strcmp(choice,"9")== 0) { bTreat = (bool)SET; SerialPutString("\r\nServer address : "); GetInputString(msg); SerialPutString("URL = "); SerialPutString(msg); // DNS if (dns_query(SOCK_DNS, (void *)msg, Sip) == 1) { printf("\r\nSIP : %d.%d.%d.%d", (u16)Sip[0],(u16)Sip[1],(u16)Sip[2],(u16)Sip[3]); while(1) { SerialPutString("\r\nType a Sender: "); GetInputString(sender); SerialPutString("Type a Password: "******"Type a Recipient: "); GetInputString(recipient); SerialPutString("Type a Subject: "); GetInputString(subject); SerialPutString("Type a message: "); GetInputString(msg); send_mail(SOCK_SMTP, (void *)sender, (void *) passwd, (void *)recipient, (void *)subject, (void *)msg, Sip); SerialPutString("\r\nIf you want send another message? [YES]: any key, [NO]: Q"); key = GetKey(); if (key == 'Q') { SerialPutString("\r\n Stop "); break; } } }else { SerialPutString("\r\nDNS error"); } } /* OTHERS CHOICE*/ if (bTreat == (bool)RESET) { SerialPutString(" wrong choice \r\n"); } } /* While(1)*/ }/* Main_Menu */
static int8 mn_set_network(menu_ctrl mctrl, int8 *mbuf) { #define INPUT_GUIDE(name_v) \ printf("Enter new "name_v" [xxx.xxx.xxx.xxx] or 'n' key to skip\r\n") #define NEXT_GUIDE(name_v, addr_v) \ do {INPUT_GUIDE(name_v); \ printf("Current "name_v" is (%d.%d.%d.%d)\r\n", \ addr_v[0], addr_v[1], addr_v[2], addr_v[3]); \ } while(0) #define SET_DONE_GUIDE(name_v, addr_v) \ printf("New "name_v" is (%d.%d.%d.%d)\r\n\r\n", \ addr_v[0], addr_v[1], addr_v[2], addr_v[3]) #define SET_STAGE(cur_name_v, next_name_v, cur_addr_v, next_addr_v) \ do {uint8 _tmp[4], _next[4]; \ if(next_addr_v != NULL) memcpy(_next, next_addr_v, 4); \ if(mbuf[0] == 'n') { \ stage++; \ if(next_addr_v != NULL) NEXT_GUIDE(next_name_v, _next); \ } else { \ ret = ip_check(mbuf, _tmp); \ if(ret == RET_OK) { \ memcpy(cur_addr_v, _tmp, 4); \ stage++; \ SetNetInfo(&netinfo); \ SET_DONE_GUIDE(cur_name_v, cur_addr_v); \ if(next_addr_v != NULL) NEXT_GUIDE(next_name_v, _next); \ } else { \ printf("wrong input(%s)\r\n\r\n", mbuf); \ INPUT_GUIDE(cur_name_v); \ } \ } \ } while(0) int8 ret; static uint8 stage = 0; static wiz_NetInfo netinfo; GetNetInfo(&netinfo); if(mctrl == MC_START) { NEXT_GUIDE("IP Address", netinfo.ip); } else if(mctrl == MC_END) { stage = 0; } else if(mctrl == MC_DATA) { switch(stage) { case 0: SET_STAGE("IP Address", "SN Mask", netinfo.ip, netinfo.sn); break; case 1: SET_STAGE("SN Mask", "GW Address", netinfo.sn, netinfo.gw); break; case 2: SET_STAGE("GW Address", "DNS Address", netinfo.gw, netinfo.dns); break; case 3: SET_STAGE("DNS Address", "", netinfo.dns, NULL); if(stage > 3) return RET_OK; break; } } return RET_NOK; #undef INPUT_GUIDE #undef NEXT_GUIDE #undef SET_DONE_GUIDE #undef SET_STAGE }
void WIZ_Config(void) { uint8 i; wiz_NetInfo netinfo; extern u_char GET_SN_MASK[4]; /**< Subnet mask received from the DHCP server */ extern u_char GET_GW_IP[4]; /**< Gateway ip address received from the DHCP server */ extern u_char GET_SIP[4]; /**< Local ip address received from the DHCP server */ Reset_W5200(); wizInit(); if(Enable_DHCP == OFF){ for(i=0; i<4; i++){ netinfo.Mac[i] = Mac[i]; netinfo.IP[i] = IP[i]; netinfo.Subnet[i] = Subnet[i]; netinfo.Gateway[i] = Gateway[i]; netinfo.DNSServerIP[i] = DNSServerIP[i]; } netinfo.Mac[i] = Mac[i]; i++; netinfo.Mac[i] = Mac[i]; } else{ for(i=0; i<6; i++){ SRC_MAC_ADDR[i] = Mac[i]; } printf("Delay for 2 Seconds..\r\n"); Delay_ms(2000); // Set DHCP init_dhcp_client(SOCK_DHCP, wizSWReset, wizSWReset); getIP_DHCPS(); for(i=0; i<4; i++){ netinfo.Mac[i] = SRC_MAC_ADDR[i]; netinfo.IP[i] = GET_SIP[i]; netinfo.Subnet[i] = GET_SN_MASK[i]; netinfo.Gateway[i] = GET_GW_IP[i]; netinfo.DNSServerIP[i] = GET_DNS_IP[i]; } netinfo.Mac[i] = SRC_MAC_ADDR[i]; i++; netinfo.Mac[i] = SRC_MAC_ADDR[i]; } SetNetInfo(&netinfo); printf("\r\n--------------------------------------- \r\n"); printf("W5200E01-M3 \r\n"); printf("Network Configuration Information \r\n"); printf("--------------------------------------- "); GetNetInfo(&netinfo); printf("\r\nMAC : %.2X.%.2X.%.2X.%.2X.%.2X.%.2X", netinfo.Mac[0],netinfo.Mac[1],netinfo.Mac[2],netinfo.Mac[3],netinfo.Mac[4],netinfo.Mac[5]); printf("\r\nIP : %d.%d.%d.%d", netinfo.IP[0],netinfo.IP[1],netinfo.IP[2],netinfo.IP[3]); printf("\r\nSN : %d.%d.%d.%d", netinfo.Subnet[0],netinfo.Subnet[1],netinfo.Subnet[2],netinfo.Subnet[3]); printf("\r\nGW : %d.%d.%d.%d", netinfo.Gateway[0],netinfo.Gateway[1],netinfo.Gateway[2],netinfo.Gateway[3]); printf("\r\nDNS server : %d.%d.%d.%d", netinfo.DNSServerIP[0],netinfo.DNSServerIP[1],netinfo.DNSServerIP[2],netinfo.DNSServerIP[3]); }
/******************************************************************************* * Function Name : Main_Menu * Description : Display/Manage a Menu on HyperTerminal Window * Input : None * Output : None * Return : None *******************************************************************************/ void Main_Menu(void) { static char choice[3]; static char msg[256]; static bool bTreat; static u8 Sip[4]; static char key = 0; static wiz_NetInfo netinfo; while (1) { /* Display Menu on HyperTerminal Window */ bTreat = (bool)RESET ; SerialPutString("\r\n====================== STM32-Discovery ===================\r\n"); SerialPutString("This Application is basic example of UART interface with\r\n"); SerialPutString("Windows Hyper Terminal. \r\n"); SerialPutString("\r\n==========================================================\r\n"); SerialPutString(" APPLICATION MENU :\r\n"); SerialPutString("\r\n==========================================================\r\n\n"); SerialPutString(" 1 - Set LD1 on \r\n"); SerialPutString(" 2 - Set LD1 off \r\n"); SerialPutString(" 3 - Show network setting\r\n"); SerialPutString(" 4 - Set network setting\r\n"); SerialPutString(" 5 - Run TCP Loopback\r\n"); SerialPutString(" 6 - Run UDP Loopback\r\n"); SerialPutString(" 7 - DNS test\r\n"); SerialPutString(" 8 - Twitter\r\n"); SerialPutString("Enter your choice : "); GetInputString(choice); /* Set LD1 on */ if (strcmp(choice,"1")== 0) { bTreat = (bool)SET; LED3_onoff(ON); LED4_onoff(ON); } /* Set LD1 off */ if ((strcmp(choice,"2") == 0)) { bTreat = (bool)SET; LED3_onoff(OFF); LED4_onoff(OFF); } if (strcmp(choice,"3") == 0) { bTreat = (bool)SET; GetNetInfo(&netinfo); printf("\r\nIP : %d.%d.%d.%d", netinfo.IP[0],netinfo.IP[1],netinfo.IP[2],netinfo.IP[3]); printf("\r\nSN : %d.%d.%d.%d", netinfo.Subnet[0],netinfo.Subnet[1],netinfo.Subnet[2],netinfo.Subnet[3]); printf("\r\nGW : %d.%d.%d.%d", netinfo.Gateway[0],netinfo.Gateway[1],netinfo.Gateway[2],netinfo.Gateway[3]); printf("\r\nDNS server : %d.%d.%d.%d", netinfo.DNSServerIP[0],netinfo.DNSServerIP[1],netinfo.DNSServerIP[2],netinfo.DNSServerIP[3]); } if (strcmp(choice,"4") == 0) { bTreat = (bool)SET; // IP address SerialPutString("\r\nIP address : "); GetInputString(msg); if(!VerifyIPAddress(msg, netinfo.IP)) { SerialPutString("\aInvalid."); } // Subnet mask SerialPutString("\r\nSubnet mask : "); GetInputString(msg); if(!VerifyIPAddress(msg, netinfo.Subnet)) { SerialPutString("\aInvalid."); } // gateway address SerialPutString("\r\nGateway address : "); GetInputString(msg); if(!VerifyIPAddress(msg, netinfo.Gateway)) { SerialPutString("\aInvalid."); } // DNS address SerialPutString("\r\nDNS address : "); GetInputString(msg); if(!VerifyIPAddress(msg, netinfo.DNSServerIP)) { SerialPutString("\aInvalid."); } printf("\r\nIP : %d.%d.%d.%d", netinfo.IP[0],netinfo.IP[1],netinfo.IP[2],netinfo.IP[3]); printf("\r\nSN : %d.%d.%d.%d", netinfo.Subnet[0],netinfo.Subnet[1],netinfo.Subnet[2],netinfo.Subnet[3]); printf("\r\nGW : %d.%d.%d.%d", netinfo.Gateway[0],netinfo.Gateway[1],netinfo.Gateway[2],netinfo.Gateway[3]); printf("\r\nDNS server : %d.%d.%d.%d", netinfo.DNSServerIP[0],netinfo.DNSServerIP[1],netinfo.DNSServerIP[2],netinfo.DNSServerIP[3]); SetNetInfo(&netinfo); } if (strcmp(choice,"5") == 0) { bTreat = (bool)SET; SerialPutString("\r\nRun TCP loopback"); printf("\r\nRun TCP loopback, port number [%d] is listened", (u16)TCP_LISTEN_PORT); SerialPutString("\r\nTo Exit, press [Q]"); while(1) { if ((SerialKeyPressed((char*)&key) == 1) && (key == 'Q')) { SerialPutString("\r\n Stop "); break; } loopback_tcps(7, (u16)TCP_LISTEN_PORT); } } if (strcmp(choice,"6") == 0) { bTreat = (bool)SET; SerialPutString("\r\nRun UDP loopback"); printf("\r\nRun UDP loopback, port number [%d] is listened", (u16)UDP_LISTEN_PORT); SerialPutString("\r\nTo Exit, press [Q]"); while(1) { if ((SerialKeyPressed((char*)&key) == 1) && (key == 'Q')) { SerialPutString("\r\n Stop "); break; } loopback_udp(7, (u16)UDP_LISTEN_PORT); } } if (strcmp(choice,"7")== 0) { bTreat = (bool)SET; SerialPutString("\r\nServer address : "); GetInputString(msg); SerialPutString("URL = "); SerialPutString(msg); if (dns_query(SOCK_DNS, (void *)msg, Sip) == 1) { printf("\r\nSIP : %d.%d.%d.%d", (u16)Sip[0],(u16)Sip[1],(u16)Sip[2],(u16)Sip[3]); }else { SerialPutString("\n\r DNS fail"); } } if (strcmp(choice,"8")== 0) { bTreat = (bool)SET; // DNS if (dns_query(SOCK_DNS, LIB_DOMAIN, Sip) == 1) { printf("\r\nSIP : %d.%d.%d.%d", (u16)Sip[0],(u16)Sip[1],(u16)Sip[2],(u16)Sip[3]); while(1) { /* sprintf(msg, "Hello, World [%d] from wiz820io", twit_cnt++); SerialPutString("\r\nSend Twitter Message: "); SerialPutString(msg); */ SerialPutString("\r\nType a message: "); GetInputString(msg); Twitter_Post(SOCK_TWITTER, (void *)msg, Sip); SerialPutString("\r\nIf you want send another message? [YES]: any key, [NO]: Q"); key = GetKey(); if (key == 'Q') { SerialPutString("\r\n Stop "); break; } } }else { SerialPutString("\r\nDNS error"); } } if (strcmp(choice,"9") == 0) { uint8 l_ip[4] = {222, 98, 173, 237}; bTreat = (bool)SET; SerialPutString("\r\nRun TCP loopback [Client]"); SerialPutString("\r\nTo Exit, press [Q]"); while(1) { if ((SerialKeyPressed((char*)&key) == 1) && (key == 'Q')) { SerialPutString("\r\n Stop "); break; } TCPClientOpen(7, 5000, l_ip, 5000); Delay_ms(3000); TCPClose(7); Delay_ms(3000); } } /* OTHERS CHOICE*/ if (bTreat == (bool)RESET) { SerialPutString(" wrong choice \r\n"); } } /* While(1)*/ }/* Main_Menu */