9#include <cfg/cs_StaticConfig.h>
24template <cs_buffer_
size_t PAYLOAD_SIZE = CS_RESULT_PACKET_DEFAULT_PAYLOAD_SIZE>
37 return _buffer->header.protocolVersion;
45 _buffer->header.protocolVersion = protocol;
53 return _buffer->header.commandType;
61 _buffer->header.commandType = type;
69 return _buffer->header.returnCode;
77 _buffer->header.returnCode = result;
102 return std::min(
_buffer->header.payloadSize, PAYLOAD_SIZE);
130 _buffer->header.payloadSize = size;
143 if (size > PAYLOAD_SIZE) {
147 _buffer->header.payloadSize = size;
148 memcpy(
_buffer->payload, payload, size);
Base class for a buffer accessor object.
Definition: cs_BufferAccessor.h:16
Definition: cs_ResultPacketAccessor.h:25
bool isInitialized() const
Only set or get fields when this instance is initialized.
Definition: cs_ResultPacketAccessor.h:30
cs_control_cmd_t getType() const
Get the command type.
Definition: cs_ResultPacketAccessor.h:51
cs_ret_code_t setPayloadSize(cs_buffer_size_t size)
Definition: cs_ResultPacketAccessor.h:125
cs_buffer_size_t getPayloadSize()
Get the size of the payload.
Definition: cs_ResultPacketAccessor.h:100
cs_data_t getPayload()
Get the payload.
Definition: cs_ResultPacketAccessor.h:85
cs_buffer_size_t getBufferSize() const
Get the capacity of the buffer.
Definition: cs_ResultPacketAccessor.h:167
cs_buffer_size_t getSerializedSize() const
Get the size of the serialized data in the buffer.
Definition: cs_ResultPacketAccessor.h:161
void setProtocolVersion(uint8_t protocol)
Set the protocol version.
Definition: cs_ResultPacketAccessor.h:43
buffer_ptr_t getPayloadBuffer()
Get the payload buffer.
Definition: cs_ResultPacketAccessor.h:110
void setResult(cs_ret_code_t result)
Set the result code.
Definition: cs_ResultPacketAccessor.h:75
result_packet_t< PAYLOAD_SIZE > * _buffer
Pointer to the packet to be sent.
Definition: cs_ResultPacketAccessor.h:185
cs_ret_code_t getResult() const
Get the result code.
Definition: cs_ResultPacketAccessor.h:67
void checkInitialized() const
Definition: cs_ResultPacketAccessor.h:187
cs_ret_code_t setPayload(buffer_ptr_t payload, cs_buffer_size_t size)
Copy payload into the packet.
Definition: cs_ResultPacketAccessor.h:141
void setType(cs_control_cmd_t type)
Set the command type.
Definition: cs_ResultPacketAccessor.h:59
cs_data_t getSerializedBuffer()
Get the pointer to the buffer.
Definition: cs_ResultPacketAccessor.h:173
uint8_t getProtocolVersion() const
Get the protocol version.
Definition: cs_ResultPacketAccessor.h:35
cs_buffer_size_t getMaxPayloadSize()
Get the capacity of the payload.
Definition: cs_ResultPacketAccessor.h:120
cs_ret_code_t assign(buffer_ptr_t buffer, cs_buffer_size_t size)
Assign the buffer used to hold the data.
Definition: cs_ResultPacketAccessor.h:153
@ ERR_SUCCESS
Definition: cs_ErrorCodes.h:10
@ ERR_BUFFER_TOO_SMALL
Definition: cs_ErrorCodes.h:16
#define assert(expr, message)
Author: Crownstone Team Date: 21 Sep., 2013 License: LGPLv3+, Apache License 2.0, and/or MIT (triple-...
Definition: cs_Error.h:22
#define LOGd(fmt,...)
Definition: cs_Logger.h:90
#define LOGe(fmt,...)
Definition: cs_Logger.h:93
static const size_t CS_RESULT_PACKET_DEFAULT_PAYLOAD_SIZE
Default payload size for a result packet.
Definition: cs_ResultPacketAccessor.h:22
#define STR_ERR_BUFFER_NOT_LARGE_ENOUGH
Definition: cs_Strings.h:101
#define FMT_ASSIGN_BUFFER_LEN
Definition: cs_Strings.h:188
uint16_t cs_buffer_size_t
Definition: cs_Typedefs.h:20
uint16_t cs_control_cmd_t
Definition: cs_Typedefs.h:22
uint16_t cs_ret_code_t
Definition: cs_Typedefs.h:21
uint8_t * buffer_ptr_t
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: 10 May....
Definition: cs_Typedefs.h:19
Packets (structs) that are used internally in the firmware, and can be changed freely.
Definition: cs_PacketsInternal.h:27
cs_buffer_size_t len
< Pointer to data.
Definition: cs_PacketsInternal.h:29
buffer_ptr_t data
Definition: cs_PacketsInternal.h:28
Result packet.
Definition: cs_Packets.h:120