Arduino - 如何使HTTPS工作?

时间:2018-02-02 08:12:30

标签: c++ arduino arduino-yun

当我使用HTTP时,微处理器Arduino YUN正在工作,但无法使用HTTPS client.get("https://me.example.com/ajax/robot?command=1");

如何使HTTPS工作?

#include <Bridge.h>
#include <HttpClient.h>

String result = String("");
void setup() {
  delay(5000);
  pinMode(2, OUTPUT);  
  Bridge.begin();  
  digitalWrite(2, HIGH);
}

void loop() {
  HttpClient client;

  // PIN 2
  //client.get("http://me.example.com/ajax/robot?command=1");
  client.get("https://me.example.com/ajax/robot?command=1");
  result = "";
  while (client.available()) {
    char c = client.read();
    result = result + c;
  }
  if(result.indexOf("reboot") >= 0) {
    digitalWrite(2, LOW);
    delay(3000);
    digitalWrite(2, HIGH);
  }

  delay(7000);
}

0 个答案:

没有答案