Program to test WirelessInterface library.
Dependencies: WirelessInterface mbed
Revision 1:c7cfaf8c38f2, committed 2016-04-28
- Comitter:
- gboggs3
- Date:
- Thu Apr 28 22:09:57 2016 +0000
- Parent:
- 0:6b892e818f10
- Commit message:
- Updated wifi communication;
Changed in this revision
WirelessInterface.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 |
--- a/WirelessInterface.lib Sun Apr 24 18:24:36 2016 +0000 +++ b/WirelessInterface.lib Thu Apr 28 22:09:57 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/gboggs3/code/WirelessInterface/#ee4d2deea4be +https://developer.mbed.org/users/gboggs3/code/WirelessInterface/#67c95e75c998
--- a/main.cpp Sun Apr 24 18:24:36 2016 +0000 +++ b/main.cpp Thu Apr 28 22:09:57 2016 +0000 @@ -6,11 +6,33 @@ //Debug serial port RawSerial pc(USBTX, USBRX); -WirelessInterface cmd(p28,p27,p26,pc); //Comment this out to manually configure each device individually +WirelessInterface cmd(p28, p27, p26, pc, 9600); //Comment this out to manually configure each device individually //Huzzah cmd(p28,p27,p26,pc); //BTFriend cmd(p28,p27,p26,pc); DigitalOut sel(p22); InterruptIn pb(p18); +DigitalOut led1(LED1); +DigitalOut led2(LED2); +RawSerial dev = cmd.getLocalSerial(); + + +bool command(const char *cmd) +{ + char result[240]; + strcpy(result,cmd); + strcat(result,"\r\n"); + //pc.printf(result); + led2 = !led2; + wait(0.250); + for (int i = 0; i<strlen(result); i++) + { + + dev.putc(result[i]); + //pc.putc(result[i]); + } + wait(0.250); + return true; +} //Interrupt function to change the selected device to communicate with void changeDevice() @@ -33,8 +55,23 @@ /* An external interrupt can be setup to change the sel pin during runtime */ pb.rise(&changeDevice); - - while(1) { + + /*Setting up the server to allow serial passthrough */ + command("sk = net.createConnection(net.TCP, 0)"); + wait(1); + command("sk:on(\"receive\", function(sck, c) print(\"Received: \" .. c) end)"); + wait(1); + command("sk:on(\"connection\", function(sck,c)"); + wait(1); + command("end)"); + wait(1); + command("sk:connect(5001,\"107.161.22.189\")"); + wait(1); + //Send sk:send(STRING_HERE) + //Received messages start with Received: + + while(1) + { sleep(); } -} +} \ No newline at end of file