Wifly and Sockets

15 Oct 2012

I could be doing something really dumb here but should this work? For some reason i cant get wifly to connect to a socket

/media/uploads/Ryan/capture.jpg

////////////////////

  1. include "mbed.h"
  2. 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

15 Oct 2012

Never mind i have fixed my problem

18 Mar 2013

did you change anything else in this program ? i can't receive the IP in the terminal, i only get : IP Address is: and nothing after that. Is there something wrong in the wiflyinterface.cpp ? bauds are 9600 on both wifly and mbed.

04 Mar 2017

Hi, how did you solve the problem?