Doing POST/GET directly and reading results

Hi,

I have a project that is working via Wifi on an Arduino - it “talks” directly over the internet.

I want to port that to an electron an be able to run over celluar data. I don’t believe I need the Particle Cloud - unless that’s they only way to get out.

How do I issue POST and/or GET api requests and receive the results via the Electron? The existing code uses the Ethernet library for such things as client.connected, client.read, client.println, etc. Are there analogous comments for cellular communication with the Electron?

Thanks.

Have you tried looking at the docs and searching the forum?

2 Likes

Yes there are and as @ScruffR pointed out, they are doc'ed:

https://docs.particle.io/reference/firmware/electron/#tcpclient

If you are using a TCP client, you should be all set, but if you are expecting the Electron to act as a server over the cellular network, the cellular network doesn't really allow that.

1 Like

Thank you!

That’s exactly what I was looking for and for some reason I looked right past it in the DOCs.

I’ve reviewed the document and it looks like most of what I need. However, I need to establish a secure connection. Using an ESP8266 over wifi, I change to using a different library (WiFiClientSecure) and talk on port 443 instead of 80. I see where I can set the port, but what tells TCPClient to establish a secure connection?

Also, is it possible to pass a URL to client.connect as a string and have it resolved or is there a function to resolve URLs into IP addresses?

Thanks.