Skip to content

Commit 8e056f2

Browse files
authored
Merge pull request #567 from blinker-iot/dev_3.0
update codes
2 parents 500adf3 + 01b9bb8 commit 8e056f2

File tree

5 files changed

+12
-130
lines changed

5 files changed

+12
-130
lines changed

examples/Blinker_Air/Air_WiFi/Air_WiFi.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void dataRead(const String & data)
6666
Blinker.print("millis", BlinkerTime);
6767

6868
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
69-
Blinker.aqi();
69+
Blinker.air();
7070

7171
Blinker.delay(60000);
7272
}

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ wechat KEYWORD2
110110
weather KEYWORD2
111111
weatherForecast KEYWORD2
112112
aqi KEYWORD2
113+
air KEYWORD2
113114
status KEYWORD2
114115
flush KEYWORD2
115116
init KEYWORD2

src/Adapters/BlinkerMQTT.h

Lines changed: 1 addition & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ void BlinkerMQTT::flush()
929929
{
930930
BLINKER_LOG_ALL(BLINKER_F("flush"));
931931

932-
_needCheckShare = false;
932+
// _needCheckShare = false;
933933

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

1866-
// WiFiClientSecure client_s;
1867-
1868-
// BearSSL::WiFiClientSecure *client_s;
1869-
1870-
// client_s = new BearSSL::WiFiClientSecure();
1871-
1872-
// BLINKER_LOG_ALL(BLINKER_F("connecting to "), host);
1873-
1874-
// // BLINKER_LOG_FreeHeap();
1875-
1876-
// uint8_t connet_times = 0;
1877-
// // client_s.stop();
1878-
// ::delay(100);
1879-
1880-
// // bool mfln = client_s.probeMaxFragmentLength(host, httpsPort, 1024);
1881-
// // if (mfln) {
1882-
// // client_s.setBufferSizes(1024, 1024);
1883-
// // }
1884-
// client_s->setFingerprint(fingerprint.c_str());
1885-
1886-
// client_s->setInsecure();
1887-
1888-
// // while (1) {
1889-
// bool cl_connected = false;
1890-
// if (!client_s->connect(host, httpsPort)) {
1891-
// BLINKER_ERR_LOG(BLINKER_F("server connection failed"));
1892-
// // connet_times++;
1893-
1894-
// ::delay(1000);
1895-
// }
1896-
// else {
1897-
// BLINKER_LOG_ALL(BLINKER_F("connection succeed"));
1898-
// cl_connected = true;
1899-
1900-
// // break;
1901-
// }
1902-
1903-
// // if (connet_times >= 4 && !cl_connected) return BLINKER_CMD_FALSE;
1904-
// // }
1905-
1906-
// String client_msg;
1907-
1908-
// String url_iot = BLINKER_F("/api/v1/user/device/diy/auth?authKey=");
1909-
// url_iot += _authKey;
1910-
// url_iot += _aliType;
1911-
// url_iot += _duerType;
1912-
1913-
// // #if defined(BLINKER_ALIGENIE_LIGHT)
1914-
// // url_iot += BLINKER_F("&aliType=light");
1915-
// // #elif defined(BLINKER_ALIGENIE_OUTLET)
1916-
// // url_iot += BLINKER_F("&aliType=outlet");
1917-
// // #elif defined(BLINKER_ALIGENIE_SWITCH)
1918-
// // #elif defined(BLINKER_ALIGENIE_SENSOR)
1919-
// // url_iot += BLINKER_F("&aliType=sensor");
1920-
// // #endif
1921-
1922-
// BLINKER_LOG_ALL(BLINKER_F("HTTPS begin: "), host, url_iot);
1923-
1924-
// client_msg = BLINKER_F("GET ");
1925-
// client_msg += url_iot;
1926-
// client_msg += BLINKER_F(" HTTP/1.1\r\nHost: ");
1927-
// client_msg += host;
1928-
// client_msg += BLINKER_F(":");
1929-
// client_msg += STRING_format(httpsPort);
1930-
// client_msg += BLINKER_F("\r\nConnection: close\r\n\r\n");
1931-
1932-
// client_s->print(client_msg);
1933-
1934-
// BLINKER_LOG_ALL(BLINKER_F("client_msg: "), client_msg);
1935-
1936-
// unsigned long timeout = millis();
1937-
// while (client_s->available() == 0) {
1938-
// if (millis() - timeout > 5000) {
1939-
// BLINKER_LOG_ALL(BLINKER_F(">>> Client Timeout !"));
1940-
// client_s->stop();
1941-
// return false;
1942-
// }
1943-
// }
1944-
1945-
// String _dataGet;
1946-
// String lastGet;
1947-
// String lengthOfJson;
1948-
// while (client_s->available()) {
1949-
// // String line = client_s.readStringUntil('\r');
1950-
// _dataGet = client_s->readStringUntil('\n');
1951-
1952-
// if (_dataGet.startsWith("Content-Length: ")){
1953-
// int addr_start = _dataGet.indexOf(' ');
1954-
// int addr_end = _dataGet.indexOf('\0', addr_start + 1);
1955-
// lengthOfJson = _dataGet.substring(addr_start + 1, addr_end);
1956-
// }
1957-
1958-
// if (_dataGet == "\r") {
1959-
// BLINKER_LOG_ALL(BLINKER_F("headers received"));
1960-
1961-
// break;
1962-
// }
1963-
// }
1964-
1965-
// for(int i=0;i<lengthOfJson.toInt();i++){
1966-
// lastGet += (char)client_s->read();
1967-
// }
1968-
1969-
// // BLINKER_LOG_FreeHeap();
1970-
1971-
// client_s->stop();
1972-
// client_s->flush();
1973-
1974-
// free(client_s);
1975-
1976-
// // BLINKER_LOG_FreeHeap();
1977-
1978-
// _dataGet = lastGet;
1979-
1980-
// BLINKER_LOG_ALL(BLINKER_F("_dataGet: "), _dataGet);
1981-
1982-
// String payload = _dataGet;
1983-
1984-
19851866
#ifndef BLINKER_WITHOUT_SSL
19861867
client_mqtt.stop();
19871868

src/Blinker/BlinkerApi.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,11 @@ class BlinkerApi : public BlinkerProtocol
376376
#if !defined(BLINKER_AT_MQTT)
377377
void weather(uint32_t _city = 0);
378378
void weatherForecast(uint32_t _city = 0);
379-
void aqi(uint32_t _city = 0);
379+
void air(uint32_t _city = 0);
380380
#else
381381
String weather(uint32_t _city = 0);
382382
String weatherForecast(uint32_t _city = 0);
383-
String aqi(uint32_t _city = 0);
383+
String air(uint32_t _city = 0);
384384
#endif
385385

386386
void log(const String & msg);
@@ -650,7 +650,7 @@ class BlinkerApi : public BlinkerProtocol
650650
int16_t yday() { return atGetInt(BLINKER_CMD_YDAY); }
651651
void weather(uint32_t _city = 0);
652652
void weatherForecast(uint32_t _city = 0);
653-
void aqi(uint32_t _city = 0);
653+
void air(uint32_t _city = 0);
654654
void log(const String & msg);
655655
void coordinate(float _long, float _lat);
656656
template<typename T>
@@ -6207,7 +6207,7 @@ float BlinkerApi::gps(b_gps_t axis)
62076207
#endif
62086208
}
62096209

