Skip to content

Commit f0db94c

Browse files
committed
Update
1 parent 6963704 commit f0db94c

File tree

7 files changed

+61
-24
lines changed

7 files changed

+61
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Firebase RTDB Arduino Client for ARM/AVR WIFI Dev Boards
22

33

4-
Google's Firebase Realtime Database Arduino Library for ARM/AVR WIFI Development Boards based on WiFiNINA library, v 1.0.0
4+
Google's Firebase Realtime Database Arduino Library for ARM/AVR WIFI Development Boards based on WiFiNINA library, v 1.0.1
55

66
This client library provides the most reliable operations for read, store, update Firebase RTDB through REST API.
77

examples/Basic/Basic.ino

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*
2+
* Created by K. Suwatchai (Mobizt)
3+
*
4+
5+
*
6+
* Github: https://github.com/mobizt
7+
*
8+
* Copyright (c) 2019 mobizt
9+
*
10+
*/
11+
12+
13+
114
//Example shows how to connect to Firebase RTDB and perform basic operation for set, get, push and update data to database
215

316
//Required WiFiNINA Library for Arduino from https://github.com/arduino-libraries/WiFiNINA
@@ -58,7 +71,7 @@ void setup()
5871
else if (firebaseData.dataType() == "float")
5972
Serial.println(firebaseData.floatData());
6073
else if (firebaseData.dataType() == "boolean")
61-
Serial.println(firebaseData.boolData());
74+
Serial.println(firebaseData.boolData() == 1 ? "true" : "false");
6275
else if (firebaseData.dataType() == "string")
6376
Serial.println(firebaseData.stringData());
6477
else if (firebaseData.dataType() == "json")
@@ -94,7 +107,7 @@ void setup()
94107
else if (firebaseData.dataType() == "float")
95108
Serial.println(firebaseData.floatData());
96109
else if (firebaseData.dataType() == "boolean")
97-
Serial.println(firebaseData.boolData());
110+
Serial.println(firebaseData.boolData() == 1 ? "true" : "false");
98111
else if (firebaseData.dataType() == "string")
99112
Serial.println(firebaseData.stringData());
100113
else if (firebaseData.dataType() == "json")
@@ -181,7 +194,7 @@ void setup()
181194
else if (firebaseData.dataType() == "float")
182195
Serial.println(firebaseData.floatData());
183196
else if (firebaseData.dataType() == "boolean")
184-
Serial.println(firebaseData.boolData());
197+
Serial.println(firebaseData.boolData() == 1 ? "true" : "false");
185198
else if (firebaseData.dataType() == "string")
186199
Serial.println(firebaseData.stringData());
187200
else if (firebaseData.dataType() == "json")

examples/Data_filter/Data_filter.ino

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Created by K. Suwatchai (Mobizt)
3+
*
4+
5+
*
6+
* Github: https://github.com/mobizt
7+
*
8+
* Copyright (c) 2019 mobizt
9+
*
10+
*/
11+
112
//Example shows how to connect to Firebase RTDB and construct queries to filter data
213

314
//Required WiFiNINA Library for Arduino from https://github.com/arduino-libraries/WiFiNINA

examples/Stream/Stream.ino

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*
2+
* Created by K. Suwatchai (Mobizt)
3+
*
4+
5+
*
6+
* Github: https://github.com/mobizt
7+
*
8+
* Copyright (c) 2019 mobizt
9+
*
10+
*/
11+
12+
13+
114
//Example shows how to connect to Firebase RTDB and get stream connection
215

316
//Required WiFiNINA Library for Arduino from https://github.com/arduino-libraries/WiFiNINA
@@ -69,7 +82,7 @@ void loop()
6982
else if (firebaseData.dataType() == "float")
7083
Serial.println(firebaseData.floatData());
7184
else if (firebaseData.dataType() == "boolean")
72-
Serial.println(firebaseData.boolData());
85+
Serial.println(firebaseData.boolData() == 1 ? "true" : "false");
7386
else if (firebaseData.dataType() == "string")
7487
Serial.println(firebaseData.stringData());
7588
else if (firebaseData.dataType() == "json")
@@ -112,7 +125,7 @@ void loop()
112125
else if (firebaseData.dataType() == "float")
113126
Serial.println(firebaseData.floatData());
114127
else if (firebaseData.dataType() == "boolean")
115-
Serial.println(firebaseData.boolData());
128+
Serial.println(firebaseData.boolData() == 1 ? "true" : "false");
116129
else if (firebaseData.dataType() == "string")
117130
Serial.println(firebaseData.stringData());
118131
else if (firebaseData.dataType() == "json")

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name=Firebase Arduino based on WiFiNINA
22

3-
version=1.0.0
3+
version=1.0.1
44

55
author=Mobizt
66

