Compare commits
2 Commits
add6d2fd1e
...
3d42f3270b
Author | SHA1 | Date |
---|---|---|
Starbeamrainbowlabs | 3d42f3270b | |
Starbeamrainbowlabs | 68cd7ac8a8 |
|
@ -45,6 +45,52 @@ PubSubClient mqtt;
|
||||||
|
|
||||||
Adafruit_BME280 bme; // I2C
|
Adafruit_BME280 bme; // I2C
|
||||||
|
|
||||||
|
#ifdef WIFI_ENTERPRISE_ENABLED
|
||||||
|
// Ref https://gist.github.com/Matheus-Garbelini/2cd780aed2eddbe17eb4adb5eca42bd6
|
||||||
|
extern "C" {
|
||||||
|
#include "user_interface.h"
|
||||||
|
#include "wpa2_enterprise.h"
|
||||||
|
#include "c_types.h"
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void connect_wifi() {
|
||||||
|
#ifndef WIFI_ENTERPRISE_ENABLED
|
||||||
|
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
||||||
|
#else
|
||||||
|
// Ref https://gist.github.com/Matheus-Garbelini/2cd780aed2eddbe17eb4adb5eca42bd6
|
||||||
|
// Setting ESP into STATION mode only (no AP mode or dual mode)
|
||||||
|
wifi_set_opmode(STATION_MODE);
|
||||||
|
|
||||||
|
struct station_config wifi_config;
|
||||||
|
|
||||||
|
memset(&wifi_config, 0, sizeof(wifi_config));
|
||||||
|
strcpy((char*)wifi_config.ssid, WIFI_SSID);
|
||||||
|
strcpy((char*)wifi_config.password, WIFI_ENTERPRISE_PASSWORD);
|
||||||
|
|
||||||
|
wifi_station_set_config(&wifi_config);
|
||||||
|
// wifi_set_macaddr(STATION_IF,target_esp_mac);
|
||||||
|
|
||||||
|
wifi_station_set_wpa2_enterprise_auth(1);
|
||||||
|
|
||||||
|
// Clean up to be sure no old data is still inside
|
||||||
|
wifi_station_clear_cert_key();
|
||||||
|
wifi_station_clear_enterprise_ca_cert();
|
||||||
|
wifi_station_clear_enterprise_identity();
|
||||||
|
wifi_station_clear_enterprise_username();
|
||||||
|
wifi_station_clear_enterprise_password();
|
||||||
|
wifi_station_clear_enterprise_new_password();
|
||||||
|
|
||||||
|
wifi_station_set_enterprise_identity((uint8*)WIFI_ENTERPRISE_USERNAME, strlen(WIFI_ENTERPRISE_USERNAME));
|
||||||
|
wifi_station_set_enterprise_username((uint8*)WIFI_ENTERPRISE_USERNAME, strlen(WIFI_ENTERPRISE_USERNAME));
|
||||||
|
wifi_station_set_enterprise_password((uint8*)WIFI_ENTERPRISE_PASSWORD, strlen((char*)WIFI_ENTERPRISE_PASSWORD));
|
||||||
|
|
||||||
|
|
||||||
|
wifi_station_connect();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
float read_analog(int channel) {
|
float read_analog(int channel) {
|
||||||
|
|
||||||
const char* bin = std::bitset<8>(channel).to_string().c_str();
|
const char* bin = std::bitset<8>(channel).to_string().c_str();
|
||||||
|
@ -96,7 +142,8 @@ void setup() {
|
||||||
// https://gist.github.com/Matheus-Garbelini/2cd780aed2eddbe17eb4adb5eca42bd6
|
// https://gist.github.com/Matheus-Garbelini/2cd780aed2eddbe17eb4adb5eca42bd6
|
||||||
// TODO Add support for enterprise WiFi here so we can connect to eduroam
|
// TODO Add support for enterprise WiFi here so we can connect to eduroam
|
||||||
Serial.print("WIFI: ");
|
Serial.print("WIFI: ");
|
||||||
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
|
||||||
|
connect_wifi();
|
||||||
|
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// The port to connect to.
|
// The port to connect to.
|
||||||
// 1883 = unencrypted, 8883 = encrypted
|
// 1883 = unencrypted, 8883 = encrypted
|
||||||
// Connections are encrypted by default. There isn't currently a way to disable it.
|
// Connections are encrypted by default. There isn't currently a way to disable it.
|
||||||
#define MQTT_PORT "8883"
|
#define MQTT_PORT 8883
|
||||||
// The username to authenticate with when connecting to the MQTT server.
|
// The username to authenticate with when connecting to the MQTT server.
|
||||||
#define MQTT_USERNAME "autoplant"
|
#define MQTT_USERNAME "autoplant"
|
||||||
// The password to authenticate with when connecting to the MQTT server.
|
// The password to authenticate with when connecting to the MQTT server.
|
||||||
|
|
Loading…
Reference in New Issue