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.
Dependencies: WifiPlusClick mbed
Revision 0:0a7aeb6d4526, committed 2013-07-29
- Comitter:
- leihen
- Date:
- Mon Jul 29 16:03:21 2013 +0000
- Commit message:
- General example application for use with the WifiPlusClick Module from MikroElektronika.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WifiPlusClick.lib Mon Jul 29 16:03:21 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/leihen/code/WifiPlusClick/#2a179bd4cc02
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/debug.h Mon Jul 29 16:03:21 2013 +0000
@@ -0,0 +1,27 @@
+#ifndef __DEBUG_H__
+#define __DEBUG_H__
+
+
+#ifdef DEBUG
+#define INFO(x, ...) std::printf("[INFO: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
+#define WARN(x, ...) std::printf("[WARN: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
+#else
+#define INFO(x, ...)
+#define WARN(x, ...)
+//#define ERR(x, ...)
+#endif
+#define ERR(x, ...) std::printf("[ERR: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
+
+
+#ifdef ENABLE_STACK_CHECK
+#define BEGIN_STACK_CHECK() char _stack_check; _stack_check = 0xA5
+#define RETURN_STACK_CHECK(x) if (_stack_check != 0xA5){ error("STACK CHECK"); while(1); } return (x)
+#define END_STACK_CHECK() if (_stack_check != 0xA5){ error("STACK CHECK"); while(1); } return
+#else
+#define BEGIN_STACK_CHECK()
+#define RETURN_STACK_CHECK(x) return (x)
+#define END_STACK_CHECK() return
+#endif
+
+
+#endif // __DEBUG_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Jul 29 16:03:21 2013 +0000
@@ -0,0 +1,70 @@
+#include "mbed.h"
+#include "WifiPlusClick.h"
+#include "TCPSocketServer.h"
+
+//#define WPA2_PASSWORD
+
+#ifndef WPA2_PASSWORD
+
+
+// Please note that when using this binary passphrase a connection can be made much faster.
+static const char passphrase[32] = {
+ 0xac, 0x4d, 0x41, 0x29, 0xa4, 0xd8, 0xfd, 0x15,
+ 0xaf, 0x29, 0xd7, 0x8d, 0xb2, 0x50, 0x3c, 0xd9,
+ 0xa7, 0x4f, 0x5e, 0x64, 0x5d, 0x82, 0x01, 0x76,
+ 0x1d, 0x7f, 0xda, 0xdc, 0x43, 0xcd, 0xa0, 0xd8};
+static const WPA_SECURITY_t sec = WPA_OR_WPA2_PSK;
+static const char ssid[] = "<your ssid>";
+#else
+// Please note that it will take approximately 30 seconds if using an ascii password because the module has to calculate the binary password before making the actual connection
+static char passphrase[] = "<Password>";
+static WPA_SECURITY_t sec = WPA_OR_WPA2_PASSPHRASE;
+static const char ssid[] = "<your ssid>";
+#endif
+
+
+
+
+Serial pc(USBTX, USBRX, "pc");
+
+
+const char *response = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nServer: mbed embedded\r\n\n\r<HTML><HEAD><META content=\"text/html\" http-equiv=Content-Type></HEAD><BODY><h1>Strike</h1><P>It just works !<P></BODY></HTML>\r\n\r\n";
+
+
+int main() {
+
+ WifiPlusClick wifi(p13, p14, p21, true, ssid, sec, passphrase, 32);
+
+ pc.baud(460800); // WARNING : I am using a higher baud rate !!!! You may need to adjust your telnet connection !!!
+ pc.printf("Good day !\n");
+
+ if (wifi.connect() ) {
+ wait(0.2);
+
+ pc.printf("Trying to setup a server socket !\n\n");
+ TCPSocketServer svr;
+
+ svr.set_blocking(true, 60000);
+ pc.printf("Trying to bind to port 80 !\n\n");
+ if (svr.bind(80) == 0) {
+ pc.printf("Successfully bound to port 80 !\n\n");
+
+ if (svr.listen(1) == 0) {
+ pc.printf("Successfully listening !\n\n");
+ TCPSocketConnection client;
+ if (svr.accept(client) == 0) {
+ pc.printf("Successfully received incoming connection !\n\n");
+
+ client.send_all((char*)response, strlen(response));
+ svr.close();
+ } else {
+ pc.printf("Failed to serve incoming connections !\n\n");
+ }
+ } else {
+ pc.printf("Failed to listen !\n\n");
+ }
+ } else {
+ pc.printf("Failed to bind to port 80 !\n\n");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jul 29 16:03:21 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17 \ No newline at end of file