src/Firebase_Arduino_WiFiNINA.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
/*
2-
* Google's Firebase Realtime Database Arduino Library for ARM/AVR WIFI Development Boards based on WiFiNINA library, version 1.0.0
3-
*
2+
* Google's Firebase Realtime Database Arduino Library for ARM/AVR WIFI Development Boards based on WiFiNINA library, version 1.0.1
43
*
4+
*
55
* This library required WiFiNINA Library to be installed.
66
* https://github.com/arduino-libraries/WiFiNINA
77
*
8-
* April 11, 2019
8+
* April 20, 2019
99
*
1010
* Feature Added:
1111
*
1212
* Feature Fixed:
13+
* Fixed Boolean data type misconception
1314
*
1415
* This library provides ARM/AVR WIFI Development Boards to perform REST API by GET PUT, POST, PATCH, DELETE data from/to with Google's Firebase database using get, set, update
1516
* and delete calls.
@@ -375,10 +376,10 @@ int Firebase_Arduino_WiFiNINA::firebaseConnect(FirebaseData &dataObj, const char
375376
method != FirebaseMethod::DELETE)
376377
{
377378
memset(payloadStr, 0, payloadStrSize);
378-
if (dataType == FirebaseDataType::STRING || dataType == FirebaseDataType::BOOLEAN)
379+
if (dataType == FirebaseDataType::STRING)
379380
strCopy_T(payloadStr, 3);
380381
strcat(payloadStr, payload);
381-
if (dataType == FirebaseDataType::STRING || dataType == FirebaseDataType::BOOLEAN)
382+
if (dataType == FirebaseDataType::STRING)
382383
strCopy_T(payloadStr, 3);
383384
}
384385

@@ -1240,9 +1241,8 @@ void Firebase_Arduino_WiFiNINA::setDataType(FirebaseData &dataObj, const char *d
12401241

12411242
if (!typeSet)
12421243
{
1243-
memset(temp, 0, len);
1244-
strncpy(temp, data, strlen(DEF_STR_108));
1245-
if (strcmp(temp, DEF_STR_108) == 0)
1244+
1245+
if (strcmp(data, DEF_STR_106) == 0 || strcmp(data, DEF_STR_107) == 0)
12461246
{
12471247
typeSet = true;
12481248
dataObj._dataType = FirebaseDataType::BOOLEAN;
@@ -1616,9 +1616,7 @@ bool FirebaseData::boolData()
16161616
{
16171617
bool res;
16181618
char *str = new char[10];
1619-
strCopy_T(str, 3, true, 10);
1620-
strCopy_T(str, 107);
1621-
strCopy_T(str, 3);
1619+
strCopy_T(str, 107, true, 10);
16221620
if (strlen(_data) > 0 && _dataType == Firebase_Arduino_WiFiNINA::FirebaseDataType::BOOLEAN)
16231621
res = strcmp(_data, str) == 0;
16241622
delete[] str;

src/Firebase_Arduino_WiFiNINA.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
/*
2-
* Google's Firebase Realtime Database Arduino Library for ARM/AVR WIFI Development Boards based on WiFiNINA library, version 1.0.0
2+
* Google's Firebase Realtime Database Arduino Library for ARM/AVR WIFI Development Boards based on WiFiNINA library, version 1.0.1
33
*
44
*
55
* This library required WiFiNINA Library to be installed.
66
* https://github.com/arduino-libraries/WiFiNINA
77
*
8-
* April 11, 2019
8+
* April 20, 2019
99
*
1010
* Feature Added:
1111
*
1212
* Feature Fixed:
13+
* Fixed Boolean data type misconception
1314
*
1415
* This library provides ARM/AVR WIFI Development Boards to perform REST API by GET PUT, POST, PATCH, DELETE data from/to with Google's Firebase database using get, set, update
1516
* and delete calls.
@@ -62,7 +63,8 @@
6263

6364
#define DEF_STR_19 "null"
6465
#define DEF_STR_4 "."
65-
#define DEF_STR_108 "\"bool,"
66+
#define DEF_STR_106 "false"
67+
#define DEF_STR_107 "true"
6668

6769
const char C_STR_0[] PROGMEM = "";
6870
const char C_STR_1[] PROGMEM = "/";
@@ -170,9 +172,9 @@ const char C_STR_102[] PROGMEM = "\"error\" : ";
170172
const char C_STR_103[] PROGMEM = "";
171173
const char C_STR_104[] PROGMEM = "";
172174
const char C_STR_105[] PROGMEM = "boolean";
173-
const char C_STR_106[] PROGMEM = "bool,0";
174-
const char C_STR_107[] PROGMEM = "bool,1";
175-
const char C_STR_108[] PROGMEM = "\"bool,";
175+
const char C_STR_106[] PROGMEM = "false";
176+
const char C_STR_107[] PROGMEM = "true";
177+
const char C_STR_108[] PROGMEM = "";
176178
const char C_STR_109[] PROGMEM = "cancel";
177179
const char C_STR_110[] PROGMEM = "auth_revoked";
178180
const char C_STR_111[] PROGMEM = "http://";

0 commit comments

Comments
 (0)