Skip to content

Commit 86fb09e

Browse files
committed
Fix incorrect file name
1 parent 67704ee commit 86fb09e

File tree

4 files changed

+207
-2
lines changed

4 files changed

+207
-2
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.1.2
4+
Google's Firebase Realtime Database Arduino Library for ARM/AVR WIFI Development Boards based on WiFiNINA library, v 1.1.3
55

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

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.1.2
3+
version=1.1.3
44

55
author=Mobizt
66

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* HTTP Client Wrapper based on WiFiNINA library, version 1.0.1
3+
*
4+
*
5+
* This library required WiFiNINA Library to be installed.
6+
* https://github.com/arduino-libraries/WiFiNINA
7+
*
8+
* March 5, 2020
9+
*
10+
*
11+
*
12+
* The MIT License (MIT)
13+
* Copyright (c) 2019 K. Suwatchai (Mobizt)
14+
*
15+
*
16+
* Permission is hereby granted, free of charge, to any person returning a copy of
17+
* this software and associated documentation files (the "Software"), to deal in
18+
* the Software without restriction, including without limitation the rights to
19+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
20+
* the Software, and to permit persons to whom the Software is furnished to do so,
21+
* subject to the following conditions:
22+
*
23+
* The above copyright notice and this permission notice shall be included in all
24+
* copies or substantial portions of the Software.
25+
*
26+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
28+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
29+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
30+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32+
*/
33+
34+
#ifndef Firebase_Arduino_WiFiNINA_HTTPClient_CPP
35+
#define FFirebase_Arduino_WiFiNINA_HTTPClient_CPP
36+
37+
#include "Firebase_Arduino_WiFiNINA_HTTPClient.h"
38+
39+
FirebaseHTTPClient::FirebaseHTTPClient()
40+
{
41+
}
42+
43+
FirebaseHTTPClient::~FirebaseHTTPClient()
44+
{
45+
client.stop();
46+
}
47+
48+
bool FirebaseHTTPClient::http_begin(const char *host, uint16_t port)
49+
{
50+
_host = host;
51+
_port = port;
52+
return true;
53+
}
54+
55+
bool FirebaseHTTPClient::http_connected()
56+
{
57+
return client.available() > 0 || client.connected();
58+
}
59+
60+
bool FirebaseHTTPClient::http_sendHeader(const char *header)
61+
{
62+
if (!http_connected())
63+
return false;
64+
client.print(header);
65+
return true;
66+
}
67+
68+
int FirebaseHTTPClient::http_sendRequest(const char *header, const char *payload)
69+
{
70+
size_t size = strlen(payload);
71+
if (!http_connect())
72+
return HTTPC_ERROR_CONNECTION_REFUSED;
73+
if (!http_sendHeader(header))
74+
return HTTPC_ERROR_SEND_HEADER_FAILED;
75+
if (size > 0)
76+
client.print(payload);
77+
return 0;
78+
}
79+
80+
bool FirebaseHTTPClient::http_connect(void)
81+
{
82+
if (http_connected())
83+
{
84+
while (client.available() > 0)
85+
client.read();
86+
return true;
87+
}
88+
89+
if (!client.connect(_host.c_str(), _port))
90+
return false;
91+
return http_connected();
92+
}
93+
#endif
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* HTTP Client Wrapper based on WiFiNINA library, version 1.0.1
3+
*
4+
*
5+
* This library required WiFiNINA Library to be installed.
6+
* https://github.com/arduino-libraries/WiFiNINA
7+
*
8+
* March 5, 2020
9+
*
10+
*
11+
*
12+
* The MIT License (MIT)
13+
* Copyright (c) 2019 K. Suwatchai (Mobizt)
14+
*
15+
*
16+
* Permission is hereby granted, free of charge, to any person returning a copy of
17+
* this software and associated documentation files (the "Software"), to deal in
18+
* the Software without restriction, including without limitation the rights to
19+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
20+
* the Software, and to permit persons to whom the Software is furnished to do so,
21+
* subject to the following conditions:
22+
*
23+
* The above copyright notice and this permission notice shall be included in all
24+
* copies or substantial portions of the Software.
25+
*
26+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
28+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
29+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
30+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32+
*/
33+
34+
#ifndef Firebase_Arduino_WiFiNINA_HTTPClient_H
35+
#define Firebase_Arduino_WiFiNINA_HTTPClient_H
36+
37+
#include <Arduino.h>
38+
#include <SPI.h>
39+
#include <WiFiNINA.h>
40+
41+
42+
/// HTTP client errors
43+
#define HTTPC_ERROR_CONNECTION_REFUSED (-1)
44+
#define HTTPC_ERROR_SEND_HEADER_FAILED (-2)
45+
#define HTTPC_ERROR_SEND_PAYLOAD_FAILED (-3)
46+
#define HTTPC_ERROR_NOT_CONNECTED (-4)
47+
#define HTTPC_ERROR_CONNECTION_LOST (-5)
48+
#define HTTPC_ERROR_NO_STREAM (-6)
49+
#define HTTPC_ERROR_NO_HTTP_SERVER (-7)
50+
#define HTTPC_ERROR_TOO_LESS_RAM (-8)
51+
#define HTTPC_ERROR_ENCODING (-9)
52+
#define HTTPC_ERROR_STREAM_WRITE (-10)
53+
#define HTTPC_ERROR_READ_TIMEOUT (-11)
54+
#define FIREBASE_ERROR_BUFFER_OVERFLOW (-13)
55+
#define FIREBASE_ERROR_DATA_TYPE_MISMATCH (-14)
56+
#define FIREBASE_ERROR_PATH_NOT_EXIST (-15)
57+
58+
/// HTTP codes see RFC7231
59+
60+
#define _HTTP_CODE_OK 200
61+
#define _HTTP_CODE_NON_AUTHORITATIVE_INFORMATION 203
62+
#define _HTTP_CODE_NO_CONTENT 204
63+
#define _HTTP_CODE_MOVED_PERMANENTLY 301
64+
#define _HTTP_CODE_USE_PROXY 305
65+
#define _HTTP_CODE_TEMPORARY_REDIRECT 307
66+
#define _HTTP_CODE_PERMANENT_REDIRECT 308
67+
#define _HTTP_CODE_BAD_REQUEST 400
68+
#define _HTTP_CODE_UNAUTHORIZED 401
69+
#define _HTTP_CODE_FORBIDDEN 403
70+
#define _HTTP_CODE_NOT_FOUND 404
71+
#define _HTTP_CODE_METHOD_NOT_ALLOWED 405
72+
#define _HTTP_CODE_NOT_ACCEPTABLE 406
73+
#define _HTTP_CODE_PROXY_AUTHENTICATION_REQUIRED 407
74+
#define _HTTP_CODE_REQUEST_TIMEOUT 408
75+
#define _HTTP_CODE_LENGTH_REQUIRED 411
76+
#define _HTTP_CODE_PAYLOAD_TOO_LARGE 413
77+
#define _HTTP_CODE_URI_TOO_LONG 414
78+
#define _HTTP_CODE_MISDIRECTED_REQUEST 421
79+
#define _HTTP_CODE_UNPROCESSABLE_ENTITY 422
80+
#define _HTTP_CODE_TOO_MANY_REQUESTS 429
81+
#define _HTTP_CODE_REQUEST_HEADER_FIELDS_TOO_LARGE 431
82+
#define _HTTP_CODE_INTERNAL_SERVER_ERROR 500
83+
#define _HTTP_CODE_NOT_IMPLEMENTED 501
84+
#define _HTTP_CODE_BAD_GATEWAY 502
85+
#define _HTTP_CODE_SERVICE_UNAVAILABLE 503
86+
#define _HTTP_CODE_GATEWAY_TIMEOUT 504
87+
#define _HTTP_CODE_HTTP_VERSION_NOT_SUPPORTED 505
88+
#define _HTTP_CODE_LOOP_DETECTED 508
89+
#define _HTTP_CODE_NETWORK_AUTHENTICATION_REQUIRED 511
90+
91+
#define _HOST_LENGTH 100
92+
93+
class FirebaseHTTPClient
94+
{
95+
public:
96+
FirebaseHTTPClient();
97+
~FirebaseHTTPClient();
98+
99+
bool http_begin(const char *host, uint16_t port);
100+
bool http_connected(void);
101+
int http_sendRequest(const char *header, const char *payload);
102+
WiFiSSLClient client;
103+
uint16_t netClientTimeout = 5000;
104+
105+
protected:
106+
bool http_connect(void);
107+
bool http_sendHeader(const char *header);
108+
String _host = "";
109+
uint16_t _port = 0;
110+
};
111+
112+
#endif /* Firebase_Arduino_WiFiNINA_HTTPClient_H */

0 commit comments

Comments
 (0)