WIZnet Developer Forum

Using WizFi 210 with Arduino

I am using the Arduino UNOr3 and ArduIDE 1.6.4 and trying to compile the example code for Basic Server Test.

Using the Arduino WizFi shield.

/******************************************************************
 WizFiShield Basic Server Test Example
 
 This sketch makes the server socket and accpet TCP connection from the client 
 
 Circuit:
 WizFiShield connected to Arduino via SPI
 
 RST: pin 2  // Output
 DRDY: pin 3  // Input
 CSB: pin 4  // output

 MOSI: pin 11  // output
 MISO: pin 12  // input
 SCK: pin 13  // out
 
 Created 27 Sep. 2012
 by James YS Kim  (jameskim@wiznet.co.kr, javakys@gmail.com)
 
 Modified 27 May. 2013
 by Jinbuhm Kim  (jbkim@wiznet.co.kr, jinbuhm.kim@gmail.com)

*****************************************************************/

// WizFi210 communicates using SPI, so include the SPI library:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SPI.h>
#include <WizFi2x0.h>
#include <WizFiClient.h>
#include <WizFiServer.h>
#include <TimerOne.h>


#define SSID 		"borsuk"        // SSID of your AP
#define Key 	  "1234678901234567890123456"  // Key or Passphrase
// Wi-Fi security option (NO_SECURITY, WEP_SECURITY, WPA_SECURITY, WPA2PSK_SECURITY)
#define Security        WPA_SECURITY

unsigned int SrcPort = 50000;    // listening port number

WizFi2x0Class myWizFi;
WizFiClient myClient[4];//(SIP, ServerPort);
WizFiServer myServer(SrcPort);
TimeoutClass ConnectInterval;

boolean Wifi_setup = false;

///////////////////////////////
// 1msec Timer
void Timer1_ISR()
{
  myWizFi.ReplyCheckTimer.CheckIsTimeout();
}
//
//////////////////////////////

void setup() {
  byte retval, i;
  
  Serial.begin(9600);
  Serial.println("\r\nSerial Init");
  
  for(i=0; i<4; i++)
    myClient[i] =  WizFiClient();
  myWizFi.begin();
 
  ConnectInterval.init();
  
  // Timer1 Initialize
  Timer1.initialize(1000); // 1msec
  Timer1.attachInterrupt(Timer1_ISR);
 
  myWizFi.SendSync();
  myWizFi.ReplyCheckTimer.TimerStart(3000);
  
  Serial.println("Send Sync data");
  
  while(1)
  {
    if(myWizFi.CheckSyncReply())
    {
      myWizFi.ReplyCheckTimer.TimerStop();
      Serial.println("Rcvd Sync data");
      break;
    }
    if(myWizFi.ReplyCheckTimer.GetIsTimeout())
    {
      Serial.println("Rcving Sync Timeout!!");
      // Nothing to do forever;
      for(;;)
      ;
    }
  }

  ////////////////////////////////////////////////////////////////////////////
  // AP association  
  while(1)
  {
    byte tmpstr[32];
    
    retval = myWizFi.associate(SSID, Key, Security, true);
    
    if(retval == 1){
      myWizFi.GetSrcIPAddr(tmpstr);
      Serial.println("AP association Success");
      Serial.print("MY IPAddress: ");
      Serial.println((char *)tmpstr);
      Wifi_setup = true;
      break;
    }else{
      Serial.println("AP association Failed");
    }
  }
  
  if(myServer.begin())
    Serial.println("Server Listen OK");
  else
    Serial.println("Server Listen Failed");
}

void loop()
{
  uint8_t i;
  byte rcvdBuf[129];
 
  memset(rcvdBuf, 0, 129);
  
  if(Wifi_setup)
  {  
    myWizFi.RcvPacket();
    for(i=0; i<4; i++)
    {
      if(myClient[i].available()){       
         if(myClient[i].read(rcvdBuf))
         {
           Serial.print("CID[");
           Serial.print((char)myClient[i].GetCID());
           Serial.print("]");
           Serial.println((char *)rcvdBuf);
           myClient[i].write(rcvdBuf);
         }
      }
    }
  }
}

The progress is stuck here:

Build options changed, rebuilding all
Using library SPI in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI 
Using library WizFiShield in folder: C:\Users\Damian\Documents\Arduino\libraries\WizFiShield (legacy)
Using library TimerOne in folder: C:\Users\Damian\Documents\Arduino\libraries\TimerOne (legacy)

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Users\Damian\Documents\Arduino\libraries\WizFiShield -IC:\Users\Damian\Documents\Arduino\libraries\TimerOne C:\Users\Damian\AppData\Local\Temp\build1556776878667064971.tmp\WizFiBasicServerTest.cpp -o C:\Users\Damian\AppData\Local\Temp\build1556776878667064971.tmp\WizFiBasicServerTest.cpp.o 
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Users\Damian\Documents\Arduino\libraries\WizFiShield -IC:\Users\Damian\Documents\Arduino\libraries\TimerOne -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\utility C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\SPI.cpp -o C:\Users\Damian\AppData\Local\Temp\build1556776878667064971.tmp\SPI\SPI.cpp.o 
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Users\Damian\Documents\Arduino\libraries\WizFiShield -IC:\Users\Damian\Documents\Arduino\libraries\TimerOne -IC:\Users\Damian\Documents\Arduino\libraries\WizFiShield\utility C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp -o C:\Users\Damian\AppData\Local\Temp\build1556776878667064971.tmp\WizFiShield\HTMLPages.cpp.o 

