Sfoglia il codice sorgente

added payload with maximum needed size to internal package type

Strobel, Stefan | Friedrich Lütze GmbH 9 mesi fa
parent
commit
93e04e04a8
1 ha cambiato i file con 14 aggiunte e 11 eliminazioni
  1. 14 11
      src/shellmatta_transport.h

+ 14 - 11
src/shellmatta_transport.h

@@ -17,14 +17,6 @@
 
 #include "shellmatta.h"
 
-/** @brief packet definition with reduced payload (for internal packets) */
-typedef struct __attribute__((__packed__))
-{
-    shellmatta_transport_header_t   header; /**< header of the packet   */
-    //char payload[SHELLMATTA_TRANPORT_PAYLOAD_MAXLENGTH]; TODO - this has to be the maximum needed internal payload
-    uint32_t                        crc;    /**< checksum of the packet */
-} shellmatta_transport_packet_int_t;
-
 /** @brief value of start-of-header character */
 #define SHELLMATTA_TRANSPORT_START_OF_HEADER    0x01u
 /** @brief currently supported protocol version */
@@ -32,17 +24,28 @@ typedef struct __attribute__((__packed__))
 
 /* header field length defines */
 /** @brief length of header */
-#define SHELLMATTA_TRANSPORT_LENGTH_HEADER  ((uint8_t)(8))
+#define SHELLMATTA_TRANSPORT_LENGTH_HEADER      ((uint8_t)(8))
+/** @brief maximum length of shellmatta internal packages (e.g. sequence counter packets) */
+#define SHELLMATTA_TRANSPORT_LENGTH_PAYLOAD_INT ((uint8_t)(32))
 /** @brief length of crc32 */
-#define SHELLMATTA_TRANSPORT_LENGTH_CRC     ((uint8_t)(4))
+#define SHELLMATTA_TRANSPORT_LENGTH_CRC         ((uint8_t)(4))
 /** @brief length of crc32 */
-#define SHELLMATTA_TRANSPORT_LENGTH_STATIC  (SHELLMATTA_TRANSPORT_LENGTH_HEADER + SHELLMATTA_TRANSPORT_LENGTH_CRC)
+#define SHELLMATTA_TRANSPORT_LENGTH_STATIC      (SHELLMATTA_TRANSPORT_LENGTH_HEADER + SHELLMATTA_TRANSPORT_LENGTH_CRC)
 
 /** @brief helper macro for CRC calculation */
 #define SHELLMATTA_TRANSPORT_CALC_CRC(transporLayer, data, size)    NULL != (transportLayer)->customCrcFct ?         \
                                                                     (transportLayer)->customCrcFct((data), (size)) : \
                                                                     crc32Calc((data), (size));
 
+/** @brief packet definition with reduced payload (for internal packets) */
+typedef struct __attribute__((__packed__))
+{
+    shellmatta_transport_header_t   header;                 /**< header of the packet   */
+    char payload[SHELLMATTA_TRANSPORT_LENGTH_PAYLOAD_INT];  /**< payload of the packet  */
+    uint32_t                        crc;                    /**< checksum of the packet */
+} shellmatta_transport_packet_int_t;
+
+
 /**
  * @brief definitions of shellmatta transport layer packet types
  */