12 :
NciMessage(message_type,
std::span<const uint8_t>(payload.begin(), payload.
size())) {}
20 const std::span<const uint8_t> payload) {
25 const std::initializer_list<uint8_t> payload)
26 :
NciMessage(message_type, gid, oid,
std::span<const uint8_t>(payload.begin(), payload.
size())) {}
85 return message_type == (this->
nci_message_[NCI_PKT_MT_GID_OFFSET] & NCI_PKT_MT_MASK);
95 return message_length == this->
nci_message_[NCI_PKT_LENGTH_OFFSET];
102 return gid == (this->
nci_message_[NCI_PKT_MT_GID_OFFSET] & NCI_PKT_GID_MASK);
109 return oid == (this->
nci_message_[NCI_PKT_OID_OFFSET] & NCI_PKT_OID_MASK);
116 return response == this->
nci_message_[NCI_PKT_PAYLOAD_OFFSET];
125 this->
nci_message_[NCI_PKT_MT_GID_OFFSET] = (message_type & NCI_PKT_MT_MASK) | (gid & NCI_PKT_GID_MASK);
126 this->
nci_message_[NCI_PKT_OID_OFFSET] = oid & NCI_PKT_OID_MASK;
131 this->
nci_message_[NCI_PKT_MT_GID_OFFSET] = message_type & NCI_PKT_MT_MASK;
138 const std::span<const uint8_t> payload) {
149 auto mt_masked = this->
nci_message_[NCI_PKT_MT_GID_OFFSET] & ~NCI_PKT_MT_MASK;
150 this->
nci_message_[NCI_PKT_MT_GID_OFFSET] = mt_masked | (message_type & NCI_PKT_MT_MASK);
157 auto gid_masked = this->
nci_message_[NCI_PKT_MT_GID_OFFSET] & ~NCI_PKT_GID_MASK;
158 this->
nci_message_[NCI_PKT_MT_GID_OFFSET] = gid_masked | (gid & NCI_PKT_GID_MASK);
165 this->
nci_message_[NCI_PKT_OID_OFFSET] = oid & NCI_PKT_OID_MASK;
175 for (
const uint8_t
byte : data) {
void push_back(const T &value)
void assign(InputIt first, InputIt last)
One NCI packet, held in a fixed buffer so building and reading messages never allocates.
uint8_t get_payload_size(bool recompute=false)
bool message_type_is(uint8_t message_type) const
bool simple_status_response_is(uint8_t response) const
uint8_t get_message_byte(uint8_t offset) const
std::span< const uint8_t > encode()
Stamps the payload length into the header and returns the packet ready to send.
bool gid_is(uint8_t gid) const
void set_gid(uint8_t gid)
void set_header(uint8_t message_type, uint8_t gid, uint8_t oid)
bool message_length_is(uint8_t message_length, bool recompute=false)
void set_payload_size(uint8_t size)
Sets the packet size to the header plus size payload bytes, for a bus driver filling the buffer direc...
std::span< const uint8_t > get_payload() const
The payload bytes that follow the header.
void set_oid(uint8_t oid)
void set_message(uint8_t message_type, std::span< const uint8_t > payload)
void set_message_type(uint8_t message_type)
uint8_t get_simple_status_response() const
bool oid_is(uint8_t oid) const
void set_payload(std::span< const uint8_t > payload)
uint8_t get_message_type() const
void append(std::span< const uint8_t > data)
Appends bytes to the payload; bytes that do not fit are dropped.