After I updated to IDE 1.6.5:

Build options changed, rebuilding all C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:5:1: error: 'prog_char' does not name a type prog_char Protocol_Msg[] PROGMEM = "HTTP/1.1 200 OK\r\n"; // "String 0" etc are strings to store - change to suit. ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:6:1: error: 'prog_char' does not name a type prog_char Page1_Line0[] PROGMEM = "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.2//EN\" "; // "String 0" etc are strings to store - change to suit. ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:7:1: error: 'prog_char' does not name a type prog_char Page1_Line1[] PROGMEM = "\"http://www.wapforum.org/DTD/xhtml-mobile 12.dtd\">\r\n"; // "String 0" etc are strings to store - change to suit. ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:8:1: error: 'prog_char' does not name a type prog_char Html_start[] PROGMEM = "<html>\r\n"; // "String 0" etc are strings to store - change to suit. ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:9:1: error: 'prog_char' does not name a type prog_char head_start[] PROGMEM = "<head>\r\n"; // "String 0" etc are strings to store - change to suit. ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:10:1: error: 'prog_char' does not name a type prog_char Page1_Line2[] PROGMEM = "<meta http-equiv=\"Content-Type\" content=\"text/html/>\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:11:1: error: 'prog_char' does not name a type prog_char Content_Msg[] PROGMEM = "Content-Type: text/html\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:12:1: error: 'prog_char' does not name a type prog_char Page1_Line3[] PROGMEM = "<meta name=\"viewport\" content=\"user-scalable=no, initial-scale=5.0,"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:13:1: error: 'prog_char' does not name a type prog_char Page1_Line4[] PROGMEM = " maximum-scale=5.0, minimum-scale=5.0, width=device-width\"/>\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:14:1: error: 'prog_char' does not name a type prog_char head_end[] PROGMEM = "</head>\r\n"; // "String 0" etc are strings to store - change to suit. ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:15:1: error: 'prog_char' does not name a type prog_char Page1_Line5[] PROGMEM = "<body>\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:16:1: error: 'prog_char' does not name a type prog_char new_Line[] PROGMEM = "\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:17:1: error: 'prog_char' does not name a type prog_char Page1_Line6[] PROGMEM = "<h1 align=\"center\">Select </h1>\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:18:1: error: 'prog_char' does not name a type prog_char Page1_Line7[] PROGMEM = "<form>\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:19:1: error: 'prog_char' does not name a type prog_char Page1_Line8[] PROGMEM = "<table width=\"100%\"><tr><td colspan=3 align=\"center\"><h1>Press button you want</h1></td></tr><tr>"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:20:1: error: 'prog_char' does not name a type prog_char Page1_Line8_cont[] PROGMEM = "<td width=\"40%\"></td><td width=\"20%\" bgcolor=\"silver\" align=\"center\"><h1><button "; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:21:1: error: 'prog_char' does not name a type prog_char Page1_Line8_cont2[] PROGMEM = "name=\"command\" value=\"FW_CMD\">forward</button></h1></td><td width=\"40%\"></td></tr>\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:22:1: error: 'prog_char' does not name a type prog_char Middle_Line[] PROGMEM = "<tr><td width= \"40%\" align=\"right\"><h1><button name=\"command\" value=\"LEFT_CMD\">LEFT</button></h1></td>"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:23:1: error: 'prog_char' does not name a type prog_char Middle_Line_cont[] PROGMEM = "<td width=\"20%\"></td><td width= \"40%\" align=\"left\"><h1><button name=\"command\" value=\"RIGHT_CMD\">"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:24:1: error: 'prog_char' does not name a type prog_char Middle_Line_cont2[] PROGMEM = "RIGHT</button></h1></td></tr>\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:25:1: error: 'prog_char' does not name a type prog_char Page1_Line9[] PROGMEM = "<tr><td width=\"40%\"></td><td width= \"20%\" bgcolor=\"#c3c3c3\" align=\"center\"><h1><button name=\"command\" "; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:26:1: error: 'prog_char' does not name a type prog_char Page1_Line9_cont[] PROGMEM = "value=\"BW_CMD\">backward</button></h1></td><td width=\"40%\"></td></tr></table>\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:27:1: error: 'prog_char' does not name a type prog_char Page1_Line10[] PROGMEM = "</form>\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:28:1: error: 'prog_char' does not name a type prog_char Page1_Line11[] PROGMEM = "</body>\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:29:1: error: 'prog_char' does not name a type prog_char Page1_Line12[] PROGMEM = "<table width=\"100%\"><tr><td colspan=3 align=\"center\"><h1>Press button you want. Battery is low.</h1></td></tr><tr>"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:30:1: error: 'prog_char' does not name a type prog_char Page1_Line13[] PROGMEM = "<table width=\"100%\"><tr><td colspan=3 align=\"center\"><h1>Alert! Battery is too low.</h1></td></tr></table>\r\n"; ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:31:1: error: 'prog_char' does not name a type prog_char Html_end[] PROGMEM = "</html>\r\n"; // "String 0" etc are strings to store - change to suit. ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:34:32: error: variable 'HTML_table' must be const in order to be put into read-only section by means of '__attribute__((progmem))' PROGMEM const char *HTML_table[] = ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:36:2: error: 'Protocol_Msg' was not declared in this scope Protocol_Msg, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:37:2: error: 'Content_Msg' was not declared in this scope Content_Msg, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:38:2: error: 'new_Line' was not declared in this scope new_Line, // 0 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:39:2: error: 'Page1_Line7' was not declared in this scope Page1_Line7, // 6 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:40:2: error: 'Page1_Line8' was not declared in this scope Page1_Line8, // 7 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:41:2: error: 'Page1_Line8_cont' was not declared in this scope Page1_Line8_cont, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:42:2: error: 'Page1_Line8_cont2' was not declared in this scope Page1_Line8_cont2, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:43:2: error: 'Middle_Line' was not declared in this scope Middle_Line, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:44:2: error: 'Middle_Line_cont' was not declared in this scope Middle_Line_cont, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:45:2: error: 'Middle_Line_cont2' was not declared in this scope Middle_Line_cont2, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:46:2: error: 'Page1_Line9' was not declared in this scope Page1_Line9, // 8 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:47:2: error: 'Page1_Line9_cont' was not declared in this scope Page1_Line9_cont, // 8 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:48:2: error: 'Page1_Line10' was not declared in this scope Page1_Line10 // 9 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:51:33: error: variable 'HTML_table2' must be const in order to be put into read-only section by means of '__attribute__((progmem))' PROGMEM const char *HTML_table2[] = ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:53:2: error: 'Protocol_Msg' was not declared in this scope Protocol_Msg, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:54:2: error: 'Content_Msg' was not declared in this scope Content_Msg, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:55:2: error: 'new_Line' was not declared in this scope new_Line, // 0 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:56:2: error: 'Page1_Line7' was not declared in this scope Page1_Line7, // 6 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:57:2: error: 'Page1_Line12' was not declared in this scope Page1_Line12, // 7 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:58:2: error: 'Page1_Line8_cont' was not declared in this scope Page1_Line8_cont, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:59:2: error: 'Page1_Line8_cont2' was not declared in this scope Page1_Line8_cont2, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:60:2: error: 'Middle_Line' was not declared in this scope Middle_Line, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:61:2: error: 'Middle_Line_cont' was not declared in this scope Middle_Line_cont, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:62:2: error: 'Middle_Line_cont2' was not declared in this scope Middle_Line_cont2, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:63:2: error: 'Page1_Line9' was not declared in this scope Page1_Line9, // 8 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:64:2: error: 'Page1_Line9_cont' was not declared in this scope Page1_Line9_cont, // 8 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:65:2: error: 'Page1_Line10' was not declared in this scope Page1_Line10 // 9 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:68:33: error: variable 'HTML_table3' must be const in order to be put into read-only section by means of '__attribute__((progmem))' PROGMEM const char *HTML_table3[] = ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:70:2: error: 'Protocol_Msg' was not declared in this scope Protocol_Msg, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:71:2: error: 'Content_Msg' was not declared in this scope Content_Msg, ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:72:2: error: 'new_Line' was not declared in this scope new_Line, // 0 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:73:2: error: 'Page1_Line7' was not declared in this scope Page1_Line7, // 6 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:74:2: error: 'Page1_Line13' was not declared in this scope Page1_Line13, // 7 ^ C:\Users\Damian\Documents\Arduino\libraries\WizFiShield\HTMLPages.cpp:75:2: error: 'Page1_Line10' was not declared in this scope Page1_Line10 // 9 ^ Error compiling.

I am working in Win8, but never had a problem until now. I have a feeling that this code is simply outdated, but then so would the literature about it.

Thanks for your help.

hi damowerko.

WizFi Shield library has been optimized in the Arduino IDE 1.0.x versions.
So I hope you try the test from a previous version.

It compiles on the old version but the Arduino fails to establish a ‘sync’ with the WizFi Shield:

“Serial init
Send sync data
Rcving sync timeout!!”

I have the same problem…

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.