This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

cc3100 - HTTP server - custom request/response

Other Parts Discussed in Thread: CC3100

Hi,
I set it as AP and want my device to receive a message (some data, say 50-100 bytes) from a cellphone, and to send data within the response.
There are many technologies to implement it, but I'm interested in the HTTP server.

I'm not a big HTTP expert, so correct me if I'm wrong.
The easiest solution is to send the data within a GET request, E.G. 192.168.1.1/Index.html;param2=value2 (query string ???), I parse it and send the response data within the HTTP response.
Regarding POST - can the server send back a response?

So, what's easiest with CC3100/simplelink?

Thanks

  • Hi Rami,


    We will look into this and get back to you.


    Regards,
    Aashish
  • Hi Rami,


    Please refer section 12 "HTTP Server" on www.ti.com/.../swru368a.pdf for GET and POSt request.


    Regards,
    Aashish
  • It was already mentioned in the forum that the HTTP chapter (12) is not written in a human-friendly way.
    It's as if it's written from the perspective of the programmer who designed it, and not from the perspective of programmers used to 'standard' web-servers (Apachi, Jetty, even CGI).
    Please take that as constructive criticism.

    Saying that, I did manage to get some things working.

    • I created a page that asks me for a token, on a GET request. The dynamic data is disaplyed on a client-browser.
    • I'm receiving POST data from both forms (within web-pages I dynamically created and saved on the FS) and non-browser POST requests, within the POST tokens I created.

    But - I can't get to combine the 2.
    I want someone to send me data and I return him data.
    GET: with a query-string is the easiest - but how can I get the query-string?
    POST: I receive the data, but how can I send a response?

    There's the 'Post/Redirect/Get' design-pattern, where the 'action' within the form will make the cc3100 response with a differnt page, and that page has my GET token. That works (I guess that's what you ment when addressing me to chapter 12).
    That works, but with browsers.
    My client will not be a browser, so how will it work in that scenario?

    Thanks

  • Hi,
    Now I'm a bit puzzled.

    This is what I have:
    1. /www/SSID.html, simple POST form:

    <!DOCTYPE html>
    <html>
      <body>
        <form method="post" action="GetMAC.html">
          SSID:
          <br>
          <input type="text" name="__SL_P_USS">
          <br>
          Password:
          <br>
          <input type="text" name="__SL_P_UPW">
          <br>
          <br>
          <input type="submit" value="Submit" id="submit">
        </form>
      </body>
    </html>

    2. /www/GetMAC.html, only a GET token:

    __SL_G_UMA

    Using a browser, I go to 192.168.1.1/SSID.html, fill the form and submit.
    The data is passed to the cc3100 and via sl_HttpServerCallback() to the host.
    Then the cc3100 redirects the browser to 192.168.1.1/GetMAC.html, where the cc3100 calls sl_HttpServerCallback() again, to GET __SL_G_UMA - the data I want to return to the browser - and all is well.

    The strange thing:
    I'm POSTing, programatically, using Python, directly to 192.168.1.1/GetMAC.html:

    import requests

    url     = 'http://192.168.1.1/GetMAC.html'
    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    data    = {'__SL_P_USS': 'SSID-12345', '__SL_P_UPW':'Password-12345', '__SL_P_UXX':'What is this?'}
    res     = requests.post(url, headers=headers, data=data)
    print()
    print(res.text)
    print(res.status_code)
    print(res.headers)
    print(res.content)
    print(res.history)

    My sl_HttpServerCallback() is called 3 times, for the 3 POST tokens, and then the cc3100 calls sl_HttpServerCallback() again, to GET __SL_G_UMA.
    My Python script receives the GetMAC.html page, even though it sent a POST request. It seems it was redirected:

    Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on Rami-Laptop, Standard
    >>> 
    F4:B8:5E:05:CF:DE
    200
    {'server': 'WebServer V1.0', 'content-type': 'text/html'}
    b'F4:B8:5E:05:CF:DE'
    [<Response [302]>]

    It's as if the cc3100 accepts POST to any URN, even non-existing.
    And - why does it treat the POST request as if it was a GET request? As apposed to the first example - here there is no redirect request...

  • Hi Rami,

    It's a small webserver to configure device configuration, device status and diagnostic; it's not a full-blow server as memory restriction. To use query string use <sdk-path>/netapp/http/server with modification or implement your own HTTP server on the host processor side.

    Regards,

    Aashish

  • I understand.
    I just wanted to know the abilities, restrictions and limitations of the HTTP-server, if it satisfies my needs.
    Th documentation isn't too clear about it.
    I hope my multiple 'HTTP' pots answer other developers.
    Thanks