Skip to content

Commit

Permalink
update codes, fix AUTO FRESH codes
Browse files Browse the repository at this point in the history
  • Loading branch information
i3water committed Mar 19, 2021
1 parent df240d3 commit 112e1f0
Showing 1 changed file with 1 addition and 120 deletions.
121 changes: 1 addition & 120 deletions src/Adapters/BlinkerMQTT.h
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ void BlinkerMQTT::flush()
{
BLINKER_LOG_ALL(BLINKER_F("flush"));

_needCheckShare = false;
// _needCheckShare = false;

free(msgBuf_MQTT); isFresh_MQTT = false; isAvail_MQTT = false;
isAliAvail = false; isDuerAvail = false; isMIOTAvail = false;//isBavail = false;
Expand Down Expand Up @@ -1863,125 +1863,6 @@ int BlinkerMQTT::connectServer() {
String host = BLINKER_F(BLINKER_SERVER_HOST);
String fingerprint = BLINKER_F("84 5f a4 8a 70 5e 79 7e f5 b3 b4 20 45 c8 35 55 72 f6 85 5a");

// WiFiClientSecure client_s;

// BearSSL::WiFiClientSecure *client_s;

// client_s = new BearSSL::WiFiClientSecure();

// BLINKER_LOG_ALL(BLINKER_F("connecting to "), host);

// // BLINKER_LOG_FreeHeap();

// uint8_t connet_times = 0;
// // client_s.stop();
// ::delay(100);

// // bool mfln = client_s.probeMaxFragmentLength(host, httpsPort, 1024);
// // if (mfln) {
// // client_s.setBufferSizes(1024, 1024);
// // }
// client_s->setFingerprint(fingerprint.c_str());

// client_s->setInsecure();

// // while (1) {
// bool cl_connected = false;
// if (!client_s->connect(host, httpsPort)) {
// BLINKER_ERR_LOG(BLINKER_F("server connection failed"));
// // connet_times++;

// ::delay(1000);
// }
// else {
// BLINKER_LOG_ALL(BLINKER_F("connection succeed"));
// cl_connected = true;

// // break;
// }

// // if (connet_times >= 4 && !cl_connected) return BLINKER_CMD_FALSE;
// // }

// String client_msg;

// String url_iot = BLINKER_F("/api/v1/user/device/diy/auth?authKey=");
// url_iot += _authKey;
// url_iot += _aliType;
// url_iot += _duerType;

// // #if defined(BLINKER_ALIGENIE_LIGHT)
// // url_iot += BLINKER_F("&aliType=light");
// // #elif defined(BLINKER_ALIGENIE_OUTLET)
// // url_iot += BLINKER_F("&aliType=outlet");
// // #elif defined(BLINKER_ALIGENIE_SWITCH)
// // #elif defined(BLINKER_ALIGENIE_SENSOR)
// // url_iot += BLINKER_F("&aliType=sensor");
// // #endif

// BLINKER_LOG_ALL(BLINKER_F("HTTPS begin: "), host, url_iot);

// client_msg = BLINKER_F("GET ");
// client_msg += url_iot;
// client_msg += BLINKER_F(" HTTP/1.1\r\nHost: ");
// client_msg += host;
// client_msg += BLINKER_F(":");
// client_msg += STRING_format(httpsPort);
// client_msg += BLINKER_F("\r\nConnection: close\r\n\r\n");

// client_s->print(client_msg);

// BLINKER_LOG_ALL(BLINKER_F("client_msg: "), client_msg);

// unsigned long timeout = millis();
// while (client_s->available() == 0) {
// if (millis() - timeout > 5000) {
// BLINKER_LOG_ALL(BLINKER_F(">>> Client Timeout !"));
// client_s->stop();
// return false;
// }
// }

// String _dataGet;
// String lastGet;
// String lengthOfJson;
// while (client_s->available()) {
// // String line = client_s.readStringUntil('\r');
// _dataGet = client_s->readStringUntil('\n');

// if (_dataGet.startsWith("Content-Length: ")){
// int addr_start = _dataGet.indexOf(' ');
// int addr_end = _dataGet.indexOf('\0', addr_start + 1);
// lengthOfJson = _dataGet.substring(addr_start + 1, addr_end);
// }

// if (_dataGet == "\r") {
// BLINKER_LOG_ALL(BLINKER_F("headers received"));

// break;
// }
// }

// for(int i=0;i<lengthOfJson.toInt();i++){
// lastGet += (char)client_s->read();
// }

// // BLINKER_LOG_FreeHeap();

// client_s->stop();
// client_s->flush();

// free(client_s);

// // BLINKER_LOG_FreeHeap();

// _dataGet = lastGet;

// BLINKER_LOG_ALL(BLINKER_F("_dataGet: "), _dataGet);

// String payload = _dataGet;


#ifndef BLINKER_WITHOUT_SSL
client_mqtt.stop();

Expand Down

0 comments on commit 112e1f0

Please sign in to comment.