uint8_t i2c_t::WriteReadBuf(uint8_t Addr, uint8_t *PW, uint16_t SzW, uint8_t *PR, uint16_t SzR) { uint8_t Rslt = 0; chSysLock(); if(Start() != 0) { Rslt = 1; goto End; } // Write Addr with Write bit (0) WriteByte(Addr<<1); if(!IsAcked()) { Rslt = 2; Uart.Printf("Addr NACK\r"); goto End; } chSysUnlock(); // Write data chSysLock(); while(SzW--) { WriteByte(*PW++); if(!IsAcked()) { Rslt = 3; Uart.Printf("NACK\r"); goto End; } } chSysUnlock(); // Send repeated start chSysLock(); Start(); // Write Addr with Read bit (1) WriteByte((Addr<<1) | 0x01); if(!IsAcked()) { Rslt = 4; Uart.Printf("Addr NACK\r"); goto End; } chSysUnlock(); // Read data chSysLock(); while(SzR) { *PR++ = ReadByte(); if(SzR != 1) Ack(); else Nack(); SzR--; } End: Stop(); chSysUnlock(); return Rslt; }
void ClientFace::receiveInterest(const Interest& interest) { this->trace(TraceEventKind::INTEREST_FROM, interest, Nack::NONE); for (Listener& listener : m_listeners) { if (listener.prefix.isPrefixOf(interest.getName())) { listener.onInterest(listener.prefix, interest); return; } } if (this->shouldNackUnmatchedInterest) { this->reply(interest, Nack(Nack::NODATA, interest)); } }