ESP8266 Gmail Notifier Issue - PullRequest
       54

ESP8266 Gmail Notifier Issue

0 голосов
/ 07 ноября 2019

Я новичок в ESP8266 и следую приведенному ниже руководству. Из этого я пытаюсь получить количество непрочитанных писем от Google. Мой код выглядит как

#include <WiFiClientSecure.h>   // Include the HTTPS library
#include <ESP8266WiFi.h>        // Include the Wi-Fi library

const char* host = "mail.google.com"; 
const char* url = "/mail/feed/atom";  
const int httpsPort = 443;  

const char* ssid     = "BSNL"; 
const char* password = "PASSWORD123";          

void setup() {
  Serial.begin(115200);
  delay(10);

  WiFi.begin(ssid, password);             // Connect to the network
  Serial.print("Connecting to ");
  Serial.print(ssid); Serial.println(" ...");

  int i = 0;
  while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
    delay(1000);
    Serial.print(++i); Serial.print(' ');
  }

  Serial.println('\n');
  Serial.println("Connection established!");  
  Serial.print("IP address:\t");
  Serial.println(WiFi.localIP());         

}


void loop(){
   int unread = getUnread();
   Serial.print(unread);
}

int getUnread() {    
  WiFiClientSecure client;  //connection
  Serial.printf("Connecting to %s:%d ... \r\n", host, httpsPort);
  if (!client.connect(host, httpsPort)) {   // Connect to the Gmail server, on port 443
    Serial.println("Connection failed");    // If the connection fails, stop and return
    return -1;
  }
}

Не завершена функция getUnread(). Но на данный момент всегда отображается «сбой соединения» и возвращается -1.

Аппаратное обеспечение: NodeMCU Amica (имеет модуль Wi-Fi ESP8266)

IDE: Arduino - последняя версия

Далее следует руководство: https://tttapa.github.io/ESP8266/Chap17%20-%20Email%20Notifier.html

Любая идея для решенияэто? TIA

Обновление: проблема устранена путем добавления client.setInsecure() в setup()

...