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.

Alternatives to Get Tokens

Other Parts Discussed in Thread: CC3100, CC3100MOD

Hello,

I'm currently developing a telemetry page with the CC3100 coupled with an MCU/SLS.

The MCU creates about 6 Kilobytes of telemetry data every second, which I want to plot on an HTML page. Inititally I wanted to put a simple GET token inside a JSON or XML file, which would then be replaced by properly formatted text with the encoded data.

But now I am stuck as I would need approx. 100 tokens in this file (the documentation says the max. length of a token is 64 Bytes).

Are there alternatives to GET tokens to bind dynamic data to a page?

EDIT: I have done some research on the topic and I found that WebSockets might be just the solution. Does anyone know some lightweight server library written in C? Or an overview on what a basic WebSockets server would have to do?

  • Patrick,

    Yes - The ideal way for implementing this usecase is w/ WebSockets. Alternatively, you can create/add the contents to a *.txt file (on sFLASH at "www/" or "www/safe") using host-driver APIs and use simple AJAX request to get this specific file - But please note that this approach might induce some delay 'coz the device will have to write/read 6KB of data every one second to/from the serial-flash.

    -Praneet

  • I wonder how long the flash chip will survive this.

    A better approach would have been if the was some kind of callback for GET requests that arent found in the flash. Give it a 2 second timeout for the callback to return a page, otherwise the 404 page is returned to the client.

    Perhaps in the next service pack? @ TI

    best regards, Dominik

  • You could listen on a tcp socket (on a different port) for a http request and respond to that with your data.

    Here is a small code that responds with the request path (rxbuffer contains the request data). Other than this, you just need to open the socket, listen and accept clients (of course, read the request data):

    #define RESPONSE \
    		"HTTP/1.1 200 OK\r\n" \
    		"Connection: close\r\n" \
    		"\r\nPath: "
    
    if (strncmp((char*)rxbuffer, "GET ", 4) == 0)
    {
    	iStatus = sl_Send(iNewSockID, RESPONSE, strlen(RESPONSE), 0);
    	if (iStatus > 0)
    	{
    		length = 0;
    		for (cmp = &rxbuffer[4]; *cmp != ' '; cmp++, length++);
    
    		iStatus = sl_Send(iNewSockID, &rxbuffer[4], length, 0);
    	}
    }
    
    sl_Close(iNewSockID);

  • Thank you for your helpful responses.

    @Andrei-Calin Tatar:

    I know how to handle sockets, but I want to use WebSockets, which aren't quite the same.

    WebSockets are standardized by the IETF and most modern Browsers implement them, but I don't know the basic steps to implement a WebSocket server on the CC31xx/CC32xx.

  • Hi Patrick,

    We don't have WebSocket support in CC31xx/CC32xx.
    Since it is essentially a protocol over regular TCP socket, using HTTP messages, you can implement it on your own over our socket API.

    For further details I suggest that you'll refer to RFC 6455.

    Thanks,
    Alon

  • Hi Alon,

    thank you for your answer. I know there is no support for WebSockets OOB, hence my question in the edit of my original post.

    I just couldn't seem to find a library for that purpose or an introduction on what a simple, basic WebSocket server has to do, but I've worked my way around it.

  • Hi Patrick,

    Sorry, I missed that. Yes, we don't have an example code for WebSocket yet.

    Good to know you worked around it, thanks for the update.

    Alon

  • Praneet,

    "Alternatively, you can create/add the contents to a *.txt file (on sFLASH at "www/" or "www/safe")"

    I had a similar thought, to just rewrite the json/xml file with every update or request.  However, if this is flash, that is probably a bad idea.  After a few thousand writes, your flash could become damaged.  So this begs the question.  What are the specs on the flash (how many writes) that will be on the cc3100mod and is there any wear-leveling implemented by TI in the firmware? 

  • Alon,

    I have similar issue that Patrick had. Is there a way to increase the token buffer size? The straight forward way is to increase the buffer size, right? why is it limited to 64 byte.

    thanks

    Peng