Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use without using Arduino_ConnectionHandler library #338

Open
chrisisbeef opened this issue Oct 4, 2022 · 12 comments
Open

Use without using Arduino_ConnectionHandler library #338

chrisisbeef opened this issue Oct 4, 2022 · 12 comments
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@chrisisbeef
Copy link

It would be really nice if there was a way to use this without it taking control of the network connection allowing someone to do their own network connection handling. Is this something that the team would consider, or would my best bet to to fork this and customize if for my own use?

@pennam
Copy link
Collaborator

pennam commented Oct 5, 2022

Hi @chrisisbeef
what do you think is missing or does not fit your needs in the Arduino_ConnectionHandler implementation?

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Oct 5, 2022
@olipinski
Copy link

An issue I have run into is using the Arduino_ConnectionHandler with a WPA2 Enterprise network, which is currently not supported AFAIK. WiFiNINA does support it though, so it can be done through that instead, but then ideally we should be able to call .begin() with no arguments.

@milanbx
Copy link

milanbx commented Jan 9, 2024

Hi, I have simmilar issue with ESP8266 board. I have created my own connection manager (not a custom handler in terms of your class) and initialize the Arduino cloud with ArduinoCloud.begin(); without any parameters. I suppose, such an approach is possible as this overload of the begin method does exist.
I have also left out the ArduinoCloud.update(); call from loop, as the docs says, that it is needed only for watch dog functionality and ESP8266 is not a supported device for this.
And the result is, that my ESP-01 board connects to my wifi, but dos not interact with the Arduino Cloud at all :-(
Here are the core parts of my sketch:

#include <ArduinoIoTCloud.h>
// #include <Arduino_ConnectionHandler.h>
#include "ESPWiFiManager.h" //my custom wifi connection manager due to need of ESP8266WiFiMulti class 

#define SECRET_DEVICE_KEY "**********************************" //masked out just for the purpose of this forum
#define SECRET_OPTIONAL_PASS "**********"
#define SECRET_SSID "***************"
const char DEVICE_LOGIN_NAME[] = "***********************";
const char SSID[] = SECRET_SSID;
const char PASS[] = SECRET_OPTIONAL_PASS;
const char DEVICE_KEY[] = SECRET_DEVICE_KEY;

// WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

bool btnState;
void onBtnStateChange()
{
  digitalWrite(LED_BUILTIN, btnState);
}

void setup()
{
  DEBUGINIT(115200); //opens the hw serial etc.

  ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
  ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
  ArduinoCloud.addProperty(btnState, READWRITE, ON_CHANGE, onBtnStateChange);

  wifiMgr.SetupWifi("ArduinoCloud", LED_BUILTIN); //sets up wifi connection, device host name and LED to blink for several infos
  wifiMgr.ConnectWifi(); //connects to my wifi

  ArduinoCloud.begin();
}

void loop()
{
    //ArduinoCloud.update();
}

What am I missing?

@per1234
Copy link
Contributor

per1234 commented Jan 10, 2024

such an approach is possible as this overload of the begin method does exist.

You make a good point:

int begin(bool const enable_watchdog = true, String brokerAddress = DEFAULT_BROKER_ADDRESS_SECURE_AUTH, uint16_t brokerPort = DEFAULT_BROKER_PORT_SECURE_AUTH);

What am I missing?

Although feedback regarding the need or lack of need for changes to the library in order to support use without the "Arduino_ConnectionHandler" library is welcome, this is not an appropriate place to request assistance with your project. Please feel free to request assistance over on Arduino Forum:

https://forum.arduino.cc/c/software/iot-cloud/152

I'm sure we'll be able to help you out over there.

@milanbx
Copy link

milanbx commented Jan 11, 2024

OK, thanks, I have creted a related topic in the forum.

@pennam
Copy link
Collaborator

pennam commented Jan 11, 2024

Hi @milanbx I've created this draft PR #405 that should do the trick. Not yet finalized, but i've tested with a couple of boards and it is working.

I have also left out the ArduinoCloud.update(); call from loop
You always have to call ArduinoCloud.update(); in the loop otherwise communication with the cloud stops.

@milanbx
Copy link

milanbx commented Jan 11, 2024

Thanks @pennam a lot!

@pennam
Copy link
Collaborator

pennam commented Jan 12, 2024

Thanks @pennam a lot!

If you give it a try, let me know if it works for you!

@milanbx
Copy link

milanbx commented Jan 12, 2024

@pennam: I have tried it and works fine! Thanks a lot! I'll wait for the PR to complete to update libraries...

@milanbx
Copy link

milanbx commented Jan 12, 2024

@pennam: Additionally, even your ArduinoIoTCloud-Client.ino example in thingProperties.h > initProperties contains following line:
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
which causes plenty of compiler warnings - see issue #402, please.

@pennam
Copy link
Collaborator

pennam commented Jan 12, 2024

I have tried it and works fine!

Good! Thanks for the feedback

I'll wait for the PR to complete to update libraries...

I'll try to complete the PR as soon as possible, this was something unplanned so please be patient.

@milanbx
Copy link

milanbx commented Jan 12, 2024

No rush, please... 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants