Skip to content

Commit af4cb40

Browse files
authored
Merge pull request #572 from blinker-iot/dev_3.0
update codes, fix rtdata bug.
2 parents 10e12ad + 65857ac commit af4cb40

File tree

10 files changed

+46
-21
lines changed

10 files changed

+46
-21
lines changed

examples/Blinker_DataStorage/Blinker_JsonData/Blinker_JsonData.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void dataRead(const String & data)
5757

5858
uint32_t BlinkerTime = millis();
5959

60-
Blinker.jsonData("{\"key\":\"value\"");
60+
Blinker.jsonData("{\"key\":\"value\"}");
6161

6262
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
6363
}

examples/Blinker_MIOT/MIOT_MULTI_OUTLET/MIOT_MULTI_OUTLET.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void miotPowerState(const String & state, uint8_t num)
8686

8787
void miotQuery(int32_t queryCode, uint8_t num)
8888
{
89-
BLINKER_LOG("AliGenie Query outlet: ", num,", codes: ", queryCode);
89+
BLINKER_LOG("MIOT Query outlet: ", num,", codes: ", queryCode);
9090

9191
switch (queryCode)
9292
{

examples/Blinker_OTA/OTA_WiFi/OTA_WiFi.ino

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* if use ESP8266 with Blinker.
1515
* https://github.com/esp8266/Arduino/releases
1616
*
17-
* Make sure installed 1.0.4 or later ESP32/Arduino package,
17+
* Make sure installed 1.0.5 or later ESP32/Arduino package,
1818
* if use ESP32 with Blinker.
1919
* https://github.com/espressif/arduino-esp32/releases
2020
*
@@ -58,9 +58,12 @@
5858
char type[] = "Your Device Type";
5959
char auth[] = "Your Device Secret Key";
6060

61+
#define BLINKER_OTA_BLINK_TIME 500
62+
6163
BlinkerButton Button1("btn-abc");
6264
BlinkerNumber Number1("num-abc");
6365

66+
uint32_t os_time;
6467
int counter = 0;
6568

6669
void button1_callback(const String & state)
@@ -142,10 +145,19 @@ void dataRead(const String & data)
142145
Number1.print(counter);
143146
}
144147

148+
// void otaStatus(uint32_t load_size, uint32_t total_size)
149+
// {
150+
// if (millis() - os_time >= BLINKER_OTA_BLINK_TIME)
151+
// {
152+
// os_time = millis();
153+
154+
// digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
155+
// }
156+
// }
157+
145158
void setup()
146159
{
147160
Serial.begin(115200);
148-
BLINKER_DEBUG.stream(Serial);
149161
BLINKER_DEBUG.debugAll();
150162

151163
pinMode(LED_BUILTIN, OUTPUT);
@@ -162,6 +174,7 @@ void setup()
162174
Blinker.attachDoubleClick(doubleClick);
163175
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
164176
#endif
177+
// BlinkerUpdater.onProgress(otaStatus);
165178
}
166179

167180
void loop()

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"type": "git",
1414
"url": "https://github.com/blinker-iot/blinker-library.git"
1515
},
16-
"version": "0.3.7",
16+
"version": "0.3.7.210421",
1717
"homepage": "https://blinker.app/",
1818
"export": {
1919
"exclude": [

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Blinker
2-
version=0.3.7
2+
version=0.3.7.210421
33
author=i3water
44
maintainer=i3wawter
55
sentence=Build a easy way for your IoT project.

src/Adapters/BlinkerMQTT.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,8 +1340,10 @@ int BlinkerMQTT::aliPrint(const String & data)
13401340
data_add += STRING_format(_messageId);
13411341
data_add += BLINKER_F("\"}");
13421342
}
1343+
13431344
data_add += BLINKER_F(",\"fromDevice\":\"");
13441345
data_add += DEVICE_NAME_MQTT;
1346+
13451347
if (_use_broker == aliyun_b)
13461348
{
13471349
data_add += BLINKER_F("\",\"toDevice\":\"AliGenie_r\"");
@@ -1350,6 +1352,7 @@ int BlinkerMQTT::aliPrint(const String & data)
13501352
{
13511353
data_add += BLINKER_F("\",\"toDevice\":\"ServerReceiver\"");
13521354
}
1355+
13531356
data_add += BLINKER_F(",\"deviceType\":\"vAssistant\"}");
13541357

13551358
if (!isJson(data_add)) return false;
@@ -1586,7 +1589,7 @@ int BlinkerMQTT::miPrint(const String & data)
15861589
data_add += STRING_format(_messageId);
15871590
data_add += BLINKER_F("\"}");
15881591
}
1589-
1592+
15901593
data_add += BLINKER_F(",\"fromDevice\":\"");
15911594
data_add += DEVICE_NAME_MQTT;
15921595
if (_use_broker == aliyun_b)

src/Adapters/BlinkerPROESP.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ int BlinkerPROESP::aliPrint(const String & data)
12921292
strcpy(send_data, data_add.c_str());
12931293
}
12941294