6210-
void BlinkerApi::aqi(uint32_t _city)
6210+
void BlinkerApi::air(uint32_t _city)
62116211
{
62126212
String data = BLINKER_F("/air?");
62136213

@@ -6384,7 +6384,7 @@ float BlinkerApi::gps(b_gps_t axis)
63846384
#endif
63856385
}
63866386

6387-
String BlinkerApi::aqi(uint32_t _city)
6387+
String BlinkerApi::air(uint32_t _city)
63886388
{
63896389
String data = BLINKER_F("/air?");
63906390

@@ -13956,7 +13956,7 @@ char * BlinkerApi::widgetName_tab(uint8_t num)
1395613956
reqData = BLINKER_F("+");
1395713957
reqData += BLINKER_CMD_WEATHER_AT;
1395813958
reqData += BLINKER_F(":");
13959-
reqData += STRING_format(weather(_slaverAT->getParam(0)));
13959+
reqData += STRING_format(weather(_slaverAT->getParam(0).toInt()));
1396013960

1396113961
BProto::serialPrint(reqData);
1396213962
BProto::serialPrint(BLINKER_CMD_OK);
@@ -13967,7 +13967,7 @@ char * BlinkerApi::widgetName_tab(uint8_t num)
1396713967
reqData = BLINKER_F("+");
1396813968
reqData += BLINKER_CMD_AQI_AT;
1396913969
reqData += BLINKER_F(":");
13970-
reqData += STRING_format(aqi(_slaverAT->getParam(0)));
13970+
reqData += STRING_format(air(_slaverAT->getParam(0).toInt()));
1397113971

1397213972
BProto::serialPrint(reqData);
1397313973
BProto::serialPrint(BLINKER_CMD_OK);
@@ -14420,7 +14420,7 @@ char * BlinkerApi::widgetName_tab(uint8_t num)
1442014420
}
1442114421

1442214422

14423-
void BlinkerApi::aqi(uint32_t _city)
14423+
void BlinkerApi::air(uint32_t _city)
1442414424
{
1442514425
if (_airFunc)
1442614426
{

src/Blinker/BlinkerConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
#define BLINKER_AT_MSG_TIMEOUT 1000UL
5353

54-
#define BLINKER_SERVER_CONNECT_LIMIT 12
54+
#define BLINKER_SERVER_CONNECT_LIMIT 3
5555

5656
#if defined(BLINKER_DATA_HOUR_UPDATE)
5757
#define BLINKER_DATA_FREQ_TIME 3600UL

0 commit comments

Comments
 (0)