eftf

Fork of WizFi310Interface_Legacy by WIZnet

Files at this revision

API Documentation at this revision

Comitter:
ajeet3004
Date:
Mon Nov 27 05:30:11 2017 +0000
Parent:
1:e08ea0ee2788
Commit message:
edfvggf

Changed in this revision

Socket/Socket.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/TCPSocketServer.cpp 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 d25ec78141e1 Socket/Socket.cpp
--- a/Socket/Socket.cpp	Tue May 02 00:31:36 2017 +0000
+++ b/Socket/Socket.cpp	Mon Nov 27 05:30:11 2017 +0000
@@ -27,6 +27,7 @@
 #include <cstring>
 
 Socket::Socket() {
+    printf("Socket Fn\n");
     _wizfi310 = NULL;
     _wizfi310 = WizFi310::getInstance();
     if (_wizfi310 == NULL)
@@ -37,6 +38,7 @@
     _server = false;
     _cid = -1;
     _port = 0;
+    printf("Socket done\n");
 }
 
 void Socket::set_blocking(bool blocking, unsigned int timeout) {
diff -r e08ea0ee2788 -r d25ec78141e1 Socket/TCPSocketServer.cpp
--- a/Socket/TCPSocketServer.cpp	Tue May 02 00:31:36 2017 +0000
+++ b/Socket/TCPSocketServer.cpp	Mon Nov 27 05:30:11 2017 +0000
@@ -30,37 +30,46 @@
 
 // Server initialization
 int TCPSocketServer::bind(int port) {
-
+printf("Port is :%d\n",port);
     _port = port;
     return 0;
 }
 
 int TCPSocketServer::listen(int backlog) {
+    
     _server = true;
+    printf("the cid value in TcpSocket %d",_cid);
     if (_cid < 0) {
         // Socket open
-        _server = false;
+        //_server = false;
         _cid = _wizfi310->listen(WizFi310::PROTO_TCP, _port);
 
-        //WIZ_DBG("TEST CID : %d",_cid);
+        WIZ_DBG("TEST CID : %d",_cid);
         if (_cid < 0) return -1;
     }
 
     if (backlog != 1)
         return -1;
+        
+      
     return 0;
+     
 }
 
 
 int TCPSocketServer::accept(TCPSocketConnection& connection) {
+    
     int acid = -1;
-
+    printf("ACCEPT Mode \n");
     while (1) {
         while (acid < 0) {
+            
             acid = _wizfi310->accept(_cid);
+            //printf("acid: %d\n",acid);
         }
 
         if (acid >= 0) {
+            printf("acceptCID Function\n");
             connection.acceptCID(acid);
             return 0;
         }
diff -r e08ea0ee2788 -r d25ec78141e1 WizFi310/WizFi310.h
--- a/WizFi310/WizFi310.h	Tue May 02 00:31:36 2017 +0000
+++ b/WizFi310/WizFi310.h	Mon Nov 27 05:30:11 2017 +0000
@@ -327,6 +327,8 @@
     
     //daniel for mqtt
     char rcvd_mqtt_topic[128];
+    
+     bool test(void);
 
 };
 
diff -r e08ea0ee2788 -r d25ec78141e1 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:30:11 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;
 }
diff -r e08ea0ee2788 -r d25ec78141e1 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:30:11 2017 +0000
@@ -221,13 +221,19 @@
 bool WizFi310::isConnected (int cid)
 {
     if ( cid < 0 || cid >=8 ) return false;
-    //printf("%d %d\r\n", cid, _con[cid].connected);
+    printf("%d %d\r\n", cid, _con[cid].connected);
+   
     return _con[cid].connected;
+    
 }
 
+
 int WizFi310::accept (int cid)
-{
-    if(!isConnected(cid))   return -1;
+{   
+    bool _is_connected=isConnected(cid);
+    //if(!isConnected(cid))   return -1;
+    if(_is_connected == false)    return -1;
+    
 
     if(_con[cid].connected && _con[cid].accept)
     {
@@ -238,6 +244,10 @@
     return -1;
 }
 
+      
+      
+   
+
 int WizFi310::getRemote(int cid, char **ip, int *port)
 {
     if (!isConnected(cid))  return -1;
diff -r e08ea0ee2788 -r d25ec78141e1 WizFi310Interface.cpp
--- a/WizFi310Interface.cpp	Tue May 02 00:31:36 2017 +0000
+++ b/WizFi310Interface.cpp	Mon Nov 27 05:30:11 2017 +0000
@@ -64,6 +64,8 @@
 	return cmdWLEAVE();
 }
 
+
+
 char* WizFi310Interface::getMACAddress()
 {
     return _state.mac;
@@ -83,5 +85,50 @@
 {
 	return cmdWANT(mode);
 }
+//int WizFi310Interface::test()
+//{
+//	return cmdWSTATUS();
+//}
 
+
+//int WizFi310Interface::test1()
+//{
+//	 Socket();
+//}
+
+//int WizFi310Interface::test2()
+//{
+//	 TCPSocketServer();
+//	 return 0;
+//}
+
+int WizFi310Interface::bind()
+{ 
+	TCPSocketServer TCPserver;
+	TCPSocketConnection TCPconnection;
+
+	TCPserver.bind(80);
+	
+	int a=TCPserver.listen();
+	
+	if(a==0)
+	printf("Listen configuration Successful\n");
+	else
+	printf("Listen configuration failure");
+	
+	
+	
+	int b=TCPserver.accept(TCPconnection);
+	
+	if(b==0)
+	printf("Accept configuration Successful\n");
+	else
+	printf("Accept configuration failure");
+	char *buffer;
+	TCPconnection.receive(buffer,strlen(buffer));
+	return 0;
+	
+}
 //char* getNetworkMask();
+
+
diff -r e08ea0ee2788 -r d25ec78141e1 WizFi310Interface.h
--- a/WizFi310Interface.h	Tue May 02 00:31:36 2017 +0000
+++ b/WizFi310Interface.h	Mon Nov 27 05:30:11 2017 +0000
@@ -27,8 +27,11 @@
 #define WIZFI310INTERFACE_H_
 
 #include "WizFi310.h"
+#include "TCPSocketServer.h"
+#include "TCPSocketConnection.h"
 
-class WizFi310Interface : public WizFi310{
+
+class WizFi310Interface : public WizFi310,public TCPSocketServer,public TCPSocketConnection{
 public:
 
     WizFi310Interface(PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm = NC, int baud = 115200);
@@ -37,13 +40,16 @@
     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();
+    //int test2();
+    //int test3();
     char* getMACAddress();
     char* getIPAddress();
     char* getGateway();
     char* getNetworkMask();
     
     int setAntMode(AntennaMode mode);
-
+    int bind();
 
 };