diff --git a/src/TinyGsmClientXBee.h b/src/TinyGsmClientXBee.h index cf6b18b..0ba9ab4 100644 --- a/src/TinyGsmClientXBee.h +++ b/src/TinyGsmClientXBee.h @@ -597,16 +597,22 @@ public: bool networkConnect(const char* ssid, const char* pwd) { if (!commandMode()) return false; // return immediately + //nh For no pwd don't set setscurity or pwd + if (NULL == ssid ) return exitAndFail(); - sendAT(GF("EE"), 2); // Set security to WPA2 + if (NULL != pwd) + { + sendAT(GF("EE"), 2); // Set security to WPA2 + if (waitResponse() != 1) return exitAndFail(); + sendAT(GF("PK"), pwd); + } else { + sendAT(GF("EE"), 0); // Set No security + } if (waitResponse() != 1) return exitAndFail(); sendAT(GF("ID"), ssid); if (waitResponse() != 1) return exitAndFail(); - sendAT(GF("PK"), pwd); - if (waitResponse() != 1) return exitAndFail(); - if (!writeChanges()) return exitAndFail(); exitCommand();