Gorka Bueno / Mbed 2 deprecated neurGAI_WIFI

Dependencies:   WiflyInterface mbed

Fork of wiflyServer by Gorka Bueno

Files at this revision

API Documentation at this revision

Comitter:
gbm
Date:
Sun Feb 28 17:19:31 2016 +0000
Child:
1:a340ab744f01
Commit message:
server con wifly, por el puerto 7

Changed in this revision

WiflyInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
softserial.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WiflyInterface.lib	Sun Feb 28 17:19:31 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/gbm/code/WiflyInterface/#fa0fb985d6be
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Feb 28 17:19:31 2016 +0000
@@ -0,0 +1,81 @@
+/*
+// este es el programa a ejecutar en ordenador, como cliente (tutoriales de java): https://docs.oracle.com/javase/tutorial/networking/sockets/readingWriting.html
+
+import java.io.*;
+import java.net.*;
+
+public class EchoClient {
+    public static void main(String[] args) throws IOException {
+        
+        if (args.length != 2) {
+            System.err.println(
+                "Usage: java EchoClient <host name> <port number>");
+            System.exit(1);
+        }
+
+        String hostName = args[0];
+        int portNumber = Integer.parseInt(args[1]);
+
+        try (
+            Socket echoSocket = new Socket(hostName, portNumber);
+            PrintWriter out =
+                new PrintWriter(echoSocket.getOutputStream(), true);
+            BufferedReader in =
+                new BufferedReader(
+                    new InputStreamReader(echoSocket.getInputStream()));
+            BufferedReader stdIn =
+                new BufferedReader(
+                    new InputStreamReader(System.in))
+        ) {
+            String userInput;
+            while ((userInput = stdIn.readLine()) != null) {
+                out.println(userInput);
+                System.out.println("echo: " + in.readLine());
+            }
+        } catch (UnknownHostException e) {
+            System.err.println("Don't know about host " + hostName);
+            System.exit(1);
+        } catch (IOException e) {
+            System.err.println("Couldn't get I/O for the connection to " +
+                hostName);
+            System.err.println(e);
+            System.exit(1);
+        } 
+    }
+}
+
+*/
+
+#include "mbed.h"
+#include "WiflyInterface.h"
+ 
+#define ECHO_SERVER_PORT   7
+ 
+WiflyInterface wifly(D3, D2, D5, LED1, "wifisarea", "wifi0712", WPA);
+ 
+int main (void)
+{
+    printf("\nEmpezando...\n\r");
+    wifly.init(); // use DHCP
+    while (!wifly.connect()); // join the network
+    printf("\nLa direccion IP es %s\n\r", wifly.getIPAddress());
+ 
+    TCPSocketServer server;
+    server.bind(ECHO_SERVER_PORT);
+    server.listen();
+ 
+    printf("\nEsperando conexion...\n");
+    TCPSocketConnection client;
+    server.accept(client);
+    printf("\nServidor aceptado...\n");
+    wait(1);    //si no se le mete un pequeño retardo, se queda colgado. También vale con el printf anterior
+    
+    char buffer[256];
+    while (true) {
+        int n = client.receive(buffer, sizeof(buffer));
+        if (n <= 0) continue;
+        buffer[n] = 0;
+ 
+        client.send_all(buffer, n);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Feb 28 17:19:31 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/softserial.lib	Sun Feb 28 17:19:31 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/gbm/code/softserial/#480d9575ac47