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

REST client does not seem to return data. #23

Open
Bam4d opened this issue Oct 9, 2016 · 1 comment
Open

REST client does not seem to return data. #23

Bam4d opened this issue Oct 9, 2016 · 1 comment

Comments

@Bam4d
Copy link

Bam4d commented Oct 9, 2016

I've flashed an arduino wifi with esp-link and using the el-client libs.

I'm trying to do a small REST request to a python server which should simply display "Hello, world!"

from flask import Flask, Response

app = Flask(__name__)

@app.route('/')
def index():
    resp = Response("Hello, World!")
    resp.headers['Server'] = ""
    resp.headers['Date'] = ""
    resp.headers['Content-Type'] = "text/html"
    return resp

if __name__ == '__main__':
    app.run(host="0.0.0.0", port=80, debug=True)

The response including headers is less than 100 chars.

my el-client code is the slightly modified REST example (to support arduino serial uart interface):

#define BUFLEN 512

void loop() {
  // process any callbacks coming from esp_link
  esp.Process();

  // if we're connected make an HTTP request
  if(wifiConnected) {
    rest.get("/");



    char response[BUFLEN];
    memset(response, 0, BUFLEN);
    uint16_t code = rest.waitResponse(response, BUFLEN);
    if(code == HTTP_STATUS_OK){
      Serial.println("ARDUINO: GET successful:");
      Serial.println(response);
    } else {
      Serial.print("ARDUINO: GET failed: ");
      Serial.println(code);
    }

    delay(1000);


  }
}

I can see the requests are being logged by the python flask server. I'm expecting to see "Hello world" in my console... but I only recieve:

ARDUINO: GET successful:
H

Not sure why I only see "H" here? but I'm guessing its either the first letter of Hello or the first letter of HTTP 200 OK in the response.

@tve
Copy link
Member

tve commented Dec 12, 2016

(Dunno whether this is still of interest, but just in case...) I am wondering what you meant by to support arduino serial uart interface. If you are using the arduino software serial interface at 9600 baud to talk to esp-link, that is not going to work. Do you have any esp-link debug log output corresponding to your issue?

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

No branches or pull requests

2 participants