Sending 6kB of data to webpage

Hi all

I need to send just under 6kB of data from a P1 device to a webpage (an array of 2880 uint16_t).
I know there are some other questions related to this problem but some are dealing with sending data to a backend, which I imagine would be relatively simple to do via TCP.

Since I’m trying to run quite a lean system, I’d rather not get into managing my own backend as it’s just another thing to maintain. Therefore the solutions I can see to my problem are:

  1. Split the data up over 10 or so Particle.variables (622 bytes each) with data converted into a string separated by a known character

  2. Send the data via 1 Particle.variable and use a function that allows the webpage to request the next chunk of data

My device is using a websockets library for another function, is there any way this could be used? I know browsers work nicely with websockets but I’m not sure if there is any way for the P1 to send the data securely in this context. I assume there is no way that you can send data via TCP to a web browser session per se?

Thanks in advance

Any ideas? I’m feeling this might belong in the too hard basket if I’m not using a backend to store data, I suppose the Particle API isn’t really set up for sending large amounts of data.
I might try to cut down the amount of data I need to send and use a Particle.variable. In this case, I suppose converting uint16_t to string format isn’t really the most efficient way to send the data? i.e 65535 would take 2 bytes if sent as a uint16_t, or 5 bytes if sent as a string (which is necessary if I want to use Particle.variable). Any ideas on other techniques?

With partly excluding the TCP route in your original post, you’ve limited the possible solutions considerably and all the options you were “suggesting” would be hacky rather than lean IMHO, so I’d not suggest any of these.

And if you want a secure communication with a browser (without a “man in the middle”), you might want to look into the HTTPS client library - not dead simple but doable I’d say.

Thanks @ScruffR

I agree with the hacky nature of the other options. I’m not excluding TCP at all, I really just wasn’t sure if it was possible to have a TCP connection between a Particle device and a browser?
I realise having a backend could make things simpler in some respects, however I’ve achieved 95% of my requirements just using the API directly so it would be great if I could avoid that completely!

I’ll check out the HTTPS client library and see how I go. The data is only sent very periodically (when a user wants to view a graph of historical data), so it won’t big overhead in terms of data transmission.

Thank you very much for your suggestion

HTTP (as lots of other protocols) work ontop of TCP, so yes it is :wink:

Here’s a nice sum-up

Cheers, in terms of HTTPS, I’ve read there is a hard requirement of about 50kB RAM for certificate storage. I’m showing only about 55kB of RAM available at the moment as I’ve already got quite a large application. Has anyone tried writing certificates to flash or is this too difficult to implement in practice?