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.
Fork of WizFi310Interface_Legacy by
Revision 2:7b906ee634bb, committed 2017-11-27
- Comitter:
- ajeet3004
- Date:
- Mon Nov 27 05:26:43 2017 +0000
- Parent:
- 1:e08ea0ee2788
- Commit message:
- sdfgh
Changed in this revision
--- a/Socket/Socket.cpp Tue May 02 00:31:36 2017 +0000
+++ b/Socket/Socket.cpp Mon Nov 27 05:26:43 2017 +0000
@@ -27,16 +27,18 @@
#include <cstring>
Socket::Socket() {
+
_wizfi310 = NULL;
_wizfi310 = WizFi310::getInstance();
if (_wizfi310 == NULL)
error("Socket constructor error: no WizFi250 instance available!\r\n");
_blocking = true;
- _timeout = 1500;
+ _timeout = 2500;
_server = false;
_cid = -1;
_port = 0;
+ printf("Socket done\n");
}
void Socket::set_blocking(bool blocking, unsigned int timeout) {
--- a/Socket/TCPSocketConnection.cpp Tue May 02 00:31:36 2017 +0000
+++ b/Socket/TCPSocketConnection.cpp Mon Nov 27 05:26:43 2017 +0000
@@ -34,16 +34,17 @@
_server = false;
_cid = _wizfi310->open(WizFi310::PROTO_TCP, get_address(), get_port());
+ printf("_cid : %d\n",_cid);
if (_cid < 0 ) return -1;
return 0;
}
bool TCPSocketConnection::is_connected(void)
-{
+{ printf("_cid: %d\n", _cid);
bool _is_connected = _wizfi310->isConnected(_cid);
if(!_is_connected) _cid = -1;
-
+ printf(" is_connected: %d\n",_is_connected);
return _is_connected;
}
@@ -141,7 +142,7 @@
if( _wizfi310->cmdSMGMT(cid) ) return;
if( !_wizfi310->getRemote(_cid, &ip, &port))
- {
+ {
set_address(ip, port);
}
}
--- a/Socket/TCPSocketServer.h Tue May 02 00:31:36 2017 +0000
+++ b/Socket/TCPSocketServer.h Mon Nov 27 05:26:43 2017 +0000
@@ -54,6 +54,7 @@
\param connection A TCPSocketConnection instance that will handle the incoming connection.
\return 0 on success, -1 on failure.
*/
+
int accept(TCPSocketConnection& connection);
};
--- a/WizFi310/WizFi310.h Tue May 02 00:31:36 2017 +0000
+++ b/WizFi310/WizFi310.h Mon Nov 27 05:26:43 2017 +0000
@@ -106,6 +106,7 @@
RES_FDNS,
RES_SMGMT,
RES_WSTATUS,
+ RES_SCON,
};
@@ -143,6 +144,7 @@
int cmdWJOIN ();
int cmdWLEAVE ();
int cmdWSTATUS ();
+ int cmdSCON ();
int cmdSCON ( const char *openType, const char *socketType, int localPort, const char *dataMode = "0");
int cmdSCON ( const char *openType, const char *socketType, const char *remoteIp, int remotePort, int localPort = 0, const char *dataMode = "0");
int cmdSSEND ( const char *data, int cid, int sendSize, const char *remoteIp = NULL, int remotePort = 0, int Timeout = 2000 );
@@ -327,6 +329,8 @@
//daniel for mqtt
char rcvd_mqtt_topic[128];
+
+ bool test(void);
};
--- a/WizFi310/WizFi310_at.cpp Tue May 02 00:31:36 2017 +0000
+++ b/WizFi310/WizFi310_at.cpp Mon Nov 27 05:26:43 2017 +0000
@@ -166,7 +166,7 @@
int WizFi310::cmdWANT(AntennaMode mode)
{
char cmd[CFG_CMD_SIZE];
- sprintf(cmd, "AT+WANT=%d",mode);
+ sprintf(cmd, "AT+WANT=%d",mode);
return sendCommand(cmd);
}
@@ -215,7 +215,7 @@
if( cmdWSTATUS() )
return -1;
- WIZ_INFO("WizFi310 is successfully join to AP");
+ //WIZ_INFO("WizFi310 is successfully join to AP");
return 0;
}
@@ -347,3 +347,14 @@
resp = sendCommand("AT+SMGMT=?", RES_SMGMT);
return resp;
}
+
+
+int WizFi310::cmdSCON()
+{
+ int resp;
+
+ resp = sendCommand("AT+SCON=?", RES_SCON,1500);
+ printf("Response: %d \n", resp);
+ return resp;
+}
+
--- a/WizFi310/WizFi310_sock.cpp Tue May 02 00:31:36 2017 +0000
+++ b/WizFi310/WizFi310_sock.cpp Mon Nov 27 05:26:43 2017 +0000
@@ -77,6 +77,8 @@
_con[cid].protocol = proto;
_con[cid].type = TYPE_CLIENT;
_con[cid].func = func;
+ printf("TYPE : %d\n",_con[cid].type);
+
return cid;
}
--- a/WizFi310Interface.cpp Tue May 02 00:31:36 2017 +0000
+++ b/WizFi310Interface.cpp Mon Nov 27 05:26:43 2017 +0000
@@ -64,6 +64,8 @@
return cmdWLEAVE();
}
+
+
char* WizFi310Interface::getMACAddress()
{
return _state.mac;
@@ -83,5 +85,42 @@
{
return cmdWANT(mode);
}
+//int WizFi310Interface::test()
+//{
+// return cmdWSTATUS();
+//}
+
+int WizFi310Interface::test1()
+{
+ // TCPSocketConnection();
+ int errConnect;
+ char http_cmd[1000] = "";
+ char buffer[2048] = "";
+ TCPSocketConnection TCPconnection;
+
+ char *p="arduino-tweet.appspot.com";
+ int a=TCPconnection.connect(p,80);
+ while (true) {
+ if(a!=0) {
+ printf("\r\ncould not connect to socket : error = %d\r\n", p);
+ a = TCPconnection.connect(p, 80);
+ } else {
+ printf("socket connected\r\n");
+ break;
+ }
+ }
+
+ sprintf((char *)http_cmd,"GET http://arduino-tweet.appspot.com/update?token=904626807491530753-sOaChz44g9YFS7EuvRkR75l1W9T303K&status=hekllotwitter4562314\r\n");
+
+ TCPconnection.send_all(http_cmd, sizeof(http_cmd));
+
+ TCPconnection.receive_all(buffer, sizeof(buffer));
+ printf("%s",buffer);
+
+
+ return 0;
+ }
//char* getNetworkMask();
+
+
--- a/WizFi310Interface.h Tue May 02 00:31:36 2017 +0000
+++ b/WizFi310Interface.h Mon Nov 27 05:26:43 2017 +0000
@@ -27,8 +27,10 @@
#define WIZFI310INTERFACE_H_
#include "WizFi310.h"
+#include "TCPSocketConnection.h"
-class WizFi310Interface : public WizFi310{
+
+class WizFi310Interface : public WizFi310,public TCPSocketConnection{
public:
WizFi310Interface(PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm = NC, int baud = 115200);
@@ -37,6 +39,7 @@
int init(const char* ip, const char* mask, const char* gateway, const char* name = NULL);
int connect(Security sec, const char* ssid, const char* phrase, WiFiMode mode = WM_STATION);
int disconnect();
+ int test1();
char* getMACAddress();
char* getIPAddress();
char* getGateway();
@@ -44,7 +47,6 @@
int setAntMode(AntennaMode mode);
-
};
