I could be doing something really dumb here but should this work? For some reason i cant get wifly to connect to a socket
////////////////////
- include "mbed.h"
- include "WiflyInterface.h"
Serial pc(USBTX, USBRX);
/* wifly object where:
- - p9 and p10 are for the serial communication
- - p25 is for the reset pin
- - p26 is for the connection status
- - "mbed" is the ssid of the network
- - "password" is the password
- - WPA is the security
- /
WiflyInterface wifly(p9, p10, p25, p26, "RADD","",NONE);
int main()
{
wifly.init(); use DHCP
while (!wifly.connect()); join the network
printf("Connection succsess full\n\r");
printf("IP Address is %s\n\r", wifly.getIPAddress());
TCPSocketConnection sock;
while(!sock.connect("mbed.org", 80));
char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
sock.send_all(http_cmd, sizeof(http_cmd)-1);
char buffer[300];
int ret;
while (true) {
ret = sock.receive(buffer, sizeof(buffer)-1);
if (ret <= 0)
break;
buffer[ret] = '\0';
printf("Received %d chars from server:\n%s\n", ret, buffer);
}
sock.close();
wifly.disconnect();
while(1) {}
}
//////////////////////
i have included everything form the EthernetInterface it compiles with no error or warnings and i am able to get an ip address, just not a socket connection
Thanks
I could be doing something really dumb here but should this work? For some reason i cant get wifly to connect to a socket
////////////////////
/* wifly object where:
int main() { wifly.init(); use DHCP while (!wifly.connect()); join the network printf("Connection succsess full\n\r"); printf("IP Address is %s\n\r", wifly.getIPAddress()); TCPSocketConnection sock; while(!sock.connect("mbed.org", 80));
char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n"; sock.send_all(http_cmd, sizeof(http_cmd)-1);
char buffer[300]; int ret; while (true) { ret = sock.receive(buffer, sizeof(buffer)-1); if (ret <= 0) break; buffer[ret] = '\0'; printf("Received %d chars from server:\n%s\n", ret, buffer); }
sock.close();
wifly.disconnect();
while(1) {} } ////////////////////// i have included everything form the EthernetInterface it compiles with no error or warnings and i am able to get an ip address, just not a socket connection Thanks