mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-11 07:32:14 +00:00
mqtt: downlink now works
This commit is contained in:
parent
a845406a19
commit
7f5ab472b9
@ -11,7 +11,7 @@
|
|||||||
*****************************************************************/
|
*****************************************************************/
|
||||||
|
|
||||||
/* Enable support for dynamically allocated fields */
|
/* Enable support for dynamically allocated fields */
|
||||||
/* #define PB_ENABLE_MALLOC 1 */
|
#define PB_ENABLE_MALLOC 1
|
||||||
|
|
||||||
/* Define this if your CPU / compiler combination does not support
|
/* Define this if your CPU / compiler combination does not support
|
||||||
* unaligned memory access to packed structures. */
|
* unaligned memory access to packed structures. */
|
||||||
@ -52,7 +52,6 @@
|
|||||||
* Feel free to look around and use the defined macros, though. *
|
* Feel free to look around and use the defined macros, though. *
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/* Version of the nanopb library. Just in case you want to check it in
|
/* Version of the nanopb library. Just in case you want to check it in
|
||||||
* your own program. */
|
* your own program. */
|
||||||
#define NANOPB_VERSION nanopb - 0.4.4
|
#define NANOPB_VERSION nanopb - 0.4.4
|
||||||
@ -71,11 +70,11 @@
|
|||||||
#ifdef PB_SYSTEM_HEADER
|
#ifdef PB_SYSTEM_HEADER
|
||||||
#include PB_SYSTEM_HEADER
|
#include PB_SYSTEM_HEADER
|
||||||
#else
|
#else
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef PB_ENABLE_MALLOC
|
#ifdef PB_ENABLE_MALLOC
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -247,8 +246,7 @@ typedef uint_least8_t pb_type_t;
|
|||||||
#define PB_ATYPE(x) ((x)&PB_ATYPE_MASK)
|
#define PB_ATYPE(x) ((x)&PB_ATYPE_MASK)
|
||||||
#define PB_HTYPE(x) ((x)&PB_HTYPE_MASK)
|
#define PB_HTYPE(x) ((x)&PB_HTYPE_MASK)
|
||||||
#define PB_LTYPE(x) ((x)&PB_LTYPE_MASK)
|
#define PB_LTYPE(x) ((x)&PB_LTYPE_MASK)
|
||||||
#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
|
#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
|
||||||
PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
|
|
||||||
|
|
||||||
/* Data type used for storing sizes of struct fields
|
/* Data type used for storing sizes of struct fields
|
||||||
* and array counts.
|
* and array counts.
|
||||||
@ -329,7 +327,11 @@ PB_STATIC_ASSERT(sizeof(uint64_t) == 2 * sizeof(uint32_t), UINT64_T_WRONG_SIZE)
|
|||||||
* It has the number of bytes in the beginning, and after that an array.
|
* It has the number of bytes in the beginning, and after that an array.
|
||||||
* Note that actual structs used will have a different length of bytes array.
|
* Note that actual structs used will have a different length of bytes array.
|
||||||
*/
|
*/
|
||||||
#define PB_BYTES_ARRAY_T(n) struct { pb_size_t size; pb_byte_t bytes[n]; }
|
#define PB_BYTES_ARRAY_T(n) \
|
||||||
|
struct { \
|
||||||
|
pb_size_t size; \
|
||||||
|
pb_byte_t bytes[n]; \
|
||||||
|
}
|
||||||
#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
|
#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
|
||||||
|
|
||||||
struct pb_bytes_array_s {
|
struct pb_bytes_array_s {
|
||||||
@ -373,12 +375,7 @@ struct pb_callback_s {
|
|||||||
extern bool pb_default_field_callback(pb_istream_t *istream, pb_ostream_t *ostream, const pb_field_t *field);
|
extern bool pb_default_field_callback(pb_istream_t *istream, pb_ostream_t *ostream, const pb_field_t *field);
|
||||||
|
|
||||||
/* Wire types. Library user needs these only in encoder callbacks. */
|
/* Wire types. Library user needs these only in encoder callbacks. */
|
||||||
typedef enum {
|
typedef enum { PB_WT_VARINT = 0, PB_WT_64BIT = 1, PB_WT_STRING = 2, PB_WT_32BIT = 5 } pb_wire_type_t;
|
||||||
PB_WT_VARINT = 0,
|
|
||||||
PB_WT_64BIT = 1,
|
|
||||||
PB_WT_STRING = 2,
|
|
||||||
PB_WT_32BIT = 5
|
|
||||||
} pb_wire_type_t;
|
|
||||||
|
|
||||||
/* Structure for defining the handling of unknown/extension fields.
|
/* Structure for defining the handling of unknown/extension fields.
|
||||||
* Usually the pb_extension_type_t structure is automatically generated,
|
* Usually the pb_extension_type_t structure is automatically generated,
|
||||||
@ -395,8 +392,7 @@ struct pb_extension_type_s {
|
|||||||
* If you run into an error, return false.
|
* If you run into an error, return false.
|
||||||
* Set to NULL for default handler.
|
* Set to NULL for default handler.
|
||||||
*/
|
*/
|
||||||
bool (*decode)(pb_istream_t *stream, pb_extension_t *extension,
|
bool (*decode)(pb_istream_t *stream, pb_extension_t *extension, uint32_t tag, pb_wire_type_t wire_type);
|
||||||
uint32_t tag, pb_wire_type_t wire_type);
|
|
||||||
|
|
||||||
/* Called once after all regular fields have been encoded.
|
/* Called once after all regular fields have been encoded.
|
||||||
* If you have something to write, do so and return true.
|
* If you have something to write, do so and return true.
|
||||||
@ -429,7 +425,10 @@ struct pb_extension_s {
|
|||||||
bool found;
|
bool found;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define pb_extension_init_zero {NULL,NULL,NULL,false}
|
#define pb_extension_init_zero \
|
||||||
|
{ \
|
||||||
|
NULL, NULL, NULL, false \
|
||||||
|
}
|
||||||
|
|
||||||
/* Memory allocation functions to use. You can define pb_realloc and
|
/* Memory allocation functions to use. You can define pb_realloc and
|
||||||
* pb_free to custom functions if you want. */
|
* pb_free to custom functions if you want. */
|
||||||
@ -458,18 +457,9 @@ struct pb_extension_s {
|
|||||||
|
|
||||||
/* Binding of a message field set into a specific structure */
|
/* Binding of a message field set into a specific structure */
|
||||||
#define PB_BIND(msgname, structname, width) \
|
#define PB_BIND(msgname, structname, width) \
|
||||||
const uint32_t structname ## _field_info[] PB_PROGMEM = \
|
const uint32_t structname##_field_info[] PB_PROGMEM = {msgname##_FIELDLIST(PB_GEN_FIELD_INFO_##width, structname) 0}; \
|
||||||
{ \
|
const pb_msgdesc_t *const structname##_submsg_info[] = {msgname##_FIELDLIST(PB_GEN_SUBMSG_INFO, structname) NULL}; \
|
||||||
msgname ## _FIELDLIST(PB_GEN_FIELD_INFO_ ## width, structname) \
|
const pb_msgdesc_t structname##_msg = { \
|
||||||
0 \
|
|
||||||
}; \
|
|
||||||
const pb_msgdesc_t* const structname ## _submsg_info[] = \
|
|
||||||
{ \
|
|
||||||
msgname ## _FIELDLIST(PB_GEN_SUBMSG_INFO, structname) \
|
|
||||||
NULL \
|
|
||||||
}; \
|
|
||||||
const pb_msgdesc_t structname ## _msg = \
|
|
||||||
{ \
|
|
||||||
structname##_field_info, \
|
structname##_field_info, \
|
||||||
structname##_submsg_info, \
|
structname##_submsg_info, \
|
||||||
msgname##_DEFAULT, \
|
msgname##_DEFAULT, \
|
||||||
@ -481,10 +471,8 @@ struct pb_extension_s {
|
|||||||
msgname##_FIELDLIST(PB_GEN_FIELD_INFO_ASSERT_##width, structname)
|
msgname##_FIELDLIST(PB_GEN_FIELD_INFO_ASSERT_##width, structname)
|
||||||
|
|
||||||
#define PB_GEN_FIELD_COUNT(structname, atype, htype, ltype, fieldname, tag) +1
|
#define PB_GEN_FIELD_COUNT(structname, atype, htype, ltype, fieldname, tag) +1
|
||||||
#define PB_GEN_REQ_FIELD_COUNT(structname, atype, htype, ltype, fieldname, tag) \
|
#define PB_GEN_REQ_FIELD_COUNT(structname, atype, htype, ltype, fieldname, tag) +(PB_HTYPE_##htype == PB_HTYPE_REQUIRED)
|
||||||
+ (PB_HTYPE_ ## htype == PB_HTYPE_REQUIRED)
|
#define PB_GEN_LARGEST_TAG(structname, atype, htype, ltype, fieldname, tag) *0 + tag
|
||||||
#define PB_GEN_LARGEST_TAG(structname, atype, htype, ltype, fieldname, tag) \
|
|
||||||
* 0 + tag
|
|
||||||
|
|
||||||
/* X-macro for generating the entries in struct_field_info[] array. */
|
/* X-macro for generating the entries in struct_field_info[] array. */
|
||||||
#define PB_GEN_FIELD_INFO_1(structname, atype, htype, ltype, fieldname, tag) \
|
#define PB_GEN_FIELD_INFO_1(structname, atype, htype, ltype, fieldname, tag) \
|
||||||
@ -516,8 +504,8 @@ struct pb_extension_s {
|
|||||||
PB_ARRAY_SIZE_##atype(_PB_HTYPE_##htype, structname, fieldname))
|
PB_ARRAY_SIZE_##atype(_PB_HTYPE_##htype, structname, fieldname))
|
||||||
|
|
||||||
#define PB_GEN_FIELD_INFO_AUTO(structname, atype, htype, ltype, fieldname, tag) \
|
#define PB_GEN_FIELD_INFO_AUTO(structname, atype, htype, ltype, fieldname, tag) \
|
||||||
PB_FIELDINFO_AUTO2(PB_FIELDINFO_WIDTH_AUTO(_PB_ATYPE_ ## atype, _PB_HTYPE_ ## htype, _PB_LTYPE_ ## ltype), \
|
PB_FIELDINFO_AUTO2(PB_FIELDINFO_WIDTH_AUTO(_PB_ATYPE_##atype, _PB_HTYPE_##htype, _PB_LTYPE_##ltype), tag, \
|
||||||
tag, PB_ATYPE_ ## atype | PB_HTYPE_ ## htype | PB_LTYPE_MAP_ ## ltype, \
|
PB_ATYPE_##atype | PB_HTYPE_##htype | PB_LTYPE_MAP_##ltype, \
|
||||||
PB_DATA_OFFSET_##atype(_PB_HTYPE_##htype, structname, fieldname), \
|
PB_DATA_OFFSET_##atype(_PB_HTYPE_##htype, structname, fieldname), \
|
||||||
PB_DATA_SIZE_##atype(_PB_HTYPE_##htype, structname, fieldname), \
|
PB_DATA_SIZE_##atype(_PB_HTYPE_##htype, structname, fieldname), \
|
||||||
PB_SIZE_OFFSET_##atype(_PB_HTYPE_##htype, structname, fieldname), \
|
PB_SIZE_OFFSET_##atype(_PB_HTYPE_##htype, structname, fieldname), \
|
||||||
@ -561,8 +549,8 @@ struct pb_extension_s {
|
|||||||
PB_ARRAY_SIZE_##atype(_PB_HTYPE_##htype, structname, fieldname))
|
PB_ARRAY_SIZE_##atype(_PB_HTYPE_##htype, structname, fieldname))
|
||||||
|
|
||||||
#define PB_GEN_FIELD_INFO_ASSERT_AUTO(structname, atype, htype, ltype, fieldname, tag) \
|
#define PB_GEN_FIELD_INFO_ASSERT_AUTO(structname, atype, htype, ltype, fieldname, tag) \
|
||||||
PB_FIELDINFO_ASSERT_AUTO2(PB_FIELDINFO_WIDTH_AUTO(_PB_ATYPE_ ## atype, _PB_HTYPE_ ## htype, _PB_LTYPE_ ## ltype), \
|
PB_FIELDINFO_ASSERT_AUTO2(PB_FIELDINFO_WIDTH_AUTO(_PB_ATYPE_##atype, _PB_HTYPE_##htype, _PB_LTYPE_##ltype), tag, \
|
||||||
tag, PB_ATYPE_ ## atype | PB_HTYPE_ ## htype | PB_LTYPE_MAP_ ## ltype, \
|
PB_ATYPE_##atype | PB_HTYPE_##htype | PB_LTYPE_MAP_##ltype, \
|
||||||
PB_DATA_OFFSET_##atype(_PB_HTYPE_##htype, structname, fieldname), \
|
PB_DATA_OFFSET_##atype(_PB_HTYPE_##htype, structname, fieldname), \
|
||||||
PB_DATA_SIZE_##atype(_PB_HTYPE_##htype, structname, fieldname), \
|
PB_DATA_SIZE_##atype(_PB_HTYPE_##htype, structname, fieldname), \
|
||||||
PB_SIZE_OFFSET_##atype(_PB_HTYPE_##htype, structname, fieldname), \
|
PB_SIZE_OFFSET_##atype(_PB_HTYPE_##htype, structname, fieldname), \
|
||||||
@ -589,7 +577,8 @@ struct pb_extension_s {
|
|||||||
#define PB_SIZE_OFFSET_CALLBACK(htype, structname, fieldname) PB_SO_CB##htype(structname, fieldname)
|
#define PB_SIZE_OFFSET_CALLBACK(htype, structname, fieldname) PB_SO_CB##htype(structname, fieldname)
|
||||||
#define PB_SO_PB_HTYPE_REQUIRED(structname, fieldname) 0
|
#define PB_SO_PB_HTYPE_REQUIRED(structname, fieldname) 0
|
||||||
#define PB_SO_PB_HTYPE_SINGULAR(structname, fieldname) 0
|
#define PB_SO_PB_HTYPE_SINGULAR(structname, fieldname) 0
|
||||||
#define PB_SO_PB_HTYPE_ONEOF(structname, fieldname) PB_SO_PB_HTYPE_ONEOF2(structname, PB_ONEOF_NAME(FULL, fieldname), PB_ONEOF_NAME(UNION, fieldname))
|
#define PB_SO_PB_HTYPE_ONEOF(structname, fieldname) \
|
||||||
|
PB_SO_PB_HTYPE_ONEOF2(structname, PB_ONEOF_NAME(FULL, fieldname), PB_ONEOF_NAME(UNION, fieldname))
|
||||||
#define PB_SO_PB_HTYPE_ONEOF2(structname, fullname, unionname) PB_SO_PB_HTYPE_ONEOF3(structname, fullname, unionname)
|
#define PB_SO_PB_HTYPE_ONEOF2(structname, fullname, unionname) PB_SO_PB_HTYPE_ONEOF3(structname, fullname, unionname)
|
||||||
#define PB_SO_PB_HTYPE_ONEOF3(structname, fullname, unionname) pb_delta(structname, fullname, which_##unionname)
|
#define PB_SO_PB_HTYPE_ONEOF3(structname, fullname, unionname) pb_delta(structname, fullname, which_##unionname)
|
||||||
#define PB_SO_PB_HTYPE_OPTIONAL(structname, fieldname) pb_delta(structname, fieldname, has_##fieldname)
|
#define PB_SO_PB_HTYPE_OPTIONAL(structname, fieldname) pb_delta(structname, fieldname, has_##fieldname)
|
||||||
@ -657,9 +646,12 @@ struct pb_extension_s {
|
|||||||
#define PB_SUBMSG_INFO_REQUIRED(ltype, structname, fieldname) PB_SI##ltype(structname##_##fieldname##_MSGTYPE)
|
#define PB_SUBMSG_INFO_REQUIRED(ltype, structname, fieldname) PB_SI##ltype(structname##_##fieldname##_MSGTYPE)
|
||||||
#define PB_SUBMSG_INFO_SINGULAR(ltype, structname, fieldname) PB_SI##ltype(structname##_##fieldname##_MSGTYPE)
|
#define PB_SUBMSG_INFO_SINGULAR(ltype, structname, fieldname) PB_SI##ltype(structname##_##fieldname##_MSGTYPE)
|
||||||
#define PB_SUBMSG_INFO_OPTIONAL(ltype, structname, fieldname) PB_SI##ltype(structname##_##fieldname##_MSGTYPE)
|
#define PB_SUBMSG_INFO_OPTIONAL(ltype, structname, fieldname) PB_SI##ltype(structname##_##fieldname##_MSGTYPE)
|
||||||
#define PB_SUBMSG_INFO_ONEOF(ltype, structname, fieldname) PB_SUBMSG_INFO_ONEOF2(ltype, structname, PB_ONEOF_NAME(UNION, fieldname), PB_ONEOF_NAME(MEMBER, fieldname))
|
#define PB_SUBMSG_INFO_ONEOF(ltype, structname, fieldname) \
|
||||||
#define PB_SUBMSG_INFO_ONEOF2(ltype, structname, unionname, membername) PB_SUBMSG_INFO_ONEOF3(ltype, structname, unionname, membername)
|
PB_SUBMSG_INFO_ONEOF2(ltype, structname, PB_ONEOF_NAME(UNION, fieldname), PB_ONEOF_NAME(MEMBER, fieldname))
|
||||||
#define PB_SUBMSG_INFO_ONEOF3(ltype, structname, unionname, membername) PB_SI ## ltype(structname ## _ ## unionname ## _ ## membername ## _MSGTYPE)
|
#define PB_SUBMSG_INFO_ONEOF2(ltype, structname, unionname, membername) \
|
||||||
|
PB_SUBMSG_INFO_ONEOF3(ltype, structname, unionname, membername)
|
||||||
|
#define PB_SUBMSG_INFO_ONEOF3(ltype, structname, unionname, membername) \
|
||||||
|
PB_SI##ltype(structname##_##unionname##_##membername##_MSGTYPE)
|
||||||
#define PB_SUBMSG_INFO_REPEATED(ltype, structname, fieldname) PB_SI##ltype(structname##_##fieldname##_MSGTYPE)
|
#define PB_SUBMSG_INFO_REPEATED(ltype, structname, fieldname) PB_SI##ltype(structname##_##fieldname##_MSGTYPE)
|
||||||
#define PB_SUBMSG_INFO_FIXARRAY(ltype, structname, fieldname) PB_SI##ltype(structname##_##fieldname##_MSGTYPE)
|
#define PB_SUBMSG_INFO_FIXARRAY(ltype, structname, fieldname) PB_SI##ltype(structname##_##fieldname##_MSGTYPE)
|
||||||
#define PB_SI_PB_LTYPE_BOOL(t)
|
#define PB_SI_PB_LTYPE_BOOL(t)
|
||||||
@ -718,18 +710,18 @@ struct pb_extension_s {
|
|||||||
(((uint32_t)(size_offset)&0x0F) << 24) | (((uint32_t)(data_size)&0x0F) << 28)),
|
(((uint32_t)(size_offset)&0x0F) << 24) | (((uint32_t)(data_size)&0x0F) << 28)),
|
||||||
|
|
||||||
#define PB_FIELDINFO_2(tag, type, data_offset, data_size, size_offset, array_size) \
|
#define PB_FIELDINFO_2(tag, type, data_offset, data_size, size_offset, array_size) \
|
||||||
(1 | (((tag) << 2) & 0xFF) | ((type) << 8) | (((uint32_t)(array_size) & 0xFFF) << 16) | (((uint32_t)(size_offset) & 0x0F) << 28)), \
|
(1 | (((tag) << 2) & 0xFF) | ((type) << 8) | (((uint32_t)(array_size)&0xFFF) << 16) | \
|
||||||
|
(((uint32_t)(size_offset)&0x0F) << 28)), \
|
||||||
(((uint32_t)(data_offset)&0xFFFF) | (((uint32_t)(data_size)&0xFFF) << 16) | (((uint32_t)(tag)&0x3c0) << 22)),
|
(((uint32_t)(data_offset)&0xFFFF) | (((uint32_t)(data_size)&0xFFF) << 16) | (((uint32_t)(tag)&0x3c0) << 22)),
|
||||||
|
|
||||||
#define PB_FIELDINFO_4(tag, type, data_offset, data_size, size_offset, array_size) \
|
#define PB_FIELDINFO_4(tag, type, data_offset, data_size, size_offset, array_size) \
|
||||||
(2 | (((tag) << 2) & 0xFF) | ((type) << 8) | (((uint32_t)(array_size)&0xFFFF) << 16)), \
|
(2 | (((tag) << 2) & 0xFF) | ((type) << 8) | (((uint32_t)(array_size)&0xFFFF) << 16)), \
|
||||||
((uint32_t)(int_least8_t)(size_offset) | (((uint32_t)(tag) << 2) & 0xFFFFFF00)), \
|
((uint32_t)(int_least8_t)(size_offset) | (((uint32_t)(tag) << 2) & 0xFFFFFF00)), (data_offset), (data_size),
|
||||||
(data_offset), (data_size),
|
|
||||||
|
|
||||||
#define PB_FIELDINFO_8(tag, type, data_offset, data_size, size_offset, array_size) \
|
#define PB_FIELDINFO_8(tag, type, data_offset, data_size, size_offset, array_size) \
|
||||||
(3 | (((tag) << 2) & 0xFF) | ((type) << 8)), \
|
(3 | (((tag) << 2) & 0xFF) | ((type) << 8)), \
|
||||||
((uint32_t)(int_least8_t)(size_offset) | (((uint32_t)(tag) << 2) & 0xFFFFFF00)), \
|
((uint32_t)(int_least8_t)(size_offset) | (((uint32_t)(tag) << 2) & 0xFFFFFF00)), (data_offset), (data_size), \
|
||||||
(data_offset), (data_size), (array_size), 0, 0, 0,
|
(array_size), 0, 0, 0,
|
||||||
|
|
||||||
/* These assertions verify that the field information fits in the allocated space.
|
/* These assertions verify that the field information fits in the allocated space.
|
||||||
* The generator tries to automatically determine the correct width that can fit all
|
* The generator tries to automatically determine the correct width that can fit all
|
||||||
@ -740,31 +732,42 @@ struct pb_extension_s {
|
|||||||
*/
|
*/
|
||||||
#define PB_FITS(value, bits) ((uint32_t)(value) < ((uint32_t)1 << bits))
|
#define PB_FITS(value, bits) ((uint32_t)(value) < ((uint32_t)1 << bits))
|
||||||
#define PB_FIELDINFO_ASSERT_1(tag, type, data_offset, data_size, size_offset, array_size) \
|
#define PB_FIELDINFO_ASSERT_1(tag, type, data_offset, data_size, size_offset, array_size) \
|
||||||
PB_STATIC_ASSERT(PB_FITS(tag,6) && PB_FITS(data_offset,8) && PB_FITS(size_offset,4) && PB_FITS(data_size,4) && PB_FITS(array_size,1), FIELDINFO_DOES_NOT_FIT_width1_field ## tag)
|
PB_STATIC_ASSERT(PB_FITS(tag, 6) && PB_FITS(data_offset, 8) && PB_FITS(size_offset, 4) && PB_FITS(data_size, 4) && \
|
||||||
|
PB_FITS(array_size, 1), \
|
||||||
|
FIELDINFO_DOES_NOT_FIT_width1_field##tag)
|
||||||
|
|
||||||
#define PB_FIELDINFO_ASSERT_2(tag, type, data_offset, data_size, size_offset, array_size) \
|
#define PB_FIELDINFO_ASSERT_2(tag, type, data_offset, data_size, size_offset, array_size) \
|
||||||
PB_STATIC_ASSERT(PB_FITS(tag,10) && PB_FITS(data_offset,16) && PB_FITS(size_offset,4) && PB_FITS(data_size,12) && PB_FITS(array_size,12), FIELDINFO_DOES_NOT_FIT_width2_field ## tag)
|
PB_STATIC_ASSERT(PB_FITS(tag, 10) && PB_FITS(data_offset, 16) && PB_FITS(size_offset, 4) && PB_FITS(data_size, 12) && \
|
||||||
|
PB_FITS(array_size, 12), \
|
||||||
|
FIELDINFO_DOES_NOT_FIT_width2_field##tag)
|
||||||
|
|
||||||
#ifndef PB_FIELD_32BIT
|
#ifndef PB_FIELD_32BIT
|
||||||
/* Maximum field sizes are still 16-bit if pb_size_t is 16-bit */
|
/* Maximum field sizes are still 16-bit if pb_size_t is 16-bit */
|
||||||
#define PB_FIELDINFO_ASSERT_4(tag, type, data_offset, data_size, size_offset, array_size) \
|
#define PB_FIELDINFO_ASSERT_4(tag, type, data_offset, data_size, size_offset, array_size) \
|
||||||
PB_STATIC_ASSERT(PB_FITS(tag,16) && PB_FITS(data_offset,16) && PB_FITS((int_least8_t)size_offset,8) && PB_FITS(data_size,16) && PB_FITS(array_size,16), FIELDINFO_DOES_NOT_FIT_width4_field ## tag)
|
PB_STATIC_ASSERT(PB_FITS(tag, 16) && PB_FITS(data_offset, 16) && PB_FITS((int_least8_t)size_offset, 8) && \
|
||||||
|
PB_FITS(data_size, 16) && PB_FITS(array_size, 16), \
|
||||||
|
FIELDINFO_DOES_NOT_FIT_width4_field##tag)
|
||||||
|
|
||||||
#define PB_FIELDINFO_ASSERT_8(tag, type, data_offset, data_size, size_offset, array_size) \
|
#define PB_FIELDINFO_ASSERT_8(tag, type, data_offset, data_size, size_offset, array_size) \
|
||||||
PB_STATIC_ASSERT(PB_FITS(tag,16) && PB_FITS(data_offset,16) && PB_FITS((int_least8_t)size_offset,8) && PB_FITS(data_size,16) && PB_FITS(array_size,16), FIELDINFO_DOES_NOT_FIT_width8_field ## tag)
|
PB_STATIC_ASSERT(PB_FITS(tag, 16) && PB_FITS(data_offset, 16) && PB_FITS((int_least8_t)size_offset, 8) && \
|
||||||
|
PB_FITS(data_size, 16) && PB_FITS(array_size, 16), \
|
||||||
|
FIELDINFO_DOES_NOT_FIT_width8_field##tag)
|
||||||
#else
|
#else
|
||||||
/* Up to 32-bit fields supported.
|
/* Up to 32-bit fields supported.
|
||||||
* Note that the checks are against 31 bits to avoid compiler warnings about shift wider than type in the test.
|
* Note that the checks are against 31 bits to avoid compiler warnings about shift wider than type in the test.
|
||||||
* I expect that there is no reasonable use for >2GB messages with nanopb anyway.
|
* I expect that there is no reasonable use for >2GB messages with nanopb anyway.
|
||||||
*/
|
*/
|
||||||
#define PB_FIELDINFO_ASSERT_4(tag, type, data_offset, data_size, size_offset, array_size) \
|
#define PB_FIELDINFO_ASSERT_4(tag, type, data_offset, data_size, size_offset, array_size) \
|
||||||
PB_STATIC_ASSERT(PB_FITS(tag,30) && PB_FITS(data_offset,31) && PB_FITS(size_offset,8) && PB_FITS(data_size,31) && PB_FITS(array_size,16), FIELDINFO_DOES_NOT_FIT_width4_field ## tag)
|
PB_STATIC_ASSERT(PB_FITS(tag, 30) && PB_FITS(data_offset, 31) && PB_FITS(size_offset, 8) && PB_FITS(data_size, 31) && \
|
||||||
|
PB_FITS(array_size, 16), \
|
||||||
|
FIELDINFO_DOES_NOT_FIT_width4_field##tag)
|
||||||
|
|
||||||
#define PB_FIELDINFO_ASSERT_8(tag, type, data_offset, data_size, size_offset, array_size) \
|
#define PB_FIELDINFO_ASSERT_8(tag, type, data_offset, data_size, size_offset, array_size) \
|
||||||
PB_STATIC_ASSERT(PB_FITS(tag,30) && PB_FITS(data_offset,31) && PB_FITS(size_offset,8) && PB_FITS(data_size,31) && PB_FITS(array_size,31), FIELDINFO_DOES_NOT_FIT_width8_field ## tag)
|
PB_STATIC_ASSERT(PB_FITS(tag, 30) && PB_FITS(data_offset, 31) && PB_FITS(size_offset, 8) && PB_FITS(data_size, 31) && \
|
||||||
|
PB_FITS(array_size, 31), \
|
||||||
|
FIELDINFO_DOES_NOT_FIT_width8_field##tag)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Automatic picking of FIELDINFO width:
|
/* Automatic picking of FIELDINFO width:
|
||||||
* Uses width 1 when possible, otherwise resorts to width 2.
|
* Uses width 1 when possible, otherwise resorts to width 2.
|
||||||
* This is used when PB_BIND() is called with "AUTO" as the argument.
|
* This is used when PB_BIND() is called with "AUTO" as the argument.
|
||||||
@ -865,11 +868,11 @@ struct pb_extension_s {
|
|||||||
#define PB_INLINE_CONSTEXPR PB_CONSTEXPR
|
#define PB_INLINE_CONSTEXPR PB_CONSTEXPR
|
||||||
#endif // __cplusplus >= 201703L
|
#endif // __cplusplus >= 201703L
|
||||||
|
|
||||||
namespace nanopb {
|
namespace nanopb
|
||||||
|
{
|
||||||
// Each type will be partially specialized by the generator.
|
// Each type will be partially specialized by the generator.
|
||||||
template <typename GenMessageT> struct MessageDescriptor;
|
template <typename GenMessageT> struct MessageDescriptor;
|
||||||
} // namespace nanopb
|
} // namespace nanopb
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -26,11 +26,14 @@ void MQTT::onPublish(char *topic, byte *payload, unsigned int length)
|
|||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Received MQTT topic %s, len=%u\n", topic, length);
|
DEBUG_MSG("Received MQTT topic %s, len=%u\n", topic, length);
|
||||||
|
|
||||||
// FIXME, ignore messages sent by us (requires decryption) or if we don't have the channel key
|
|
||||||
if (e.packet) {
|
if (e.packet) {
|
||||||
MeshPacket *p = packetPool.allocCopy(*e.packet);
|
MeshPacket *p = packetPool.allocCopy(*e.packet);
|
||||||
if (router)
|
|
||||||
|
// ignore messages sent by us or if we don't have the channel key
|
||||||
|
if (router && p->from != nodeDB.getNodeNum() && perhapsDecode(p))
|
||||||
router->enqueueReceivedMessage(p);
|
router->enqueueReceivedMessage(p);
|
||||||
|
else
|
||||||
|
packetPool.release(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure to free both strings and the MeshPacket (passing in NULL is acceptable)
|
// make sure to free both strings and the MeshPacket (passing in NULL is acceptable)
|
||||||
|
Loading…
Reference in New Issue
Block a user