Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: WizFi250_AP_HelloWorld
Fork of WizFi250Interface by
Revision 7:ba28fe711055, committed 2014-11-14
- Comitter:
- DongEun Koak
- Date:
- Fri Nov 14 15:27:47 2014 +0900
- Parent:
- 6:e149bf87a1bd
- Child:
- 8:431172d536ee
- Commit message:
- Fixed bug in init function of WizFi250.
Removed sendCommand for operating polling in order to wait response.
Fixed some bug.
Changed in this revision
--- a/WizFi250/WizFi250.cpp Fri Nov 14 15:22:27 2014 +0900
+++ b/WizFi250/WizFi250.cpp Fri Nov 14 15:27:47 2014 +0900
@@ -48,15 +48,18 @@
}
initUart(cts, rts, alarm, baud);
- wait_ms(300);
- setReset(false);
- wait_ms(1000);
+ wait_ms(500);
- _debug.baud(baud);
-
+ cmdAT();
cmdMECHO(false);
-// cmdMECHO(true);
- cmdUSET(115200,"HW");
+ if(cts != NC && rts != NC)
+ cmdUSET(baud,"HW");
+ else
+ cmdUSET(baud,"N");
+
+ // WizFi250 will restart by cmdUSET command.
+ wait_ms(1000);
+ cmdAT();
}
int WizFi250::join()
--- a/WizFi250/WizFi250.h Fri Nov 14 15:22:27 2014 +0900
+++ b/WizFi250/WizFi250.h Fri Nov 14 15:27:47 2014 +0900
@@ -121,7 +121,6 @@
// --------- WizFi250_at.cpp ---------
void clearFlags ();
- int sendCommand (const char * cmd, const char *ACK, char *res = NULL , int timeout = DEFAULT_WAIT_RESP_TIMEOUT, int opt = 2);
int sendCommand (const char * cmd, Response res = RES_NULL, int timeout = DEFAULT_WAIT_RESP_TIMEOUT, int opt = 2);
int cmdAT ();
@@ -222,7 +221,6 @@
void(*func)(int);
} _con[8];
-
// --------- WizFi250.cpp ---------
int join ();
--- a/WizFi250/WizFi250_at.cpp Fri Nov 14 15:22:27 2014 +0900
+++ b/WizFi250/WizFi250_at.cpp Fri Nov 14 15:27:47 2014 +0900
@@ -33,88 +33,10 @@
_state.n = 0;
}
-int WizFi250::sendCommand(const char * cmd, const char *ACK, char *res , int timeout, int opt)
-{
- char read;
- int i;
- Timer t;
- string checking;
- size_t found = string::npos;
-
-
- //attach_rx(false);
- if (lockUart(timeout)) return -1;
-
- // flush the buffer
- while(_wizfi.readable())
- {
- printf("%c",_wizfi.getc());
- }
-
- clearFlags();
-
- INFO("command: '%s'", cmd)
- for (i=0; i< strlen(cmd); i++)
- {
- putUart(cmd[i]);
- }
-
- if(opt == 0)
- {
-
- }
- else if(opt == 1)
- {
- putUart('\r');
- }
- else
- {
- putUart('\r');
- putUart('\n');
- }
- unlockUart();
-
- while(1)
- {
- if(t.read_ms() > timeout)
- {
- while(_wizfi.readable())
- _wizfi.getc();
-
- DBG("check: %s\r\n", checking.c_str());
- return -1;
- }
- else if(_wizfi.readable())
- {
- read = _wizfi.getc();
- if(read != '\r' && read != '\n')
- {
- checking += read;
- found = checking.find(ACK);
- if (found != string::npos)
- {
- wait(0.01);
-
- while(_wizfi.readable())
- _wizfi.getc();
-
- break;
- }
- }
- }
- }
- DBG("check:%s\r\n", checking.c_str());
-
-// attach_rx(true);
-
- return 0;
-}
-
-
int WizFi250::sendCommand(const char * cmd, Response res, int timeout, int opt)
{
- int i, cnt=0;
+ unsigned int i;
Timer t;
if (lockUart(timeout)) return -1;
@@ -128,15 +50,11 @@
putUart(cmd[i]);
}
- if(opt == 0)
- {
-
- }
- else if(opt == 1)
+ if(opt == 1)
{
putUart('\r');
}
- else
+ else if(opt == 2)
{
putUart('\r');
putUart('\n');
@@ -155,6 +73,7 @@
{
WIZ_WARN("failure of timeout[%d]ms\r\n",t.read_ms());
_state.res = RES_NULL;
+ t.stop();
return -1;
}
}
@@ -175,9 +94,6 @@
resp = sendCommand("AT");
return resp;
-
- //return sendCommand("AT");
- //sendCommand("AT","[OK]");
}
int WizFi250::cmdMECHO(bool flg)
@@ -223,10 +139,6 @@
{
sprintf(cmd, "AT+MMAC=?");
resp = sendCommand(cmd, RES_MACADDRESS);
- if (!resp && strncmp(_state.mac, xmac, 17) == 0)
- {
- resp = -1;
- }
}
return resp;
@@ -266,7 +178,6 @@
int WizFi250::cmdWJOIN()
{
- sendCommand("AT+WJOIN", RES_WJOIN, CFG_TIMEOUT);
if( sendCommand("AT+WJOIN", RES_WJOIN, CFG_JOIN_TIMEOUT) ) return -1;
@@ -277,7 +188,6 @@
return 0;
}
-
int WizFi250::cmdSCON ( const char *openType, const char *socketType, int localPort, const char *dataMode)
{
char cmd[CFG_CMD_SIZE];
@@ -327,7 +237,7 @@
unlockUart();
if(resp){
WIZ_DBG("Fail cmdSSEND")
- return -1;
+ return -1;
}
for(i=0; i<sendSize; i++)
@@ -372,7 +282,7 @@
int resp;
sprintf(cmd,"AT+FDNS=%s,1000",host);
- resp = sendCommand(cmd, RES_FDNS, CFG_TIMEOUT);
+ resp = sendCommand(cmd, RES_FDNS);
WIZ_DBG("%s",_state.resolv);
return resp;
--- a/WizFi250/WizFi250_conf.h Fri Nov 14 15:22:27 2014 +0900 +++ b/WizFi250/WizFi250_conf.h Fri Nov 14 15:27:47 2014 +0900 @@ -26,11 +26,13 @@ #define CFG_TRYJOIN 3 -#define DEFAULT_WAIT_RESP_TIMEOUT 1000 -#define CFG_TIMEOUT 30000 // ms +#define DEFAULT_WAIT_RESP_TIMEOUT 2000 // ms +#define CFG_JOIN_TIMEOUT 30000 // ms #define CFG_CMD_SIZE 128 #define CFG_DATA_SIZE 512 +#define CFG_DEFAULT_MAC "00:08:DC:00:00:00" + #endif /* WIZFI250_CONF_H_ */
--- a/WizFi250/WizFi250_msg.cpp Fri Nov 14 15:22:27 2014 +0900
+++ b/WizFi250/WizFi250_msg.cpp Fri Nov 14 15:27:47 2014 +0900
@@ -303,7 +303,10 @@
strncpy(_state.mac, buf, sizeof(_state.mac));
_state.mac[17] = 0;
_state.res = RES_NULL;
- //DBG("mac %s\r\n", _state.mac);
+ if(strncmp(_state.mac,CFG_DEFAULT_MAC,sizeof(CFG_DEFAULT_MAC)) == 0)
+ _state.ok = false;
+
+ _state.ok = true;
}
}
--- a/WizFi250Interface.cpp Fri Nov 14 15:22:27 2014 +0900
+++ b/WizFi250Interface.cpp Fri Nov 14 15:27:47 2014 +0900
@@ -51,6 +51,8 @@
case WM_AP:
return 0;
}
+
+ return 0;
}
int WizFi250Interface::disconnect()
