mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-01 21:10:58 +02:00
Esp32 s3 support (#6341)
Co-authored-by: Jason2866 <24528715+Jason2866@users.noreply.github.com> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com> Co-authored-by: Tomáš Pilný <34927466+PilnyTomas@users.noreply.github.com> Co-authored-by: Pedro Minatel <pedro.minatel@espressif.com> Co-authored-by: Ivan Grokhotkov <ivan@espressif.com> Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net>
This commit is contained in:
92
tools/sdk/esp32/include/json_generator/json_generator.h → tools/sdk/esp32/include/json_generator/upstream/json_generator.h
Executable file → Normal file
92
tools/sdk/esp32/include/json_generator/json_generator.h → tools/sdk/esp32/include/json_generator/upstream/json_generator.h
Executable file → Normal file
@ -1,11 +1,26 @@
|
||||
/** \file json_gen_generator.h
|
||||
* \brief JSON String Generator
|
||||
/*
|
||||
* Copyright 2020 Piyush Shah <shahpiyushv@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JSON String Generator
|
||||
*
|
||||
* This module can be used to create JSON strings with a facility
|
||||
* to flush out data if the destination buffer is full. All commas
|
||||
* and colons as required are automatically added by the APIs
|
||||
*
|
||||
* Code taken from: https://github.com/shahpiyushv/json_gen_generator
|
||||
*/
|
||||
#ifndef _JSON_GENERATOR_H
|
||||
#define _JSON_GENERATOR_H
|
||||
@ -18,7 +33,10 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** Float precision i.e. number of digits after decimal point */
|
||||
#ifndef JSON_FLOAT_PRECISION
|
||||
#define JSON_FLOAT_PRECISION 5
|
||||
#endif
|
||||
|
||||
/** JSON string flush callback prototype
|
||||
*
|
||||
@ -38,12 +56,20 @@ typedef void (*json_gen_flush_cb_t) (char *buf, void *priv);
|
||||
* Just define this structure and pass a pointer to it in the APIs below
|
||||
*/
|
||||
typedef struct {
|
||||
/** Pointer to the JSON buffer provided by the calling function */
|
||||
char *buf;
|
||||
/** Size of the above buffer */
|
||||
int buf_size;
|
||||
/** (Optional) callback function to invoke when the buffer gets full */
|
||||
json_gen_flush_cb_t flush_cb;
|
||||
/** (Optional) Private data to pass to the callback function */
|
||||
void *priv;
|
||||
/** (For Internal use only) */
|
||||
bool comma_req;
|
||||
/** (For Internal use only) */
|
||||
char *free_ptr;
|
||||
/** Total length */
|
||||
int total_len;
|
||||
} json_gen_str_t;
|
||||
|
||||
/** Start a JSON String
|
||||
@ -58,11 +84,11 @@ typedef struct {
|
||||
* \param[out] buf Pointer to an allocated buffer into which the JSON
|
||||
* string will be written
|
||||
* \param[in] buf_size Size of the buffer
|
||||
* \param[in] Pointer to the flushing function of type \ref json_gen_flush_cb_t
|
||||
* \param[in] flush_cb Pointer to the flushing function of type \ref json_gen_flush_cb_t
|
||||
* which will be invoked either when the buffer is full or when json_gen_str_end()
|
||||
* is invoked. Can be left NULL.
|
||||
* \param[in] priv Private data to be passed to the flushing function callback.
|
||||
* Can be something like a session identifier (Eg. socket). Can be left NULL
|
||||
* Can be something like a session identifier (Eg. socket). Can be left NULL.
|
||||
*/
|
||||
void json_gen_str_start(json_gen_str_t *jstr, char *buf, int buf_size,
|
||||
json_gen_flush_cb_t flush_cb, void *priv);
|
||||
@ -72,16 +98,18 @@ void json_gen_str_start(json_gen_str_t *jstr, char *buf, int buf_size,
|
||||
* This should be the last function to be called after the entire JSON string
|
||||
* has been generated.
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return Total length of the JSON created, including the NULL termination byte.
|
||||
*/
|
||||
void json_gen_str_end(json_gen_str_t *jstr);
|
||||
int json_gen_str_end(json_gen_str_t *jstr);
|
||||
|
||||
/** Start a JSON object
|
||||
*
|
||||
* This starts a JSON object by adding a '{'
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
@ -95,7 +123,7 @@ int json_gen_start_object(json_gen_str_t *jstr);
|
||||
*
|
||||
* This ends a JSON object by adding a '}'
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
@ -109,7 +137,7 @@ int json_gen_end_object(json_gen_str_t *jstr);
|
||||
*
|
||||
* This starts a JSON object by adding a '['
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
@ -123,7 +151,7 @@ int json_gen_start_array(json_gen_str_t *jstr);
|
||||
*
|
||||
* This ends a JSON object by adding a ']'
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
@ -137,7 +165,7 @@ int json_gen_end_array(json_gen_str_t *jstr);
|
||||
*
|
||||
* This adds a JSON object like "name":{
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the object
|
||||
*
|
||||
@ -153,7 +181,7 @@ int json_gen_push_object(json_gen_str_t *jstr, char *name);
|
||||
* This ends a JSON object by adding a '}'. This is basically same as
|
||||
* json_gen_end_object() but included so as to complement json_gen_push_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
@ -170,7 +198,7 @@ int json_gen_pop_object(json_gen_str_t *jstr);
|
||||
* Eg. json_gen_push_object_str(jstr, "pre-formatted", "{\"a\":1,\"b\":2}");
|
||||
* This will add "pre-formatted":{"a":1,"b":2}
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the JSON object string
|
||||
* \param[in] object_str The pre-formatted JSON object string
|
||||
@ -186,7 +214,7 @@ int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str)
|
||||
*
|
||||
* This adds a JSON array like "name":[
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the array
|
||||
*
|
||||
@ -202,7 +230,7 @@ int json_gen_push_array(json_gen_str_t *jstr, char *name);
|
||||
* This ends a JSON array by adding a ']'. This is basically same as
|
||||
* json_gen_end_array() but included so as to complement json_gen_push_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
@ -219,7 +247,7 @@ int json_gen_pop_array(json_gen_str_t *jstr);
|
||||
* Eg. json_gen_push_object_str(jstr, "pre-formatted", "[1,2,3]");
|
||||
* This will add "pre-formatted":[1,2,3]
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the JSON array string
|
||||
* \param[in] array_str The pre-formatted JSON array string
|
||||
@ -238,7 +266,7 @@ int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str);
|
||||
* \note This must be called between json_gen_start_object()/json_gen_push_object()
|
||||
* and json_gen_end_object()/json_gen_pop_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the element
|
||||
* \param[in] val Boolean value of the element
|
||||
@ -257,7 +285,7 @@ int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val);
|
||||
* \note This must be called between json_gen_start_object()/json_gen_push_object()
|
||||
* and json_gen_end_object()/json_gen_pop_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the element
|
||||
* \param[in] val Integer value of the element
|
||||
@ -276,7 +304,7 @@ int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val);
|
||||
* \note This must be called between json_gen_start_object()/json_gen_push_object()
|
||||
* and json_gen_end_object()/json_gen_pop_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the element
|
||||
* \param[in] val Float value of the element
|
||||
@ -295,7 +323,7 @@ int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val);
|
||||
* \note This must be called between json_gen_start_object()/json_gen_push_object()
|
||||
* and json_gen_end_object()/json_gen_pop_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the element
|
||||
* \param[in] val Null terminated string value of the element
|
||||
@ -314,7 +342,7 @@ int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val);
|
||||
* \note This must be called between json_gen_start_object()/json_gen_push_object()
|
||||
* and json_gen_end_object()/json_gen_pop_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the element
|
||||
*
|
||||
@ -330,7 +358,7 @@ int json_gen_obj_set_null(json_gen_str_t *jstr, char *name);
|
||||
* \note This must be called between json_gen_start_array()/json_gen_push_array()
|
||||
* and json_gen_end_array()/json_gen_pop_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] val Boolean value of the element
|
||||
*
|
||||
@ -346,7 +374,7 @@ int json_gen_arr_set_bool(json_gen_str_t *jstr, bool val);
|
||||
* \note This must be called between json_gen_start_array()/json_gen_push_array()
|
||||
* and json_gen_end_array()/json_gen_pop_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] val Integer value of the element
|
||||
*
|
||||
@ -362,7 +390,7 @@ int json_gen_arr_set_int(json_gen_str_t *jstr, int val);
|
||||
* \note This must be called between json_gen_start_array()/json_gen_push_array()
|
||||
* and json_gen_end_array()/json_gen_pop_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] val Float value of the element
|
||||
*
|
||||
@ -378,7 +406,7 @@ int json_gen_arr_set_float(json_gen_str_t *jstr, float val);
|
||||
* \note This must be called between json_gen_start_array()/json_gen_push_array()
|
||||
* and json_gen_end_array()/json_gen_pop_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] val Null terminated string value of the element
|
||||
*
|
||||
@ -394,7 +422,7 @@ int json_gen_arr_set_string(json_gen_str_t *jstr, char *val);
|
||||
* \note This must be called between json_gen_start_array()/json_gen_push_array()
|
||||
* and json_gen_end_array()/json_gen_pop_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
*
|
||||
* \return 0 on Success
|
||||
@ -414,7 +442,7 @@ int json_gen_arr_set_null(json_gen_str_t *jstr);
|
||||
* \note This must be called between json_gen_start_object()/json_gen_push_object()
|
||||
* and json_gen_end_object()/json_gen_pop_object()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] name Name of the element
|
||||
* \param[in] val Null terminated initial part of the string value. It can also be NULL
|
||||
@ -436,7 +464,7 @@ int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val);
|
||||
* \note This must be called between json_gen_start_array()/json_gen_push_array()
|
||||
* and json_gen_end_array()/json_gen_pop_array()
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by
|
||||
* json_gen_str_start()
|
||||
* \param[in] val Null terminated initial part of the string value. It can also be NULL
|
||||
*
|
||||
@ -453,7 +481,7 @@ int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val);
|
||||
* json_gen_arr_start_long_string(). After the entire string is created, it should be terminated
|
||||
* with json_gen_end_long_string().
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by json_gen_str_start()
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by json_gen_str_start()
|
||||
* \param[in] val Null terminated extending part of the string value.
|
||||
*
|
||||
* \return 0 on Success
|
||||
@ -468,7 +496,7 @@ int json_gen_add_to_long_string(json_gen_str_t *jstr, char *val);
|
||||
* This ends the string initialised by json_gen_obj_start_long_string() or
|
||||
* json_gen_arr_start_long_string() by adding the ending quotes.
|
||||
*
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initilised by json_gen_str_start()
|
||||
* \param[in] jstr Pointer to the \ref json_gen_str_t structure initialised by json_gen_str_start()
|
||||
*
|
||||
*
|
||||
* \return 0 on Success
|
||||
@ -477,9 +505,7 @@ int json_gen_add_to_long_string(json_gen_str_t *jstr, char *val);
|
||||
* added after that
|
||||
*/
|
||||
int json_gen_end_long_string(json_gen_str_t *jstr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user