10 static const char *
const TAG =
"NciMessage";
21 const std::vector<uint8_t> &payload) {
36 return this->
nci_message_[nfc::NCI_PKT_MT_GID_OFFSET] & nfc::NCI_PKT_MT_MASK;
54 if (this->
nci_message_.size() > nfc::NCI_PKT_PAYLOAD_OFFSET) {
73 return message_type == (this->
nci_message_[nfc::NCI_PKT_MT_GID_OFFSET] & nfc::NCI_PKT_MT_MASK);
79 if (this->
nci_message_.size() > nfc::NCI_PKT_LENGTH_OFFSET) {
83 return message_length == this->
nci_message_[nfc::NCI_PKT_LENGTH_OFFSET];
89 if (this->
nci_message_.size() > nfc::NCI_PKT_MT_GID_OFFSET) {
90 return gid == (this->
nci_message_[nfc::NCI_PKT_MT_GID_OFFSET] & nfc::NCI_PKT_GID_MASK);
96 if (this->
nci_message_.size() > nfc::NCI_PKT_OID_OFFSET) {
97 return oid == (this->
nci_message_[nfc::NCI_PKT_OID_OFFSET] & nfc::NCI_PKT_OID_MASK);
103 if (this->
nci_message_.size() > nfc::NCI_PKT_PAYLOAD_OFFSET) {
104 return response == this->
nci_message_[nfc::NCI_PKT_PAYLOAD_OFFSET];
110 if (this->
nci_message_.size() < nfc::NCI_PKT_HEADER_SIZE) {
114 (message_type & nfc::NCI_PKT_MT_MASK) | (gid & nfc::NCI_PKT_GID_MASK);
115 this->
nci_message_[nfc::NCI_PKT_OID_OFFSET] = oid & nfc::NCI_PKT_OID_MASK;
120 this->
nci_message_[nfc::NCI_PKT_LENGTH_OFFSET] = payload.size();
125 const std::vector<uint8_t> &payload) {
128 (message_type & nfc::NCI_PKT_MT_MASK) | (gid & nfc::NCI_PKT_GID_MASK);
129 this->
nci_message_[nfc::NCI_PKT_OID_OFFSET] = oid & nfc::NCI_PKT_OID_MASK;
130 this->
nci_message_[nfc::NCI_PKT_LENGTH_OFFSET] = payload.size();
135 if (this->
nci_message_.size() < nfc::NCI_PKT_HEADER_SIZE) {
138 auto mt_masked = this->
nci_message_[nfc::NCI_PKT_MT_GID_OFFSET] & ~nfc::NCI_PKT_MT_MASK;
139 this->
nci_message_[nfc::NCI_PKT_MT_GID_OFFSET] = mt_masked | (message_type & nfc::NCI_PKT_MT_MASK);
143 if (this->
nci_message_.size() < nfc::NCI_PKT_HEADER_SIZE) {
146 auto gid_masked = this->
nci_message_[nfc::NCI_PKT_MT_GID_OFFSET] & ~nfc::NCI_PKT_GID_MASK;
147 this->
nci_message_[nfc::NCI_PKT_MT_GID_OFFSET] = gid_masked | (gid & nfc::NCI_PKT_GID_MASK);
151 if (this->
nci_message_.size() < nfc::NCI_PKT_HEADER_SIZE) {
154 this->
nci_message_[nfc::NCI_PKT_OID_OFFSET] = oid & nfc::NCI_PKT_OID_MASK;
160 message.insert(message.end(), payload.begin(), payload.end());
161 message[nfc::NCI_PKT_LENGTH_OFFSET] = payload.size();
uint8_t get_message_type() const
bool message_type_is(uint8_t message_type) const
uint8_t get_message_byte(uint8_t offset) const
void set_oid(uint8_t oid)
std::vector< uint8_t > & get_message()
void set_header(uint8_t message_type, uint8_t gid, uint8_t oid)
bool gid_is(uint8_t gid) const
void set_message_type(uint8_t message_type)
std::vector< uint8_t > nci_message_
bool simple_status_response_is(uint8_t response) const
void set_payload(const std::vector< uint8_t > &payload)
void set_message(uint8_t message_type, const std::vector< uint8_t > &payload)
bool oid_is(uint8_t oid) const
uint8_t get_payload_size(bool recompute=false)
void set_gid(uint8_t gid)
bool message_length_is(uint8_t message_length, bool recompute=false)
Implementation of SPI Controller mode.
std::vector< uint8_t > encode()
uint8_t get_simple_status_response() const