ghj

Fork of WizFi310Interface_Legacy by WIZnet

Files at this revision

API Documentation at this revision

Comitter:
ajeet3004
Date:
Mon Nov 27 05:26:43 2017 +0000
Parent:
1:e08ea0ee2788
Commit message:
sdfgh

Changed in this revision

Socket/Socket.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/TCPSocketConnection.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/TCPSocketServer.h Show annotated file Show diff for this revision Revisions of this file
WizFi310/WizFi310.h Show annotated file Show diff for this revision Revisions of this file
WizFi310/WizFi310_at.cpp Show annotated file Show diff for this revision Revisions of this file
WizFi310/WizFi310_sock.cpp Show annotated file Show diff for this revision Revisions of this file
WizFi310Interface.cpp Show annotated file Show diff for this revision Revisions of this file
WizFi310Interface.h Show annotated file Show diff for this revision Revisions of this file
diff -r e08ea0ee2788 -r 7b906ee634bb Socket/Socket.cpp
--- 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) {
diff -r e08ea0ee2788 -r 7b906ee634bb Socket/TCPSocketConnection.cpp
--- 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);
     }
 }
diff -r e08ea0ee2788 -r 7b906ee634bb Socket/TCPSocketServer.h
--- 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);
 };
 
diff -r e08ea0ee2788 -r 7b906ee634bb WizFi310/WizFi310.h
--- 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);
 
 };
 
diff -r e08ea0ee2788 -r 7b906ee634bb WizFi310/WizFi310_at.cpp
--- 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;
+}
+
diff -r e08ea0ee2788 -r 7b906ee634bb WizFi310/WizFi310_sock.cpp
--- 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;
 }
 
diff -r e08ea0ee2788 -r 7b906ee634bb WizFi310Interface.cpp
--- 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();
+
+
diff -r e08ea0ee2788 -r 7b906ee634bb WizFi310Interface.h
--- 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);
 
-
 };