|
@@ -69,6 +69,7 @@ shellmatta_retCode_t shellmatta_transport_init( shellmatta_transport_layer_t
|
|
{
|
|
{
|
|
/** -# clear instance and store write function */
|
|
/** -# clear instance and store write function */
|
|
memset(transportLayer, 0u, sizeof(shellmatta_transport_layer_t));
|
|
memset(transportLayer, 0u, sizeof(shellmatta_transport_layer_t));
|
|
|
|
+ transportLayer->hostBufferSize = SHELLMATTA_TRANPORT_PAYLOAD_MAXLENGTH;
|
|
transportLayer->writeFct = writeFct;
|
|
transportLayer->writeFct = writeFct;
|
|
|
|
|
|
return SHELLMATTA_OK;
|
|
return SHELLMATTA_OK;
|
|
@@ -261,7 +262,7 @@ shellmatta_retCode_t shellmatta_transport_process(shellmatta_transport_layer_t
|
|
*length = header->payloadLength;
|
|
*length = header->payloadLength;
|
|
ret = SHELLMATTA_OK;
|
|
ret = SHELLMATTA_OK;
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
case SHELLMATTA_TRANSPORT_PACKET_SEQ_CNT_REQUEST:
|
|
case SHELLMATTA_TRANSPORT_PACKET_SEQ_CNT_REQUEST:
|
|
/** -# send out packet with no payload */
|
|
/** -# send out packet with no payload */
|
|
intPacket.header.packetType = SHELLMATTA_TRANSPORT_PACKET_SEQ_CNT_RESPOND;
|
|
intPacket.header.packetType = SHELLMATTA_TRANSPORT_PACKET_SEQ_CNT_RESPOND;
|
|
@@ -272,19 +273,26 @@ shellmatta_retCode_t shellmatta_transport_process(shellmatta_transport_layer_t
|
|
case SHELLMATTA_TRANSPORT_PACKET_SEQ_CNT_RESPOND:
|
|
case SHELLMATTA_TRANSPORT_PACKET_SEQ_CNT_RESPOND:
|
|
/** -# ignore #SHELLMATTA_TRANSPORT_PACKET_SEQ_CNT_RESPOND - nothing to do */
|
|
/** -# ignore #SHELLMATTA_TRANSPORT_PACKET_SEQ_CNT_RESPOND - nothing to do */
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
case SHELLMATTA_TRANSPORT_PACKET_MAX_BUFFERSIZE_REQUEST:
|
|
case SHELLMATTA_TRANSPORT_PACKET_MAX_BUFFERSIZE_REQUEST:
|
|
- /** @todo implement */
|
|
|
|
|
|
+ /** -# store the hosts buffersize */
|
|
|
|
+ transportLayer->hostBufferSize = (uint8_t)transportLayer->inPacket.payload[0];
|
|
|
|
+
|
|
|
|
+ /** -# respont with our own buffer size */
|
|
|
|
+ intPacket.header.packetType = SHELLMATTA_TRANSPORT_PACKET_MAX_BUFFERSIZE_RESPOND;
|
|
|
|
+ intPacket.header.payloadLength = 1u;
|
|
|
|
+ intPacket.payload[0] = SHELLMATTA_TRANPORT_PAYLOAD_MAXLENGTH;
|
|
|
|
+ (void)shellmatta_transport_send(transportLayer, (shellmatta_transport_packet_t *)&intPacket);
|
|
break;
|
|
break;
|
|
|
|
|
|
case SHELLMATTA_TRANSPORT_PACKET_MAX_BUFFERSIZE_RESPOND:
|
|
case SHELLMATTA_TRANSPORT_PACKET_MAX_BUFFERSIZE_RESPOND:
|
|
/** -# ignore #SHELLMATTA_TRANSPORT_PACKET_MAX_BUFFERSIZE_RESPOND - nothing to do */
|
|
/** -# ignore #SHELLMATTA_TRANSPORT_PACKET_MAX_BUFFERSIZE_RESPOND - nothing to do */
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
case SHELLMATTA_TRANSPORT_PACKET_SEARCH_DEVICE_REQUEST:
|
|
case SHELLMATTA_TRANSPORT_PACKET_SEARCH_DEVICE_REQUEST:
|
|
/** @todo implement */
|
|
/** @todo implement */
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
case SHELLMATTA_TRANSPORT_PACKET_SEARCH_DEVICE_RESPOND:
|
|
case SHELLMATTA_TRANSPORT_PACKET_SEARCH_DEVICE_RESPOND:
|
|
/** -# ignore #SHELLMATTA_TRANSPORT_PACKET_SEARCH_DEVICE_RESPOND - nothing to do */
|
|
/** -# ignore #SHELLMATTA_TRANSPORT_PACKET_SEARCH_DEVICE_RESPOND - nothing to do */
|
|
break;
|
|
break;
|
|
@@ -313,7 +321,7 @@ shellmatta_retCode_t shellmatta_transport_process(shellmatta_transport_layer_t
|
|
transportLayer->state = SHELLMATTA_TRANSPORT_STATE_WAIT;
|
|
transportLayer->state = SHELLMATTA_TRANSPORT_STATE_WAIT;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -323,13 +331,13 @@ shellmatta_retCode_t shellmatta_transport_process(shellmatta_transport_layer_t
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Wrapper function for the write-function of shellmatta handle
|
|
* @brief Wrapper function for the write-function of shellmatta handle
|
|
- *
|
|
|
|
|
|
+ *
|
|
* This function is used to transmit data with the tranport layer protocol.\n
|
|
* This function is used to transmit data with the tranport layer protocol.\n
|
|
* The input data is copied into a new array along with the header and crc32.\n
|
|
* The input data is copied into a new array along with the header and crc32.\n
|
|
* The resulting buffer is the forwarded to the original write function.\n
|
|
* The resulting buffer is the forwarded to the original write function.\n
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @note If length of data exceeds #UINT8_MAX, data is sent in multiple packets.\n
|
|
* @note If length of data exceeds #UINT8_MAX, data is sent in multiple packets.\n
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param[in, out] transportLayer transport layer instance to work on
|
|
* @param[in, out] transportLayer transport layer instance to work on
|
|
* @param[in] data pointer to input data to process
|
|
* @param[in] data pointer to input data to process
|
|
* @param[in] length length of data to process
|
|
* @param[in] length length of data to process
|
|
@@ -357,9 +365,9 @@ shellmatta_retCode_t shellmatta_transport_write(shellmatta_transport_layer_t *tr
|
|
|
|
|
|
/* compute length of next payload split */
|
|
/* compute length of next payload split */
|
|
restOfPayload = (outPayloadLength - processedLength);
|
|
restOfPayload = (outPayloadLength - processedLength);
|
|
- if (restOfPayload > (SHELLMATTA_TRANPORT_PAYLOAD_MAXLENGTH - piledUpPayload))
|
|
|
|
|
|
+ if (restOfPayload > (transportLayer->hostBufferSize - piledUpPayload))
|
|
{
|
|
{
|
|
- splitLength = SHELLMATTA_TRANPORT_PAYLOAD_MAXLENGTH - piledUpPayload;
|
|
|
|
|
|
+ splitLength = transportLayer->hostBufferSize - piledUpPayload;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -370,7 +378,7 @@ shellmatta_retCode_t shellmatta_transport_write(shellmatta_transport_layer_t *tr
|
|
header->payloadLength += splitLength;
|
|
header->payloadLength += splitLength;
|
|
processedLength += splitLength;
|
|
processedLength += splitLength;
|
|
|
|
|
|
- if(header->payloadLength >= SHELLMATTA_TRANPORT_PAYLOAD_MAXLENGTH)
|
|
|
|
|
|
+ if(header->payloadLength >= transportLayer->hostBufferSize)
|
|
{
|
|
{
|
|
/** -# packet is full - send */
|
|
/** -# packet is full - send */
|
|
header->packetType = SHELLMATTA_TRANSPORT_PACKET_DATA;
|
|
header->packetType = SHELLMATTA_TRANSPORT_PACKET_DATA;
|
|
@@ -384,7 +392,7 @@ shellmatta_retCode_t shellmatta_transport_write(shellmatta_transport_layer_t *tr
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Send out piled up payload
|
|
* @brief Send out piled up payload
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param[in, out] handle shellmatta handle of the instance
|
|
* @param[in, out] handle shellmatta handle of the instance
|
|
* @return errorcode
|
|
* @return errorcode
|
|
*/
|
|
*/
|