Quantcast
Channel: Seeedstudio Forum
Viewing all articles
Browse latest Browse all 6612

Wifi Shield WLS06201 is always in unstable TCP connection

$
0
0
My code :

#include "Wifly.h"
#include <SoftwareSerial.h>
WiflyClass Wifly(2,3);

#define HTTP_POST_HEADERS "U-ApiKey: a6db4904d575e9ceb9a592a23f50\r\n"
unsigned long start_millis = 0;
char post_data_buf[32];


void setup()
{
Serial.begin(9600);//use the hardware serial to communicate with the PC
Wifly.init();//Initialize the wifishield
Wifly.setConfig("NETGEAR","1234567"); //here to set the ssid and password of the Router
Wifly.join("NETGEAR");
Wifly.checkAssociated();
}


void loop()
{
if ((millis() - start_millis) < 20000)
{
return;
}
else
{
start_millis = millis();
}

Serial.println("\r\n\r\nTry to post data to url");
Serial.println("-------------------------------");
snprintf(post_data_buf, sizeof(post_data_buf), "{\"value\":%d}\r\n",20);

while(!Wifly.connect("42.96.164.52","80")); //connect the remote service
.
.(short connecttion)
.
.
Wifly.writeToSocket(post_data_buf);
}

Statistics : Posted by djt322 • on Sun Jun 15, 2014 9:45 am • Replies 1 • Views 6

Viewing all articles
Browse latest Browse all 6612

Trending Articles