|
@@ -119,17 +119,17 @@ typedef struct shellmatta_cmd
|
|
*/
|
|
*/
|
|
typedef enum
|
|
typedef enum
|
|
{
|
|
{
|
|
- STATE_GET_SOH =0u, /**< start of header state of transport layer */
|
|
|
|
- STATE_MANUAL_INPUT ,
|
|
|
|
- STATE_GET_PROTOCOL_VERSION , /**< protocol version state of transport layer */
|
|
|
|
- STATE_GET_PACKET_TYPE , /**< packet type state of transport layer */
|
|
|
|
- STATE_GET_PAYLOAD_LENGTH , /**< payload length state of transport layer */
|
|
|
|
- STATE_GET_SOURCE , /**< source state of transport layer */
|
|
|
|
- STATE_GET_DESTINATION , /**< destination state of transport layer */
|
|
|
|
- STATE_GET_H2S_SEQUENCE_CNT , /**< host to shellmatta sequence counter state of transport layer */
|
|
|
|
- STATE_GET_S2H_SEQUENCE_CNT , /**< shellmatta to host sequence counter state of transport layer */
|
|
|
|
- STATE_GET_PAYLOAD , /**< payload state of transport layer */
|
|
|
|
- STATE_GET_CRC , /**< crc state of transport layer */
|
|
|
|
|
|
+ STATE_GET_SOH =0u, /**< start of header state of transport layer */
|
|
|
|
+ STATE_MANUAL_INPUT , /**< state for manual input => transport layer disabled */
|
|
|
|
+ STATE_GET_PROTOCOL_VERSION , /**< protocol version state of transport layer */
|
|
|
|
+ STATE_GET_PACKET_TYPE , /**< packet type state of transport layer */
|
|
|
|
+ STATE_GET_PAYLOAD_LENGTH , /**< payload length state of transport layer */
|
|
|
|
+ STATE_GET_SOURCE , /**< source state of transport layer */
|
|
|
|
+ STATE_GET_DESTINATION , /**< destination state of transport layer */
|
|
|
|
+ STATE_GET_H2S_SEQUENCE_CNT , /**< host to shellmatta sequence counter state of transport layer */
|
|
|
|
+ STATE_GET_S2H_SEQUENCE_CNT , /**< shellmatta to host sequence counter state of transport layer */
|
|
|
|
+ STATE_GET_PAYLOAD , /**< payload state of transport layer */
|
|
|
|
+ STATE_GET_CRC , /**< crc state of transport layer */
|
|
STATE_PROCESS_PAYLOAD
|
|
STATE_PROCESS_PAYLOAD
|
|
} shellmatta_transport_state_t;
|
|
} shellmatta_transport_state_t;
|
|
|
|
|
|
@@ -138,15 +138,15 @@ typedef enum
|
|
*/
|
|
*/
|
|
typedef enum
|
|
typedef enum
|
|
{
|
|
{
|
|
- PACKET_DATA = 0x00u, /**< packet type to send plain data */
|
|
|
|
- PACKET_SEQ_CNT_REQUEST = 0x01u, /**< packet type to request sequence counters */
|
|
|
|
- PACKET_SEQ_CNT_RESPOND = 0x81u, /**< packet type to respond with sequence counters */
|
|
|
|
- PACKET_MAX_BUFFERSIZE_REQUEST = 0x02u, /**< packet type to set and request max buffersize */
|
|
|
|
- PACKET_MAX_BUFFERSIZE_RESPOND = 0x82u, /**< packet type to respond with max buffersize */
|
|
|
|
|
|
+ PACKET_DATA = 0x00u, /**< packet type to send plain data */
|
|
|
|
+ PACKET_SEQ_CNT_REQUEST = 0x01u, /**< packet type to request sequence counters */
|
|
|
|
+ PACKET_SEQ_CNT_RESPOND = 0x81u, /**< packet type to respond with sequence counters */
|
|
|
|
+ PACKET_MAX_BUFFERSIZE_REQUEST = 0x02u, /**< packet type to set and request max buffersize */
|
|
|
|
+ PACKET_MAX_BUFFERSIZE_RESPOND = 0x82u, /**< packet type to respond with max buffersize */
|
|
PACKET_SEARCH_DEVICE_REQUEST = 0x03u, /**< UNUSED: packet type to request search for a device by unique id */
|
|
PACKET_SEARCH_DEVICE_REQUEST = 0x03u, /**< UNUSED: packet type to request search for a device by unique id */
|
|
- PACKET_SEARCH_DEVICE_RESPOND = 0x83u, /**< UNUSED: packet type to respond with search results */
|
|
|
|
- PACKET_SET_ADDRESS_REQUEST = 0x04u, /**< UNUSED: packet type to set and request an address */
|
|
|
|
- PACKET_SET_ADDRESS_RESPOND = 0x84u /**< UNUSED: packet type to respond with a set address */
|
|
|
|
|
|
+ PACKET_SEARCH_DEVICE_RESPOND = 0x83u, /**< UNUSED: packet type to respond with search results */
|
|
|
|
+ PACKET_SET_ADDRESS_REQUEST = 0x04u, /**< UNUSED: packet type to set and request an address */
|
|
|
|
+ PACKET_SET_ADDRESS_RESPOND = 0x84u /**< UNUSED: packet type to respond with a set address */
|
|
} shellmatta_transport_packet_t;
|
|
} shellmatta_transport_packet_t;
|
|
|
|
|
|
/* payload length defines */
|
|
/* payload length defines */
|
|
@@ -158,25 +158,24 @@ typedef enum
|
|
*/
|
|
*/
|
|
typedef struct
|
|
typedef struct
|
|
{
|
|
{
|
|
- uint8_t h2s_sequenceCnt; /**< */
|
|
|
|
- uint8_t s2h_sequenceCnt; /**< */
|
|
|
|
- shellmatta_transport_state_t state; /**< */
|
|
|
|
- bool mandatory; /**< */
|
|
|
|
- bool active; /**< */
|
|
|
|
- bool continueStep; /**< */
|
|
|
|
- shellmatta_write_t originalWrite; /**< */
|
|
|
|
- /* init global variables */
|
|
|
|
- uint8_t protocolVersion;
|
|
|
|
- shellmatta_transport_packet_t packetType;
|
|
|
|
- uint32_t payloadLength;
|
|
|
|
- uint8_t source;
|
|
|
|
- uint8_t destination;
|
|
|
|
- uint32_t crc32;
|
|
|
|
- uint8_t payloadCounter;
|
|
|
|
- uint8_t crcCounter;
|
|
|
|
- uint8_t packetSequenceCounter_h2s;
|
|
|
|
- uint8_t packetSequenceCounter_s2h;
|
|
|
|
- char payloadBuffer[SHELLMATTA_PAYLOAD_MAXLENGTH];
|
|
|
|
|
|
+ uint8_t h2s_sequenceCnt; /**< TODO */
|
|
|
|
+ uint8_t s2h_sequenceCnt; /**< */
|
|
|
|
+ shellmatta_transport_state_t state; /**< */
|
|
|
|
+ bool mandatory; /**< */
|
|
|
|
+ bool active; /**< */
|
|
|
|
+ bool continueStep; /**< */
|
|
|
|
+ shellmatta_write_t originalWrite; /**< */
|
|
|
|
+ uint8_t protocolVersion; /**< */
|
|
|
|
+ shellmatta_transport_packet_t packetType; /**< */
|
|
|
|
+ uint32_t payloadLength; /**< */
|
|
|
|
+ uint8_t source; /**< */
|
|
|
|
+ uint8_t destination; /**< */
|
|
|
|
+ uint32_t crc32; /**< */
|
|
|
|
+ uint8_t payloadCounter; /**< */
|
|
|
|
+ uint8_t crcCounter; /**< */
|
|
|
|
+ uint8_t packetSequenceCounter_h2s; /**< */
|
|
|
|
+ uint8_t packetSequenceCounter_s2h; /**< */
|
|
|
|
+ char payloadBuffer[SHELLMATTA_PAYLOAD_MAXLENGTH]; /**< */
|
|
} shellmatta_transport_layer_t;
|
|
} shellmatta_transport_layer_t;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -221,6 +220,12 @@ typedef struct
|
|
shellmatta_transport_layer_t transportLayer; /**< transport layer instance */
|
|
shellmatta_transport_layer_t transportLayer; /**< transport layer instance */
|
|
} shellmatta_instance_t;
|
|
} shellmatta_instance_t;
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * @brief helper macro for the send function
|
|
|
|
+ */
|
|
|
|
+#define SHELLMATTA_WRITE(data, length) inst->transportLayer.active == true ? \
|
|
|
|
+ shellmatta_write_transport((shellmatta_transport_layer_t*)&inst->transportLayer, (data), (length)) : \
|
|
|
|
+ inst->write((data), (length))
|
|
|
|
|
|
shellmatta_retCode_t shellmatta_doInit( shellmatta_instance_t *inst,
|
|
shellmatta_retCode_t shellmatta_doInit( shellmatta_instance_t *inst,
|
|
shellmatta_handle_t *handle,
|
|
shellmatta_handle_t *handle,
|