1295-
if (! mqtt_MQTT->publish(BLINKER_RRPC_PUB_TOPIC_MQTT, send_data))
1295+
if (! mqtt_PRO->publish(BLINKER_RRPC_PUB_TOPIC_MQTT, send_data))
12961296
{
12971297
BLINKER_LOG_ALL(data_add);
12981298
BLINKER_LOG_ALL(BLINKER_F("...Failed"));
@@ -1423,7 +1423,7 @@ int BlinkerPROESP::duerPrint(const String & data, bool report)
14231423
strcpy(send_data, data_add.c_str());
14241424
}
14251425

1426-
if (! mqtt_MQTT->publish(BLINKER_RRPC_PUB_TOPIC_MQTT, send_data))
1426+
if (! mqtt_PRO->publish(BLINKER_RRPC_PUB_TOPIC_MQTT, send_data))
14271427
{
14281428
BLINKER_LOG_ALL(data_add);
14291429
BLINKER_LOG_ALL(BLINKER_F("...Failed"));
@@ -1539,7 +1539,7 @@ int BlinkerPROESP::miPrint(const String & data)
15391539
strcpy(send_data, data_add.c_str());
15401540
}
15411541

1542-
if (! mqtt_MQTT->publish(BLINKER_RRPC_PUB_TOPIC_MQTT, send_data))
1542+
if (! mqtt_PRO->publish(BLINKER_RRPC_PUB_TOPIC_MQTT, send_data))
15431543
{
15441544
BLINKER_LOG_ALL(data_add);
15451545
BLINKER_LOG_ALL(BLINKER_F("...Failed"));

src/Blinker.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#define BLINKER_MQTT
3131
#endif
3232

33+
#define BLINKER_PROTOCOL_HTTP_SERVER
34+
3335
#include "BlinkerAssistant.h"
3436

3537
#if (defined(ESP8266) || defined(ESP32)) && !defined(BLINKER_MQTT_AT)
@@ -78,6 +80,8 @@
7880
#endif
7981
#endif
8082

83+
#define BLINKER_PROTOCOL_HTTP_SERVER
84+
8185
#if defined(ESP8266) || defined(ESP32)
8286
#include "BlinkerESPPRO.h"
8387

src/Blinker/BlinkerApi.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ class BlinkerApi : public BlinkerProtocol
496496
#endif
497497

498498
#if defined(BLINKER_WIFI) || defined(BLINKER_MQTT) || \
499-
defined(BLINKER_PRO)
499+
defined(BLINKER_PRO) || defined(BLINKER_PRO_ESP)
500500

501501
void attachRTData(char _name[], blinker_callback_t newFunction)
502502
{
@@ -1073,7 +1073,7 @@ class BlinkerApi : public BlinkerProtocol
10731073
#endif
10741074

10751075
#if defined(BLINKER_WIFI) || defined(BLINKER_MQTT) || \
1076-
defined(BLINKER_PRO)
1076+
defined(BLINKER_PRO) || defined(BLINKER_PRO_ESP)
10771077
char _RTDataKey[16];
10781078
blinker_callback_t _RTDataFunc = NULL;
10791079
Ticker _RTTicker;
@@ -1187,7 +1187,7 @@ class BlinkerApi : public BlinkerProtocol
11871187
blinker_callback_with_string_arg_t _dataGetFunc = NULL;
11881188

11891189
#if defined(BLINKER_WIFI) || defined(BLINKER_MQTT) || \
1190-
defined(BLINKER_PRO)
1190+
defined(BLINKER_PRO) || defined(BLINKER_PRO_ESP)
11911191
void rtParse(const JsonObject& data);
11921192
#endif
11931193

@@ -4626,7 +4626,7 @@ void BlinkerApi::run()
46264626
}
46274627

46284628
#if defined(BLINKER_WIFI) || defined(BLINKER_MQTT) || \
4629-
defined(BLINKER_PRO)
4629+
defined(BLINKER_PRO) || defined(BLINKER_PRO_ESP)
46304630
void BlinkerApi::rtParse(const JsonObject& data)
46314631
{
46324632
String get_key = data[_RTDataKey][BLINKER_CMD_GET];
@@ -4702,8 +4702,10 @@ void BlinkerApi::parse(char _data[], bool ex_data)
47024702
defined(BLINKER_WIFI_SUBDEVICE) || defined(BLINKE_HTTP)
47034703
shareParse(root);
47044704
autoManager(root);
4705-
4705+
4706+
#if !defined(BLINKER_AT_MQTT)
47064707
rtParse(root);
4708+
#endif
47074709
#if !defined(BLINKER_WIFI_SUBDEVICE)
47084710
otaParse(root);
47094711
numParse(root);
@@ -6348,6 +6350,8 @@ float BlinkerApi::gps(b_gps_t axis)
63486350
{
63496351
String data = BLINKER_F("{\"token\":\"");
63506352
data += BProto::token();
6353+
data += BLINKER_F("\",\"device\":\"");
6354+
data += BProto::deviceName();
63516355
data += BLINKER_F("\",\"data\":[[");
63526356
data += STRING_format(time());
63536357
data += BLINKER_F(",\"");
@@ -6831,7 +6835,7 @@ float BlinkerApi::gps(b_gps_t axis)
68316835
}
68326836
}
68336837

6834-
6838+
#if !defined(BLINKER_AT_MQTT)
68356839
void BlinkerApi::RTDataStorage(char _name[], int msg)
68366840
{
68376841
// String _msg = STRING_format(msg);
@@ -6912,6 +6916,7 @@ float BlinkerApi::gps(b_gps_t axis)
69126916

69136917
printObject(_RTDataKey, data);
69146918
}
6919+
#endif
69156920

69166921

69176922
void BlinkerApi::timeSlotData(char _name[], int32_t _data)
@@ -12145,9 +12150,9 @@ char * BlinkerApi::widgetName_tab(uint8_t num)
1214512150
case BLINKER_CMD_TEXT_DATA_NUMBER :
1214612151
// url_iot = host;
1214712152
#ifndef BLINKER_WITHOUT_SSL
12148-
url_iot = BLINKER_F("https://storage.diandeng.tech/api/v1/storage/text");
12153+
url_iot = BLINKER_F("https://storage.diandeng.tech/api/v1/storage/tt");
1214912154
#else
12150-
url_iot = BLINKER_F("http://storage.diandeng.tech/api/v1/storage/text");
12155+
url_iot = BLINKER_F("http://storage.diandeng.tech/api/v1/storage/tt");
1215112156
#endif
1215212157

1215312158
#if defined(ESP8266)
@@ -12166,9 +12171,9 @@ char * BlinkerApi::widgetName_tab(uint8_t num)
1216612171
case BLINKER_CMD_JSON_DATA_NUMBER :
1216712172
// url_iot = host;
1216812173
#ifndef BLINKER_WITHOUT_SSL
12169-
url_iot = BLINKER_F("https://storage.diandeng.tech/api/v1/storage/object");
12174+
url_iot = BLINKER_F("https://storage.diandeng.tech/api/v1/storage/ot");
1217012175
#else
12171-
url_iot = BLINKER_F("http://storage.diandeng.tech/api/v1/storage/object");
12176+
url_iot = BLINKER_F("http://storage.diandeng.tech/api/v1/storage/ot");
1217212177
#endif
1217312178

1217412179
#if defined(ESP8266)

src/Blinker/BlinkerConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// #include "Blinker/BlinkerUtility.h"
66
#include "../Server/BlinkerServer.h"
77

8-
#define BLINKER_VERSION "0.3.7"
8+
#define BLINKER_VERSION "0.3.7.210421"
99

1010
#define BLINKER_CONNECT_TIMEOUT_MS 10000UL
1111

0 commit comments

Comments
 (0)