Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In My Arduino program reateTCP(HostName,port) return false #74

Open
NyanNaingTun opened this issue Sep 26, 2016 · 1 comment
Open

In My Arduino program reateTCP(HostName,port) return false #74

NyanNaingTun opened this issue Sep 26, 2016 · 1 comment

Comments

@NyanNaingTun
Copy link

My program is shown

setup begin
FW Version:AT version:0.21.0.0
SDK version:0.9.5
to station ok
Join AP success
IP:+CIFSR:STAIP,"192.168.1.104"
+CIFSR:STAMAC,"18:fe:34:f8:c0:39"
setup end

create tcp err

create tcp err

create tcp err

I don't know Why it cannot connect to TCP. Please help me?

`

include "ESP8266.h"

include<SoftwareSerial.h>

define SSID "MTHGROUP"

define PASSWORD "mth21444"

define HOST_NAME "184.106.153.149"

SoftwareSerial esp8266(3,2);
ESP8266 wifi(esp8266,9600);

void setup()
{
Serial.begin(9600);
esp8266.begin(9600);
Serial.print("setup begin\r\n");

Serial.print("FW Version:");
Serial.println(wifi.getVersion().c_str());

if (wifi.setOprToStation()) {
    Serial.print("to station  ok\r\n");
} else {
    Serial.print("to station  err\r\n");
}

while(1){
if (wifi.joinAP(SSID, PASSWORD)) {
    Serial.print("Join AP success\r\n");

    Serial.print("IP:");
    Serial.println( wifi.getLocalIP().c_str());     
    break;  
} else {
    Serial.print("Join AP failure\r\n");
}}

/*if (wifi.disableMUX()) {
    Serial.print("Single  ok\r\n");
} else {
    Serial.print("Single err\r\n");
}
*/
Serial.print("setup end\r\n");

}

void loop()
{
uint8_t buffer[1024] = {0};
while(1){
if (wifi.createTCP(HOST_NAME, 80)) {
Serial.print("create tcp ok\r\n");
break;
} else {
Serial.print("create tcp err\r\n");

}
}
int val=random(500);
char *hello = "GET /update?api_key=HZTUOVT84WUYTW8L&field2=400\r\n\r\n";
wifi.send((const uint8_t*)hello, strlen(hello));

uint32_t len = wifi.recv(buffer, sizeof(buffer), 10000);
if (len > 0) {
    Serial.print("Received:[");
    for(uint32_t i = 0; i < len; i++) {
        Serial.print((char)buffer[i]);
    }
    Serial.print("]\r\n");
}

if (wifi.releaseTCP()) {
    Serial.print("release tcp ok\r\n");
} else {
    Serial.print("release tcp err\r\n");
}

}

@jpatillo
Copy link

Is it not connecting, or is it just saying it isn't? wifi.createTCP(HOST_NAME, 80) returns false for me too, but wifi.send((const uint8_t*)hello, strlen(hello)); still sends the data (sometimes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants