client version of coap
Dependencies: nRF24L01P cantcoap3
Revision 5:d633e12f113f, committed 2019-01-25
- Comitter:
- Ka_myk
- Date:
- Fri Jan 25 12:10:49 2019 +0000
- Parent:
- 4:792cf53a73c4
- Commit message:
- all mains;
Changed in this revision
coapClient.cpp | Show annotated file Show diff for this revision Revisions of this file |
coapClient.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 792cf53a73c4 -r d633e12f113f coapClient.cpp --- a/coapClient.cpp Fri Jan 25 02:00:42 2019 +0000 +++ b/coapClient.cpp Fri Jan 25 12:10:49 2019 +0000 @@ -21,6 +21,7 @@ bool CoapClient::isAck(CoapPDU& response, uint16_t message_id, char* uri) { if (response.validate()) { response.printHuman(); + DBG("WANNA: %d %s", message_id, uri); if (isExpectedResponse(response, message_id, uri)) { return true; } @@ -51,6 +52,7 @@ Timer t; CoapPDU coapPDU = CoapPDU(); uint16_t messageId = preparePDU(coapPDU); + this->message_counter +=4; coapPDU.setCode(CoapPDU::COAP_GET); coapPDU.setURI(uri); @@ -108,6 +110,7 @@ Timer t; CoapPDU coapPDU = CoapPDU(); uint16_t messageId = preparePDU(coapPDU); + this->message_counter +=4; coapPDU.setCode(CoapPDU::COAP_POST); coapPDU.setURI(uri); @@ -150,13 +153,12 @@ coapPDU.setType(CoapPDU::COAP_CONFIRMABLE); coapPDU.setMessageID(this->message_counter); coapPDU.setToken(this->token, 1); - return this->message_counter++; + return this->message_counter; } -CoapClient::CoapClient(uint8_t* token, int retransmissionLimit, int timeout, int channel, unsigned long long rx_address, - unsigned long long tx_address) : +CoapClient::CoapClient(uint16_t counter, uint8_t* token, int retransmissionLimit, int timeout, int channel, unsigned long long rx_address, + unsigned long long tx_address): listeningTimeout(timeout), retransmissionLimit(retransmissionLimit), - radioWrapper(channel, rx_address, tx_address) { + radioWrapper(channel, rx_address, tx_address), message_counter(counter) { std::memcpy(this->token, token, 1); - this->message_counter = 666; // set to random } \ No newline at end of file
diff -r 792cf53a73c4 -r d633e12f113f coapClient.h --- a/coapClient.h Fri Jan 25 02:00:42 2019 +0000 +++ b/coapClient.h Fri Jan 25 12:10:49 2019 +0000 @@ -28,7 +28,7 @@ public: - CoapClient(uint8_t* token, int retransmissionLimit, int timeout, int channel, unsigned long long rx_address, + CoapClient(uint16_t counter, uint8_t* token, int retransmissionLimit, int timeout, int channel, unsigned long long rx_address, unsigned long long tx_address); int get(uint8_t buffer[], int len, char* uri);