ArduinoIoTCloud icon indicating copy to clipboard operation
ArduinoIoTCloud copied to clipboard

Documentation: Obtaining WiFiClient from ArduinoCloud object.

Open Frenzoid opened this issue 2 years ago • 6 comments

Ref to: https://forum.arduino.cc/t/getting-wificlient-from-arduinocloud-object/973385

Is there a way to get the WiFiClient object that ArduinoCloud creates when connecting to WiFi?

Best regards.

Frenzoid avatar Apr 06 '22 18:04 Frenzoid

Hi @Frenzoid, you should try to call ArduinoCloud.getConnection() https://github.com/arduino-libraries/ArduinoIoTCloud/blob/451d57d53da33dfad490c6c0cd9f521780066e7c/src/ArduinoIoTCloud.h#L105

and then getClient() on the returned ConnectionHandler Object https://github.com/arduino-libraries/Arduino_ConnectionHandler/blob/98db5e61bfde16e8f0be1aca008749cc106a7745/src/Arduino_WiFiConnectionHandler.h#L41

pennam avatar Apr 07 '22 07:04 pennam

Hi @Frenzoid do you need more help or we can close it ?

pennam avatar Apr 12 '22 06:04 pennam

Hello,

My issue is solved, but after talking with some peeps in the forums I've reopened so that devs can track this issue ( missing documentation/clarification regarding this function ).

Yet, if you want to close it, feel free to do so :)

Best regards.

Frenzoid avatar Apr 12 '22 06:04 Frenzoid

My issue is solved

Hi Frenzoid,

Thank you for raising this issue. A lot of libraries requiere to use wifi objects to send data. Im currently trying to use HTTPClient on ESP8266 and ESP32 and they requiere to declare the connection object to use. Normally you would use the WiFiClient object but with ArduinoCloud there is no documentation on how to access this and examples other than diggin up in git and forums.

Regards

Isaacbg84 avatar Mar 30 '24 21:03 Isaacbg84

@Isaacbg84 see answer above.

Using the method above you will get the Client ArduinoCloud is using to connect to the mqtt broker, if you need to keep ArduinoCloud and another connection, to be used with HTTPClient, running i would declare a new WiFiClient object instead of using the ArduinoCloud one.

pennam avatar Apr 02 '24 08:04 pennam

@Isaacbg84 see answer above.

Using the method above you will get the Client ArduinoCloud is using to connect to the mqtt broker, if you need to keep ArduinoCloud and another connection, to be used with HTTPClient, running i would declare a new WiFiClient object instead of using the ArduinoCloud one.

Got it. I was trying to use ArduinoIoT WiFiConnectionHandler object for this, but your answer makes a lot more sense. Thank you.

Isaacbg84 avatar Apr 06 '24 02:04 Isaacbg84